aboutsummaryrefslogtreecommitdiff
path: root/libindicator
diff options
context:
space:
mode:
authorMarco Trevisan (TreviƱo) <mail@3v1n0.net>2013-05-29 17:16:46 +0000
committerTarmac <Unknown>2013-05-29 17:16:46 +0000
commitab3b6ee20a8aa6a76372aa97747692750a77edc5 (patch)
tree7c3a092bda5a124e6b69b9d57f1710de7f4c836b /libindicator
parentd652787d2dcbb06be48bdee3344760e30757a36f (diff)
parentf88266a60437836f325b34fe125b93cb1e8bec3d (diff)
downloadlibayatana-indicator-ab3b6ee20a8aa6a76372aa97747692750a77edc5.tar.gz
libayatana-indicator-ab3b6ee20a8aa6a76372aa97747692750a77edc5.tar.bz2
libayatana-indicator-ab3b6ee20a8aa6a76372aa97747692750a77edc5.zip
IndicatorDesktopShortcuts: Use the proper way to create an AppInfo from command-line
Removed the hack that we used to create a .desktop app-info from a locally generated keyfile, using g_app_info_create_from_commandline instead. Fixes: https://bugs.launchpad.net/bugs/1168373. Approved by PS Jenkins bot, Ted Gould.
Diffstat (limited to 'libindicator')
-rw-r--r--libindicator/indicator-desktop-shortcuts.c34
1 files changed, 11 insertions, 23 deletions
diff --git a/libindicator/indicator-desktop-shortcuts.c b/libindicator/indicator-desktop-shortcuts.c
index 70d964e..740d7e1 100644
--- a/libindicator/indicator-desktop-shortcuts.c
+++ b/libindicator/indicator-desktop-shortcuts.c
@@ -625,46 +625,34 @@ indicator_desktop_shortcuts_nick_exec_with_context (IndicatorDesktopShortcuts *
NULL,
NULL);
- /* 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");
+ GAppInfoCreateFlags flags = G_APP_INFO_CREATE_NONE;
- g_free(name); g_free(exec);
- /* g_debug("Desktop file: \n%s", desktopdata); */
+ if (launch_context) {
+ flags |= G_APP_INFO_CREATE_SUPPORTS_STARTUP_NOTIFICATION;
+ }
- GKeyFile * launcher = g_key_file_new();
- g_key_file_load_from_data(launcher, desktopdata, -1, G_KEY_FILE_NONE, &error);
- g_free(desktopdata);
+ GAppInfo * appinfo = g_app_info_create_from_commandline(exec, name, flags, &error);
+ g_free(name); g_free(exec);
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);
- return FALSE;
+ g_clear_error(&error);
}
g_object_unref(appinfo);
- g_key_file_free(launcher);
return launched;
}