Merge lp://staging/~3v1n0/unity/launcher-draggable-icons into lp://staging/unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 2713
Proposed branch: lp://staging/~3v1n0/unity/launcher-draggable-icons
Merge into: lp://staging/unity
Diff against target: 7548 lines (+3855/-1096)
72 files modified
UnityCore/DesktopUtilities.cpp (+29/-9)
UnityCore/DesktopUtilities.h (+1/-0)
UnityCore/GLibDBusProxy.cpp (+0/-4)
com.canonical.Unity.gschema.xml (+3/-3)
launcher/AbstractLauncherIcon.h (+16/-2)
launcher/BFBLauncherIcon.cpp (+1/-0)
launcher/BamfLauncherIcon.cpp (+31/-48)
launcher/BamfLauncherIcon.h (+0/-1)
launcher/CMakeLists.txt (+1/-0)
launcher/DesktopLauncherIcon.cpp (+19/-6)
launcher/DesktopLauncherIcon.h (+4/-12)
launcher/DeviceLauncherSection.cpp (+14/-7)
launcher/DeviceLauncherSection.h (+3/-5)
launcher/DndData.cpp (+5/-5)
launcher/DndData.h (+1/-1)
launcher/ExpoLauncherIcon.cpp (+64/-0)
launcher/ExpoLauncherIcon.h (+45/-0)
launcher/FavoriteStore.cpp (+93/-4)
launcher/FavoriteStore.h (+21/-8)
launcher/FavoriteStoreGSettings.cpp (+67/-68)
launcher/FavoriteStoreGSettings.h (+7/-4)
launcher/FavoriteStorePrivate.cpp (+14/-0)
launcher/FavoriteStorePrivate.h (+3/-1)
launcher/HudLauncherIcon.cpp (+2/-1)
launcher/Launcher.cpp (+82/-108)
launcher/Launcher.h (+5/-8)
launcher/LauncherController.cpp (+526/-341)
launcher/LauncherController.h (+1/-3)
launcher/LauncherControllerPrivate.h (+28/-41)
launcher/LauncherIcon.cpp (+31/-4)
launcher/LauncherIcon.h (+5/-9)
launcher/LauncherModel.cpp (+34/-32)
launcher/MockLauncherIcon.h (+11/-15)
launcher/SoftwareCenterLauncherIcon.cpp (+27/-38)
launcher/SoftwareCenterLauncherIcon.h (+1/-1)
launcher/SpacerLauncherIcon.cpp (+1/-1)
launcher/SpacerLauncherIcon.h (+0/-4)
launcher/StandaloneLauncher.cpp (+1/-1)
launcher/TrashLauncherIcon.cpp (+1/-0)
launcher/VolumeLauncherIcon.cpp (+34/-4)
launcher/VolumeLauncherIcon.h (+3/-0)
manual-tests/Launcher.txt (+15/-0)
panel/PanelMenuView.h (+0/-1)
plugins/unityshell/src/unityshell.cpp (+5/-7)
plugins/unityshell/unityshell.xml.in (+0/-6)
tests/CMakeLists.txt (+19/-11)
tests/gmockvolume.c (+3/-2)
tests/test_bamf_launcher_icon.cpp (+70/-2)
tests/test_bfb_launcher_icon.cpp (+11/-8)
tests/test_desktop_launcher_icon.cpp (+80/-0)
tests/test_desktop_utilities.cpp (+52/-22)
tests/test_device_launcher_section.cpp (+19/-54)
tests/test_expo_launcher_icon.cpp (+58/-0)
tests/test_favorite_store.cpp (+111/-0)
tests/test_favorite_store_gsettings.cpp (+52/-29)
tests/test_hud_launcher_icon.cpp (+53/-0)
tests/test_launcher.cpp (+226/-15)
tests/test_launcher_controller.cpp (+1246/-44)
tests/test_launcher_icon.cpp (+113/-0)
tests/test_launcher_model.cpp (+182/-40)
tests/test_main.cpp (+1/-0)
tests/test_main_xless.cpp (+1/-1)
tests/test_mock_devices.h (+93/-0)
tests/test_software_center_launcher_icon.cpp (+74/-0)
tests/test_trash_launcher_icon.cpp (+39/-0)
tests/test_volume_launcher_icon.cpp (+67/-46)
unity-shared/PluginAdapter.h (+2/-0)
unity-shared/PluginAdapterCompiz.cpp (+5/-0)
unity-shared/PluginAdapterStandalone.cpp (+15/-7)
unity-shared/WindowManager.cpp (+5/-0)
unity-shared/WindowManager.h (+1/-0)
unity-standalone/StandaloneUnity.cpp (+2/-2)
To merge this branch: bzr merge lp://staging/~3v1n0/unity/launcher-draggable-icons
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Approve
Brandon Schaefer (community) Approve
Review via email: mp+123311@code.staging.launchpad.net

