aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2013-04-12 13:40:18 +0200
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2013-04-12 13:40:18 +0200
commit0312ffa2d621b398462659429a7c2b778da93ca8 (patch)
treeb421c2381787df6f0a7169979e0fcb1356934ab2
parentbd9abfc7d47ae16cf92632a6d9507150338e7cfc (diff)
downloadlibayatana-indicator-0312ffa2d621b398462659429a7c2b778da93ca8.tar.gz
libayatana-indicator-0312ffa2d621b398462659429a7c2b778da93ca8.tar.bz2
libayatana-indicator-0312ffa2d621b398462659429a7c2b778da93ca8.zip
IndicatorDesktopShortcuts: Use the proper way to create an AppInfo from command-line
We remove the workaround that we used to create a .desktop app-info from a locally generated keyfile.
-rw-r--r--libindicator/indicator-desktop-shortcuts.c31
1 files changed, 10 insertions, 21 deletions
diff --git a/libindicator/indicator-desktop-shortcuts.c b/libindicator/indicator-desktop-shortcuts.c
index 70d964e..52d237c 100644
--- a/libindicator/indicator-desktop-shortcuts.c
+++ b/libindicator/indicator-desktop-shortcuts.c
@@ -624,47 +624,36 @@ indicator_desktop_shortcuts_nick_exec_with_context (IndicatorDesktopShortcuts *
G_KEY_FILE_DESKTOP_KEY_EXEC,
NULL,
NULL);
+ GAppInfoCreateFlags flags = 0;
- /* Build a new desktop file with the name and exec in the desktop
- group. We have to do this with data as apparently there isn't
- and add_group function in g_key_file. Go figure. */
- gchar * desktopdata = g_strdup_printf("[" G_KEY_FILE_DESKTOP_GROUP "]\n"
- G_KEY_FILE_DESKTOP_KEY_TYPE "=" G_KEY_FILE_DESKTOP_TYPE_APPLICATION "\n"
- G_KEY_FILE_DESKTOP_KEY_NAME "=%s\n"
- G_KEY_FILE_DESKTOP_KEY_EXEC "=%s\n"
- G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY "=%s\n",
- name, exec, launch_context ? "true" : "false");
+ if (launch_context) {
+ flags |= G_APP_INFO_CREATE_SUPPORTS_STARTUP_NOTIFICATION;
+ }
+ GAppInfo * appinfo = g_app_info_create_from_commandline(exec, name, flags, &error);
g_free(name); g_free(exec);
- /* g_debug("Desktop file: \n%s", desktopdata); */
-
- GKeyFile * launcher = g_key_file_new();
- g_key_file_load_from_data(launcher, desktopdata, -1, G_KEY_FILE_NONE, &error);
- g_free(desktopdata);
if (error != NULL) {
- g_warning("Unable to build desktop keyfile for executing shortcut '%s': %s", nick, error->message);
+ g_warning("Unable to build Command line App info: %s", error->message);
g_error_free(error);
return FALSE;
}
- GDesktopAppInfo * appinfo = g_desktop_app_info_new_from_keyfile(launcher);
if (appinfo == NULL) {
- g_warning("Unable to build Desktop App info (unknown)");
- g_key_file_free(launcher);
+ g_warning("Unable to build Command line App info (unknown)");
return FALSE;
}
- gboolean launched = g_app_info_launch(G_APP_INFO(appinfo), NULL, launch_context, &error);
+
+ gboolean launched = g_app_info_launch(appinfo, NULL, launch_context, &error);
if (error != NULL) {
g_warning("Unable to launch file from nick '%s': %s", nick, error->message);
g_error_free(error);
- g_key_file_free(launcher);
+ g_object_unref(appinfo);
return FALSE;
}
g_object_unref(appinfo);
- g_key_file_free(launcher);
return launched;
}