Merge lp:~desrt/indicator-appmenu/hud-rewrite-wip into lp:indicator-appmenu/0.4

Proposed by Allison Karlitskaya
Status: Merged
Approved by: Charles Kerr
Approved revision: 242
Merge reported by: Charles Kerr
Merged at revision: not available
Proposed branch: lp:~desrt/indicator-appmenu/hud-rewrite-wip
Merge into: lp:indicator-appmenu/0.4
Diff against target: 493 lines (+106/-28)
12 files modified
src/hudappindicatorsource.c (+28/-2)
src/huddbusmenucollector.c (+37/-5)
src/huddbusmenucollector.h (+5/-1)
src/huddebugsource.c (+1/-1)
src/hudindicatorsource.c (+1/-0)
src/huditem.c (+10/-4)
src/huditem.h (+2/-0)
src/hudmenumodelcollector.c (+9/-4)
src/hudmenumodelcollector.h (+2/-1)
src/hudquery.c (+0/-8)
src/hudwindowsource.c (+7/-2)
tools-vala/hud-gtk.vala (+4/-0)
To merge this branch: bzr merge lp:~desrt/indicator-appmenu/hud-rewrite-wip
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
Review via email: mp+99046@code.launchpad.net

Description of the change

add back support for icons

also, remove some comments that no longer apply

To post a comment you must log in.
241. By Allison Karlitskaya

hud-gtk: close query if we have the empty string

242. By Allison Karlitskaya

hud: don't send duplicate OPENED events on property changes

