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

Proposed by Adam Bieńkowski
Status: Merged
Approved by: Cody Garver
Approved revision: 633
Merged at revision: 635
Proposed branch: lp:~donadigo/slingshot/show-app-badges-new
Merge into: lp:~elementary-pantheon/slingshot/trunk
Diff against target: 231 lines (+114/-4)
4 files modified
src/Backend/App.vala (+37/-1)
src/Slingshot.vala (+7/-1)
src/SlingshotView.vala (+37/-1)
src/Widgets/AppEntry.vala (+33/-1)
To merge this branch: bzr merge lp:~donadigo/slingshot/show-app-badges-new
Reviewer Review Type Date Requested Status
elementary Pantheon team Pending
Review via email: mp+286386@code.launchpad.net

This proposal supersedes a proposal from 2016-02-12.

Commit message

* Fixes bug #710498: "Support Launcher API in order to show badges".

Description of the change

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

The implementation is done entirely by using the new plank UnityClient and Surface API.

NOTE: In order to have app badges shown in the Slingshot, you must have plank version greater or equal to r1490 (compiled from trunk).

To post a comment you must log in.
Revision history for this message
Rico Tzschichholz (ricotz) wrote : Posted in a previous version of this proposal

Hmm, didn't you realize that this is public API of libplank?

Revision history for this message
Adam Bieńkowski (donadigo) wrote : Posted in a previous version of this proposal

ricotz: Ahhh, sory, I didn't realize that I could use the UnityClient interface directly. Thanks for pointing out, it now uses only the libplank API. Branch updated.

Revision history for this message
Rico Tzschichholz (ricotz) wrote : Posted in a previous version of this proposal

if application.count_visible is true you should not draw anything, so don't uselessly call draw_item_count().

Revision history for this message
Ezekiel Michael Angel (nolenumar) wrote :

Please stop sending me these emails
On Feb 22, 2016 6:13 PM, <email address hidden> wrote:

