Merge lp:~donadigo/slingshot/uninstall-apps into lp:~elementary-pantheon/slingshot/trunk

Proposed by Adam Bieńkowski
Status: Work in progress
Proposed branch: lp:~donadigo/slingshot/uninstall-apps
Merge into: lp:~elementary-pantheon/slingshot/trunk
Diff against target: 117 lines (+49/-2)
3 files modified
CMakeLists.txt (+1/-1)
src/CMakeLists.txt (+1/-0)
src/Widgets/AppEntry.vala (+47/-1)
To merge this branch: bzr merge lp:~donadigo/slingshot/uninstall-apps
Reviewer Review Type Date Requested Status
Danielle Foré Needs Fixing
Jung-Kyu Park (community) Approve
Neal Gompa (community) Needs Information
Review via email: mp+313915@code.launchpad.net

Commit message

* Add uninstall item to app right-click menu to uninstall apps

Description of the change

This branch fixes bug #1211570: "Uninstall apps from context menu in Slingshot".

The implementation is done with appstream, altough on Slack we also talked about a possible implementation depending on Contractor / appstream-glib in the future.

The Gtk.show_uri error is only handeled internally, so there is no warning message shown to the user when the app handling appstream URI couldn't be launched for some reason (definitely should be shown in the future).

Please test, if launching wingpanel doesn't take too much time, because this branch uses heavy AppStream.Pool.load () which could make impact on loading times on logging in first time or launching wingpanel from terminal.

To post a comment you must log in.
714. By Adam Bieńkowski

Remove unneded return line; check if component id is already assigned

Revision history for this message
Neal Gompa (ngompa13) wrote :

If you're going to use AppStream instead of appstream-glib, be sure to target AppStream 0.10 or newer only. There's an API break between 0.9.x and 0.10.x.

review: Needs Fixing
Revision history for this message
Neal Gompa (ngompa13) wrote :

Also, I'm curious why you moved the #ifdef for HAS_PLANK. There doesn't seem to be an obvious reason for it.

review: Needs Information
715. By Adam Bieńkowski

Bump appstream version to 0.10.0

Revision history for this message
Jung-Kyu Park (bagjunggyu) wrote :

It works good with AppCenter.

review: Approve
Revision history for this message
Danielle Foré (danrabbit) wrote :

This is not working for David and me. But even if it were working, I would not merge because it doesn't do what it says it does. It says "Uninstall" but it doesn't actually perform an uninstall.

review: Needs Fixing
Revision history for this message
Rico Tzschichholz (ricotz) wrote :

This is already merged!

Revision history for this message
Adam Bieńkowski (donadigo) wrote :

