diff options
-rw-r--r-- | libindicator/indicator-desktop-shortcuts.c | 31 |
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; } |