Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
6678efaa
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6678efaa
编写于
6月 09, 2020
作者:
R
Robert Ancell
提交者:
Robert Ancell
12月 11, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implement SystemSound.play
上级
14c8c244
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
29 addition
and
0 deletion
+29
-0
shell/platform/linux/fl_platform_plugin.cc
shell/platform/linux/fl_platform_plugin.cc
+29
-0
未找到文件。
shell/platform/linux/fl_platform_plugin.cc
浏览文件 @
6678efaa
...
...
@@ -18,12 +18,16 @@ static constexpr char kFailedError[] = "Failed";
static
constexpr
char
kGetClipboardDataMethod
[]
=
"Clipboard.getData"
;
static
constexpr
char
kSetClipboardDataMethod
[]
=
"Clipboard.setData"
;
static
constexpr
char
kClipboardHasStringsMethod
[]
=
"Clipboard.hasStrings"
;
static
constexpr
char
kPlaySoundMethod
[]
=
"SystemSound.play"
;
static
constexpr
char
kSystemNavigatorPopMethod
[]
=
"SystemNavigator.pop"
;
static
constexpr
char
kTextKey
[]
=
"text"
;
static
constexpr
char
kValueKey
[]
=
"value"
;
static
constexpr
char
kTextPlainFormat
[]
=
"text/plain"
;
static
constexpr
char
kSoundTypeAlert
[]
=
"SystemSoundType.alert"
;
static
constexpr
char
kSoundTypeClick
[]
=
"SystemSoundType.click"
;
struct
_FlPlatformPlugin
{
GObject
parent_instance
;
...
...
@@ -136,6 +140,29 @@ static FlMethodResponse* clipboard_has_strings_async(
return
nullptr
;
}
// Called when Flutter wants to play a sound.
static
FlMethodResponse
*
system_sound_play
(
FlPlatformPlugin
*
self
,
FlValue
*
args
)
{
if
(
fl_value_get_type
(
args
)
!=
FL_VALUE_TYPE_STRING
)
{
return
FL_METHOD_RESPONSE
(
fl_method_error_response_new
(
kBadArgumentsError
,
"Expected string"
,
nullptr
));
}
const
gchar
*
type
=
fl_value_get_string
(
args
);
if
(
strcmp
(
type
,
kSoundTypeAlert
)
==
0
)
{
GdkDisplay
*
display
=
gdk_display_get_default
();
if
(
display
!=
nullptr
)
{
gdk_display_beep
(
display
);
}
}
else
if
(
strcmp
(
type
,
kSoundTypeClick
)
==
0
)
{
// We don't make sounds for keyboard on desktops.
}
else
{
g_warning
(
"Ignoring unknown sound type %s in SystemSound.play.
\n
"
,
type
);
}
return
FL_METHOD_RESPONSE
(
fl_method_not_implemented_response_new
());
}
// Called when Flutter wants to quit the application.
static
FlMethodResponse
*
system_navigator_pop
(
FlPlatformPlugin
*
self
)
{
GApplication
*
app
=
g_application_get_default
();
...
...
@@ -165,6 +192,8 @@ static void method_call_cb(FlMethodChannel* channel,
response
=
clipboard_get_data_async
(
self
,
method_call
);
}
else
if
(
strcmp
(
method
,
kClipboardHasStringsMethod
)
==
0
)
{
response
=
clipboard_has_strings_async
(
self
,
method_call
);
}
else
if
(
strcmp
(
method
,
kPlaySoundMethod
)
==
0
)
{
response
=
system_sound_play
(
self
,
args
);
}
else
if
(
strcmp
(
method
,
kSystemNavigatorPopMethod
)
==
0
)
{
response
=
system_navigator_pop
(
self
);
}
else
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录