Merge lp:~kamstrup/unity/localapps into lp:unity

Proposed by Mikkel Kamstrup Erlandsen
Status: Merged
Approved by: Mirco Müller
Approved revision: no longer in the source branch.
Merged at revision: 954
Proposed branch: lp:~kamstrup/unity/localapps
Merge into: lp:unity
Diff against target: 72 lines (+39/-10)
1 file modified
src/PlacesView.cpp (+39/-10)
To merge this branch: bzr merge lp:~kamstrup/unity/localapps
Reviewer Review Type Date Requested Status
Mirco Müller (community) Approve
Review via email: mp+53248@code.launchpad.net

Description of the change

See commit msg

To post a comment you must log in.
Revision history for this message
Mirco Müller (macslow) wrote :

Uff... that was taking quite some time to test. But approved now.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/PlacesView.cpp'
2--- src/PlacesView.cpp 2011-03-10 15:21:45 +0000
3+++ src/PlacesView.cpp 2011-03-14 14:27:17 +0000
4@@ -487,6 +487,7 @@
5 PlacesView::OnResultActivated (GVariant *data, PlacesView *self)
6 {
7 const char *uri;
8+ int i;
9
10 uri = g_variant_get_string (data, NULL);
11
12@@ -498,22 +499,50 @@
13
14 if (g_str_has_prefix (uri, "application://"))
15 {
16- const char *id = &uri[14];
17+ char *id = g_strdup (&uri[14]);
18 GDesktopAppInfo *info;
19
20- info = g_desktop_app_info_new (id);
21- if (G_IS_DESKTOP_APP_INFO (info))
22+ /* The docs for g_desktop_app_info_new() says it respects "-" to "/"
23+ * substitution as per XDG Menu Spec, but it only seems to work for
24+ * exactly 1 substitution where as Wine programs often require many.
25+ * Bottom line: We must do some manual trial and error to find desktop
26+ * files in deeply nested directories */
27+ while (id != NULL)
28 {
29- GError *error = NULL;
30-
31- g_app_info_launch (G_APP_INFO (info), NULL, NULL, &error);
32- if (error)
33+ info = g_desktop_app_info_new (id);
34+ if (info != NULL)
35 {
36- g_warning ("Unable to launch %s: %s", id, error->message);
37- g_error_free (error);
38+ GError *error = NULL;
39+
40+ g_app_info_launch (G_APP_INFO (info), NULL, NULL, &error);
41+ if (error)
42+ {
43+ g_warning ("Unable to launch %s: %s", id, error->message);
44+ g_error_free (error);
45+ }
46+ g_object_unref (info);
47+ break;
48 }
49- g_object_unref (info);
50+
51+ /* Try to replace the next - with a / and do the lookup again.
52+ * If we set id=NULL we'll exit the outer loop */
53+ for (i = 0; ; i++)
54+ {
55+ if (id[i] == '-')
56+ {
57+ id[i] = '/';
58+ break;
59+ }
60+ else if (id[i] == '\0')
61+ {
62+ g_free (id);
63+ id = NULL;
64+ break;
65+ }
66+ }
67 }
68+
69+ g_free (id);
70 }
71 else
72 {