Merge lp:~lukas-vacek/unity/bamficon_windowlist-raring into lp:unity

Proposed by Adolfo Jayme Barrientos
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 3143
Proposed branch: lp:~lukas-vacek/unity/bamficon_windowlist-raring
Merge into: lp:unity
Diff against target: 308 lines (+191/-1)
7 files modified
launcher/ApplicationLauncherIcon.cpp (+59/-0)
launcher/ApplicationLauncherIcon.h (+2/-0)
launcher/QuicklistMenuItem.cpp (+24/-1)
launcher/QuicklistMenuItem.h (+3/-0)
tests/mock-application.h (+1/-0)
tests/test_application_launcher_icon.cpp (+82/-0)
tests/test_quicklist_menu_item.cpp (+20/-0)
To merge this branch: bzr merge lp:~lukas-vacek/unity/bamficon_windowlist-raring
Reviewer Review Type Date Requested Status
John Lea (community) design Approve
Marco Trevisan (Treviño) Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+145676@code.launchpad.net

Commit message

ApplicationLauncherIcon: Show a list of related windows in a Launcher icon's Quicklist

(LP: #1107866)

Description of the change

Show a list of windows in a Launcher icon's Quicklist. (LP: #1107866)

To post a comment you must log in.
Revision history for this message
Michael Terry (mterry) wrote :

Seems like it could use a test.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

10 + WindowManager& wm = WindowManager::Default();
11 + // delete all menu items for windows

29 + char menu_item_name[name_size];
30 + sprintf(menu_item_name,"w_list_%d",i);

44 + _menu_items[menu_item_name] = menu_item;

Please, don't add these items to _menu_items. Use instead another container (such as
std::vector<glib::Object<DbusmenuMenuitem>> _windows_menu_items and add the items you generate there in AddMenuItemsWindowList.

22 + for ( auto w: Windows() ) {

Use for (auto const& w : Windows())

At that point call it into GetMenus() putting the items you computed into the result list.

36 + _gsignals.Add(
37 + new glib::Signal<void, DbusmenuMenuitem*, int>(menu_item,

You can use the utility Add function to save some space:
_gsignals.Add<void, DbusmenuMenuitem*, int>(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED ...

39 + [w,&wm] (DbusmenuMenuitem*,int) -> void {

Just pass w, while generate the WM inside the lambda body (even if that pointer won't change, it's safer not to pass by reference inside a lambda that is going to be executed when the local variable is dead). Also it's not needed to specify the "-> void" return type. g++ will guess it for you.

45 + std::string winName( ( wm.GetWindowName( w->window_id() ) ) );
46 + dbusmenu_menuitem_property_set(menu_item,
47 + DBUSMENU_MENUITEM_PROP_LABEL, winName.c_str() );

Only use:
dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_LABEL, w->title().c_str());

51 + if (windows_added) {
52 + // add seperator

65 + }

Do this into GetMenus.

Also, long quicklist items should be cut. I'll provide I way to do it as I need it also on another branch, please ping me on IRC in case you'd need help.

Fix the style to match the one we use in unity (2 spaces indentation, brackets on next line)

Need tests.

review: Needs Fixing
Revision history for this message
John Lea (johnlea) wrote :

Also the maximum string length of each Window title should be limited to 45 characters including spaces. Anything more than 45 characters should be chopped at 43 characters and have "..." applied to the end e.g.

"bamficon_windowlist_rearing : Code : Unity..." (In the case of this window)

review: Needs Fixing (design)
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

> Also the maximum string length of each Window title should be limited to 45
> characters including spaces. Anything more than 45 characters should be
> chopped at 43 characters and have "..." applied to the end e.g.
>
> "bamficon_windowlist_rearing : Code : Unity..." (In the case of this window)

Yes, I agree with this (as I wrote above).
The fix for that is needed also by bug #893652 and will be provided by lp:~3v1n0/unity/quicklist-max-label-width.

Just set the QuicklistMenuItem::MAXIMUM_LABEL_WIDTH_PROPERTY DBusMenuItem int property (wanted px-width will be provided by design).

Revision history for this message
John Lea (johnlea) wrote :

Update to my comment above:

- The max width should be 300px
- The window title should be ellipsized at the end
- This entry should only be displayed if there are 2 or more windows. If the application only has 1 or 0 windows open nothing should be displayed.

The format of the option should be:

====================
[application specific quicklist options area]
--------------
[application name]
--------------
Windows:
[window title 1]
[window title 2]
[window title 3]
--------------
Most recent files:
file one.odt
file two.odt
file three.odt
file four.odt
file five.odt
--------------
Keep in launcher
Quit
====================

thanks!

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

36 + // delete all menu items for windows
37 + _menu_items_windows.clear();

Please do this on EnsureMenuItemsWindowsReady

17 + _gsignals.Add<void, DbusmenuMenuitem*, int>(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
18 + [w] (DbusmenuMenuitem*,int) {

This is ok, but since using [w] means copying the the WindowPtr, I'd prefer if you instead do:

Window xid = w->window_id();
_gsignals.Add<void, DbusmenuMenuitem*, int>(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, [xid] (DbusmenuMenuitem*,int) {
...
wm.Raise(xid);
}

22 + } );

Remove this padding, please (use also for the lambda two spaces for indenting).

24 + dbusmenu_menuitem_property_set(menu_item, QuicklistMenuItem::MAXIMUM_LABEL_WIDTH_PROPERTY, "300");

That property is an integer, you should do instead:

dbusmenu_menuitem_property_set_int(menu_item, QuicklistMenuItem::MAXIMUM_LABEL_WIDTH_PROPERTY, MAXIMUM_QUICKLIST_WIDTH);

Where MAXIMUM_QUICKLIST_WIDTH is a const int that you should define in the unnamed namespace that we have at the top of the ApplicationLauncherIcon.cpp file ;).

40 + // add windows menu items
41 + if (_menu_items_windows.size() > 1 )

Mh, I'd prefer to iterate one more time than allocating some extra memory here, so just use if (Windows().size() > 1), and move EnsureMenuItemsWindowsReady under this check.

Thanks ;)

Revision history for this message
Lukas Vacek (lukas-vacek) wrote :

Thanks for your fast reply. I will fix that and push the changes tonight.

> 24 + dbusmenu_menuitem_property_set(menu_item,
> QuicklistMenuItem::MAXIMUM_LABEL_WIDTH_PROPERTY, "300");
>
> That property is an integer, you should do instead:
>
> dbusmenu_menuitem_property_set_int(menu_item,
> QuicklistMenuItem::MAXIMUM_LABEL_WIDTH_PROPERTY, MAXIMUM_QUICKLIST_WIDTH);
>
> Where MAXIMUM_QUICKLIST_WIDTH is a const int that you should define in the
> unnamed namespace that we have at the top of the ApplicationLauncherIcon.cpp
> file ;).
>

I am not sure about this one - to me it seems the property is const char* and it won't compile if I set it to an integer. I am not sure how to fix my code here.

Revision history for this message
Andrea Azzarone (azzar1) wrote :

> Thanks for your fast reply. I will fix that and push the changes tonight.
>
> > 24 + dbusmenu_menuitem_property_set(menu_item,
> > QuicklistMenuItem::MAXIMUM_LABEL_WIDTH_PROPERTY, "300");
> >
> > That property is an integer, you should do instead:
> >
> > dbusmenu_menuitem_property_set_int(menu_item,
> > QuicklistMenuItem::MAXIMUM_LABEL_WIDTH_PROPERTY, MAXIMUM_QUICKLIST_WIDTH);
> >
> > Where MAXIMUM_QUICKLIST_WIDTH is a const int that you should define in the
> > unnamed namespace that we have at the top of the ApplicationLauncherIcon.cpp
> > file ;).
> >
>
> I am not sure about this one - to me it seems the property is const char* and
> it won't compile if I set it to an integer. I am not sure how to fix my code
> here.

Keep in mind you need to use dbusmenu_menuitem_property_***set_int***

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Ah, also... It would be needed an unit-test or AP test. If you need some guidance, ping me on IRC.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

I think it's now ready to go in trunk... We have tests and correctly cut long entries!

review: Approve
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

New screenshot for design re-review: http://i.imgur.com/NUfgdKm.png

Revision history for this message
John Lea (johnlea) wrote :

Looks good to me now, thanks!

review: Approve (design)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'launcher/ApplicationLauncherIcon.cpp'
--- launcher/ApplicationLauncherIcon.cpp 2013-02-05 02:14:32 +0000
+++ launcher/ApplicationLauncherIcon.cpp 2013-02-08 15:07:28 +0000
@@ -51,6 +51,7 @@
51const std::string ICON_REMOVE_TIMEOUT = "bamf-icon-remove";51const std::string ICON_REMOVE_TIMEOUT = "bamf-icon-remove";
52//const std::string ICON_DND_OVER_TIMEOUT = "bamf-icon-dnd-over";52//const std::string ICON_DND_OVER_TIMEOUT = "bamf-icon-dnd-over";
53const std::string DEFAULT_ICON = "application-default-icon";53const std::string DEFAULT_ICON = "application-default-icon";
54const int MAXIMUM_QUICKLIST_WIDTH = 300;
54}55}
5556
56NUX_IMPLEMENT_OBJECT_TYPE(ApplicationLauncherIcon);57NUX_IMPLEMENT_OBJECT_TYPE(ApplicationLauncherIcon);
@@ -692,6 +693,42 @@
692 EmitNeedsRedraw();693 EmitNeedsRedraw();
693}694}
694695
696void ApplicationLauncherIcon::EnsureMenuItemsWindowsReady()
697{
698 // delete all menu items for windows
699 _menu_items_windows.clear();
700
701 auto const& windows = Windows();
702
703 // We only add quicklist menu-items for windows if we have more than one window
704 if (windows.size() < 2)
705 return;
706
707 // add menu items for all open windows
708 for (auto const& w : windows)
709 {
710 if (w->title().empty())
711 continue;
712
713 glib::Object<DbusmenuMenuitem> menu_item(dbusmenu_menuitem_new());
714 dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_LABEL, w->title().c_str());
715 dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true);
716 dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true);
717 dbusmenu_menuitem_property_set_bool(menu_item, QuicklistMenuItem::MARKUP_ACCEL_DISABLED_PROPERTY, true);
718 dbusmenu_menuitem_property_set_int(menu_item, QuicklistMenuItem::MAXIMUM_LABEL_WIDTH_PROPERTY, MAXIMUM_QUICKLIST_WIDTH);
719
720 Window xid = w->window_id();
721 _gsignals.Add<void, DbusmenuMenuitem*, int>(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
722 [xid] (DbusmenuMenuitem*, int) {
723 WindowManager& wm = WindowManager::Default();
724 wm.Activate(xid);
725 wm.Raise(xid);
726 });
727
728 _menu_items_windows.push_back(menu_item);
729 }
730}
731
695void ApplicationLauncherIcon::UpdateMenus()732void ApplicationLauncherIcon::UpdateMenus()
696{733{
697 // add dynamic quicklist734 // add dynamic quicklist
@@ -926,6 +963,28 @@
926 }963 }
927 result.push_back(item);964 result.push_back(item);
928965
966 EnsureMenuItemsWindowsReady();
967
968 if (!_menu_items_windows.empty())
969 {
970 for (auto const& it : _menu_items_windows)
971 result.push_back(it);
972
973 auto third_sep = _menu_items_extra.find("ThirdSeparator");
974 if (third_sep != _menu_items_extra.end())
975 {
976 item = third_sep->second;
977 }
978 else
979 {
980 item = dbusmenu_menuitem_new();
981 dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
982 _menu_items_extra["ThirdSeparator"] = glib::Object<DbusmenuMenuitem>(item);
983 }
984
985 result.push_back(item);
986 }
987
929 EnsureMenuItemsReady();988 EnsureMenuItemsReady();
930989
931 for (auto it : _menu_items)990 for (auto it : _menu_items)
932991
=== modified file 'launcher/ApplicationLauncherIcon.h'
--- launcher/ApplicationLauncherIcon.h 2013-02-05 02:14:32 +0000
+++ launcher/ApplicationLauncherIcon.h 2013-02-08 15:07:28 +0000
@@ -108,6 +108,7 @@
108 };108 };
109109
110 void EnsureWindowState();110 void EnsureWindowState();
111 void EnsureMenuItemsWindowsReady();
111 void EnsureMenuItemsReady();112 void EnsureMenuItemsReady();
112 void UpdateBackgroundColor();113 void UpdateBackgroundColor();
113 void UpdateMenus();114 void UpdateMenus();
@@ -130,6 +131,7 @@
130 std::map<std::string, glib::Object<DbusmenuClient>> _menu_clients;131 std::map<std::string, glib::Object<DbusmenuClient>> _menu_clients;
131 std::map<std::string, glib::Object<DbusmenuMenuitem>> _menu_items;132 std::map<std::string, glib::Object<DbusmenuMenuitem>> _menu_items;
132 std::map<std::string, glib::Object<DbusmenuMenuitem>> _menu_items_extra;133 std::map<std::string, glib::Object<DbusmenuMenuitem>> _menu_items_extra;
134 std::vector<glib::Object<DbusmenuMenuitem>> _menu_items_windows;
133 glib::Object<IndicatorDesktopShortcuts> _desktop_shortcuts;135 glib::Object<IndicatorDesktopShortcuts> _desktop_shortcuts;
134 glib::Object<DbusmenuMenuitem> _menu_desktop_shortcuts;136 glib::Object<DbusmenuMenuitem> _menu_desktop_shortcuts;
135 glib::Object<GFileMonitor> _desktop_file_monitor;137 glib::Object<GFileMonitor> _desktop_file_monitor;
136138
=== modified file 'launcher/QuicklistMenuItem.cpp'
--- launcher/QuicklistMenuItem.cpp 2013-01-31 14:54:19 +0000
+++ launcher/QuicklistMenuItem.cpp 2013-02-08 15:07:28 +0000
@@ -29,6 +29,7 @@
29namespace unity29namespace unity
30{30{
31const char* QuicklistMenuItem::MARKUP_ENABLED_PROPERTY = "unity-use-markup";31const char* QuicklistMenuItem::MARKUP_ENABLED_PROPERTY = "unity-use-markup";
32const char* QuicklistMenuItem::MARKUP_ACCEL_DISABLED_PROPERTY = "unity-disable-accel";
32const char* QuicklistMenuItem::MAXIMUM_LABEL_WIDTH_PROPERTY = "unity-max-label-width";33const char* QuicklistMenuItem::MAXIMUM_LABEL_WIDTH_PROPERTY = "unity-max-label-width";
33const char* QuicklistMenuItem::OVERLAY_MENU_ITEM_PROPERTY = "unity-overlay-item";34const char* QuicklistMenuItem::OVERLAY_MENU_ITEM_PROPERTY = "unity-overlay-item";
3435
@@ -280,7 +281,11 @@
280 std::shared_ptr<PangoFontDescription> desc(pango_font_description_from_string(font_name), pango_font_description_free);281 std::shared_ptr<PangoFontDescription> desc(pango_font_description_from_string(font_name), pango_font_description_free);
281 pango_layout_set_font_description(layout, desc.get());282 pango_layout_set_font_description(layout, desc.get());
282 pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);283 pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
283 pango_layout_set_markup_with_accel(layout, _text.c_str(), -1, '_', nullptr);284
285 if (IsMarkupAccelEnabled())
286 pango_layout_set_markup_with_accel(layout, _text.c_str(), -1, '_', nullptr);
287 else
288 pango_layout_set_markup(layout, _text.c_str(), -1);
284289
285 if (GetMaxLabelWidth() > 0)290 if (GetMaxLabelWidth() > 0)
286 {291 {
@@ -360,6 +365,24 @@
360 return (markup != FALSE);365 return (markup != FALSE);
361}366}
362367
368void QuicklistMenuItem::EnableLabelMarkupAccel(bool enabled)
369{
370 if (IsMarkupAccelEnabled() != enabled)
371 {
372 dbusmenu_menuitem_property_set_bool(_menu_item, MARKUP_ACCEL_DISABLED_PROPERTY, enabled ? FALSE : TRUE);
373 InitializeText();
374 }
375}
376
377bool QuicklistMenuItem::IsMarkupAccelEnabled() const
378{
379 if (!_menu_item)
380 return false;
381
382 gboolean disabled = dbusmenu_menuitem_property_get_bool(_menu_item, MARKUP_ACCEL_DISABLED_PROPERTY);
383 return (disabled == FALSE);
384}
385
363void QuicklistMenuItem::SetMaxLabelWidth(int max_width)386void QuicklistMenuItem::SetMaxLabelWidth(int max_width)
364{387{
365 if (GetMaxLabelWidth() != max_width)388 if (GetMaxLabelWidth() != max_width)
366389
=== modified file 'launcher/QuicklistMenuItem.h'
--- launcher/QuicklistMenuItem.h 2013-01-31 13:41:35 +0000
+++ launcher/QuicklistMenuItem.h 2013-02-08 15:07:28 +0000
@@ -61,6 +61,8 @@
6161
62 void EnableLabelMarkup(bool enabled);62 void EnableLabelMarkup(bool enabled);
63 bool IsMarkupEnabled() const;63 bool IsMarkupEnabled() const;
64 void EnableLabelMarkupAccel(bool enabled);
65 bool IsMarkupAccelEnabled() const;
6466
65 void SetMaxLabelWidth(int max_width);67 void SetMaxLabelWidth(int max_width);
66 int GetMaxLabelWidth() const;68 int GetMaxLabelWidth() const;
@@ -85,6 +87,7 @@
85 sigc::signal<void, QuicklistMenuItem*, int, int> sigMouseDrag;87 sigc::signal<void, QuicklistMenuItem*, int, int> sigMouseDrag;
8688
87 static const char* MARKUP_ENABLED_PROPERTY;89 static const char* MARKUP_ENABLED_PROPERTY;
90 static const char* MARKUP_ACCEL_DISABLED_PROPERTY;
88 static const char* MAXIMUM_LABEL_WIDTH_PROPERTY;91 static const char* MAXIMUM_LABEL_WIDTH_PROPERTY;
89 static const char* OVERLAY_MENU_ITEM_PROPERTY;92 static const char* OVERLAY_MENU_ITEM_PROPERTY;
9093
9194
=== modified file 'tests/mock-application.h'
--- tests/mock-application.h 2013-02-05 02:10:45 +0000
+++ tests/mock-application.h 2013-02-08 15:07:28 +0000
@@ -30,6 +30,7 @@
30 MockApplicationWindow(Window xid)30 MockApplicationWindow(Window xid)
31 : xid_(xid)31 : xid_(xid)
32 , monitor_(0)32 , monitor_(0)
33 , title_("MockApplicationWindow "+std::to_string(xid_))
33 , type_("window")34 , type_("window")
34 , visible_(true)35 , visible_(true)
35 , active_(false)36 , active_(false)
3637
=== modified file 'tests/test_application_launcher_icon.cpp'
--- tests/test_application_launcher_icon.cpp 2013-02-05 02:14:46 +0000
+++ tests/test_application_launcher_icon.cpp 2013-02-08 15:07:28 +0000
@@ -180,4 +180,86 @@
180 EXPECT_TRUE(mock_icon->IsActive());180 EXPECT_TRUE(mock_icon->IsActive());
181}181}
182182
183TEST_F(TestApplicationLauncherIcon, NoWindowListMenusWithOneWindow)
184{
185 auto win = std::make_shared<MockApplicationWindow>(g_random_int());
186 mock_app->window_list_ = { win };
187
188 auto const& menus = mock_icon->Menus();
189 auto menu_it = std::find_if(menus.begin(), menus.end(), [win] (glib::Object<DbusmenuMenuitem> it) {
190 auto* label = dbusmenu_menuitem_property_get(it, DBUSMENU_MENUITEM_PROP_LABEL);
191 return (label && std::string(label) == win->title());
192 });
193
194 EXPECT_EQ(menu_it, menus.end());
195}
196
197TEST_F(TestApplicationLauncherIcon, WindowListMenusWithTwoWindows)
198{
199 auto win1 = std::make_shared<MockApplicationWindow>(1);
200 auto wm_win1 = std::make_shared<StandaloneWindow>(win1->window_id());
201 auto win2 = std::make_shared<MockApplicationWindow>(2);
202 auto wm_win2 = std::make_shared<StandaloneWindow>(win2->window_id());
203
204 mock_app->window_list_ = { win1, win2 };
205 WM->AddStandaloneWindow(wm_win1);
206 WM->AddStandaloneWindow(wm_win2);
207 ASSERT_TRUE(wm_win2->active());
208
209 auto const& menus = mock_icon->Menus();
210
211 auto menu1_it = std::find_if(menus.begin(), menus.end(), [win1] (glib::Object<DbusmenuMenuitem> it) {
212 auto* label = dbusmenu_menuitem_property_get(it, DBUSMENU_MENUITEM_PROP_LABEL);
213 return (label && std::string(label) == win1->title());
214 });
215
216 ASSERT_NE(menu1_it, menus.end());
217 EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(*menu1_it, DBUSMENU_MENUITEM_PROP_ENABLED));
218 EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(*menu1_it, DBUSMENU_MENUITEM_PROP_VISIBLE));
219 EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(*menu1_it, QuicklistMenuItem::MARKUP_ACCEL_DISABLED_PROPERTY));
220 EXPECT_EQ(dbusmenu_menuitem_property_get_int(*menu1_it, QuicklistMenuItem::MAXIMUM_LABEL_WIDTH_PROPERTY), 300);
221
222 auto menu2_it = std::find_if(menus.begin(), menus.end(), [win2] (glib::Object<DbusmenuMenuitem> it) {
223 auto* label = dbusmenu_menuitem_property_get(it, DBUSMENU_MENUITEM_PROP_LABEL);
224 return (label && std::string(label) == win2->title());
225 });
226
227 ASSERT_NE(menu2_it, menus.end());
228 EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(*menu2_it, DBUSMENU_MENUITEM_PROP_ENABLED));
229 EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(*menu2_it, DBUSMENU_MENUITEM_PROP_VISIBLE));
230 EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(*menu2_it, QuicklistMenuItem::MARKUP_ACCEL_DISABLED_PROPERTY));
231 EXPECT_EQ(dbusmenu_menuitem_property_get_int(*menu2_it, QuicklistMenuItem::MAXIMUM_LABEL_WIDTH_PROPERTY), 300);
232
233 bool activated = false;
234 wm_win1->active.changed.connect([&activated] (bool a) { activated = a; });
235 g_signal_emit_by_name(*menu1_it, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, 0);
236
237 EXPECT_TRUE(wm_win1->active());
238 EXPECT_TRUE(activated);
239
240 activated = false;
241 wm_win2->active.changed.connect([&activated] (bool a) { activated = a; });
242 g_signal_emit_by_name(*menu2_it, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, 0);
243
244 EXPECT_TRUE(wm_win2->active());
245 EXPECT_TRUE(activated);
246}
247
248TEST_F(TestApplicationLauncherIcon, WindowListMenusWithEmptyTitles)
249{
250 auto win1 = std::make_shared<MockApplicationWindow>(1);
251 auto win2 = std::make_shared<MockApplicationWindow>(2);
252 win1->title_.clear();
253
254 mock_app->window_list_ = { win1, win2 };
255 auto const& menus = mock_icon->Menus();
256
257 auto menu1_it = std::find_if(menus.begin(), menus.end(), [win1] (glib::Object<DbusmenuMenuitem> it) {
258 auto* label = dbusmenu_menuitem_property_get(it, DBUSMENU_MENUITEM_PROP_LABEL);
259 return (label && std::string(label) == win1->title());
260 });
261
262 ASSERT_EQ(menu1_it, menus.end());
263}
264
183}265}
184266
=== modified file 'tests/test_quicklist_menu_item.cpp'
--- tests/test_quicklist_menu_item.cpp 2013-01-31 13:43:13 +0000
+++ tests/test_quicklist_menu_item.cpp 2013-02-08 15:07:28 +0000
@@ -139,6 +139,26 @@
139 EXPECT_EQ(dbusmenu_menuitem_property_get_int(item, QuicklistMenuItem::MAXIMUM_LABEL_WIDTH_PROPERTY), max_width);139 EXPECT_EQ(dbusmenu_menuitem_property_get_int(item, QuicklistMenuItem::MAXIMUM_LABEL_WIDTH_PROPERTY), max_width);
140}140}
141141
142TEST_F(TestQuicklistMenuItem, MarkupAccelEnabled)
143{
144 dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_LABEL, "Label");
145 dbusmenu_menuitem_property_set_bool(item, DBUSMENU_MENUITEM_PROP_ENABLED, true);
146
147 nux::ObjectPtr<QuicklistMenuItemLabel> qlitem(new QuicklistMenuItemLabel(item));
148 EXPECT_TRUE(qlitem->IsMarkupAccelEnabled());
149
150 dbusmenu_menuitem_property_set_bool(item, QuicklistMenuItem::MARKUP_ACCEL_DISABLED_PROPERTY, true);
151 EXPECT_FALSE(qlitem->IsMarkupAccelEnabled());
152
153 qlitem->EnableLabelMarkupAccel(true);
154 EXPECT_TRUE(qlitem->IsMarkupAccelEnabled());
155 EXPECT_FALSE(dbusmenu_menuitem_property_get_bool(item, QuicklistMenuItem::MARKUP_ACCEL_DISABLED_PROPERTY));
156
157 qlitem->EnableLabelMarkupAccel(false);
158 EXPECT_FALSE(qlitem->IsMarkupAccelEnabled());
159 EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(item, QuicklistMenuItem::MARKUP_ACCEL_DISABLED_PROPERTY));
160}
161
142TEST_F(TestQuicklistMenuItem, ItemActivate)162TEST_F(TestQuicklistMenuItem, ItemActivate)
143{163{
144 dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_LABEL, "Label");164 dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_LABEL, "Label");