[gnome-settings-daemon] Use MIME types for schemes, not GConf
- From: Rodrigo Moya <rodrigo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] Use MIME types for schemes, not GConf
- Date: Thu, 7 Oct 2010 09:57:02 +0000 (UTC)
commit 3e4dbcd54412a58d7e6ebde58f191d2a001518b8
Author: Rodrigo Moya <rodrigo gnome-db org>
Date: Wed Oct 6 10:38:00 2010 +0200
Use MIME types for schemes, not GConf
plugins/media-keys/gsd-media-keys-manager.c | 106 +++------------------------
1 files changed, 10 insertions(+), 96 deletions(-)
---
diff --git a/plugins/media-keys/gsd-media-keys-manager.c b/plugins/media-keys/gsd-media-keys-manager.c
index 7281a26..debc6f8 100644
--- a/plugins/media-keys/gsd-media-keys-manager.c
+++ b/plugins/media-keys/gsd-media-keys-manager.c
@@ -439,71 +439,17 @@ dialog_show (GsdMediaKeysManager *manager)
}
static void
-do_unknown_action (GsdMediaKeysManager *manager,
- const char *url)
+do_url_action (GsdMediaKeysManager *manager,
+ const char *scheme)
{
- char *string;
- GSettings *settings;
-
- g_return_if_fail (url != NULL);
-
- settings = g_settings_new ("org.gnome.desktop.url-handlers.unknown");
- string = g_settings_get_string (settings, "command");
-
- if ((string != NULL) && (strcmp (string, "") != 0)) {
- char *cmd;
- cmd = g_strdup_printf (string, url);
- execute (manager, cmd, FALSE, FALSE);
- g_free (cmd);
- }
-
- g_free (string);
- g_object_unref (settings);
-}
-
-static void
-do_help_action (GsdMediaKeysManager *manager)
-{
- char *string;
- GSettings *settings;
-
- settings = g_settings_new ("org.gnome.desktop.url-handlers.ghelp");
- string = g_settings_get_string (settings, "command");
+ GAppInfo *app_info;
- if ((string != NULL) && (strcmp (string, "") != 0)) {
- char *cmd;
- cmd = g_strdup_printf (string, "");
- execute (manager, cmd, FALSE, FALSE);
- g_free (cmd);
+ app_info = g_app_info_get_default_for_uri_scheme (scheme);
+ if (app_info != NULL) {
+ execute (manager, g_app_info_get_commandline (app_info), FALSE, /* FIXME */ FALSE);
} else {
- do_unknown_action (manager, "ghelp:");
- }
-
- g_free (string);
- g_object_unref (settings);
-}
-
-static void
-do_mail_action (GsdMediaKeysManager *manager)
-{
- char *string;
- GSettings *settings;
-
- settings = g_settings_new ("org.gnome.desktop.url-handlers.mailto");
- string = g_settings_get_string (settings, "command");
-
- if ((string != NULL) && (strcmp (string, "") != 0)) {
- char *cmd;
- cmd = g_strdup_printf (string, "");
- execute (manager,
- cmd,
- FALSE,
- g_settings_get_boolean (settings, "needs-terminal"));
- g_free (cmd);
+ g_warning ("Could not find default application for '%s' scheme", scheme);
}
-
- g_free (string);
- g_object_unref (settings);
}
static void
@@ -526,38 +472,6 @@ do_media_action (GsdMediaKeysManager *manager)
}
static void
-do_www_action (GsdMediaKeysManager *manager,
- const char *url)
-{
- char *string;
- GSettings *settings;
-
- settings = g_settings_new ("org.gnome.desktop.url-handlers.http");
- string = g_settings_get_string (settings, "command");
-
- if ((string != NULL) && (strcmp (string, "") != 0)) {
- gchar *cmd;
-
- if (url == NULL) {
- cmd = g_strdup_printf (string, "");
- } else {
- cmd = g_strdup_printf (string, url);
- }
-
- execute (manager,
- cmd,
- FALSE,
- g_settings_get_boolean (settings, "needs-terminal"));
- g_free (cmd);
- } else {
- do_unknown_action (manager, url ? url : "");
- }
-
- g_free (string);
- g_object_unref (settings);
-}
-
-static void
do_exit_action (GsdMediaKeysManager *manager)
{
execute (manager, "gnome-session-save --shutdown-dialog", FALSE, FALSE);
@@ -947,7 +861,7 @@ do_action (GsdMediaKeysManager *manager,
g_free (cmd);
break;
case EMAIL_KEY:
- do_mail_action (manager);
+ do_url_action (manager, "mailto");
break;
case SCREENSAVER_KEY:
if ((cmd = g_find_program_in_path ("gnome-screensaver-command"))) {
@@ -959,10 +873,10 @@ do_action (GsdMediaKeysManager *manager,
g_free (cmd);
break;
case HELP_KEY:
- do_help_action (manager);
+ do_url_action (manager, "ghelp");
break;
case WWW_KEY:
- do_www_action (manager, NULL);
+ do_url_action (manager, "http");
break;
case MEDIA_KEY:
do_media_action (manager);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]