Merge lp:~3v1n0/libindicator/use-gappinfo-commandline-13.04 into lp:libindicator/13.04

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Ted Gould
Approved revision: 487
Merged at revision: 488
Proposed branch: lp:~3v1n0/libindicator/use-gappinfo-commandline-13.04
Merge into: lp:libindicator/13.04
Diff against target: 62 lines (+12/-22)
1 file modified
libindicator/indicator-desktop-shortcuts.c (+12/-22)
To merge this branch: bzr merge lp:~3v1n0/libindicator/use-gappinfo-commandline-13.04
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+158571@code.launchpad.net

Commit message

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.

Description of the change

To post a comment you must log in.
487. By Marco Trevisan (Treviño)

IndicatorDesktopShortcuts: initialize flags using the default define

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ted Gould (ted) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libindicator/indicator-desktop-shortcuts.c'
2--- libindicator/indicator-desktop-shortcuts.c 2013-04-09 02:59:08 +0000
3+++ libindicator/indicator-desktop-shortcuts.c 2013-04-12 11:52:27 +0000
4@@ -625,46 +625,36 @@
5 NULL,
6 NULL);
7
8- /* Build a new desktop file with the name and exec in the desktop
9- group. We have to do this with data as apparently there isn't
10- and add_group function in g_key_file. Go figure. */
11- gchar * desktopdata = g_strdup_printf("[" G_KEY_FILE_DESKTOP_GROUP "]\n"
12- G_KEY_FILE_DESKTOP_KEY_TYPE "=" G_KEY_FILE_DESKTOP_TYPE_APPLICATION "\n"
13- G_KEY_FILE_DESKTOP_KEY_NAME "=%s\n"
14- G_KEY_FILE_DESKTOP_KEY_EXEC "=%s\n"
15- G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY "=%s\n",
16- name, exec, launch_context ? "true" : "false");
17-
18+ GAppInfoCreateFlags flags = G_APP_INFO_CREATE_NONE;
19+
20+ if (launch_context) {
21+ flags |= G_APP_INFO_CREATE_SUPPORTS_STARTUP_NOTIFICATION;
22+ }
23+
24+ GAppInfo * appinfo = g_app_info_create_from_commandline(exec, name, flags, &error);
25 g_free(name); g_free(exec);
26- /* g_debug("Desktop file: \n%s", desktopdata); */
27-
28- GKeyFile * launcher = g_key_file_new();
29- g_key_file_load_from_data(launcher, desktopdata, -1, G_KEY_FILE_NONE, &error);
30- g_free(desktopdata);
31
32 if (error != NULL) {
33- g_warning("Unable to build desktop keyfile for executing shortcut '%s': %s", nick, error->message);
34+ g_warning("Unable to build Command line App info: %s", error->message);
35 g_error_free(error);
36 return FALSE;
37 }
38
39- GDesktopAppInfo * appinfo = g_desktop_app_info_new_from_keyfile(launcher);
40 if (appinfo == NULL) {
41- g_warning("Unable to build Desktop App info (unknown)");
42- g_key_file_free(launcher);
43+ g_warning("Unable to build Command line App info (unknown)");
44 return FALSE;
45 }
46- gboolean launched = g_app_info_launch(G_APP_INFO(appinfo), NULL, launch_context, &error);
47+
48+ gboolean launched = g_app_info_launch(appinfo, NULL, launch_context, &error);
49
50 if (error != NULL) {
51 g_warning("Unable to launch file from nick '%s': %s", nick, error->message);
52 g_error_free(error);
53- g_key_file_free(launcher);
54+ g_object_unref(appinfo);
55 return FALSE;
56 }
57
58 g_object_unref(appinfo);
59- g_key_file_free(launcher);
60
61 return launched;
62 }

Subscribers

People subscribed via source and target branches