ricotz: We discussed this on Slack, it will be just reverted, hence the review.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2016-08-14 19:55:27 +0000
+++ CMakeLists.txt 2016-12-30 12:20:39 +0000
@@ -77,7 +77,7 @@
77 endif ()77 endif ()
78endif ()78endif ()
7979
80set (CORE_DEPS "gobject-2.0;glib-2.0;gio-2.0;gio-unix-2.0;libsoup-2.4;gee-0.8;libgnome-menu-3.0;json-glib-1.0;${UNITY_DEPS};${PLANK_DEPS};")80set (CORE_DEPS "gobject-2.0;glib-2.0;gio-2.0;gio-unix-2.0;libsoup-2.4;gee-0.8;libgnome-menu-3.0;json-glib-1.0;${UNITY_DEPS};${PLANK_DEPS};appstream>=0.10.0;")
81set (UI_DEPS "wingpanel-2.0;gtk+-3.0>=3.12.0;granite;${ZEITGEIST_DEPS};")81set (UI_DEPS "wingpanel-2.0;gtk+-3.0>=3.12.0;granite;${ZEITGEIST_DEPS};")
8282
83pkg_check_modules (DEPS REQUIRED "${CORE_DEPS}${UI_DEPS}" gthread-2.0)83pkg_check_modules (DEPS REQUIRED "${CORE_DEPS}${UI_DEPS}" gthread-2.0)
8484
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2015-11-21 11:47:57 +0000
+++ src/CMakeLists.txt 2016-12-30 12:20:39 +0000
@@ -29,6 +29,7 @@
29 ${UI_DEPS}29 ${UI_DEPS}
30 synapse-core30 synapse-core
31 synapse-plugins31 synapse-plugins
32 appstream
32CUSTOM_VAPIS33CUSTOM_VAPIS
33 ../vapi/config.vapi34 ../vapi/config.vapi
34OPTIONS35OPTIONS
3536
=== modified file 'src/Widgets/AppEntry.vala'
--- src/Widgets/AppEntry.vala 2016-12-27 21:08:33 +0000
+++ src/Widgets/AppEntry.vala 2016-12-30 12:20:39 +0000
@@ -50,9 +50,10 @@
50 private Gtk.Image count_image;50 private Gtk.Image count_image;
51 private bool dragging = false; //prevent launching51 private bool dragging = false; //prevent launching
52 private Backend.App application;52 private Backend.App application;
53 private string? appstream_comp_id = null;
5354
54#if HAS_PLANK
55 static construct {55 static construct {
56#if HAS_PLANK
56 Plank.Paths.initialize ("plank", Build.PKGDATADIR);57 Plank.Paths.initialize ("plank", Build.PKGDATADIR);
57 plank_theme = new Plank.DockTheme (Plank.Theme.GTK_THEME_NAME);58 plank_theme = new Plank.DockTheme (Plank.Theme.GTK_THEME_NAME);
58#if HAS_PLANK_0_1159#if HAS_PLANK_0_11
@@ -60,10 +61,23 @@
60#else61#else
61 plank_client = Plank.DBus.Client.get_instance ();62 plank_client = Plank.DBus.Client.get_instance ();
62#endif63#endif
64#endif
65
66 has_appstream_handler = AppInfo.get_default_for_uri_scheme ("appstream") != null;
67 appstream_pool = new AppStream.Pool ();
68 try {
69 appstream_pool.load ();
70 } catch (Error e) {
71 warning (e.message);
72 }
63 }73 }
6474
65 private const int ICON_SIZE = 64;75 private const int ICON_SIZE = 64;
6676
77 private static AppStream.Pool appstream_pool;
78 private static bool has_appstream_handler = false;
79
80#if HAS_PLANK
67#if HAS_PLANK_0_1181#if HAS_PLANK_0_11
68 private const int SURFACE_SIZE = 48;82 private const int SURFACE_SIZE = 48;
69 private static Plank.DockTheme plank_theme;83 private static Plank.DockTheme plank_theme;
@@ -88,6 +102,12 @@
88 application = app;102 application = app;
89 tooltip_text = app.description;103 tooltip_text = app.description;
90104
105 appstream_pool.get_components ().foreach ((comp) => {
106 if (appstream_comp_id == null && desktop_id == comp.get_desktop_id () && comp.get_pkgname () != null) {
107 appstream_comp_id = comp.get_id ();
108 }
109 });
110
91 get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT);111 get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT);
92112
93 app_label = new Gtk.Label (app_name);113 app_label = new Gtk.Label (app_name);
@@ -217,6 +237,14 @@
217 });237 });
218 }238 }
219239
240 if (has_appstream_handler && appstream_comp_id != null) {
241 if (menu.get_children ().length () > 0) {
242 menu.add (new Gtk.SeparatorMenuItem ());
243 }
244
245 menu.add (get_uninstall_menuitem ());
246 }
247
220#if HAS_PLANK248#if HAS_PLANK
221 if (plank_client != null && plank_client.is_connected) {249 if (plank_client != null && plank_client.is_connected) {
222 if (menu.get_children ().length () > 0)250 if (menu.get_children ().length () > 0)
@@ -229,6 +257,24 @@
229 menu.show_all ();257 menu.show_all ();
230 }258 }
231259
260 private Gtk.MenuItem get_uninstall_menuitem () {
261 var uninstall_menuitem = new Gtk.MenuItem ();
262 uninstall_menuitem.set_label (_("Uninstall"));
263 uninstall_menuitem.activate.connect (uninstall_menuitem_activate);
264
265 return uninstall_menuitem;
266 }
267
268 private void uninstall_menuitem_activate () {
269 try {
270 Gtk.show_uri (null, "appstream://%s".printf (appstream_comp_id), Gdk.CURRENT_TIME);
271 } catch (Error e) {
272 warning (e.message);
273 }
274
275 app_launched ();
276 }
277
232#if HAS_PLANK278#if HAS_PLANK
233 private Gtk.MenuItem get_plank_menuitem () {279 private Gtk.MenuItem get_plank_menuitem () {
234 docked = (desktop_uri in plank_client.get_persistent_applications ());280 docked = (desktop_uri in plank_client.get_persistent_applications ());

Subscribers

People subscribed via source and target branches