Merge lp:~3v1n0/libunity/desktop-use-snap-namespace-x into lp:libunity/xenial

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Andrea Azzarone
Approved revision: 325
Merged at revision: 325
Proposed branch: lp:~3v1n0/libunity/desktop-use-snap-namespace-x
Merge into: lp:libunity/xenial
Diff against target: 221 lines (+69/-21)
7 files modified
Makefile.decl (+1/-1)
configure.ac (+1/-1)
debian/changelog (+7/-0)
examples/Makefile.am (+16/-3)
examples/launcher.py (+1/-1)
examples/launcher.vala (+2/-3)
src/unity-launcher.vala (+41/-12)
To merge this branch: bzr merge lp:~3v1n0/libunity/desktop-use-snap-namespace-x
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Approve
Review via email: mp+337274@code.launchpad.net

Commit message

UnityLauncher: Prepend snap namespace to desktop file or desktop-id

To post a comment you must log in.
Revision history for this message
Andrea Azzarone (azzar1) wrote :

LGTM.

review: Approve
326. By Marco Trevisan (Treviño)

launcher: fix a typo, don't double-check for same var

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Makefile.decl'
--- Makefile.decl 2013-01-10 11:20:42 +0000
+++ Makefile.decl 2018-02-09 14:37:54 +0000
@@ -74,7 +74,7 @@
74LOG_PATH = headless-logs74LOG_PATH = headless-logs
75test-headless:75test-headless:
76 set -e; \76 set -e; \
77 $(XVFB) -a make test-nonrecursive; \77 $(DBUS_LAUNCH) $(XVFB) -a make test-nonrecursive; \
78 sleep 1;78 sleep 1;
79else79else
80check-local: test-nonrecursive80check-local: test-nonrecursive
8181
=== modified file 'configure.ac'
--- configure.ac 2014-02-04 21:38:14 +0000
+++ configure.ac 2018-02-09 14:37:54 +0000
@@ -210,7 +210,7 @@
210210
211if test "x$enable_headless_tests" = "xyes"; then211if test "x$enable_headless_tests" = "xyes"; then
212 AC_PATH_PROG([XVFB],[xvfb-run])212 AC_PATH_PROG([XVFB],[xvfb-run])
213 AC_PATH_PROG([DBUS_LAUNCH],[dbus-launch])213 AC_PATH_PROG([DBUS_LAUNCH],[dbus-run-session])
214fi214fi
215215
216###########################216###########################
217217
=== modified file 'debian/changelog'
--- debian/changelog 2016-07-01 10:44:10 +0000
+++ debian/changelog 2018-02-09 14:37:54 +0000
@@ -1,3 +1,10 @@
1libunity (7.1.4+16.04.20160701-0ubuntu2) UNRELEASED; urgency=medium
2
3 * UnityLauncher: Prepend snap namespace to desktop file or desktop-id
4 (LP: #1747814)
5
6 -- Marco Trevisan (Treviño) <mail@3v1n0.net> Wed, 07 Feb 2018 15:48:55 +0100
7
1libunity (7.1.4+16.04.20160701-0ubuntu1) xenial; urgency=medium8libunity (7.1.4+16.04.20160701-0ubuntu1) xenial; urgency=medium
29
3 [ Andrea Azzarone ]10 [ Andrea Azzarone ]
411
=== modified file 'examples/Makefile.am'
--- examples/Makefile.am 2013-06-25 08:09:45 +0000
+++ examples/Makefile.am 2018-02-09 14:37:54 +0000
@@ -13,6 +13,7 @@
13unitylibdir = $(libdir)/unity13unitylibdir = $(libdir)/unity
1414
15noinst_LTLIBRARIES = scope1.la scope2.la15noinst_LTLIBRARIES = scope1.la scope2.la
16noinst_PROGRAMS = launcher
1617
17scope1_la_VALASOURCES = scope1.vala18scope1_la_VALASOURCES = scope1.vala
18scope1_la_SOURCES = $(scope1_la_VALASOURCES:.vala=.c)19scope1_la_SOURCES = $(scope1_la_VALASOURCES:.vala=.c)
@@ -28,9 +29,17 @@
28 $(top_builddir)/src/libunity.la \29 $(top_builddir)/src/libunity.la \
29 $(LIBUNITY_LIBS)30 $(LIBUNITY_LIBS)
3031
32launcher_VALASOURCES = launcher.vala
33launcher_SOURCES = $(launcher_VALASOURCES:.vala=.c)
34launcher_LDFLAGS = -shared -module -no-undefined -rpath $(unitylibdir)
35launcher_LDADD = \
36 $(top_builddir)/src/libunity.la \
37 $(LIBUNITY_LIBS)
38
31BUILT_SOURCES = \39BUILT_SOURCES = \
32 scope1.vala.stamp \40 scope1.vala.stamp \
33 scope2.vala.stamp41 scope2.vala.stamp \
42 launcher.vala.stamp
3443
35scope1.vala.stamp: $(scope1_la_VALASOURCES)44scope1.vala.stamp: $(scope1_la_VALASOURCES)
36 $(AM_V_GEN)$(VALAC) -C $(AM_VALAFLAGS) $(VALAFLAGS) $^45 $(AM_V_GEN)$(VALAC) -C $(AM_VALAFLAGS) $(VALAFLAGS) $^
@@ -40,11 +49,15 @@
40 $(AM_V_GEN)$(VALAC) -C $(AM_VALAFLAGS) $(VALAFLAGS) $^49 $(AM_V_GEN)$(VALAC) -C $(AM_VALAFLAGS) $(VALAFLAGS) $^
41 @touch $@50 @touch $@
4251
52launcher.vala.stamp: $(launcher_VALASOURCES)
53 $(AM_V_GEN)$(VALAC) -C $(AM_VALAFLAGS) $(VALAFLAGS) $^
54 @touch $@
55
43EXTRA_DIST = \56EXTRA_DIST = \
44 $(scope1_la_VALASOURCES) \57 $(scope1_la_VALASOURCES) \
45 $(scope2_la_VALASOURCES) \58 $(scope2_la_VALASOURCES) \
46 launcher.py \59 $(launcher_VALASOURCES) \
47 launcher.vala60 launcher.py
4861
49CLEANFILES = $(scope1_la_SOURCES) $(scope2_la_SOURCES) $(BUILT_SOURCES)62CLEANFILES = $(scope1_la_SOURCES) $(scope2_la_SOURCES) $(BUILT_SOURCES)
5063
5164
=== modified file 'examples/launcher.py'
--- examples/launcher.py 2011-04-07 08:05:31 +0000
+++ examples/launcher.py 2018-02-09 14:37:54 +0000
@@ -3,7 +3,7 @@
3loop = GObject.MainLoop()3loop = GObject.MainLoop()
44
5# Pretend to be evolution for the sake of the example 5# Pretend to be evolution for the sake of the example
6launcher = Unity.LauncherEntry.get_for_desktop_id ("evolution.desktop")6launcher = Unity.LauncherEntry.get_for_desktop_id ("firefox.desktop")
77
8# Show a count of 124 on the icon8# Show a count of 124 on the icon
9launcher.set_property("count", 124)9launcher.set_property("count", 124)
1010
=== modified file 'examples/launcher.vala'
--- examples/launcher.vala 2011-04-07 08:05:31 +0000
+++ examples/launcher.vala 2018-02-09 14:37:54 +0000
@@ -4,7 +4,7 @@
4 public static void main ()4 public static void main ()
5 {5 {
6 /* Pretend to be evolution for the sake of the example */6 /* Pretend to be evolution for the sake of the example */
7 var l = Unity.LauncherEntry.get_for_desktop_id ("evolution.desktop");7 var l = Unity.LauncherEntry.get_for_desktop_id ("firefox.desktop");
88
9 /* Show a count of 124 on the icon */9 /* Show a count of 124 on the icon */
10 l.count = 124;10 l.count = 124;
@@ -16,7 +16,7 @@
1616
17 /* Set us as urgent. Quickly! Go! Go! Go! Now! Now! */17 /* Set us as urgent. Quickly! Go! Go! Go! Now! Now! */
18 l.urgent = true;18 l.urgent = true;
19 19
20 /* We also want a quicklist */20 /* We also want a quicklist */
21 var ql = new Dbusmenu.Menuitem ();21 var ql = new Dbusmenu.Menuitem ();
22 var item1 = new Dbusmenu.Menuitem ();22 var item1 = new Dbusmenu.Menuitem ();
@@ -29,5 +29,4 @@
2929
30 new MainLoop().run();30 new MainLoop().run();
31 }31 }
32
33}32}
3433
=== modified file 'src/unity-launcher.vala'
--- src/unity-launcher.vala 2015-09-21 17:53:48 +0000
+++ src/unity-launcher.vala 2018-02-09 14:37:54 +0000
@@ -28,7 +28,10 @@
28 28
29using GLib;29using GLib;
3030
31namespace Unity { 31namespace Unity {
32
33 private const string APP_PREFIX = "application://";
34 private const string FILE_PREFIX = "file://";
3235
33 /* Private class to wire up the DBus stuff. Private so that we don't36 /* Private class to wire up the DBus stuff. Private so that we don't
34 * leak DBus implementation details into the public API */37 * leak DBus implementation details into the public API */
@@ -170,27 +173,56 @@
170 {173 {
171 Object (app_uri : app_uri);174 Object (app_uri : app_uri);
172 }175 }
173 176
174 public static LauncherEntry get_for_app_uri (string app_uri)177 public static LauncherEntry get_for_app_uri (string app_uri)
175 {178 {
176 if (global_entries_map == null)179 if (global_entries_map == null)
177 global_entries_map =180 global_entries_map =
178 new HashTable<string, LauncherEntry> (str_hash, str_equal);181 new HashTable<string, LauncherEntry> (str_hash, str_equal);
179 182
180 LauncherEntry? entry = global_entries_map.lookup (app_uri);183 string real_app_uri = app_uri;
184 unowned string snap_path = Environment.get_variable ("SNAP");
185 unowned string snap_name = Environment.get_variable ("SNAP_NAME");
186
187 if (snap_path != null && snap_name != null)
188 {
189 debug (@"App is running into a snap container ($snap_name)");
190 string app = app_uri.substring (APP_PREFIX.length);
191
192 if (app[0] == '/')
193 {
194 if (!FileUtils.test (app, FileTest.IS_REGULAR))
195 {
196 real_app_uri = APP_PREFIX + snap_path + app;
197 debug (@"Impossible to read file $app, trying with snap namespace: $real_app_uri");
198 }
199 }
200 else
201 {
202 string snap_app_prefix = snap_name + "_";
203
204 if (!app.has_prefix (snap_app_prefix))
205 {
206 real_app_uri = APP_PREFIX + snap_app_prefix + app;
207 debug (@"App uri does not contain the snap prefix, fixed: '$real_app_uri'");
208 }
209 }
210 }
211
212 LauncherEntry? entry = global_entries_map.lookup (real_app_uri);
181 if (entry != null)213 if (entry != null)
182 {214 {
183 return entry;215 return entry;
184 }216 }
185 217
186 entry = new LauncherEntry (app_uri);218 entry = new LauncherEntry (real_app_uri);
187 global_entries_map.insert (app_uri, entry);219 global_entries_map.insert (real_app_uri, entry);
188 return entry;220 return entry;
189 }221 }
190 222
191 public static LauncherEntry get_for_desktop_id (string desktop_id)223 public static LauncherEntry get_for_desktop_id (string desktop_id)
192 {224 {
193 return LauncherEntry.get_for_app_uri ("application://" + desktop_id);225 return LauncherEntry.get_for_app_uri (APP_PREFIX + desktop_id);
194 }226 }
195 227
196 public static LauncherEntry get_for_desktop_file (string desktop_file)228 public static LauncherEntry get_for_desktop_file (string desktop_file)
@@ -381,9 +413,6 @@
381 fav_cache.remove_all ();413 fav_cache.remove_all ();
382 fav_list = {};414 fav_list = {};
383415
384 const string APP_PREFIX = "application://";
385 const string FILE_PREFIX = "file://";
386
387 foreach (string id in settings.get_strv ("favorites"))416 foreach (string id in settings.get_strv ("favorites"))
388 {417 {
389 if (id.has_prefix (APP_PREFIX))418 if (id.has_prefix (APP_PREFIX))

Subscribers

People subscribed via source and target branches