From 0312ffa2d621b398462659429a7c2b778da93ca8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 12 Apr 2013 13:40:18 +0200 Subject: 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. --- libindicator/indicator-desktop-shortcuts.c | 31 ++++++++++-------------------- 1 file changed, 10 insertions(+), 21 deletions(-) (limited to 'libindicator') 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; } -- cgit v1.2.3 From 7f0c703a70b02b7c7724abb36d3bc1be8b613521 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 12 Apr 2013 13:50:05 +0200 Subject: IndicatorDesktopShortcuts: initialize flags using the default define --- libindicator/indicator-desktop-shortcuts.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libindicator') diff --git a/libindicator/indicator-desktop-shortcuts.c b/libindicator/indicator-desktop-shortcuts.c index 52d237c..41a2d3e 100644 --- a/libindicator/indicator-desktop-shortcuts.c +++ b/libindicator/indicator-desktop-shortcuts.c @@ -624,7 +624,8 @@ indicator_desktop_shortcuts_nick_exec_with_context (IndicatorDesktopShortcuts * G_KEY_FILE_DESKTOP_KEY_EXEC, NULL, NULL); - GAppInfoCreateFlags flags = 0; + + GAppInfoCreateFlags flags = G_APP_INFO_CREATE_NONE; if (launch_context) { flags |= G_APP_INFO_CREATE_SUPPORTS_STARTUP_NOTIFICATION; -- cgit v1.2.3 From f88266a60437836f325b34fe125b93cb1e8bec3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 19 Apr 2013 13:49:32 +0200 Subject: IndicatorDesktopShortcuts: some code cleanup --- libindicator/indicator-desktop-shortcuts.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'libindicator') diff --git a/libindicator/indicator-desktop-shortcuts.c b/libindicator/indicator-desktop-shortcuts.c index 41a2d3e..740d7e1 100644 --- a/libindicator/indicator-desktop-shortcuts.c +++ b/libindicator/indicator-desktop-shortcuts.c @@ -649,9 +649,7 @@ indicator_desktop_shortcuts_nick_exec_with_context (IndicatorDesktopShortcuts * if (error != NULL) { g_warning("Unable to launch file from nick '%s': %s", nick, error->message); - g_error_free(error); - g_object_unref(appinfo); - return FALSE; + g_clear_error(&error); } g_object_unref(appinfo); -- cgit v1.2.3