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