Merge lp:~3v1n0/unity/quicklist-menu-items-leak-fix into lp:unity
- quicklist-menu-items-leak-fix
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Marco Trevisan (Treviño) | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 2565 | ||||
Proposed branch: | lp:~3v1n0/unity/quicklist-menu-items-leak-fix | ||||
Merge into: | lp:unity | ||||
Diff against target: |
759 lines (+106/-124) 26 files modified
launcher/AbstractLauncherIcon.h (+2/-1) launcher/BFBLauncherIcon.cpp (+16/-31) launcher/BFBLauncherIcon.h (+7/-5) launcher/BamfLauncherIcon.cpp (+31/-25) launcher/BamfLauncherIcon.h (+1/-1) launcher/DeviceLauncherIcon.cpp (+3/-3) launcher/DeviceLauncherIcon.h (+1/-1) launcher/HudLauncherIcon.cpp (+0/-6) launcher/HudLauncherIcon.h (+0/-1) launcher/LauncherIcon.cpp (+8/-7) launcher/LauncherIcon.h (+2/-2) launcher/MockLauncherIcon.h (+2/-2) launcher/QuicklistMenuItem.cpp (+2/-2) launcher/QuicklistMenuItem.h (+1/-1) launcher/QuicklistMenuItemCheckmark.cpp (+1/-1) launcher/QuicklistMenuItemCheckmark.h (+1/-1) launcher/QuicklistMenuItemLabel.cpp (+1/-1) launcher/QuicklistMenuItemLabel.h (+1/-1) launcher/QuicklistMenuItemRadio.cpp (+1/-1) launcher/QuicklistMenuItemRadio.h (+1/-1) launcher/QuicklistMenuItemSeparator.cpp (+1/-1) launcher/QuicklistMenuItemSeparator.h (+1/-1) launcher/TrashLauncherIcon.cpp (+7/-14) launcher/TrashLauncherIcon.h (+2/-2) tests/test_bfb_launcher_icon.cpp (+1/-1) tests/test_quicklist_view.cpp (+12/-11) |
||||
To merge this branch: | bzr merge lp:~3v1n0/unity/quicklist-menu-items-leak-fix | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Marco Trevisan (Treviño) | Approve | ||
Tim Penhey | Pending | ||
Andrea Azzarone | Pending | ||
Review via email:
|
This proposal supersedes a proposal from 2012-08-13.
Commit message
AbstractLaunche
Description of the change
We have some leak around in the quicklist menu items, for many icons the allocated DbusmenuMenuitem are never unreferenced.
Fixing this by moving the whole stack to the usage of the glib::Object<
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Tim Penhey (thumper) wrote : Posted in a previous version of this proposal | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Marco Trevisan (Treviño) (3v1n0) wrote : Posted in a previous version of this proposal | # |
Ooops... Because I wanted to test one thing and I forgot to put the things back.
Thanks for noticing it, fixed!
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Andrea Azzarone (azzar1) wrote : Posted in a previous version of this proposal | # |
typedef std::vector<
/me doesn't like this typedef beucase it adds disinformation ;)
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Marco Trevisan (Treviño) (3v1n0) wrote : Posted in a previous version of this proposal | # |
Yes, I don't like either, but the type here was really too complex and long to keep it in the original form...
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Andrea Azzarone (azzar1) wrote : Posted in a previous version of this proposal | # |
> Yes, I don't like either, but the type here was really too complex and long to
> keep it in the original form...
What about MenuItemsVector?
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Marco Trevisan (Treviño) (3v1n0) wrote : Posted in a previous version of this proposal | # |
If you really prefer this one... Done!
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Andrea Azzarone (azzar1) : Posted in a previous version of this proposal | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Unity Merger (unity-merger) wrote : Posted in a previous version of this proposal | # |
No proposals found for merge of lp:~3v1n0/unity/bfb-quicklist-does-not-close-dash into lp:unity.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
Approving as it was already approved by andyrock.
Preview Diff
1 | === modified file 'launcher/AbstractLauncherIcon.h' |
2 | --- launcher/AbstractLauncherIcon.h 2012-08-02 13:16:06 +0000 |
3 | +++ launcher/AbstractLauncherIcon.h 2012-08-14 18:43:57 +0000 |
4 | @@ -79,6 +79,7 @@ |
5 | public: |
6 | typedef nux::ObjectPtr<AbstractLauncherIcon> Ptr; |
7 | typedef std::vector<nux::Vector4> TransformVector; |
8 | + typedef std::vector<glib::Object<DbusmenuMenuitem>> MenuItemsVector; |
9 | |
10 | enum class IconType |
11 | { |
12 | @@ -179,7 +180,7 @@ |
13 | |
14 | virtual std::string RemoteUri() = 0; |
15 | |
16 | - virtual std::list<DbusmenuMenuitem*> Menus() = 0; |
17 | + virtual MenuItemsVector Menus() = 0; |
18 | |
19 | virtual nux::DndAction QueryAcceptDrop(DndData const& dnd_data) = 0; |
20 | |
21 | |
22 | === modified file 'launcher/BFBLauncherIcon.cpp' |
23 | --- launcher/BFBLauncherIcon.cpp 2012-08-14 10:42:42 +0000 |
24 | +++ launcher/BFBLauncherIcon.cpp 2012-08-14 18:43:57 +0000 |
25 | @@ -18,20 +18,17 @@ |
26 | * Andrea Azzarone <azzaronea@gmail.com> |
27 | */ |
28 | |
29 | +#include <glib/gi18n-lib.h> |
30 | +#include "unity-shared/UBusMessages.h" |
31 | + |
32 | #include "BFBLauncherIcon.h" |
33 | #include "Launcher.h" |
34 | |
35 | -#include "unity-shared/UBusMessages.h" |
36 | - |
37 | -#include <glib/gi18n-lib.h> |
38 | - |
39 | namespace unity |
40 | { |
41 | namespace launcher |
42 | { |
43 | |
44 | -UBusManager BFBLauncherIcon::ubus_manager_; |
45 | - |
46 | BFBLauncherIcon::BFBLauncherIcon(LauncherHideMode hide_mode) |
47 | : SimpleLauncherIcon(IconType::HOME) |
48 | , reader_(dash::LensDirectoryReader::GetDefault()) |
49 | @@ -96,35 +93,29 @@ |
50 | // dont chain down to avoid random dash close events |
51 | } |
52 | |
53 | -void BFBLauncherIcon::OnMenuitemActivated(DbusmenuMenuitem* item, |
54 | - int time, |
55 | - gchar* lens) |
56 | +void BFBLauncherIcon::OnMenuitemActivated(DbusmenuMenuitem* item, int time, std::string const& lens) |
57 | { |
58 | - if (lens != NULL) |
59 | - { |
60 | - ubus_manager_.SendMessage(UBUS_PLACE_ENTRY_ACTIVATE_REQUEST, g_variant_new("(sus)", lens, dash::GOTO_DASH_URI, "")); |
61 | - g_free(lens); |
62 | - } |
63 | + if (lens.empty()) |
64 | + return; |
65 | + |
66 | + ubus_manager_.SendMessage(UBUS_PLACE_ENTRY_ACTIVATE_REQUEST, g_variant_new("(sus)", lens.c_str(), dash::GOTO_DASH_URI, "")); |
67 | } |
68 | |
69 | -std::list<DbusmenuMenuitem*> BFBLauncherIcon::GetMenus() |
70 | +AbstractLauncherIcon::MenuItemsVector BFBLauncherIcon::GetMenus() |
71 | { |
72 | - std::list<DbusmenuMenuitem*> result; |
73 | - DbusmenuMenuitem* menu_item; |
74 | + MenuItemsVector result; |
75 | + glib::Object<DbusmenuMenuitem> menu_item; |
76 | + |
77 | + typedef glib::Signal<void, DbusmenuMenuitem*, int> ItemSignal; |
78 | + auto callback = sigc::mem_fun(this, &BFBLauncherIcon::OnMenuitemActivated); |
79 | |
80 | // Home dash |
81 | menu_item = dbusmenu_menuitem_new(); |
82 | - |
83 | dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Dash Home")); |
84 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true); |
85 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); |
86 | dbusmenu_menuitem_property_set_bool(menu_item, QuicklistMenuItem::OVERLAY_MENU_ITEM_PROPERTY, true); |
87 | - |
88 | - g_signal_connect(menu_item, |
89 | - DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, |
90 | - (GCallback)&BFBLauncherIcon::OnMenuitemActivated, |
91 | - g_strdup("home.lens")); |
92 | - |
93 | + signals_.Add(new ItemSignal(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, sigc::bind(callback, "home.lens"))); |
94 | result.push_back(menu_item); |
95 | |
96 | // Other lenses.. |
97 | @@ -134,17 +125,11 @@ |
98 | continue; |
99 | |
100 | menu_item = dbusmenu_menuitem_new(); |
101 | - |
102 | dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_LABEL, lens->name); |
103 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true); |
104 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); |
105 | dbusmenu_menuitem_property_set_bool(menu_item, QuicklistMenuItem::OVERLAY_MENU_ITEM_PROPERTY, true); |
106 | - |
107 | - g_signal_connect(menu_item, |
108 | - DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, |
109 | - (GCallback)&BFBLauncherIcon::OnMenuitemActivated, |
110 | - g_strdup(lens->id)); |
111 | - |
112 | + signals_.Add(new ItemSignal(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, sigc::bind(callback, lens->id.Str()))); |
113 | result.push_back(menu_item); |
114 | } |
115 | |
116 | |
117 | === modified file 'launcher/BFBLauncherIcon.h' |
118 | --- launcher/BFBLauncherIcon.h 2012-05-28 16:16:06 +0000 |
119 | +++ launcher/BFBLauncherIcon.h 2012-08-14 18:43:57 +0000 |
120 | @@ -20,11 +20,12 @@ |
121 | #ifndef UNITYSHELL_BFBLAUNCHERICON_H |
122 | #define UNITYSHELL_BFBLAUNCHERICON_H |
123 | |
124 | -#include "SimpleLauncherIcon.h" |
125 | - |
126 | #include <UnityCore/FilesystemLenses.h> |
127 | +#include <UnityCore/GLibWrapper.h> |
128 | +#include <UnityCore/GLibSignal.h> |
129 | |
130 | #include "LauncherOptions.h" |
131 | +#include "SimpleLauncherIcon.h" |
132 | #include "unity-shared/UBusWrapper.h" |
133 | |
134 | namespace unity |
135 | @@ -45,17 +46,18 @@ |
136 | void SetHideMode(LauncherHideMode hide_mode); |
137 | |
138 | protected: |
139 | - std::list<DbusmenuMenuitem*> GetMenus(); |
140 | + MenuItemsVector GetMenus(); |
141 | std::string GetName() const; |
142 | |
143 | private: |
144 | void OnOverlayShown(GVariant *data, bool visible); |
145 | - static void OnMenuitemActivated(DbusmenuMenuitem* item, int time, gchar* lens); |
146 | + void OnMenuitemActivated(DbusmenuMenuitem* item, int time, std::string const& lens); |
147 | |
148 | - static unity::UBusManager ubus_manager_; |
149 | nux::Color background_color_; |
150 | dash::LensDirectoryReader::Ptr reader_; |
151 | LauncherHideMode launcher_hide_mode_; |
152 | + UBusManager ubus_manager_; |
153 | + glib::SignalManager signals_; |
154 | }; |
155 | |
156 | } |
157 | |
158 | === modified file 'launcher/BamfLauncherIcon.cpp' |
159 | --- launcher/BamfLauncherIcon.cpp 2012-08-14 10:42:42 +0000 |
160 | +++ launcher/BamfLauncherIcon.cpp 2012-08-14 18:43:57 +0000 |
161 | @@ -820,14 +820,14 @@ |
162 | continue; |
163 | |
164 | std::string address = bamf_indicator_get_remote_address(indicator); |
165 | - DbusmenuClient* client = dbusmenu_client_new(address.c_str(), path.c_str()); |
166 | - _menu_clients[path] = glib::Object<DbusmenuClient>(client); |
167 | + glib::Object<DbusmenuClient> client(dbusmenu_client_new(address.c_str(), path.c_str())); |
168 | + _menu_clients[path] = client; |
169 | } |
170 | |
171 | g_list_free(children); |
172 | |
173 | // add dynamic quicklist |
174 | - if (_menuclient_dynamic_quicklist && DBUSMENU_IS_CLIENT(_menuclient_dynamic_quicklist.RawPtr())) |
175 | + if (_menuclient_dynamic_quicklist && _menuclient_dynamic_quicklist.IsType(DBUSMENU_TYPE_CLIENT)) |
176 | { |
177 | if (_menu_clients["dynamicquicklist"] != _menuclient_dynamic_quicklist) |
178 | { |
179 | @@ -841,7 +841,7 @@ |
180 | } |
181 | |
182 | // make a client for desktop file actions |
183 | - if (!DBUSMENU_IS_MENUITEM(_menu_desktop_shortcuts.RawPtr())) |
184 | + if (!_menu_desktop_shortcuts.IsType(DBUSMENU_TYPE_MENUITEM)) |
185 | { |
186 | UpdateDesktopQuickList(); |
187 | } |
188 | @@ -907,7 +907,7 @@ |
189 | |
190 | void BamfLauncherIcon::EnsureMenuItemsReady() |
191 | { |
192 | - DbusmenuMenuitem* menu_item; |
193 | + glib::Object<DbusmenuMenuitem> menu_item; |
194 | |
195 | /* Pin */ |
196 | if (_menu_items.find("Pin") == _menu_items.end()) |
197 | @@ -921,7 +921,7 @@ |
198 | ToggleSticky(); |
199 | })); |
200 | |
201 | - _menu_items["Pin"] = glib::Object<DbusmenuMenuitem>(menu_item); |
202 | + _menu_items["Pin"] = menu_item; |
203 | } |
204 | |
205 | const char* label = !IsSticky() ? _("Lock to Launcher") : _("Unlock from Launcher"); |
206 | @@ -942,25 +942,26 @@ |
207 | Quit(); |
208 | })); |
209 | |
210 | - _menu_items["Quit"] = glib::Object<DbusmenuMenuitem>(menu_item); |
211 | + _menu_items["Quit"] = menu_item; |
212 | } |
213 | } |
214 | |
215 | -std::list<DbusmenuMenuitem*> BamfLauncherIcon::GetMenus() |
216 | +AbstractLauncherIcon::MenuItemsVector BamfLauncherIcon::GetMenus() |
217 | { |
218 | - std::list<DbusmenuMenuitem*> result; |
219 | + MenuItemsVector result; |
220 | bool first_separator_needed = false; |
221 | - DbusmenuMenuitem* item = nullptr; |
222 | |
223 | // FIXME for O: hack around the wrong abstraction |
224 | UpdateMenus(); |
225 | |
226 | - for (auto it = _menu_clients.begin(); it != _menu_clients.end(); ++it) |
227 | + for (auto const& cli : _menu_clients) |
228 | { |
229 | GList* child = nullptr; |
230 | - DbusmenuClient* client = it->second; |
231 | - if (!client) |
232 | + auto const& client = cli.second; |
233 | + |
234 | + if (!client || !client.IsType(DBUSMENU_TYPE_CLIENT)) |
235 | continue; |
236 | + |
237 | DbusmenuMenuitem* root = dbusmenu_client_get_root(client); |
238 | |
239 | if (!root || !dbusmenu_menuitem_property_get_bool(root, DBUSMENU_MENUITEM_PROP_VISIBLE)) |
240 | @@ -968,9 +969,9 @@ |
241 | |
242 | for (child = dbusmenu_menuitem_get_children(root); child; child = child->next) |
243 | { |
244 | - DbusmenuMenuitem* item = (DbusmenuMenuitem*) child->data; |
245 | + glib::Object<DbusmenuMenuitem> item(static_cast<DbusmenuMenuitem*>(child->data), glib::AddRef()); |
246 | |
247 | - if (!item || !DBUSMENU_IS_MENUITEM(item)) |
248 | + if (!item || !item.IsType(DBUSMENU_TYPE_MENUITEM)) |
249 | continue; |
250 | |
251 | if (dbusmenu_menuitem_property_get_bool(item, DBUSMENU_MENUITEM_PROP_VISIBLE)) |
252 | @@ -990,9 +991,9 @@ |
253 | |
254 | for (child = dbusmenu_menuitem_get_children(_menu_desktop_shortcuts); child; child = child->next) |
255 | { |
256 | - DbusmenuMenuitem* item = (DbusmenuMenuitem*) child->data; |
257 | + glib::Object<DbusmenuMenuitem> item(static_cast<DbusmenuMenuitem*>(child->data), glib::AddRef()); |
258 | |
259 | - if (!item) |
260 | + if (!item || !item.IsType(DBUSMENU_TYPE_MENUITEM)) |
261 | continue; |
262 | |
263 | first_separator_needed = true; |
264 | @@ -1001,9 +1002,12 @@ |
265 | } |
266 | } |
267 | |
268 | + glib::Object<DbusmenuMenuitem> item; |
269 | + |
270 | if (first_separator_needed) |
271 | { |
272 | auto first_sep = _menu_items_extra.find("FirstSeparator"); |
273 | + |
274 | if (first_sep != _menu_items_extra.end()) |
275 | { |
276 | item = first_sep->second; |
277 | @@ -1014,7 +1018,7 @@ |
278 | dbusmenu_menuitem_property_set(item, |
279 | DBUSMENU_MENUITEM_PROP_TYPE, |
280 | DBUSMENU_CLIENT_TYPES_SEPARATOR); |
281 | - _menu_items_extra["FirstSeparator"] = glib::Object<DbusmenuMenuitem>(item); |
282 | + _menu_items_extra["FirstSeparator"] = item; |
283 | } |
284 | result.push_back(item); |
285 | } |
286 | @@ -1070,21 +1074,23 @@ |
287 | |
288 | EnsureMenuItemsReady(); |
289 | |
290 | - for (auto it_m = _menu_items.begin(); it_m != _menu_items.end(); ++it_m) |
291 | + for (auto it : _menu_items) |
292 | { |
293 | - if (!IsRunning() && it_m->first == "Quit") |
294 | + if (!IsRunning() && it.first == "Quit") |
295 | continue; |
296 | |
297 | bool exists = false; |
298 | - std::string label_default(dbusmenu_menuitem_property_get(it_m->second, DBUSMENU_MENUITEM_PROP_LABEL)); |
299 | + std::string label_default(dbusmenu_menuitem_property_get(it.second, DBUSMENU_MENUITEM_PROP_LABEL)); |
300 | |
301 | for (auto menu_item : result) |
302 | { |
303 | const gchar* type = dbusmenu_menuitem_property_get(menu_item, DBUSMENU_MENUITEM_PROP_TYPE); |
304 | - if (type == nullptr)//(g_strcmp0 (type, DBUSMENU_MENUITEM_PROP_LABEL) == 0) |
305 | + |
306 | + if (!type)//(g_strcmp0 (type, DBUSMENU_MENUITEM_PROP_LABEL) == 0) |
307 | { |
308 | - std::string label_menu(dbusmenu_menuitem_property_get(menu_item, DBUSMENU_MENUITEM_PROP_LABEL)); |
309 | - if (label_menu == label_default) |
310 | + const gchar* label = dbusmenu_menuitem_property_get(menu_item, DBUSMENU_MENUITEM_PROP_LABEL); |
311 | + |
312 | + if (label && std::string(label) == label_default) |
313 | { |
314 | exists = true; |
315 | break; |
316 | @@ -1093,7 +1099,7 @@ |
317 | } |
318 | |
319 | if (!exists) |
320 | - result.push_back(it_m->second); |
321 | + result.push_back(it.second); |
322 | } |
323 | |
324 | return result; |
325 | |
326 | === modified file 'launcher/BamfLauncherIcon.h' |
327 | --- launcher/BamfLauncherIcon.h 2012-08-02 12:13:38 +0000 |
328 | +++ launcher/BamfLauncherIcon.h 2012-08-14 18:43:57 +0000 |
329 | @@ -82,7 +82,7 @@ |
330 | bool OnShouldHighlightOnDrag(DndData const& dnd_data); |
331 | nux::DndAction OnQueryAcceptDrop(DndData const& dnd_data); |
332 | |
333 | - std::list<DbusmenuMenuitem*> GetMenus(); |
334 | + MenuItemsVector GetMenus(); |
335 | std::set<std::string> ValidateUrisForLaunch(DndData const& dnd_data); |
336 | |
337 | std::string GetRemoteUri(); |
338 | |
339 | === modified file 'launcher/DeviceLauncherIcon.cpp' |
340 | --- launcher/DeviceLauncherIcon.cpp 2012-08-02 13:16:06 +0000 |
341 | +++ launcher/DeviceLauncherIcon.cpp 2012-08-14 18:43:57 +0000 |
342 | @@ -118,10 +118,10 @@ |
343 | return g_volume_can_eject(volume_); |
344 | } |
345 | |
346 | -std::list<DbusmenuMenuitem*> DeviceLauncherIcon::GetMenus() |
347 | +AbstractLauncherIcon::MenuItemsVector DeviceLauncherIcon::GetMenus() |
348 | { |
349 | - std::list<DbusmenuMenuitem*> result; |
350 | - DbusmenuMenuitem* menu_item; |
351 | + MenuItemsVector result; |
352 | + glib::Object<DbusmenuMenuitem> menu_item; |
353 | glib::Object<GDrive> drive(g_volume_get_drive(volume_)); |
354 | |
355 | // "Lock to Launcher"/"Unlock from Launcher" item |
356 | |
357 | === modified file 'launcher/DeviceLauncherIcon.h' |
358 | --- launcher/DeviceLauncherIcon.h 2012-07-18 16:06:32 +0000 |
359 | +++ launcher/DeviceLauncherIcon.h 2012-08-14 18:43:57 +0000 |
360 | @@ -43,7 +43,7 @@ |
361 | void Eject(); |
362 | |
363 | protected: |
364 | - std::list<DbusmenuMenuitem*> GetMenus(); |
365 | + MenuItemsVector GetMenus(); |
366 | std::string GetName() const; |
367 | |
368 | private: |
369 | |
370 | === modified file 'launcher/HudLauncherIcon.cpp' |
371 | --- launcher/HudLauncherIcon.cpp 2012-08-02 13:16:06 +0000 |
372 | +++ launcher/HudLauncherIcon.cpp 2012-08-14 18:43:57 +0000 |
373 | @@ -123,12 +123,6 @@ |
374 | } |
375 | } |
376 | |
377 | -std::list<DbusmenuMenuitem*> HudLauncherIcon::GetMenus() |
378 | -{ |
379 | - std::list<DbusmenuMenuitem*> result; |
380 | - return result; |
381 | -} |
382 | - |
383 | std::string HudLauncherIcon::GetName() const |
384 | { |
385 | return "HudLauncherIcon"; |
386 | |
387 | === modified file 'launcher/HudLauncherIcon.h' |
388 | --- launcher/HudLauncherIcon.h 2012-05-28 16:16:06 +0000 |
389 | +++ launcher/HudLauncherIcon.h 2012-08-14 18:43:57 +0000 |
390 | @@ -43,7 +43,6 @@ |
391 | void SetHideMode(LauncherHideMode hide_mode); |
392 | |
393 | protected: |
394 | - std::list<DbusmenuMenuitem*> GetMenus(); |
395 | std::string GetName() const; |
396 | |
397 | private: |
398 | |
399 | === modified file 'launcher/LauncherIcon.cpp' |
400 | --- launcher/LauncherIcon.cpp 2012-08-13 18:25:57 +0000 |
401 | +++ launcher/LauncherIcon.cpp 2012-08-14 18:43:57 +0000 |
402 | @@ -547,7 +547,7 @@ |
403 | |
404 | bool LauncherIcon::OpenQuicklist(bool select_first_item, int monitor) |
405 | { |
406 | - std::list<DbusmenuMenuitem*> menus = Menus(); |
407 | + MenuItemsVector const& menus = Menus(); |
408 | |
409 | if (!_quicklist) |
410 | LoadQuicklist(); |
411 | @@ -557,11 +557,12 @@ |
412 | |
413 | if (_tooltip) |
414 | _tooltip->ShowWindow(false); |
415 | + |
416 | _quicklist->RemoveAllMenuItem(); |
417 | |
418 | - for (auto menu_item : menus) |
419 | + for (auto const& menu_item : menus) |
420 | { |
421 | - QuicklistMenuItem* ql_item; |
422 | + QuicklistMenuItem* ql_item = nullptr; |
423 | |
424 | const gchar* type = dbusmenu_menuitem_property_get(menu_item, DBUSMENU_MENUITEM_PROP_TYPE); |
425 | const gchar* toggle_type = dbusmenu_menuitem_property_get(menu_item, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE); |
426 | @@ -602,7 +603,7 @@ |
427 | monitor = 0; |
428 | } |
429 | |
430 | - nux::Geometry geo = _parent_geo[monitor]; |
431 | + nux::Geometry const& geo = _parent_geo[monitor]; |
432 | int tip_x = geo.x + geo.width - 4 * geo.width / 48; |
433 | int tip_y = _center[monitor].y; |
434 | |
435 | @@ -913,14 +914,14 @@ |
436 | return _progress; |
437 | } |
438 | |
439 | -std::list<DbusmenuMenuitem*> LauncherIcon::Menus() |
440 | +AbstractLauncherIcon::MenuItemsVector LauncherIcon::Menus() |
441 | { |
442 | return GetMenus(); |
443 | } |
444 | |
445 | -std::list<DbusmenuMenuitem*> LauncherIcon::GetMenus() |
446 | +AbstractLauncherIcon::MenuItemsVector LauncherIcon::GetMenus() |
447 | { |
448 | - std::list<DbusmenuMenuitem*> result; |
449 | + MenuItemsVector result; |
450 | return result; |
451 | } |
452 | |
453 | |
454 | === modified file 'launcher/LauncherIcon.h' |
455 | --- launcher/LauncherIcon.h 2012-08-13 18:25:57 +0000 |
456 | +++ launcher/LauncherIcon.h 2012-08-14 18:43:57 +0000 |
457 | @@ -154,7 +154,7 @@ |
458 | |
459 | nux::BaseTexture* Emblem(); |
460 | |
461 | - std::list<DbusmenuMenuitem*> Menus(); |
462 | + MenuItemsVector Menus(); |
463 | |
464 | void InsertEntryRemote(LauncherEntryRemote::Ptr const& remote); |
465 | |
466 | @@ -227,7 +227,7 @@ |
467 | |
468 | void SetEmblem(BaseTexturePtr const& emblem); |
469 | |
470 | - virtual std::list<DbusmenuMenuitem*> GetMenus(); |
471 | + virtual MenuItemsVector GetMenus(); |
472 | |
473 | virtual nux::BaseTexture* GetTextureForSize(int size) = 0; |
474 | |
475 | |
476 | === modified file 'launcher/MockLauncherIcon.h' |
477 | --- launcher/MockLauncherIcon.h 2012-08-13 18:25:57 +0000 |
478 | +++ launcher/MockLauncherIcon.h 2012-08-14 18:43:57 +0000 |
479 | @@ -260,9 +260,9 @@ |
480 | return 0; |
481 | } |
482 | |
483 | - std::list<DbusmenuMenuitem*> Menus() |
484 | + MenuItemsVector Menus() |
485 | { |
486 | - return std::list<DbusmenuMenuitem*> (); |
487 | + return MenuItemsVector (); |
488 | } |
489 | |
490 | nux::DndAction QueryAcceptDrop(DndData const& dnd_data) |
491 | |
492 | === modified file 'launcher/QuicklistMenuItem.cpp' |
493 | --- launcher/QuicklistMenuItem.cpp 2012-08-13 16:01:13 +0000 |
494 | +++ launcher/QuicklistMenuItem.cpp 2012-08-14 18:43:57 +0000 |
495 | @@ -33,10 +33,10 @@ |
496 | |
497 | NUX_IMPLEMENT_OBJECT_TYPE(QuicklistMenuItem); |
498 | |
499 | -QuicklistMenuItem::QuicklistMenuItem(QuicklistMenuItemType type, DbusmenuMenuitem* item, NUX_FILE_LINE_DECL) |
500 | +QuicklistMenuItem::QuicklistMenuItem(QuicklistMenuItemType type, glib::Object<DbusmenuMenuitem> const& item, NUX_FILE_LINE_DECL) |
501 | : nux::View(NUX_FILE_LINE_PARAM) |
502 | , _item_type(type) |
503 | - , _menu_item(item, glib::AddRef()) |
504 | + , _menu_item(item) |
505 | , _prelight(false) |
506 | { |
507 | mouse_up.connect(sigc::mem_fun(this, &QuicklistMenuItem::RecvMouseUp)); |
508 | |
509 | === modified file 'launcher/QuicklistMenuItem.h' |
510 | --- launcher/QuicklistMenuItem.h 2012-08-13 16:01:13 +0000 |
511 | +++ launcher/QuicklistMenuItem.h 2012-08-14 18:43:57 +0000 |
512 | @@ -49,7 +49,7 @@ |
513 | { |
514 | NUX_DECLARE_OBJECT_TYPE(QuicklistMenuItem, nux::View); |
515 | public: |
516 | - QuicklistMenuItem(QuicklistMenuItemType type, DbusmenuMenuitem* item, NUX_FILE_LINE_PROTO); |
517 | + QuicklistMenuItem(QuicklistMenuItemType type, glib::Object<DbusmenuMenuitem> const& item, NUX_FILE_LINE_PROTO); |
518 | virtual ~QuicklistMenuItem(); |
519 | |
520 | QuicklistMenuItemType GetItemType() const; |
521 | |
522 | === modified file 'launcher/QuicklistMenuItemCheckmark.cpp' |
523 | --- launcher/QuicklistMenuItemCheckmark.cpp 2012-08-13 13:41:13 +0000 |
524 | +++ launcher/QuicklistMenuItemCheckmark.cpp 2012-08-14 18:43:57 +0000 |
525 | @@ -25,7 +25,7 @@ |
526 | namespace unity |
527 | { |
528 | |
529 | -QuicklistMenuItemCheckmark::QuicklistMenuItemCheckmark(DbusmenuMenuitem* item, NUX_FILE_LINE_DECL) |
530 | +QuicklistMenuItemCheckmark::QuicklistMenuItemCheckmark(glib::Object<DbusmenuMenuitem> const& item, NUX_FILE_LINE_DECL) |
531 | : QuicklistMenuItem(QuicklistMenuItemType::CHECK, item, NUX_FILE_LINE_PARAM) |
532 | { |
533 | InitializeText(); |
534 | |
535 | === modified file 'launcher/QuicklistMenuItemCheckmark.h' |
536 | --- launcher/QuicklistMenuItemCheckmark.h 2012-08-13 13:41:13 +0000 |
537 | +++ launcher/QuicklistMenuItemCheckmark.h 2012-08-14 18:43:57 +0000 |
538 | @@ -30,7 +30,7 @@ |
539 | class QuicklistMenuItemCheckmark : public QuicklistMenuItem |
540 | { |
541 | public: |
542 | - QuicklistMenuItemCheckmark(DbusmenuMenuitem* item, NUX_FILE_LINE_PROTO); |
543 | + QuicklistMenuItemCheckmark(glib::Object<DbusmenuMenuitem> const& item, NUX_FILE_LINE_PROTO); |
544 | |
545 | protected: |
546 | std::string GetName() const; |
547 | |
548 | === modified file 'launcher/QuicklistMenuItemLabel.cpp' |
549 | --- launcher/QuicklistMenuItemLabel.cpp 2012-08-13 13:41:13 +0000 |
550 | +++ launcher/QuicklistMenuItemLabel.cpp 2012-08-14 18:43:57 +0000 |
551 | @@ -25,7 +25,7 @@ |
552 | namespace unity |
553 | { |
554 | |
555 | -QuicklistMenuItemLabel::QuicklistMenuItemLabel(DbusmenuMenuitem* item, NUX_FILE_LINE_DECL) |
556 | +QuicklistMenuItemLabel::QuicklistMenuItemLabel(glib::Object<DbusmenuMenuitem> const& item, NUX_FILE_LINE_DECL) |
557 | : QuicklistMenuItem(QuicklistMenuItemType::LABEL, item, NUX_FILE_LINE_PARAM) |
558 | { |
559 | InitializeText(); |
560 | |
561 | === modified file 'launcher/QuicklistMenuItemLabel.h' |
562 | --- launcher/QuicklistMenuItemLabel.h 2012-08-13 13:41:13 +0000 |
563 | +++ launcher/QuicklistMenuItemLabel.h 2012-08-14 18:43:57 +0000 |
564 | @@ -30,7 +30,7 @@ |
565 | class QuicklistMenuItemLabel : public QuicklistMenuItem |
566 | { |
567 | public: |
568 | - QuicklistMenuItemLabel(DbusmenuMenuitem* item, NUX_FILE_LINE_PROTO); |
569 | + QuicklistMenuItemLabel(glib::Object<DbusmenuMenuitem> const& item, NUX_FILE_LINE_PROTO); |
570 | |
571 | protected: |
572 | std::string GetName() const; |
573 | |
574 | === modified file 'launcher/QuicklistMenuItemRadio.cpp' |
575 | --- launcher/QuicklistMenuItemRadio.cpp 2012-08-13 13:41:13 +0000 |
576 | +++ launcher/QuicklistMenuItemRadio.cpp 2012-08-14 18:43:57 +0000 |
577 | @@ -24,7 +24,7 @@ |
578 | namespace unity |
579 | { |
580 | |
581 | -QuicklistMenuItemRadio::QuicklistMenuItemRadio(DbusmenuMenuitem* item, NUX_FILE_LINE_DECL) |
582 | +QuicklistMenuItemRadio::QuicklistMenuItemRadio(glib::Object<DbusmenuMenuitem> const& item, NUX_FILE_LINE_DECL) |
583 | : QuicklistMenuItem(QuicklistMenuItemType::RADIO, item, NUX_FILE_LINE_PARAM) |
584 | { |
585 | InitializeText(); |
586 | |
587 | === modified file 'launcher/QuicklistMenuItemRadio.h' |
588 | --- launcher/QuicklistMenuItemRadio.h 2012-08-13 13:41:13 +0000 |
589 | +++ launcher/QuicklistMenuItemRadio.h 2012-08-14 18:43:57 +0000 |
590 | @@ -29,7 +29,7 @@ |
591 | class QuicklistMenuItemRadio : public QuicklistMenuItem |
592 | { |
593 | public: |
594 | - QuicklistMenuItemRadio(DbusmenuMenuitem* item, NUX_FILE_LINE_PROTO); |
595 | + QuicklistMenuItemRadio(glib::Object<DbusmenuMenuitem> const& item, NUX_FILE_LINE_PROTO); |
596 | |
597 | protected: |
598 | std::string GetName() const; |
599 | |
600 | === modified file 'launcher/QuicklistMenuItemSeparator.cpp' |
601 | --- launcher/QuicklistMenuItemSeparator.cpp 2012-08-13 13:41:13 +0000 |
602 | +++ launcher/QuicklistMenuItemSeparator.cpp 2012-08-14 18:43:57 +0000 |
603 | @@ -24,7 +24,7 @@ |
604 | namespace unity |
605 | { |
606 | |
607 | -QuicklistMenuItemSeparator::QuicklistMenuItemSeparator(DbusmenuMenuitem* item, NUX_FILE_LINE_DECL) |
608 | +QuicklistMenuItemSeparator::QuicklistMenuItemSeparator(glib::Object<DbusmenuMenuitem> const& item, NUX_FILE_LINE_DECL) |
609 | : QuicklistMenuItem(QuicklistMenuItemType::SEPARATOR, item, NUX_FILE_LINE_PARAM) |
610 | , _color(1.0f, 1.0f, 1.0f, 0.5f) |
611 | , _premultiplied_color(0.5f, 0.5f, 0.5f, 0.5f) |
612 | |
613 | === modified file 'launcher/QuicklistMenuItemSeparator.h' |
614 | --- launcher/QuicklistMenuItemSeparator.h 2012-08-13 13:41:13 +0000 |
615 | +++ launcher/QuicklistMenuItemSeparator.h 2012-08-14 18:43:57 +0000 |
616 | @@ -29,7 +29,7 @@ |
617 | class QuicklistMenuItemSeparator : public QuicklistMenuItem |
618 | { |
619 | public: |
620 | - QuicklistMenuItemSeparator(DbusmenuMenuitem* item, NUX_FILE_LINE_PROTO); |
621 | + QuicklistMenuItemSeparator(glib::Object<DbusmenuMenuitem> const& item, NUX_FILE_LINE_PROTO); |
622 | |
623 | virtual bool GetSelectable(); |
624 | |
625 | |
626 | === modified file 'launcher/TrashLauncherIcon.cpp' |
627 | --- launcher/TrashLauncherIcon.cpp 2012-08-10 10:08:13 +0000 |
628 | +++ launcher/TrashLauncherIcon.cpp 2012-08-14 18:43:57 +0000 |
629 | @@ -73,22 +73,20 @@ |
630 | g_cancellable_cancel(cancellable_); |
631 | } |
632 | |
633 | -std::list<DbusmenuMenuitem*> TrashLauncherIcon::GetMenus() |
634 | +AbstractLauncherIcon::MenuItemsVector TrashLauncherIcon::GetMenus() |
635 | { |
636 | - std::list<DbusmenuMenuitem*> result; |
637 | - DbusmenuMenuitem* menu_item; |
638 | + MenuItemsVector result; |
639 | |
640 | /* Empty Trash */ |
641 | - menu_item = dbusmenu_menuitem_new(); |
642 | - g_object_ref(menu_item); |
643 | - |
644 | + glib::Object<DbusmenuMenuitem> menu_item(dbusmenu_menuitem_new()); |
645 | dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Empty Trash...")); |
646 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, !empty_); |
647 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); |
648 | + empty_activated_signal_.Connect(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, |
649 | + [this] (DbusmenuMenuitem*, int) { |
650 | + proxy_.Call("EmptyTrash"); |
651 | + }); |
652 | |
653 | - g_signal_connect(menu_item, |
654 | - DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, |
655 | - (GCallback)&TrashLauncherIcon::OnEmptyTrash, this); |
656 | result.push_back(menu_item); |
657 | |
658 | return result; |
659 | @@ -102,11 +100,6 @@ |
660 | g_spawn_command_line_async("xdg-open trash://", &error); |
661 | } |
662 | |
663 | -void TrashLauncherIcon::OnEmptyTrash(DbusmenuMenuitem* item, int time, TrashLauncherIcon* self) |
664 | -{ |
665 | - self->proxy_.Call("EmptyTrash"); |
666 | -} |
667 | - |
668 | void TrashLauncherIcon::UpdateTrashIcon() |
669 | { |
670 | glib::Object<GFile> location(g_file_new_for_uri("trash:///")); |
671 | |
672 | === modified file 'launcher/TrashLauncherIcon.h' |
673 | --- launcher/TrashLauncherIcon.h 2012-08-10 10:08:13 +0000 |
674 | +++ launcher/TrashLauncherIcon.h 2012-08-14 18:43:57 +0000 |
675 | @@ -51,16 +51,16 @@ |
676 | |
677 | private: |
678 | void ActivateLauncherIcon(ActionArg arg); |
679 | - std::list<DbusmenuMenuitem*> GetMenus(); |
680 | + MenuItemsVector GetMenus(); |
681 | |
682 | static void UpdateTrashIconCb(GObject* source, GAsyncResult* res, gpointer data); |
683 | - static void OnEmptyTrash(DbusmenuMenuitem* item, int time, TrashLauncherIcon* self); |
684 | |
685 | gboolean empty_; |
686 | glib::DBusProxy proxy_; |
687 | glib::Object<GCancellable> cancellable_; |
688 | glib::Object<GFileMonitor> trash_monitor_; |
689 | glib::Signal<void, GFileMonitor*, GFile*, GFile*, GFileMonitorEvent> trash_changed_signal_; |
690 | + glib::Signal<void, DbusmenuMenuitem*, int> empty_activated_signal_; |
691 | }; |
692 | |
693 | } |
694 | |
695 | === modified file 'tests/test_bfb_launcher_icon.cpp' |
696 | --- tests/test_bfb_launcher_icon.cpp 2012-08-13 16:17:22 +0000 |
697 | +++ tests/test_bfb_launcher_icon.cpp 2012-08-14 18:43:57 +0000 |
698 | @@ -34,7 +34,7 @@ |
699 | : BFBLauncherIcon(LauncherHideMode::LAUNCHER_HIDE_NEVER) |
700 | {} |
701 | |
702 | - std::list<DbusmenuMenuitem*> GetMenus() |
703 | + AbstractLauncherIcon::MenuItemsVector GetMenus() |
704 | { |
705 | return BFBLauncherIcon::GetMenus(); |
706 | } |
707 | |
708 | === modified file 'tests/test_quicklist_view.cpp' |
709 | --- tests/test_quicklist_view.cpp 2012-08-13 14:23:15 +0000 |
710 | +++ tests/test_quicklist_view.cpp 2012-08-14 18:43:57 +0000 |
711 | @@ -39,7 +39,7 @@ |
712 | : quicklist(new QuicklistView()) |
713 | {} |
714 | |
715 | - void AddMenuItems(DbusmenuMenuitem* root) |
716 | + void AddMenuItems(glib::Object<DbusmenuMenuitem> const& root) |
717 | { |
718 | quicklist->RemoveAllMenuItem(); |
719 | |
720 | @@ -48,28 +48,29 @@ |
721 | |
722 | for (GList* child = dbusmenu_menuitem_get_children(root); child; child = child->next) |
723 | { |
724 | - const gchar* type = dbusmenu_menuitem_property_get((DbusmenuMenuitem*)child->data, DBUSMENU_MENUITEM_PROP_TYPE); |
725 | - const gchar* toggle_type = dbusmenu_menuitem_property_get((DbusmenuMenuitem*)child->data, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE); |
726 | + glib::Object<DbusmenuMenuitem> item(static_cast<DbusmenuMenuitem*>(child->data), glib::AddRef()); |
727 | + const gchar* type = dbusmenu_menuitem_property_get(item, DBUSMENU_MENUITEM_PROP_TYPE); |
728 | + const gchar* toggle_type = dbusmenu_menuitem_property_get(item, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE); |
729 | |
730 | if (g_strcmp0(type, DBUSMENU_CLIENT_TYPES_SEPARATOR) == 0) |
731 | { |
732 | - QuicklistMenuItemSeparator* item = new QuicklistMenuItemSeparator((DbusmenuMenuitem*)child->data, NUX_TRACKER_LOCATION); |
733 | - quicklist->AddMenuItem(item); |
734 | + QuicklistMenuItemSeparator* qlitem = new QuicklistMenuItemSeparator(item, NUX_TRACKER_LOCATION); |
735 | + quicklist->AddMenuItem(qlitem); |
736 | } |
737 | else if (g_strcmp0(toggle_type, DBUSMENU_MENUITEM_TOGGLE_CHECK) == 0) |
738 | { |
739 | - QuicklistMenuItemCheckmark* item = new QuicklistMenuItemCheckmark((DbusmenuMenuitem*)child->data, NUX_TRACKER_LOCATION); |
740 | - quicklist->AddMenuItem(item); |
741 | + QuicklistMenuItemCheckmark* qlitem = new QuicklistMenuItemCheckmark(item, NUX_TRACKER_LOCATION); |
742 | + quicklist->AddMenuItem(qlitem); |
743 | } |
744 | else if (g_strcmp0(toggle_type, DBUSMENU_MENUITEM_TOGGLE_RADIO) == 0) |
745 | { |
746 | - QuicklistMenuItemRadio* item = new QuicklistMenuItemRadio((DbusmenuMenuitem*)child->data, NUX_TRACKER_LOCATION); |
747 | - quicklist->AddMenuItem(item); |
748 | + QuicklistMenuItemRadio* qlitem = new QuicklistMenuItemRadio(item, NUX_TRACKER_LOCATION); |
749 | + quicklist->AddMenuItem(qlitem); |
750 | } |
751 | else //if (g_strcmp0 (type, DBUSMENU_MENUITEM_PROP_LABEL) == 0) |
752 | { |
753 | - QuicklistMenuItemLabel* item = new QuicklistMenuItemLabel((DbusmenuMenuitem*)child->data, NUX_TRACKER_LOCATION); |
754 | - quicklist->AddMenuItem(item); |
755 | + QuicklistMenuItemLabel* qlitem = new QuicklistMenuItemLabel(item, NUX_TRACKER_LOCATION); |
756 | + quicklist->AddMenuItem(qlitem); |
757 | } |
758 | } |
759 | } |
Why did you make a bunch of properties public in QuicklistMenuItem?