Commit message

LauncherController, FavoriteStore, Launcher, Icons: always use sort priority based on favorites to get positioned on launcher

Description of the change

This is the continuum of the work started in lp:~3v1n0/unity/keep-priority-launcher-model, here we use the launcher icons priority to correctly order the icons in the launcher, based on the position that they have in the favorite store.

The unity launcher favorite store now handles not only desktop paths or id but also (mostly) icons uris (such as application://desktop-id or unity://desktop-icon or device://uuid); these values are used by LauncherController to dispose these icons in the launchers.

To do this, I had to change AbstractLauncherIcon to define a position property that now LauncherModel uses together with the icon priority (that is now set by default to the icon type but then can change during the usage, or based on favorites).

The icons ordering has changed a lot: now the favorites control everything (except BFB and trash) and we add the icons based on their defined position. Added two special places: "unity://running-apps" and "unity://devices" that optionally defines where these kind of icons should be placed. This is not strict by the way, because if these uris are not defined we add them by default at the bottom of the launcher main model.

When a new Device or Application icon is added to the launcher, we append it to the list of the non-sticky devices or applications.

Favorites reordering, removal or additions have been refactored to fit to our new system; when we save the favorites, the position of the "running-apps" or "attached-devices" is computed based on where the first icon of this type is placed.

The expo icon is handled differently, since it is not added if we have no workspaces available; it also updates its visibility based on the workspaces settings.

SoftwareCenterLauncher icons are now handled differently: we now fully consider them as sticky application icons, so we firstly add them to the model (setting their priority based on the last sticky icon we have), then we animate them. They already know where they should go, based on model calculations (also fixed a bug that caused them not to get the overlay shourtcut when added).

See other commit messages for more info, they should be quite comprehensive.

----

Testing: updated and added a lot of new unit tests to cover (hopefully) all the changes I've done (that's mostly why this diff is so big, since the real changes are less than the half of the changed code) and to test the areas that we never tested before, just few stats:

test-gtest: added 13 new test cases (+5%)
test-gtest-xless: added 94 new test cases (+56%)

To post a comment you must log in.
Revision history for this message
Andrea Azzarone (azzar1) wrote :

340 +std::string DesktopLauncherIcon::GetRemoteUri()
341 +{
342 + return "unity://desktop-icon";
343 +}

 +bool DesktopLauncherIcon::ShowInSwitcher(bool current)
351 +{
352 + return show_in_switcher_;
353 +}

Can we make these methods const?

---

+#ifndef EXPO_LAUNCHER_ICON_H

I'd prefer UNITYSHELL_EXPO... But it's not blocking :)

...

+FavoriteStore* favoritestore_instance = nullptr;

FavoriteStore should not be a singleton. You can use DI in launcher::Controller.

---

621 +bool FavoriteStore::IsValidFavoriteUri(std::string const& uri)
622 +{
623 + if (uri.empty())
624 + return false;
625 +
626 + if (uri.find(URI_PREFIX_APP) == 0 || uri.find(URI_PREFIX_FILE) == 0)
627 + {
628 + return internal::impl::IsDesktopFilePath(uri);
629 + }

Can this method be const? Also you know we prefer to use operator ! :)

+ const std::string prefix_separator = "://";
 + const std::string proto_separator = "://";
813 + const std::string desktop_ext = ".desktop";

I'd make it static or I'd move it out of the function.

//auto const& system_dirs = DesktopUtilities::GetDataDirectories();

Remove it if you don't need it.

+bool FavoriteStoreGSettings::IsFavorite(std::string const& icon_uri)

const :)

+ const std::string desktop_ext = ".desktop";

Make it static.

1199 - if (max > 0.0f)
1200 - {
1201 - color = color * (1.0f / max);
1202 - }
1203 + color = color * (1.0f / max);

Why have you done this?

* I'll continue the review later *

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

