diff -Nru libunity-7.1.4+16.04.20160701/configure.ac libunity-7.1.4+16.04.20180209.1/configure.ac --- libunity-7.1.4+16.04.20160701/configure.ac 2016-07-01 10:43:33.000000000 +0000 +++ libunity-7.1.4+16.04.20180209.1/configure.ac 2018-02-09 15:48:31.000000000 +0000 @@ -210,7 +210,7 @@ if test "x$enable_headless_tests" = "xyes"; then AC_PATH_PROG([XVFB],[xvfb-run]) - AC_PATH_PROG([DBUS_LAUNCH],[dbus-launch]) + AC_PATH_PROG([DBUS_LAUNCH],[dbus-run-session]) fi ########################### diff -Nru libunity-7.1.4+16.04.20160701/debian/changelog libunity-7.1.4+16.04.20180209.1/debian/changelog --- libunity-7.1.4+16.04.20160701/debian/changelog 2018-02-19 10:12:13.000000000 +0000 +++ libunity-7.1.4+16.04.20180209.1/debian/changelog 2018-02-19 10:12:14.000000000 +0000 @@ -1,3 +1,10 @@ +libunity (7.1.4+16.04.20180209.1-0ubuntu1) xenial; urgency=medium + + * UnityLauncher: Prepend snap namespace to desktop file or desktop-id + (LP: #1747814) + + -- Marco Trevisan (TreviƱo) Fri, 09 Feb 2018 15:48:43 +0000 + libunity (7.1.4+16.04.20160701-0ubuntu1) xenial; urgency=medium [ Andrea Azzarone ] diff -Nru libunity-7.1.4+16.04.20160701/examples/launcher.py libunity-7.1.4+16.04.20180209.1/examples/launcher.py --- libunity-7.1.4+16.04.20160701/examples/launcher.py 2016-07-01 10:43:33.000000000 +0000 +++ libunity-7.1.4+16.04.20180209.1/examples/launcher.py 2018-02-09 15:48:31.000000000 +0000 @@ -3,7 +3,7 @@ loop = GObject.MainLoop() # Pretend to be evolution for the sake of the example -launcher = Unity.LauncherEntry.get_for_desktop_id ("evolution.desktop") +launcher = Unity.LauncherEntry.get_for_desktop_id ("firefox.desktop") # Show a count of 124 on the icon launcher.set_property("count", 124) diff -Nru libunity-7.1.4+16.04.20160701/examples/launcher.vala libunity-7.1.4+16.04.20180209.1/examples/launcher.vala --- libunity-7.1.4+16.04.20160701/examples/launcher.vala 2016-07-01 10:43:33.000000000 +0000 +++ libunity-7.1.4+16.04.20180209.1/examples/launcher.vala 2018-02-09 15:48:31.000000000 +0000 @@ -4,7 +4,7 @@ public static void main () { /* Pretend to be evolution for the sake of the example */ - var l = Unity.LauncherEntry.get_for_desktop_id ("evolution.desktop"); + var l = Unity.LauncherEntry.get_for_desktop_id ("firefox.desktop"); /* Show a count of 124 on the icon */ l.count = 124; @@ -16,7 +16,7 @@ /* Set us as urgent. Quickly! Go! Go! Go! Now! Now! */ l.urgent = true; - + /* We also want a quicklist */ var ql = new Dbusmenu.Menuitem (); var item1 = new Dbusmenu.Menuitem (); @@ -29,5 +29,4 @@ new MainLoop().run(); } - } diff -Nru libunity-7.1.4+16.04.20160701/examples/Makefile.am libunity-7.1.4+16.04.20180209.1/examples/Makefile.am --- libunity-7.1.4+16.04.20160701/examples/Makefile.am 2016-07-01 10:43:33.000000000 +0000 +++ libunity-7.1.4+16.04.20180209.1/examples/Makefile.am 2018-02-09 15:48:31.000000000 +0000 @@ -13,6 +13,7 @@ unitylibdir = $(libdir)/unity noinst_LTLIBRARIES = scope1.la scope2.la +noinst_PROGRAMS = launcher scope1_la_VALASOURCES = scope1.vala scope1_la_SOURCES = $(scope1_la_VALASOURCES:.vala=.c) @@ -28,9 +29,17 @@ $(top_builddir)/src/libunity.la \ $(LIBUNITY_LIBS) +launcher_VALASOURCES = launcher.vala +launcher_SOURCES = $(launcher_VALASOURCES:.vala=.c) +launcher_LDFLAGS = -shared -module -no-undefined -rpath $(unitylibdir) +launcher_LDADD = \ + $(top_builddir)/src/libunity.la \ + $(LIBUNITY_LIBS) + BUILT_SOURCES = \ scope1.vala.stamp \ - scope2.vala.stamp + scope2.vala.stamp \ + launcher.vala.stamp scope1.vala.stamp: $(scope1_la_VALASOURCES) $(AM_V_GEN)$(VALAC) -C $(AM_VALAFLAGS) $(VALAFLAGS) $^ @@ -40,11 +49,15 @@ $(AM_V_GEN)$(VALAC) -C $(AM_VALAFLAGS) $(VALAFLAGS) $^ @touch $@ +launcher.vala.stamp: $(launcher_VALASOURCES) + $(AM_V_GEN)$(VALAC) -C $(AM_VALAFLAGS) $(VALAFLAGS) $^ + @touch $@ + EXTRA_DIST = \ $(scope1_la_VALASOURCES) \ $(scope2_la_VALASOURCES) \ - launcher.py \ - launcher.vala + $(launcher_VALASOURCES) \ + launcher.py CLEANFILES = $(scope1_la_SOURCES) $(scope2_la_SOURCES) $(BUILT_SOURCES) diff -Nru libunity-7.1.4+16.04.20160701/Makefile.decl libunity-7.1.4+16.04.20180209.1/Makefile.decl --- libunity-7.1.4+16.04.20160701/Makefile.decl 2016-07-01 10:43:33.000000000 +0000 +++ libunity-7.1.4+16.04.20180209.1/Makefile.decl 2018-02-09 15:48:31.000000000 +0000 @@ -74,7 +74,7 @@ LOG_PATH = headless-logs test-headless: set -e; \ - $(XVFB) -a make test-nonrecursive; \ + $(DBUS_LAUNCH) $(XVFB) -a make test-nonrecursive; \ sleep 1; else check-local: test-nonrecursive diff -Nru libunity-7.1.4+16.04.20160701/src/unity-launcher.vala libunity-7.1.4+16.04.20180209.1/src/unity-launcher.vala --- libunity-7.1.4+16.04.20160701/src/unity-launcher.vala 2016-07-01 10:43:33.000000000 +0000 +++ libunity-7.1.4+16.04.20180209.1/src/unity-launcher.vala 2018-02-09 15:48:31.000000000 +0000 @@ -28,7 +28,10 @@ using GLib; -namespace Unity { +namespace Unity { + + private const string APP_PREFIX = "application://"; + private const string FILE_PREFIX = "file://"; /* Private class to wire up the DBus stuff. Private so that we don't * leak DBus implementation details into the public API */ @@ -170,27 +173,56 @@ { Object (app_uri : app_uri); } - + public static LauncherEntry get_for_app_uri (string app_uri) { if (global_entries_map == null) global_entries_map = new HashTable (str_hash, str_equal); - - LauncherEntry? entry = global_entries_map.lookup (app_uri); + + string real_app_uri = app_uri; + unowned string snap_path = Environment.get_variable ("SNAP"); + unowned string snap_name = Environment.get_variable ("SNAP_NAME"); + + if (snap_path != null && snap_name != null) + { + debug (@"App is running into a snap container ($snap_name)"); + string app = app_uri.substring (APP_PREFIX.length); + + if (app[0] == '/') + { + if (!FileUtils.test (app, FileTest.IS_REGULAR)) + { + real_app_uri = APP_PREFIX + snap_path + app; + debug (@"Impossible to read file $app, trying with snap namespace: $real_app_uri"); + } + } + else + { + string snap_app_prefix = snap_name + "_"; + + if (!app.has_prefix (snap_app_prefix)) + { + real_app_uri = APP_PREFIX + snap_app_prefix + app; + debug (@"App uri does not contain the snap prefix, fixed: '$real_app_uri'"); + } + } + } + + LauncherEntry? entry = global_entries_map.lookup (real_app_uri); if (entry != null) { return entry; } - - entry = new LauncherEntry (app_uri); - global_entries_map.insert (app_uri, entry); + + entry = new LauncherEntry (real_app_uri); + global_entries_map.insert (real_app_uri, entry); return entry; } - + public static LauncherEntry get_for_desktop_id (string desktop_id) { - return LauncherEntry.get_for_app_uri ("application://" + desktop_id); + return LauncherEntry.get_for_app_uri (APP_PREFIX + desktop_id); } public static LauncherEntry get_for_desktop_file (string desktop_file) @@ -381,9 +413,6 @@ fav_cache.remove_all (); fav_list = {}; - const string APP_PREFIX = "application://"; - const string FILE_PREFIX = "file://"; - foreach (string id in settings.get_strv ("favorites")) { if (id.has_prefix (APP_PREFIX))