summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiaotian Wu <[email protected]>2023-01-07 19:23:26 +0800
committerraveit65 <[email protected]>2023-10-22 10:20:39 +0200
commit6ae0b8e104b233b2466a2ffa248e667148117d3b (patch)
tree205366563076448640a66d494710d7df997ee2a3
parentecc7815307afd7502f69267820971e5f550e42d4 (diff)
downloadmate-settings-daemon-6ae0b8e104b233b2466a2ffa248e667148117d3b.tar.bz2
mate-settings-daemon-6ae0b8e104b233b2466a2ffa248e667148117d3b.tar.xz
Open default application using async function
-rw-r--r--plugins/media-keys/msd-media-keys-manager.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/plugins/media-keys/msd-media-keys-manager.c b/plugins/media-keys/msd-media-keys-manager.c
index 0aee95f..5ab8946 100644
--- a/plugins/media-keys/msd-media-keys-manager.c
+++ b/plugins/media-keys/msd-media-keys-manager.c
@@ -493,26 +493,31 @@ dialog_show (MsdMediaKeysManager *manager)
}
static void
+launch_default_for_uri_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GError *error = NULL;
+ gchar *uri = user_data;
+
+ if (!g_app_info_launch_default_for_uri_finish (res, &error))
+ {
+ g_warning ("Could not launch '%s': %s", uri,
+ error->message);
+ g_clear_error (&error);
+ }
+ g_free (uri);
+}
+
+static void
do_url_action (MsdMediaKeysManager *manager,
const gchar *scheme)
{
- GError *error = NULL;
- GAppInfo *app_info;
-
- app_info = g_app_info_get_default_for_uri_scheme (scheme);
-
- if (app_info != NULL) {
- if (!g_app_info_launch (app_info, NULL, NULL, &error)) {
- g_warning ("Could not launch '%s': %s",
- g_app_info_get_commandline (app_info),
- error->message);
- g_object_unref (app_info);
- g_error_free (error);
- }
- }
- else {
- g_warning ("Could not find default application for '%s' scheme", scheme);
- }
+ g_app_info_launch_default_for_uri_async (scheme,
+ NULL,
+ NULL,
+ launch_default_for_uri_cb,
+ g_strdup (scheme));
}
static void