> 340 +std::string DesktopLauncherIcon::GetRemoteUri()
> 341 +{
> 342 + return "unity://desktop-icon";
> 343 +}
>
> +bool DesktopLauncherIcon::ShowInSwitcher(bool current)
> 351 +{
> 352 + return show_in_switcher_;
> 353 +}
>
> Can we make these methods const?

The first one no (due to BamfLauncherIcon). Probably it should be fixed there as well... I'll see.

> +FavoriteStore* favoritestore_instance = nullptr;
>
> FavoriteStore should not be a singleton. You can use DI in
> launcher::Controller.

I kept it in this way since it used to be like that, also it made testing easier (not to mention that it was a singleton because it was used also in the icons).
However, I could probably avoid to use it in this manner by adding a new icon signal and then using launcher::Controller. I see how it impacts on tests.

> 621 +bool FavoriteStore::IsValidFavoriteUri(std::string const& uri)
> 622 +{
> 623 + if (uri.empty())
> 624 + return false;
> 625 +
> 626 + if (uri.find(URI_PREFIX_APP) == 0 || uri.find(URI_PREFIX_FILE) ==
> 0)
> 627 + {
> 628 + return internal::impl::IsDesktopFilePath(uri);
> 629 + }
>
> Can this method be const? Also you know we prefer to use operator ! :)

A static method? :)
We use the operator! when a method returns false, but find returns the position of the found item, and we want to make sure that our strings starts with it.

> + const std::string prefix_separator = "://";
> + const std::string proto_separator = "://";
> 813 + const std::string desktop_ext = ".desktop";
>
> I'd make it static or I'd move it out of the function.

Yeah, probably... I thought the same.

> +bool FavoriteStoreGSettings::IsFavorite(std::string const& icon_uri)
>
> const :)

Yeah, I fogot to do it also for FavoritePosition.

> 1199 - if (max > 0.0f)
> 1200 - {
> 1201 - color = color * (1.0f / max);
> 1202 - }
> 1203 + color = color * (1.0f / max);
>
> Why have you done this?

Mhm, probably I made a wrong merge. Thanks for pointing out.

> * I'll continue the review later *

Nice, thanks ;)

Revision history for this message
Łukasz Zemczak (sil2100) wrote :

What about the switcher icon? Is it also handled now by the favorites?

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

> What about the switcher icon? Is it also handled now by the favorites?

Yep, the special uri unity://expo-icon controls it, however it wont' be visible if the WS have been disabled.

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

> > 340 +std::string DesktopLauncherIcon::GetRemoteUri()
> > 341 +{
> > 342 + return "unity://desktop-icon";
> > 343 +}
> >
> > +bool DesktopLauncherIcon::ShowInSwitcher(bool current)
> > 351 +{
> > 352 + return show_in_switcher_;
> > 353 +}
> >
> > Can we make these methods const?
>
> The first one no (due to BamfLauncherIcon). Probably it should be fixed there
> as well... I'll see.
>
>
> > +FavoriteStore* favoritestore_instance = nullptr;
> >
> > FavoriteStore should not be a singleton. You can use DI in
> > launcher::Controller.
>
> I kept it in this way since it used to be like that, also it made testing
> easier (not to mention that it was a singleton because it was used also in the
> icons).

Really singleton makes testing easier? :) You can pass it to the icons using the ctor.

> However, I could probably avoid to use it in this manner by adding a new icon
> signal and then using launcher::Controller. I see how it impacts on tests.
>
> > 621 +bool FavoriteStore::IsValidFavoriteUri(std::string const& uri)
> > 622 +{
> > 623 + if (uri.empty())
> > 624 + return false;
> > 625 +
> > 626 + if (uri.find(URI_PREFIX_APP) == 0 || uri.find(URI_PREFIX_FILE) ==
> > 0)
> > 627 + {
> > 628 + return internal::impl::IsDesktopFilePath(uri);
> > 629 + }
> >
> > Can this method be const? Also you know we prefer to use operator ! :)
>
> A static method? :)

Whops :) sorry

> We use the operator! when a method returns false, but find returns the
> position of the found item, and we want to make sure that our strings starts
> with it.
>

ok

