Merge lp://qastaging/~lukas-vacek/unity/bamficon_windowlist-raring into lp://qastaging/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://qastaging/~lukas-vacek/unity/bamficon_windowlist-raring
Merge into: lp://qastaging/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://qastaging/~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.qastaging.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
The diff is not available at this time. You can reload the page or download it.