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
=== modified file 'src/PlacesView.cpp'
--- src/PlacesView.cpp 2011-03-10 15:21:45 +0000
+++ src/PlacesView.cpp 2011-03-14 14:27:17 +0000
@@ -487,6 +487,7 @@
487PlacesView::OnResultActivated (GVariant *data, PlacesView *self)487PlacesView::OnResultActivated (GVariant *data, PlacesView *self)
488{488{
489 const char *uri;489 const char *uri;
490 int i;
490491
491 uri = g_variant_get_string (data, NULL);492 uri = g_variant_get_string (data, NULL);
492493
@@ -498,22 +499,50 @@
498499
499 if (g_str_has_prefix (uri, "application://"))500 if (g_str_has_prefix (uri, "application://"))
500 {501 {
501 const char *id = &uri[14];502 char *id = g_strdup (&uri[14]);
502 GDesktopAppInfo *info;503 GDesktopAppInfo *info;
503504
504 info = g_desktop_app_info_new (id);505 /* The docs for g_desktop_app_info_new() says it respects "-" to "/"
505 if (G_IS_DESKTOP_APP_INFO (info))506 * substitution as per XDG Menu Spec, but it only seems to work for
507 * exactly 1 substitution where as Wine programs often require many.
508 * Bottom line: We must do some manual trial and error to find desktop
509 * files in deeply nested directories */
510 while (id != NULL)
506 {511 {
507 GError *error = NULL;512 info = g_desktop_app_info_new (id);
508513 if (info != NULL)
509 g_app_info_launch (G_APP_INFO (info), NULL, NULL, &error);
510 if (error)
511 {514 {
512 g_warning ("Unable to launch %s: %s", id, error->message);515 GError *error = NULL;
513 g_error_free (error);516
517 g_app_info_launch (G_APP_INFO (info), NULL, NULL, &error);
518 if (error)
519 {
520 g_warning ("Unable to launch %s: %s", id, error->message);
521 g_error_free (error);
522 }
523 g_object_unref (info);
524 break;
514 }525 }
515 g_object_unref (info);526
527 /* Try to replace the next - with a / and do the lookup again.
528 * If we set id=NULL we'll exit the outer loop */
529 for (i = 0; ; i++)
530 {
531 if (id[i] == '-')
532 {
533 id[i] = '/';
534 break;
535 }
536 else if (id[i] == '\0')
537 {
538 g_free (id);
539 id = NULL;
540 break;
541 }
542 }
516 }543 }
544
545 g_free (id);
517 }546 }
518 else547 else
519 {548 {