>
> > + const std::string prefix_separator = "://";
> > + const std::string proto_separator = "://";
> > 813 + const std::string desktop_ext = ".desktop";
> >
> > I'd make it static or I'd move it out of the function.
>
> Yeah, probably... I thought the same.
>
>
> > +bool FavoriteStoreGSettings::IsFavorite(std::string const& icon_uri)
> >
> > const :)
>
> Yeah, I fogot to do it also for FavoritePosition.
>
>
> > 1199 - if (max > 0.0f)
> > 1200 - {
> > 1201 - color = color * (1.0f / max);
> > 1202 - }
> > 1203 + color = color * (1.0f / max);
> >
> > Why have you done this?
>
> Mhm, probably I made a wrong merge. Thanks for pointing out.
>
>
> > * I'll continue the review later *
>
> Nice, thanks ;)

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

1959 - uscreen->resuming.connect([&]() -> void {
1960 - for (auto launcher : launchers)
1961 - launcher->QueueDraw();
1962 - });

Why have you removed this code?

In volume VolumeLauncherIcon you are calling parent_->UnStick(); before TryToUnblacklist. I think you should call it when you receive the changed signal from device_settings.

+ void Stick(bool save = true);

You should not use default values for virtual function (consider NVI to fix this "issue").

200 +#ifndef TEST_MOCK_DEVICES_H
4201 +#define TEST_MOCK_DEVICES_H

Why do you need this guards?

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

*these

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

> 1959 - uscreen->resuming.connect([&]() -> void {
> 1960 - for (auto launcher : launchers)
> 1961 - launcher->QueueDraw();
> 1962 - });
>
> Why have you removed this code?

This code was added in order to workaround a nvidia redraw issue that we had on resuming, but since now we properly fixed the issue, we can safely remove this hack (tested here on one machine that was affected).

> In volume VolumeLauncherIcon you are calling parent_->UnStick(); before
> TryToUnblacklist. I think you should call it when you receive the changed
> signal from device_settings.

Why on changed signal?

> + void Stick(bool save = true);
>
> You should not use default values for virtual function (consider NVI to fix
> this "issue").

Yeah, this is not the best thing ever... It was introduced a lot time ago, probably it's better to split it into two methods (Stick and StickAndSave)

> 200 +#ifndef TEST_MOCK_DEVICES_H
> 4201 +#define TEST_MOCK_DEVICES_H
>
> Why do you need this guards?

Well, to avoid the redefinition of these objects. These won't probably be ever broken, but they won't surely create any issue.

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

> > 1959 - uscreen->resuming.connect([&]() -> void {
> > 1960 - for (auto launcher : launchers)
> > 1961 - launcher->QueueDraw();
> > 1962 - });
> >
> > Why have you removed this code?
>
> This code was added in order to workaround a nvidia redraw issue that we had
> on resuming, but since now we properly fixed the issue, we can safely remove
> this hack (tested here on one machine that was affected).
>

Cool.

>
> > In volume VolumeLauncherIcon you are calling parent_->UnStick(); before
> > TryToUnblacklist. I think you should call it when you receive the changed
> > signal from device_settings.
>
> Why on changed signal?
>

This is how it works now. When you call TryToUnblacklist devices_settings emit a changed signal. In the changed signal handler of VoluleLauncherIcon we update the visibility. Before we had ignore_signals inside device_settings and was error prone.

>
> > + void Stick(bool save = true);
> >
> > You should not use default values for virtual function (consider NVI to fix
> > this "issue").
>
> Yeah, this is not the best thing ever... It was introduced a lot time ago,
> probably it's better to split it into two methods (Stick and StickAndSave)
>
>
> > 200 +#ifndef TEST_MOCK_DEVICES_H
> > 4201 +#define TEST_MOCK_DEVICES_H
> >
> > Why do you need this guards?
>
> Well, to avoid the redefinition of these objects. These won't probably be ever
> broken, but they won't surely create any issue.

Yeah but i don't like it in a cpp file :) Use an unnamed namespace.

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

One question...

Is this intended?

Setup:
Open gedit
Move it to the top of the launcher
Make sure it is not locked to the launcher

Then:
Open the gnome-cacluator
Make sure it is on the bottom of the launcher
Right click and lock it to the launcher

Result:
The gnome-calc moves below the gedit icon that is not locked to the launcher...

Just wanted to double check that is expected :).

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Other then that question, all the code looks good, the tests pass, and testing it manually also works :).

+1

review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-unity/1329/console reported an error when processing this lp:~3v1n0/unity/launcher-draggable-icons branch.
Not merging it.

Revision history for this message
Andrea Azzarone (azzar1) :
review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-unity/1336/console reported an error when processing this lp:~3v1n0/unity/launcher-draggable-icons branch.
Not merging it.

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.