Revision history for this message
Charles Kerr (charlesk) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/hudappindicatorsource.c'
2--- src/hudappindicatorsource.c 2012-03-15 18:26:35 +0000
3+++ src/hudappindicatorsource.c 2012-03-26 15:29:24 +0000
4@@ -83,9 +83,11 @@
5 const gchar *dbus_path;
6 GSequenceIter *iter;
7 const gchar *id;
8+ const gchar *icon_name;
9 gint32 position;
10 gchar *title;
11
12+ g_variant_get_child (description, 0, "&s", &icon_name);
13 g_variant_get_child (description, 1, "i", &position);
14 g_variant_get_child (description, 2, "&s", &dbus_name);
15 g_variant_get_child (description, 3, "&o", &dbus_path);
16@@ -102,9 +104,10 @@
17 for Network Manager would be 'nm-applet'. */
18 title = g_strdup_printf(_("Untitled Indicator (%s)"), id);
19 }
20- g_debug ("adding appindicator %s at %d ('%s', %s, %s)", id, position, title, dbus_name, dbus_path);
21+ g_debug ("adding appindicator %s at %d ('%s', %s, %s, %s)", id, position, title, icon_name, dbus_name, dbus_path);
22
23- collector = hud_dbusmenu_collector_new_for_endpoint (id, title, hud_settings.indicator_penalty,
24+ collector = hud_dbusmenu_collector_new_for_endpoint (id, title, icon_name,
25+ hud_settings.indicator_penalty,
26 dbus_name, dbus_path);
27 g_signal_connect (collector, "changed", G_CALLBACK (hud_app_indicator_source_collector_changed), source);
28
29@@ -201,6 +204,29 @@
30 hud_dbusmenu_collector_set_prefix (collector, title);
31 }
32 }
33+
34+ else if (g_str_equal (signal_name, "ApplicationIconChanged"))
35+ {
36+ GSequenceIter *iter;
37+ const gchar *icon;
38+ gint32 position;
39+
40+ if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(iss)")))
41+ return;
42+
43+ g_variant_get (parameters, "(i&ss)", &position, &icon, NULL);
44+
45+ g_debug ("changing icon of appindicator at %d to '%s'", position, icon);
46+
47+ iter = g_sequence_get_iter_at_pos (source->indicators, position);
48+ if (!g_sequence_iter_is_end (iter))
49+ {
50+ HudDbusmenuCollector *collector;
51+
52+ collector = g_sequence_get (iter);
53+ hud_dbusmenu_collector_set_icon (collector, icon);
54+ }
55+ }
56 }
57
58 static void
59
60=== modified file 'src/huddbusmenucollector.c'
61--- src/huddbusmenucollector.c 2012-03-17 16:07:32 +0000
62+++ src/huddbusmenucollector.c 2012-03-26 15:29:24 +0000
63@@ -159,6 +159,7 @@
64 static HudDbusmenuItem *
65 hud_dbusmenu_item_new (HudStringList *context,
66 const gchar *desktop_file,
67+ const gchar *icon,
68 DbusmenuMenuitem *menuitem)
69 {
70 HudStringList *tokens;
71@@ -195,7 +196,7 @@
72 if (enabled)
73 enabled &= !dbusmenu_menuitem_property_exist (menuitem, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY);
74
75- item = hud_item_construct (hud_dbusmenu_item_get_type (), tokens, desktop_file, enabled);
76+ item = hud_item_construct (hud_dbusmenu_item_get_type (), tokens, desktop_file, icon, enabled);
77 item->menuitem = g_object_ref (menuitem);
78
79 hud_string_list_unref (tokens);
80@@ -211,6 +212,7 @@
81 DbusmenuMenuitem *root;
82 gchar *application_id;
83 HudStringList *prefix;
84+ gchar *icon;
85 GHashTable *items;
86 guint penalty;
87 guint xid;
88@@ -357,6 +359,7 @@
89 DbusmenuMenuitem *parent;
90 HudStringList *context;
91 HudDbusmenuItem *item;
92+ gboolean was_open;
93
94 g_assert (!collector->reentrance_check);
95
96@@ -372,10 +375,13 @@
97 else
98 context = collector->prefix;
99
100- item = hud_dbusmenu_item_new (context, collector->application_id, menuitem);
101+ item = g_hash_table_lookup (collector->items, menuitem);
102+ was_open = item->is_opened;
103 g_hash_table_remove (collector->items, menuitem);
104
105- if (collector->use_count && dbusmenu_menuitem_property_exist (menuitem, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY))
106+ item = hud_dbusmenu_item_new (context, collector->application_id, collector->icon, menuitem);
107+
108+ if (collector->use_count && !was_open && dbusmenu_menuitem_property_exist (menuitem, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY))
109 {
110 dbusmenu_menuitem_handle_event (menuitem, DBUSMENU_MENUITEM_EVENT_OPENED, NULL, 0);
111 item->is_opened = TRUE;
112@@ -394,7 +400,7 @@
113 HudDbusmenuItem *item;
114 GList *child;
115
116- item = hud_dbusmenu_item_new (context, NULL, menuitem);
117+ item = hud_dbusmenu_item_new (context, collector->application_id, collector->icon, menuitem);
118 context = hud_item_get_tokens (HUD_ITEM (item));
119
120 g_signal_connect (menuitem, "property-changed", G_CALLBACK (hud_dbusmenu_collector_property_changed), collector);
121@@ -525,6 +531,7 @@
122 g_hash_table_unref (collector->items);
123
124 g_free (collector->application_id);
125+ g_free (collector->icon);
126
127 hud_string_list_unref (collector->prefix);
128 g_clear_object (&collector->client);
129@@ -555,7 +562,9 @@
130
131 /**
132 * hud_dbusmenu_collector_new_for_endpoint:
133+ * @application_id: a unique identifier for the application
134 * @prefix: the title to prefix to all items
135+ * @icon: the icon for the appliction
136 * @penalty: the penalty to apply to all results
137 * @bus_name: a D-Bus bus name
138 * @object_path: an object path at the destination given by @bus_name
139@@ -580,6 +589,7 @@
140 HudDbusmenuCollector *
141 hud_dbusmenu_collector_new_for_endpoint (const gchar *application_id,
142 const gchar *prefix,
143+ const gchar *icon,
144 guint penalty,
145 const gchar *bus_name,
146 const gchar *object_path)
147@@ -588,6 +598,7 @@
148
149 collector = g_object_new (HUD_TYPE_DBUSMENU_COLLECTOR, NULL);
150 collector->application_id = g_strdup (application_id);
151+ collector->icon = g_strdup (icon);
152 if (prefix)
153 collector->prefix = hud_string_list_cons (prefix, NULL);
154 collector->penalty = penalty;
155@@ -611,12 +622,14 @@
156 **/
157 HudDbusmenuCollector *
158 hud_dbusmenu_collector_new_for_window (BamfWindow *window,
159- const gchar *desktop_file)
160+ const gchar *desktop_file,
161+ const gchar *icon)
162 {
163 HudDbusmenuCollector *collector;
164
165 collector = g_object_new (HUD_TYPE_DBUSMENU_COLLECTOR, NULL);
166 collector->application_id = g_strdup (desktop_file);
167+ collector->icon = g_strdup (icon);
168 collector->xid = bamf_window_get_xid (window);
169 g_debug ("dbusmenu on %d", collector->xid);
170 hud_app_menu_registrar_add_observer (hud_app_menu_registrar_get (), collector->xid,
171@@ -645,3 +658,22 @@
172 collector->prefix = hud_string_list_cons (prefix, NULL);
173 hud_dbusmenu_collector_setup_root (collector, collector->root);
174 }
175+
176+/**
177+ * hud_dbusmenu_collector_set_icon:
178+ * @collector: a #HudDbusmenuCollector
179+ * @icon: the application icon
180+ *
181+ * Changes the application icon used for all items of the collector.
182+ *
183+ * This will involve destroying all of the items and recreating them
184+ * (since each item's icon has to be changed).
185+ **/
186+void
187+hud_dbusmenu_collector_set_icon (HudDbusmenuCollector *collector,
188+ const gchar *icon)
189+{
190+ g_free (collector->icon);
191+ collector->icon = g_strdup (icon);
192+ hud_dbusmenu_collector_setup_root (collector, collector->root);
193+}
194
195=== modified file 'src/huddbusmenucollector.h'
196--- src/huddbusmenucollector.h 2012-03-12 16:25:31 +0000
197+++ src/huddbusmenucollector.h 2012-03-26 15:29:24 +0000
198@@ -33,12 +33,16 @@
199
200 HudDbusmenuCollector * hud_dbusmenu_collector_new_for_endpoint (const gchar *application_id,
201 const gchar *prefix,
202+ const gchar *icon,
203 guint penalty,
204 const gchar *bus_name,
205 const gchar *object_path);
206 HudDbusmenuCollector * hud_dbusmenu_collector_new_for_window (BamfWindow *window,
207- const gchar *desktop_file);
208+ const gchar *desktop_file,
209+ const gchar *icon);
210 void hud_dbusmenu_collector_set_prefix (HudDbusmenuCollector *collector,
211 const gchar *prefix);
212+void hud_dbusmenu_collector_set_icon (HudDbusmenuCollector *collector,
213+ const gchar *icon);
214
215 #endif /* __HUD_DBUSMENU_COLLECTOR_H__ */
216
217=== modified file 'src/huddebugsource.c'
218--- src/huddebugsource.c 2012-03-15 22:30:20 +0000
219+++ src/huddebugsource.c 2012-03-26 15:29:24 +0000
220@@ -71,7 +71,7 @@
221 g_date_time_unref (now);
222 g_free (time);
223
224- source->item = hud_item_new (tokens, NULL, TRUE);
225+ source->item = hud_item_new (tokens, NULL, NULL, TRUE);
226 hud_string_list_unref (tokens);
227
228 hud_source_changed (HUD_SOURCE (source));
229
230=== modified file 'src/hudindicatorsource.c'
231--- src/hudindicatorsource.c 2012-03-16 12:16:40 +0000
232+++ src/hudindicatorsource.c 2012-03-26 15:29:24 +0000
233@@ -184,6 +184,7 @@
234
235 collector = hud_dbusmenu_collector_new_for_endpoint (indicator->info->indicator_name,
236 _(indicator->info->user_visible_name),
237+ indicator->info->icon,
238 hud_settings.indicator_penalty,
239 name_owner, indicator->info->dbus_menu_path);
240 g_signal_connect (collector, "changed", G_CALLBACK (hud_indicator_source_collector_changed), indicator);
241
242=== modified file 'src/huditem.c'
243--- src/huditem.c 2012-03-15 18:27:03 +0000
244+++ src/huditem.c 2012-03-26 15:29:24 +0000
245@@ -54,6 +54,7 @@
246
247 HudStringList *tokens;
248 gchar *usage_tag;
249+ gchar *app_icon;
250 gboolean enabled;
251 guint usage;
252 guint64 id;
253@@ -130,6 +131,7 @@
254 * @g_type: a #GType
255 * @tokens: the search tokens for the item
256 * @desktop_file: the desktop file of the provider of the item
257+ * @app_icon: the icon name for the application that created this item
258 * @enabled: if the item is enabled
259 *
260 * This is the Vala-style chain-up constructor corresponding to
261@@ -143,6 +145,7 @@
262 hud_item_construct (GType g_type,
263 HudStringList *tokens,
264 const gchar *desktop_file,
265+ const gchar *app_icon,
266 gboolean enabled)
267 {
268 HudItem *item;
269@@ -150,6 +153,7 @@
270 item = g_object_new (g_type, NULL);
271 item->priv->tokens = hud_string_list_ref (tokens);
272 item->priv->desktop_file = g_strdup (desktop_file);
273+ item->priv->app_icon = g_strdup (app_icon);
274 item->priv->enabled = enabled;
275 item->priv->id = hud_item_next_id++;
276
277@@ -165,6 +169,7 @@
278 * hud_item_new:
279 * @tokens: the search tokens for the item
280 * @desktop_file: the desktop file of the provider of the item
281+ * @app_icon: the icon name for the application that created this item
282 * @enabled: if the item is enabled
283 *
284 * Creates a new #HudItem.
285@@ -177,9 +182,10 @@
286 HudItem *
287 hud_item_new (HudStringList *tokens,
288 const gchar *desktop_file,
289+ const gchar *app_icon,
290 gboolean enabled)
291 {
292- return hud_item_construct (HUD_TYPE_ITEM, tokens, desktop_file, enabled);
293+ return hud_item_construct (HUD_TYPE_ITEM, tokens, desktop_file, app_icon, enabled);
294 }
295
296 /**
297@@ -236,7 +242,7 @@
298 *
299 * Gets the icon for the action represented by @item, if one exists.
300 *
301- * Returns: the icon name, or %NULL if there is no icon
302+ * Returns: the icon name, or "" if there is no icon
303 **/
304 const gchar *
305 hud_item_get_item_icon (HudItem *item)
306@@ -250,12 +256,12 @@
307 *
308 * Gets the icon of the application that @item lies within.
309 *
310- * Returns: the icon name, or %NULL if there is no icon
311+ * Returns: the icon name, or "" if there is no icon
312 **/
313 const gchar *
314 hud_item_get_app_icon (HudItem *item)
315 {
316- return "";
317+ return item->priv->app_icon ? item->priv->app_icon : "";
318 }
319
320 /**
321
322=== modified file 'src/huditem.h'
323--- src/huditem.h 2012-03-07 21:55:41 +0000
324+++ src/huditem.h 2012-03-26 15:29:24 +0000
325@@ -59,9 +59,11 @@
326 gpointer hud_item_construct (GType g_type,
327 HudStringList *tokens,
328 const gchar *desktop_file,
329+ const gchar *app_icon,
330 gboolean enabled);
331 HudItem * hud_item_new (HudStringList *tokens,
332 const gchar *desktop_file,
333+ const gchar *app_icon,
334 gboolean enabled);
335 void hud_item_activate (HudItem *item,
336 GVariant *platform_data);
337
338=== modified file 'src/hudmenumodelcollector.c'
339--- src/hudmenumodelcollector.c 2012-03-15 18:25:50 +0000
340+++ src/hudmenumodelcollector.c 2012-03-26 15:29:24 +0000
341@@ -60,6 +60,7 @@
342 GDBusActionGroup *window;
343
344 gchar *desktop_file;
345+ gchar *icon;
346 GPtrArray *items;
347 gint use_count;
348 };
349@@ -119,13 +120,14 @@
350 static HudItem *
351 hud_model_item_new (HudStringList *tokens,
352 const gchar *desktop_file,
353+ const gchar *icon,
354 GRemoteActionGroup *action_group,
355 const gchar *action_name,
356 GVariant *target)
357 {
358 HudModelItem *item;
359
360- item = hud_item_construct (hud_model_item_get_type (), tokens, desktop_file, TRUE);
361+ item = hud_item_construct (hud_model_item_get_type (), tokens, desktop_file, icon, TRUE);
362 item->group = g_object_ref (action_group);
363 item->action_name = g_strdup (action_name);
364 item->target = target ? g_variant_ref_sink (target) : NULL;
365@@ -262,8 +264,7 @@
366
367 target = g_menu_model_get_item_attribute_value (model, i, G_MENU_ATTRIBUTE_TARGET, NULL);
368
369- /* XXX: todo: target */
370- item = hud_model_item_new (tokens, collector->desktop_file,
371+ item = hud_model_item_new (tokens, collector->desktop_file, collector->icon,
372 G_REMOTE_ACTION_GROUP (action_group),
373 value + 4, target);
374 g_ptr_array_add (collector->items, item);
375@@ -381,6 +382,7 @@
376 g_clear_object (&collector->window);
377
378 g_free (collector->desktop_file);
379+ g_free (collector->icon);
380
381 g_ptr_array_unref (collector->items);
382
383@@ -412,6 +414,7 @@
384 * hud_menu_model_collector_get:
385 * @window: a #BamfWindow
386 * @desktop_file: the desktop file of the application of @window
387+ * @icon: the application icon's name
388 *
389 * If the given @window has #GMenuModel-style menus then returns a
390 * collector for them, otherwise returns %NULL.
391@@ -422,7 +425,8 @@
392 **/
393 HudMenuModelCollector *
394 hud_menu_model_collector_get (BamfWindow *window,
395- const gchar *desktop_file)
396+ const gchar *desktop_file,
397+ const gchar *icon)
398 {
399 HudMenuModelCollector *collector;
400 gchar *unique_bus_name;
401@@ -466,6 +470,7 @@
402 collector->window = g_dbus_action_group_get (session, unique_bus_name, window_object_path);
403
404 collector->desktop_file = g_strdup (desktop_file);
405+ collector->icon = g_strdup (icon);
406
407 /* when the action groups change, we could end up having items
408 * enabled/disabled. how to deal with that?
409
410=== modified file 'src/hudmenumodelcollector.h'
411--- src/hudmenumodelcollector.h 2012-03-12 16:25:31 +0000
412+++ src/hudmenumodelcollector.h 2012-03-26 15:29:24 +0000
413@@ -33,6 +33,7 @@
414 GType hud_menu_model_collector_get_type (void);
415
416 HudMenuModelCollector * hud_menu_model_collector_get (BamfWindow *window,
417- const gchar *desktop_file);
418+ const gchar *desktop_file,
419+ const gchar *icon);
420
421 #endif /* __HUD_MENU_MODEL_COLLECTOR_H__ */
422
423=== modified file 'src/hudquery.c'
424--- src/hudquery.c 2012-03-15 19:32:27 +0000
425+++ src/hudquery.c 2012-03-26 15:29:24 +0000
426@@ -106,14 +106,6 @@
427 if (query->search_string[0] != '\0')
428 hud_source_search (query->source, query->results, query->search_string);
429
430- /* XXX: The old code queried, sorted, truncated to 15, got usage data,
431- * then sorted again.
432- *
433- * We try to do it only once.
434- *
435- * This may change the results...
436- */
437-
438 g_ptr_array_foreach (query->results, hud_query_find_max_usage, &max_usage);
439 g_ptr_array_sort_with_data (query->results, hud_query_compare_results, GINT_TO_POINTER (max_usage));
440 if (query->results->len > query->num_results)
441
442=== modified file 'src/hudwindowsource.c'
443--- src/hudwindowsource.c 2012-03-15 21:06:48 +0000
444+++ src/hudwindowsource.c 2012-03-26 15:29:24 +0000
445@@ -67,6 +67,7 @@
446 BamfWindow *active_window;
447 BamfApplication *active_application;
448 const gchar *active_desktop_file;
449+ const gchar *active_icon;
450 HudSource *active_collector;
451 gint use_count;
452 };
453@@ -167,12 +168,15 @@
454 * For that reason, we check first for GMenuModel and assume if it
455 * doesn't exist then it must be dbusmenu.
456 */
457- menumodel_collector = hud_menu_model_collector_get (source->active_window, source->active_desktop_file);
458+ menumodel_collector = hud_menu_model_collector_get (source->active_window,
459+ source->active_desktop_file,
460+ source->active_icon);
461 if (menumodel_collector)
462 collector = HUD_SOURCE (menumodel_collector);
463 else
464 collector = HUD_SOURCE (hud_dbusmenu_collector_new_for_window (source->active_window,
465- source->active_desktop_file));
466+ source->active_desktop_file,
467+ source->active_icon));
468
469 g_object_set_qdata_full (G_OBJECT (source->active_window), menu_collector_quark, collector, g_object_unref);
470 }
471@@ -254,6 +258,7 @@
472 source->active_window = g_object_ref (window);
473 source->active_application = g_object_ref (application);
474 source->active_desktop_file = desktop_file;
475+ source->active_icon = bamf_view_get_icon (BAMF_VIEW (application));
476 source->active_collector = g_object_ref (hud_window_source_get_collector (source));
477
478 if (source->use_count)
479
480=== modified file 'tools-vala/hud-gtk.vala'
481--- tools-vala/hud-gtk.vala 2012-03-21 17:16:38 +0000
482+++ tools-vala/hud-gtk.vala 2012-03-26 15:29:24 +0000
483@@ -53,6 +53,10 @@
484 query_key = null;
485 model.clear ();
486
487+ if (entry.text == "") {
488+ return;
489+ }
490+
491 try {
492 var session = Bus.get_sync (BusType.SESSION, null);
493 var reply = session.call_sync ("com.canonical.hud", "/com/canonical/hud", "com.canonical.hud",

Subscribers

People subscribed via source and target branches