Merge lp:~ted/ubuntu-app-launch/lp1365408-symbolic-icon into lp:ubuntu-app-launch/14.10

Proposed by Ted Gould
Status: Merged
Approved by: Charles Kerr
Approved revision: 175
Merged at revision: 171
Proposed branch: lp:~ted/ubuntu-app-launch/lp1365408-symbolic-icon
Merge into: lp:ubuntu-app-launch/14.10
Diff against target: 144 lines (+61/-25)
1 file modified
desktop-hook.c (+61/-25)
To merge this branch: bzr merge lp:~ted/ubuntu-app-launch/lp1365408-symbolic-icon
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+235307@code.launchpad.net

Commit message

Add handling for X-Ubuntu-SymbolicIcon in desktop hook

Description of the change

The feature is that we're handling the symbolic icon just like we do the icon field. Also did some cleanups in making the fields all defines and making it so that we can specify the icon error in the recoverable error.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote :

hooray for symbolic constants!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'desktop-hook.c'
2--- desktop-hook.c 2014-06-05 03:40:03 +0000
3+++ desktop-hook.c 2014-09-19 16:14:16 +0000
4@@ -59,6 +59,17 @@
5 guint64 desktop_modified;
6 };
7
8+/* Desktop Group */
9+#define DESKTOP_GROUP "Desktop Entry"
10+/* Desktop Keys */
11+#define APP_ID_KEY "X-Ubuntu-Application-ID"
12+#define PATH_KEY "Path"
13+#define EXEC_KEY "Exec"
14+#define ICON_KEY "Icon"
15+#define SYMBOLIC_ICON_KEY "X-Ubuntu-SymbolicIcon"
16+/* Other */
17+#define OLD_KEY_PREFIX "X-Ubuntu-Old-"
18+
19 /* Find an entry in the app array */
20 app_state_t *
21 find_app_entry (const gchar * name, GArray * app_array)
22@@ -212,7 +223,7 @@
23
24 /* Code to report an error, so we can start tracking how important this is */
25 static void
26-report_recoverable_error (const gchar * app_id, const gchar * originalicon, const gchar * iconpath)
27+report_recoverable_error (const gchar * app_id, const gchar * iconfield, const gchar * originalicon, const gchar * iconpath)
28 {
29 GError * error = NULL;
30 gint error_stdin = 0;
31@@ -254,10 +265,14 @@
32 write_string(error_stdin, iconpath);
33 write_null(error_stdin);
34
35+ write_string(error_stdin, "IconField");
36+ write_null(error_stdin);
37+ write_string(error_stdin, iconfield);
38+ write_null(error_stdin);
39+
40 write_string(error_stdin, "DuplicateSignature");
41 write_null(error_stdin);
42- write_string(error_stdin, "icon-path-unhandled-");
43- write_string(error_stdin, app_id);
44+ write_string(error_stdin, "icon-path-unhandled");
45 /* write_null(error_stdin); -- No final NULL */
46
47 close(error_stdin);
48@@ -309,32 +324,53 @@
49 }
50
51 /* Path Hanlding */
52- if (g_key_file_has_key(keyfile, "Desktop Entry", "Path", NULL)) {
53- gchar * oldpath = g_key_file_get_string(keyfile, "Desktop Entry", "Path", NULL);
54- g_debug("Desktop file '%s' has a Path set to '%s'. Setting as X-Ubuntu-Old-Path.", from, oldpath);
55+ if (g_key_file_has_key(keyfile, DESKTOP_GROUP, PATH_KEY, NULL)) {
56+ gchar * oldpath = g_key_file_get_string(keyfile, DESKTOP_GROUP, PATH_KEY, NULL);
57+ g_debug("Desktop file '%s' has a Path set to '%s'. Setting as " OLD_KEY_PREFIX PATH_KEY ".", from, oldpath);
58
59- g_key_file_set_string(keyfile, "Desktop Entry", "X-Ubuntu-Old-Path", oldpath);
60+ g_key_file_set_string(keyfile, DESKTOP_GROUP, OLD_KEY_PREFIX PATH_KEY, oldpath);
61
62 g_free(oldpath);
63 }
64
65- g_key_file_set_string(keyfile, "Desktop Entry", "Path", appdir);
66+ g_key_file_set_string(keyfile, DESKTOP_GROUP, PATH_KEY, appdir);
67
68 /* Icon Handling */
69- if (g_key_file_has_key(keyfile, "Desktop Entry", "Icon", NULL)) {
70- gchar * originalicon = g_key_file_get_string(keyfile, "Desktop Entry", "Icon", NULL);
71- gchar * iconpath = g_build_filename(appdir, originalicon, NULL);
72-
73- /* If the icon in the path exists, let's use that */
74- if (g_file_test(iconpath, G_FILE_TEST_EXISTS)) {
75- g_key_file_set_string(keyfile, "Desktop Entry", "Icon", iconpath);
76- /* Save the old value, because, debugging */
77- g_key_file_set_string(keyfile, "Desktop Entry", "X-Ubuntu-Old-Icon", originalicon);
78- } else {
79- /* So here we are, realizing all is lost. Let's file a bug. */
80- /* The goal here is to realize how often this case is, so we know how to prioritize fixing it */
81-
82- report_recoverable_error(app_id, originalicon, iconpath);
83+ if (g_key_file_has_key(keyfile, DESKTOP_GROUP, ICON_KEY, NULL)) {
84+ gchar * originalicon = g_key_file_get_string(keyfile, DESKTOP_GROUP, ICON_KEY, NULL);
85+ gchar * iconpath = g_build_filename(appdir, originalicon, NULL);
86+
87+ /* If the icon in the path exists, let's use that */
88+ if (g_file_test(iconpath, G_FILE_TEST_EXISTS)) {
89+ g_key_file_set_string(keyfile, DESKTOP_GROUP, ICON_KEY, iconpath);
90+ /* Save the old value, because, debugging */
91+ g_key_file_set_string(keyfile, DESKTOP_GROUP, OLD_KEY_PREFIX ICON_KEY, originalicon);
92+ } else {
93+ /* So here we are, realizing all is lost. Let's file a bug. */
94+ /* The goal here is to realize how often this case is, so we know how to prioritize fixing it */
95+
96+ report_recoverable_error(app_id, ICON_KEY, originalicon, iconpath);
97+ }
98+
99+ g_free(iconpath);
100+ g_free(originalicon);
101+ }
102+
103+ /* SymbolicIcon Handling */
104+ if (g_key_file_has_key(keyfile, DESKTOP_GROUP, SYMBOLIC_ICON_KEY, NULL)) {
105+ gchar * originalicon = g_key_file_get_string(keyfile, DESKTOP_GROUP, SYMBOLIC_ICON_KEY, NULL);
106+ gchar * iconpath = g_build_filename(appdir, originalicon, NULL);
107+
108+ /* If the icon in the path exists, let's use that */
109+ if (g_file_test(iconpath, G_FILE_TEST_EXISTS)) {
110+ g_key_file_set_string(keyfile, DESKTOP_GROUP, SYMBOLIC_ICON_KEY, iconpath);
111+ /* Save the old value, because, debugging */
112+ g_key_file_set_string(keyfile, DESKTOP_GROUP, OLD_KEY_PREFIX SYMBOLIC_ICON_KEY, originalicon);
113+ } else {
114+ /* So here we are, realizing all is lost. Let's file a bug. */
115+ /* The goal here is to realize how often this case is, so we know how to prioritize fixing it */
116+
117+ report_recoverable_error(app_id, SYMBOLIC_ICON_KEY, originalicon, iconpath);
118 }
119
120 g_free(iconpath);
121@@ -349,12 +385,12 @@
122 }
123
124 gchar * newexec = g_strdup_printf("aa-exec-click -p %s -- %s", app_id, oldexec);
125- g_key_file_set_string(keyfile, "Desktop Entry", "Exec", newexec);
126+ g_key_file_set_string(keyfile, DESKTOP_GROUP, EXEC_KEY, newexec);
127 g_free(newexec);
128 g_free(oldexec);
129
130 /* Adding an Application ID */
131- g_key_file_set_string(keyfile, "Desktop Entry", "X-Ubuntu-Application-ID", app_id);
132+ g_key_file_set_string(keyfile, DESKTOP_GROUP, APP_ID_KEY, app_id);
133
134 /* Output */
135 gsize datalen = 0;
136@@ -448,7 +484,7 @@
137 G_KEY_FILE_NONE,
138 NULL);
139
140- if (!g_key_file_has_key(keyfile, "Desktop Entry", "X-Ubuntu-Application-ID", NULL)) {
141+ if (!g_key_file_has_key(keyfile, DESKTOP_GROUP, APP_ID_KEY, NULL)) {
142 g_debug("Desktop file '%s' is not one created by us.", desktoppath);
143 g_key_file_unref(keyfile);
144 g_free(desktoppath);

Subscribers

People subscribed via source and target branches