Merge lp:~donadigo/slingshot/show-app-badges into lp:~elementary-pantheon/slingshot/trunk

Proposed by Adam Bieńkowski
Status: Rejected
Rejected by: Adam Bieńkowski
Proposed branch: lp:~donadigo/slingshot/show-app-badges
Merge into: lp:~elementary-pantheon/slingshot/trunk
Diff against target: 180 lines (+80/-7)
3 files modified
src/Backend/App.vala (+18/-0)
src/SlingshotView.vala (+32/-1)
src/Widgets/AppEntry.vala (+30/-6)
To merge this branch: bzr merge lp:~donadigo/slingshot/show-app-badges
Reviewer Review Type Date Requested Status
Adam Bieńkowski (community) Disapprove
Cody Garver (community) Needs Fixing
Review via email: mp+277172@code.launchpad.net

Commit message

* Fixes bug #710498.

Description of the change

This branch fixes bug #710498 Support Launcher API in order to show badges.

Although the implementation itself isn't based on Unity Launcher API (vapi), it uses DBus to know when and what app has changed it's info from "com.canonical.Unity.LauncherEntry" interface. This data is now included and used in Backend.App. For drawing this uses a Plank vapi in order to draw the same surface as the plank do.

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

Use set_from_surface; margin_left to 12; use doubles for color

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

you might want to overthink implementing it that way
e.g. https://bugs.launchpad.net/plank/+bug/1514201 a DDoS-like scenario

you need to update only once when you open slingshot or switch an app page, so you don't need to listen all the time

maybe even plank could provide those values via dbusclient

Revision history for this message
Cody Garver (codygarver) wrote :

Conflicts with trunk

review: Needs Fixing
Revision history for this message
Adam Bieńkowski (donadigo) wrote :
review: Disapprove

Unmerged revisions

598. By Adam Bieńkowski

Use set_from_surface; margin_left to 12; use doubles for color

597. By Adam Bieńkowski

Private not public

596. By Adam Bieńkowski