> The proposal to merge lp:~donadigo/slingshot/show-app-badges-new into
> lp:slingshot has been updated.
>
> Status: Approved => Merged
>
> For more details, see:
>
> https://code.launchpad.net/~donadigo/slingshot/show-app-badges-new/+merge/286386
> --
> You are subscribed to branch lp:slingshot.
>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Backend/App.vala'
2--- src/Backend/App.vala 2015-12-22 17:07:27 +0000
3+++ src/Backend/App.vala 2016-02-17 19:09:20 +0000
4@@ -44,6 +44,12 @@
5 public string generic_name { get; private set; default = ""; }
6 public AppType app_type { get; private set; default = AppType.APP; }
7
8+#if HAS_PLANK_0_11
9+ public string? unity_sender_name = null;
10+ public bool count_visible = false;
11+ public int64 current_count = 0;
12+#endif
13+
14 public Synapse.Match? match { get; private set; default = null; }
15 public Synapse.Match? target { get; private set; default = null; }
16 public Gee.ArrayList<string> actions { get; private set; default = null; }
17@@ -51,6 +57,10 @@
18
19 public signal void launched (App app);
20
21+#if HAS_PLANK_0_11
22+ public signal void unity_update_info ();
23+#endif
24+
25 // for FDO Desktop Actions
26 // see http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#extra-actions
27 private const string DESKTOP_ACTION_KEY = "Actions";
28@@ -151,7 +161,7 @@
29 }
30
31 // Quicklist code from Plank
32- public void init_actions () throws KeyFileError {
33+ public void init_actions () throws KeyFileError {
34 actions = new Gee.ArrayList<string> ();
35 actions_map = new Gee.HashMap<string, string> ();
36
37@@ -231,4 +241,30 @@
38 }
39 }
40 }
41+
42+#if HAS_PLANK_0_11
43+ public void perform_unity_update (string sender_name, VariantIter prop_iter) {
44+ unity_sender_name = sender_name;
45+
46+ string prop_key;
47+ Variant prop_value;
48+ while (prop_iter.next ("{sv}", out prop_key, out prop_value)) {
49+ if (prop_key == "count") {
50+ current_count = prop_value.get_int64 ();
51+ } else if (prop_key == "count-visible") {
52+ count_visible = prop_value.get_boolean ();
53+ }
54+ }
55+
56+ unity_update_info ();
57+ }
58+
59+ public void unity_reset () {
60+ unity_sender_name = null;
61+ count_visible = false;
62+ current_count = 0;
63+
64+ unity_update_info ();
65+ }
66+#endif
67 }
68
69=== modified file 'src/Slingshot.vala'
70--- src/Slingshot.vala 2015-11-27 17:32:57 +0000
71+++ src/Slingshot.vala 2016-02-17 19:09:20 +0000
72@@ -43,10 +43,16 @@
73
74 view = new SlingshotView ();
75
76+#if HAS_PLANK_0_11
77+ unowned Plank.Unity client = Plank.Unity.get_default ();
78+ client.add_client (view);
79+#endif
80+
81 view.close_indicator.connect (on_close_indicator);
82
83- if (dbus_service == null)
84+ if (dbus_service == null) {
85 dbus_service = new DBusService (view);
86+ }
87 }
88
89 return view;
90
91=== modified file 'src/SlingshotView.vala'
92--- src/SlingshotView.vala 2016-01-16 01:08:13 +0000
93+++ src/SlingshotView.vala 2016-02-17 19:09:20 +0000
94@@ -24,7 +24,11 @@
95 SEARCH_VIEW
96 }
97
98+#if HAS_PLANK_0_11
99+ public class SlingshotView : Gtk.Grid, Plank.UnityClient {
100+#else
101 public class SlingshotView : Gtk.Grid {
102+#endif
103 // Widgets
104 public Gtk.SearchEntry search_entry;
105 public Gtk.Stack stack;
106@@ -224,7 +228,6 @@
107 }
108
109 private void connect_signals () {
110-
111 this.focus_in_event.connect (() => {
112 search_entry.grab_focus ();
113 return false;
114@@ -283,6 +286,39 @@
115 motion_notify_event.connect (hotcorner_trigger);
116 }
117
118+#if HAS_PLANK_0_11
119+ public void update_launcher_entry (string sender_name, GLib.Variant parameters, bool is_retry = false) {
120+ if (!is_retry) {
121+ // Wait to let further update requests come in to catch the case where one application
122+ // sends out multiple LauncherEntry-updates with different application-uris, e.g. Nautilus
123+ Idle.add (() => {
124+ update_launcher_entry (sender_name, parameters, true);
125+ return false;
126+ });
127+
128+ return;
129+ }
130+
131+ string app_uri;
132+ VariantIter prop_iter;
133+ parameters.get ("(sa{sv})", out app_uri, out prop_iter);
134+
135+ foreach (var app in app_system.get_apps_by_name ()) {
136+ if (app_uri == "application://" + app.desktop_id) {
137+ app.perform_unity_update (sender_name, prop_iter);
138+ }
139+ }
140+ }
141+
142+ public void remove_launcher_entry (string sender_name) {
143+ foreach (var app in app_system.get_apps_by_name ()) {
144+ if (app.unity_sender_name == sender_name) {
145+ app.unity_reset ();
146+ }
147+ }
148+ }
149+#endif
150+
151 private void gala_settings_changed () {
152 if (Slingshot.settings.gala_settings.hotcorner_topleft == "open-launcher") {
153 can_trigger_hotcorner = true;
154
155=== modified file 'src/Widgets/AppEntry.vala'
156--- src/Widgets/AppEntry.vala 2016-01-17 14:03:44 +0000
157+++ src/Widgets/AppEntry.vala 2016-02-17 19:09:20 +0000
158@@ -47,6 +47,7 @@
159 }
160
161 private new Gtk.Image image;
162+ private Gtk.Image count_image;
163 private bool dragging = false; //prevent launching
164 private Backend.App application;
165
166@@ -60,6 +61,9 @@
167 }
168
169 #if HAS_PLANK_0_11
170+ private const int SURFACE_SIZE = 48;
171+ private static Plank.DockTheme plank_theme = new Plank.DockTheme ("Gtk+");
172+
173 private static Plank.DBusClient plank_client;
174 #else
175 private static Plank.DBus.Client plank_client;
176@@ -96,12 +100,22 @@
177 image.pixel_size = 64;
178 image.margin_top = 12;
179
180+ count_image = new Gtk.Image ();
181+ count_image.no_show_all = true;
182+ count_image.visible = false;
183+ count_image.margin_start = 18;
184+ count_image.margin_bottom = 12;
185+
186+ var overlay = new Gtk.Overlay ();
187+ overlay.add (image);
188+ overlay.add_overlay (count_image);
189+
190 var grid = new Gtk.Grid ();
191 grid.orientation = Gtk.Orientation.VERTICAL;
192 grid.row_spacing = 6;
193 grid.expand = true;
194 grid.halign = Gtk.Align.CENTER;
195- grid.add (image);
196+ grid.add (overlay);
197 grid.add (app_label);
198
199 add (grid);
200@@ -133,6 +147,10 @@
201 sel.set_uris ({File.new_for_path (desktop_path).get_uri ()});
202 });
203
204+#if HAS_PLANK_0_11
205+ app.unity_update_info.connect (update_unity_icon);
206+#endif
207+
208 app.notify["icon"].connect (() => {
209 ((Gtk.Image) image).gicon = app.icon;
210 });
211@@ -153,6 +171,20 @@
212 app_launched ();
213 }
214
215+#if HAS_PLANK_0_11
216+ private void update_unity_icon () {
217+ var visible = application.count_visible;
218+ count_image.visible = visible;
219+ if (!visible)
220+ return;
221+
222+ var surface = new Plank.Surface (SURFACE_SIZE, SURFACE_SIZE);
223+ plank_theme.draw_item_count (surface, SURFACE_SIZE, { 0.85, 0.23, 0.29, 0.89 }, application.current_count);
224+
225+ count_image.set_from_surface (surface.Internal);
226+ }
227+#endif
228+
229 private void create_menu () {
230 // Display the apps static quicklist items in a popover menu
231 if (application.actions == null) {

Subscribers

People subscribed via source and target branches