Show app badges

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/Backend/App.vala'
--- src/Backend/App.vala 2014-10-18 01:57:49 +0000
+++ src/Backend/App.vala 2015-11-10 20:05:31 +0000
@@ -45,6 +45,9 @@
45 public string generic_name { get; private set; default = ""; }45 public string generic_name { get; private set; default = ""; }
46 public AppType app_type { get; private set; default = AppType.APP; }46 public AppType app_type { get; private set; default = AppType.APP; }
4747
48 public bool count_visible = false;
49 public int64 current_count = 0;
50
48 public Synapse.Match? match { get; private set; default = null; }51 public Synapse.Match? match { get; private set; default = null; }
49 public Synapse.Match? target { get; private set; default = null; }52 public Synapse.Match? target { get; private set; default = null; }
50 public Gee.ArrayList<string> actions { get; private set; default = null; }53 public Gee.ArrayList<string> actions { get; private set; default = null; }
@@ -375,4 +378,19 @@
375 }378 }
376 }379 }
377 }380 }
381
382 public void update_unity_info (string sender_name, VariantIter prop_iter) {
383 string prop_key;
384 Variant prop_value;
385
386 while (prop_iter.next ("{sv}", out prop_key, out prop_value)) {
387 if (prop_key == "count") {
388 current_count = prop_value.get_int64 ();
389 } else if (prop_key == "count-visible") {
390 count_visible = prop_value.get_boolean ();
391 }
392 }
393
394 icon_changed ();
395 }
378}396}
379\ No newline at end of file397\ No newline at end of file
380398
=== modified file 'src/SlingshotView.vala'
--- src/SlingshotView.vala 2015-02-01 15:13:15 +0000
+++ src/SlingshotView.vala 2015-11-10 20:05:31 +0000
@@ -48,6 +48,7 @@
48 public Backend.AppSystem app_system;48 public Backend.AppSystem app_system;
49 private Gee.ArrayList<GMenu.TreeDirectory> categories;49 private Gee.ArrayList<GMenu.TreeDirectory> categories;
50 public Gee.HashMap<string, Gee.ArrayList<Backend.App>> apps;50 public Gee.HashMap<string, Gee.ArrayList<Backend.App>> apps;
51 private DBusConnection connection;
5152
52 private Modality modality;53 private Modality modality;
53 private bool can_trigger_hotcorner = true;54 private bool can_trigger_hotcorner = true;
@@ -98,6 +99,12 @@
98 categories = app_system.get_categories ();99 categories = app_system.get_categories ();
99 apps = app_system.get_apps ();100 apps = app_system.get_apps ();
100101
102 try {
103 connection = Bus.get_sync (BusType.SESSION);
104 } catch (IOError e) {
105 warning ("%s\n", e.message);
106 }
107
101 primary_monitor = screen.get_primary_monitor ();108 primary_monitor = screen.get_primary_monitor ();
102 Gdk.Rectangle geometry;109 Gdk.Rectangle geometry;
103 screen.get_monitor_geometry (primary_monitor, out geometry);110 screen.get_monitor_geometry (primary_monitor, out geometry);
@@ -300,7 +307,6 @@
300 }307 }
301308
302 private void connect_signals () {309 private void connect_signals () {
303
304 this.focus_in_event.connect (() => {310 this.focus_in_event.connect (() => {
305 search_entry.grab_focus ();311 search_entry.grab_focus ();
306 return false;312 return false;
@@ -373,6 +379,31 @@
373379
374 // hotcorner management380 // hotcorner management
375 motion_notify_event.connect (hotcorner_trigger);381 motion_notify_event.connect (hotcorner_trigger);
382
383 connection.signal_subscribe (null, "com.canonical.Unity.LauncherEntry",
384 null, null, null, DBusSignalFlags.NONE, handle_entry_signal);
385 }
386
387 private void handle_entry_signal (DBusConnection connection, string sender_name, string object_path,
388 string interface_name, string signal_name, Variant parameters) {
389
390 if (parameters == null
391 || !parameters.is_of_type (new VariantType ("(sa{sv})"))
392 || signal_name == null
393 || sender_name == null
394 || signal_name != "Update") {
395 return;
396 }
397
398 string app_uri;
399 VariantIter prop_iter;
400 parameters.get ("(sa{sv})", out app_uri, out prop_iter);
401
402 foreach (var app in app_system.get_apps_by_name ()) {
403 if (app_uri == "application://" + app.desktop_id) {
404 app.update_unity_info (sender_name, prop_iter);
405 }
406 }
376 }407 }
377408
378 private void gala_settings_changed () {409 private void gala_settings_changed () {
379410
=== modified file 'src/Widgets/AppEntry.vala'
--- src/Widgets/AppEntry.vala 2015-11-03 15:36:28 +0000
+++ src/Widgets/AppEntry.vala 2015-11-10 20:05:31 +0000
@@ -22,6 +22,7 @@
22 public Gtk.Label app_label;22 public Gtk.Label app_label;
23 private Gdk.Pixbuf icon;23 private Gdk.Pixbuf icon;
24 private new Gtk.Image image;24 private new Gtk.Image image;
25 private Gtk.Image count_image;
2526
26 public string exec_name;27 public string exec_name;
27 public string app_name;28 public string app_name;
@@ -36,7 +37,11 @@
36 private Backend.App application;37 private Backend.App application;
3738
38#if HAS_PLANK39#if HAS_PLANK
40 private static Plank.DockTheme plank_theme;
41
39 static construct {42 static construct {
43 plank_theme = new Plank.DockTheme ("Gtk+");
44
40#if HAS_PLANK_0_1145#if HAS_PLANK_0_11
41 plank_client = Plank.DBusClient.get_instance ();46 plank_client = Plank.DBusClient.get_instance ();
42#else47#else
@@ -85,12 +90,21 @@
85 image.icon_size = icon_size;90 image.icon_size = icon_size;
86 image.margin_top = 12;91 image.margin_top = 12;
8792
93 count_image = new Gtk.Image ();
94 count_image.no_show_all = true;
95 count_image.visible = false;
96 count_image.margin_left = 12;
97
98 var overlay = new Gtk.Overlay ();
99 overlay.add (image);
100 overlay.add_overlay (count_image);
101
88 var grid = new Gtk.Grid ();102 var grid = new Gtk.Grid ();
89 grid.orientation = Gtk.Orientation.VERTICAL;103 grid.orientation = Gtk.Orientation.VERTICAL;
90 grid.row_spacing = 6;104 grid.row_spacing = 6;
91 grid.expand = true;105 grid.expand = true;
92 grid.halign = Gtk.Align.CENTER;106 grid.halign = Gtk.Align.CENTER;
93 grid.add (image);107 grid.add (overlay);
94 grid.add (app_label);108 grid.add (app_label);
95109
96 add (grid);110 add (grid);
@@ -125,11 +139,8 @@
125 sel.set_uris ({File.new_for_path (desktop_path).get_uri ()});139 sel.set_uris ({File.new_for_path (desktop_path).get_uri ()});
126 });140 });
127141
128 app.icon_changed.connect (() => {142 app.icon_changed.connect (update_icon);
129 icon = app.icon;143 update_icon ();
130 image.set_from_pixbuf (icon);
131 });
132
133 }144 }
134145
135 public override void get_preferred_width (out int minimum_width, out int natural_width) {146 public override void get_preferred_width (out int minimum_width, out int natural_width) {
@@ -147,6 +158,19 @@
147 app_launched ();158 app_launched ();
148 }159 }
149160
161 private void update_icon () {
162 icon = application.icon;
163 image.set_from_pixbuf (icon);
164
165#if HAS_PLANK
166 var surface = new Plank.Surface (icon_size, icon_size);
167 plank_theme.draw_item_count (surface, 48, { 0.85, 0.23, 0.29, 0.89 }, application.current_count);
168
169 count_image.set_from_surface (surface.Internal);
170 count_image.visible = application.count_visible;
171#endif
172 }
173
150 private void create_menu () {174 private void create_menu () {
151 // Display the apps static quicklist items in a popover menu175 // Display the apps static quicklist items in a popover menu
152 if (application.actions == null) {176 if (application.actions == null) {

Subscribers

People subscribed via source and target branches