Merge lp:~3v1n0/unity/launcher-filemanager-integration into lp:unity
- launcher-filemanager-integration
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Andrea Azzarone |
Approved revision: | no longer in the source branch. |
Merged at revision: | 4069 |
Proposed branch: | lp:~3v1n0/unity/launcher-filemanager-integration |
Merge into: | lp:unity |
Prerequisite: | lp:~3v1n0/unity/switcher-dynamic-model |
Diff against target: |
5139 lines (+2020/-1214) 47 files modified
UnityCore/DesktopUtilities.cpp (+5/-0) UnityCore/DesktopUtilities.h (+1/-0) UnityCore/GLibDBusProxy.cpp (+3/-3) debian/control (+1/-0) launcher/AbstractLauncherIcon.h (+11/-7) launcher/ApplicationLauncherIcon.cpp (+118/-685) launcher/ApplicationLauncherIcon.h (+51/-94) launcher/CMakeLists.txt (+3/-0) launcher/DesktopLauncherIcon.cpp (+5/-0) launcher/DesktopLauncherIcon.h (+1/-0) launcher/DeviceLauncherSection.h (+4/-0) launcher/FileManagerLauncherIcon.cpp (+128/-0) launcher/FileManagerLauncherIcon.h (+52/-0) launcher/Launcher.cpp (+2/-9) launcher/LauncherController.cpp (+24/-7) launcher/LauncherControllerPrivate.h (+2/-1) launcher/LauncherIcon.cpp (+12/-2) launcher/LauncherIcon.h (+14/-10) launcher/MockLauncherIcon.h (+38/-28) launcher/SoftwareCenterLauncherIcon.cpp (+2/-1) launcher/StorageLauncherIcon.cpp (+119/-0) launcher/StorageLauncherIcon.h (+55/-0) launcher/SwitcherController.cpp (+4/-7) launcher/SwitcherModel.cpp (+2/-11) launcher/SwitcherView.cpp (+1/-1) launcher/TrashLauncherIcon.cpp (+49/-21) launcher/TrashLauncherIcon.h (+5/-7) launcher/VolumeLauncherIcon.cpp (+101/-63) launcher/VolumeLauncherIcon.h (+7/-5) launcher/WindowedLauncherIcon.cpp (+618/-0) launcher/WindowedLauncherIcon.h (+100/-0) tests/CMakeLists.txt (+1/-0) tests/mock-application.h (+12/-2) tests/test_application_launcher_icon.cpp (+15/-30) tests/test_launcher_controller.cpp (+53/-48) tests/test_mock_filemanager.h (+8/-5) tests/test_software_center_launcher_icon.cpp (+3/-2) tests/test_switcher_controller.h (+6/-16) tests/test_switcher_controller_class.cpp (+9/-18) tests/test_trash_launcher_icon.cpp (+72/-2) tests/test_volume_launcher_icon.cpp (+169/-27) unity-shared/ApplicationManager.h (+3/-0) unity-shared/BamfApplicationManager.cpp (+8/-4) unity-shared/BamfApplicationManager.h (+3/-1) unity-shared/FileManager.h (+5/-6) unity-shared/GnomeFileManager.cpp (+113/-86) unity-shared/GnomeFileManager.h (+2/-5) |
To merge this branch: | bzr merge lp:~3v1n0/unity/launcher-filemanager-integration |
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Andrea Azzarone (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email: mp+279812@code.launchpad.net |
Commit message
Launcher: add FileManager, Trash and Volume icons integration
Now the launcher will link each nautilus window to the related volume or trash
icon, while the Nautilus launcher icon will only be active if the file manager is
browsing other locations.
It's now possible to manage sub-windows from the parent icon like it happens for
every other application (so even spreading them or select from QL)
The windows management logic has been moved to WindowedLaunche
base class of ApplicationLaun
VolumeLauncherIcon and TrashLauncherIcon are now based on StorageLauncherIcon
which connects to the FileManager to get the windows for a given location.
FileManagerLaun
and a StorageLauncher
Lots of random code cleanup included too.
Description of the change
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:4102
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:4103
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:4104
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:4106
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:4108
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:4109
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:4111
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:4112
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:4113
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Andrea Azzarone (azzar1) wrote : | # |
+1. Code looks good and I tested it in the last two weeks and everything works fine.
Preview Diff
1 | === modified file 'UnityCore/DesktopUtilities.cpp' | |||
2 | --- UnityCore/DesktopUtilities.cpp 2014-09-23 23:35:43 +0000 | |||
3 | +++ UnityCore/DesktopUtilities.cpp 2016-02-09 10:44:04 +0000 | |||
4 | @@ -90,6 +90,11 @@ | |||
5 | 90 | return ""; | 90 | return ""; |
6 | 91 | } | 91 | } |
7 | 92 | 92 | ||
8 | 93 | std::string DesktopUtilities::GetUserTrashDirectory() | ||
9 | 94 | { | ||
10 | 95 | return GetUserDataDirectory().append(G_DIR_SEPARATOR_S "Trash" G_DIR_SEPARATOR_S "files" G_DIR_SEPARATOR_S); | ||
11 | 96 | } | ||
12 | 97 | |||
13 | 93 | std::vector<std::string> DesktopUtilities::GetSystemDataDirectories() | 98 | std::vector<std::string> DesktopUtilities::GetSystemDataDirectories() |
14 | 94 | { | 99 | { |
15 | 95 | const char* const* system_dirs = g_get_system_data_dirs(); | 100 | const char* const* system_dirs = g_get_system_data_dirs(); |
16 | 96 | 101 | ||
17 | === modified file 'UnityCore/DesktopUtilities.h' | |||
18 | --- UnityCore/DesktopUtilities.h 2014-08-26 22:59:57 +0000 | |||
19 | +++ UnityCore/DesktopUtilities.h 2016-02-09 10:44:04 +0000 | |||
20 | @@ -33,6 +33,7 @@ | |||
21 | 33 | static std::string GetUserCacheDirectory(); | 33 | static std::string GetUserCacheDirectory(); |
22 | 34 | static std::string GetUserRuntimeDirectory(); | 34 | static std::string GetUserRuntimeDirectory(); |
23 | 35 | static std::string GetUserConfigDirectory(); | 35 | static std::string GetUserConfigDirectory(); |
24 | 36 | static std::string GetUserTrashDirectory(); | ||
25 | 36 | static std::vector<std::string> GetSystemDataDirectories(); | 37 | static std::vector<std::string> GetSystemDataDirectories(); |
26 | 37 | static std::vector<std::string> GetDataDirectories(); | 38 | static std::vector<std::string> GetDataDirectories(); |
27 | 38 | 39 | ||
28 | 39 | 40 | ||
29 | === modified file 'UnityCore/GLibDBusProxy.cpp' | |||
30 | --- UnityCore/GLibDBusProxy.cpp 2015-09-30 16:32:38 +0000 | |||
31 | +++ UnityCore/GLibDBusProxy.cpp 2016-02-09 10:44:04 +0000 | |||
32 | @@ -301,7 +301,7 @@ | |||
33 | 301 | } | 301 | } |
34 | 302 | } | 302 | } |
35 | 303 | 303 | ||
37 | 304 | g_variant_iter_free (iter); | 304 | g_variant_iter_free(iter); |
38 | 305 | } | 305 | } |
39 | 306 | 306 | ||
40 | 307 | for (const gchar *property_name = *invalidated; property_name; property_name = *(++invalidated)) | 307 | for (const gchar *property_name = *invalidated; property_name; property_name = *(++invalidated)) |
41 | @@ -624,7 +624,7 @@ | |||
42 | 624 | [] (GObject *source, GAsyncResult *res, gpointer user_data) { | 624 | [] (GObject *source, GAsyncResult *res, gpointer user_data) { |
43 | 625 | glib::Error err; | 625 | glib::Error err; |
44 | 626 | std::unique_ptr<ReplyCallback> callback(static_cast<ReplyCallback*>(user_data)); | 626 | std::unique_ptr<ReplyCallback> callback(static_cast<ReplyCallback*>(user_data)); |
46 | 627 | Variant result(g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), res, &err)); | 627 | Variant result(g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), res, &err), StealRef()); |
47 | 628 | 628 | ||
48 | 629 | if (err) | 629 | if (err) |
49 | 630 | { | 630 | { |
50 | @@ -660,7 +660,7 @@ | |||
51 | 660 | nullptr, G_DBUS_CALL_FLAGS_NONE, -1, pimpl->cancellable_, | 660 | nullptr, G_DBUS_CALL_FLAGS_NONE, -1, pimpl->cancellable_, |
52 | 661 | [] (GObject *source, GAsyncResult *res, gpointer user_data) { | 661 | [] (GObject *source, GAsyncResult *res, gpointer user_data) { |
53 | 662 | glib::Error err; | 662 | glib::Error err; |
55 | 663 | Variant result(g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), res, &err)); | 663 | Variant result(g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), res, &err), StealRef()); |
56 | 664 | if (err) | 664 | if (err) |
57 | 665 | { | 665 | { |
58 | 666 | LOG_ERROR(logger) << "Impossible to set property: " << err; | 666 | LOG_ERROR(logger) << "Impossible to set property: " << err; |
59 | 667 | 667 | ||
60 | === modified file 'debian/control' | |||
61 | --- debian/control 2016-02-08 20:34:08 +0000 | |||
62 | +++ debian/control 2016-02-09 10:44:04 +0000 | |||
63 | @@ -83,6 +83,7 @@ | |||
64 | 83 | Provides: indicator-renderer | 83 | Provides: indicator-renderer |
65 | 84 | Recommends: unity-control-center, | 84 | Recommends: unity-control-center, |
66 | 85 | ${unity-default-masterscopes} | 85 | ${unity-default-masterscopes} |
67 | 86 | nautilus, | ||
68 | 86 | indicator-appmenu (>= 15.02.0), | 87 | indicator-appmenu (>= 15.02.0), |
69 | 87 | indicator-application, | 88 | indicator-application, |
70 | 88 | indicator-sound, | 89 | indicator-sound, |
71 | 89 | 90 | ||
72 | === modified file 'launcher/AbstractLauncherIcon.h' | |||
73 | --- launcher/AbstractLauncherIcon.h 2015-11-02 18:08:08 +0000 | |||
74 | +++ launcher/AbstractLauncherIcon.h 2016-02-09 10:44:04 +0000 | |||
75 | @@ -174,13 +174,17 @@ | |||
76 | 174 | 174 | ||
77 | 175 | virtual WindowList Windows() = 0; | 175 | virtual WindowList Windows() = 0; |
78 | 176 | 176 | ||
86 | 177 | virtual std::vector<Window> WindowsForMonitor(int monitor) = 0; | 177 | virtual WindowList WindowsForMonitor(int monitor) = 0; |
87 | 178 | 178 | ||
88 | 179 | virtual std::vector<Window> WindowsOnViewport() = 0; | 179 | virtual WindowList WindowsOnViewport() = 0; |
89 | 180 | 180 | ||
90 | 181 | virtual const bool WindowVisibleOnMonitor(int monitor) = 0; | 181 | virtual bool WindowVisibleOnMonitor(int monitor) const = 0; |
91 | 182 | 182 | ||
92 | 183 | virtual const bool WindowVisibleOnViewport() = 0; | 183 | virtual bool WindowVisibleOnViewport() const = 0; |
93 | 184 | |||
94 | 185 | virtual size_t WindowsVisibleOnMonitor(int monitor) const = 0; | ||
95 | 186 | |||
96 | 187 | virtual size_t WindowsVisibleOnViewport() const = 0; | ||
97 | 184 | 188 | ||
98 | 185 | virtual float PresentUrgency() = 0; | 189 | virtual float PresentUrgency() = 0; |
99 | 186 | 190 | ||
100 | 187 | 191 | ||
101 | === modified file 'launcher/ApplicationLauncherIcon.cpp' | |||
102 | --- launcher/ApplicationLauncherIcon.cpp 2015-12-11 12:45:28 +0000 | |||
103 | +++ launcher/ApplicationLauncherIcon.cpp 2016-02-09 10:44:04 +0000 | |||
104 | @@ -1,6 +1,6 @@ | |||
105 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
106 | 2 | /* | 2 | /* |
108 | 3 | * Copyright (C) 2010-2012 Canonical Ltd | 3 | * Copyright (C) 2010-2015 Canonical Ltd |
109 | 4 | * | 4 | * |
110 | 5 | * This program is free software: you can redistribute it and/or modify | 5 | * This program is free software: you can redistribute it and/or modify |
111 | 6 | * it under the terms of the GNU General Public License version 3 as | 6 | * it under the terms of the GNU General Public License version 3 as |
112 | @@ -19,10 +19,8 @@ | |||
113 | 19 | */ | 19 | */ |
114 | 20 | 20 | ||
115 | 21 | #include "config.h" | 21 | #include "config.h" |
116 | 22 | #include <boost/algorithm/string.hpp> | ||
117 | 23 | 22 | ||
118 | 24 | #include <Nux/Nux.h> | 23 | #include <Nux/Nux.h> |
119 | 25 | #include <Nux/BaseWindow.h> | ||
120 | 26 | #include <NuxCore/Logger.h> | 24 | #include <NuxCore/Logger.h> |
121 | 27 | 25 | ||
122 | 28 | #include <UnityCore/GLibWrapper.h> | 26 | #include <UnityCore/GLibWrapper.h> |
123 | @@ -30,12 +28,7 @@ | |||
124 | 30 | 28 | ||
125 | 31 | #include "ApplicationLauncherIcon.h" | 29 | #include "ApplicationLauncherIcon.h" |
126 | 32 | #include "FavoriteStore.h" | 30 | #include "FavoriteStore.h" |
127 | 33 | #include "MultiMonitor.h" | ||
128 | 34 | #include "unity-shared/DesktopApplicationManager.h" | 31 | #include "unity-shared/DesktopApplicationManager.h" |
129 | 35 | #include "unity-shared/GnomeFileManager.h" | ||
130 | 36 | #include "unity-shared/UBusWrapper.h" | ||
131 | 37 | #include "unity-shared/UBusMessages.h" | ||
132 | 38 | #include "unity-shared/UScreen.h" | ||
133 | 39 | 32 | ||
134 | 40 | #include <glib/gi18n-lib.h> | 33 | #include <glib/gi18n-lib.h> |
135 | 41 | #include <gio/gdesktopappinfo.h> | 34 | #include <gio/gdesktopappinfo.h> |
136 | @@ -44,15 +37,13 @@ | |||
137 | 44 | { | 37 | { |
138 | 45 | namespace launcher | 38 | namespace launcher |
139 | 46 | { | 39 | { |
140 | 40 | namespace | ||
141 | 41 | { | ||
142 | 47 | DECLARE_LOGGER(logger, "unity.launcher.icon.application"); | 42 | DECLARE_LOGGER(logger, "unity.launcher.icon.application"); |
148 | 48 | namespace | 43 | |
149 | 49 | { | 44 | // We use the "application-" prefix since the manager is protected, to avoid name clash |
150 | 50 | // We use the "bamf-" prefix since the manager is protected, to avoid name clash | 45 | const std::string ICON_REMOVE_TIMEOUT = "application-icon-remove"; |
146 | 51 | const std::string ICON_REMOVE_TIMEOUT = "bamf-icon-remove"; | ||
147 | 52 | const std::string ICON_DND_OVER_TIMEOUT = "bamf-icon-dnd-over"; | ||
151 | 53 | const std::string DEFAULT_ICON = "application-default-icon"; | 46 | const std::string DEFAULT_ICON = "application-default-icon"; |
152 | 54 | const int MAXIMUM_QUICKLIST_WIDTH = 300; | ||
153 | 55 | const int COMPIZ_SCALE_DND_SPREAD = 1 << 7; | ||
154 | 56 | 47 | ||
155 | 57 | enum MenuItemType | 48 | enum MenuItemType |
156 | 58 | { | 49 | { |
157 | @@ -67,10 +58,8 @@ | |||
158 | 67 | NUX_IMPLEMENT_OBJECT_TYPE(ApplicationLauncherIcon); | 58 | NUX_IMPLEMENT_OBJECT_TYPE(ApplicationLauncherIcon); |
159 | 68 | 59 | ||
160 | 69 | ApplicationLauncherIcon::ApplicationLauncherIcon(ApplicationPtr const& app) | 60 | ApplicationLauncherIcon::ApplicationLauncherIcon(ApplicationPtr const& app) |
165 | 70 | : SimpleLauncherIcon(IconType::APPLICATION) | 61 | : WindowedLauncherIcon(IconType::APPLICATION) |
166 | 71 | , _startup_notification_timestamp(0) | 62 | , startup_notification_timestamp_(0) |
163 | 72 | , _last_scroll_timestamp(0) | ||
164 | 73 | , _progressive_scroll(0) | ||
167 | 74 | , use_custom_bg_color_(false) | 63 | , use_custom_bg_color_(false) |
168 | 75 | , bg_color_(nux::color::White) | 64 | , bg_color_(nux::color::White) |
169 | 76 | { | 65 | { |
170 | @@ -83,13 +72,6 @@ | |||
171 | 83 | << ", running: " << (app->running() ? "yes" : "no"); | 72 | << ", running: " << (app->running() ? "yes" : "no"); |
172 | 84 | 73 | ||
173 | 85 | SetApplication(app); | 74 | SetApplication(app); |
174 | 86 | |||
175 | 87 | WindowManager& wm = WindowManager::Default(); | ||
176 | 88 | wm.window_minimized.connect(sigc::mem_fun(this, &ApplicationLauncherIcon::OnWindowMinimized)); | ||
177 | 89 | wm.screen_viewport_switch_ended.connect(sigc::mem_fun(this, &ApplicationLauncherIcon::EnsureWindowState)); | ||
178 | 90 | wm.terminate_expo.connect(sigc::mem_fun(this, &ApplicationLauncherIcon::EnsureWindowState)); | ||
179 | 91 | UScreen::GetDefault()->changed.connect(sigc::hide(sigc::hide(sigc::mem_fun(this, &ApplicationLauncherIcon::EnsureWindowsLocation)))); | ||
180 | 92 | |||
181 | 93 | EnsureWindowsLocation(); | 75 | EnsureWindowsLocation(); |
182 | 94 | } | 76 | } |
183 | 95 | 77 | ||
184 | @@ -157,23 +139,19 @@ | |||
185 | 157 | signals_conn_.Add(app_->window_opened.connect([this](ApplicationWindowPtr const& win) { | 139 | signals_conn_.Add(app_->window_opened.connect([this](ApplicationWindowPtr const& win) { |
186 | 158 | signals_conn_.Add(win->monitor.changed.connect([this] (int) { EnsureWindowsLocation(); })); | 140 | signals_conn_.Add(win->monitor.changed.connect([this] (int) { EnsureWindowsLocation(); })); |
187 | 159 | EnsureWindowsLocation(); | 141 | EnsureWindowsLocation(); |
188 | 160 | |||
189 | 161 | if (WindowManager::Default().IsScaleActiveForGroup() && IsActive()) | ||
190 | 162 | Spread(true, 0, false); | ||
191 | 163 | })); | 142 | })); |
192 | 164 | 143 | ||
195 | 165 | auto ensure_win_location_cb = sigc::hide(sigc::mem_fun(this, &ApplicationLauncherIcon::EnsureWindowsLocation)); | 144 | signals_conn_.Add(app_->window_closed.connect([this] (ApplicationWindowPtr const&) { EnsureWindowsLocation(); })); |
194 | 166 | signals_conn_.Add(app_->window_closed.connect(ensure_win_location_cb)); | ||
196 | 167 | 145 | ||
197 | 168 | for (auto& win : app_->GetWindows()) | 146 | for (auto& win : app_->GetWindows()) |
199 | 169 | signals_conn_.Add(win->monitor.changed.connect(ensure_win_location_cb)); | 147 | signals_conn_.Add(win->monitor.changed.connect([this] (int) { EnsureWindowsLocation(); })); |
200 | 170 | 148 | ||
202 | 171 | signals_conn_.Add(app_->urgent.changed.connect([this](bool const& urgent) { | 149 | signals_conn_.Add(app_->urgent.changed.connect([this](bool urgent) { |
203 | 172 | LOG_DEBUG(logger) << tooltip_text() << " urgent now " << (urgent ? "true" : "false"); | 150 | LOG_DEBUG(logger) << tooltip_text() << " urgent now " << (urgent ? "true" : "false"); |
204 | 173 | SetQuirk(Quirk::URGENT, urgent); | 151 | SetQuirk(Quirk::URGENT, urgent); |
205 | 174 | })); | 152 | })); |
206 | 175 | 153 | ||
208 | 176 | signals_conn_.Add(app_->active.changed.connect([this](bool const& active) { | 154 | signals_conn_.Add(app_->active.changed.connect([this](bool active) { |
209 | 177 | LOG_DEBUG(logger) << tooltip_text() << " active now " << (active ? "true" : "false"); | 155 | LOG_DEBUG(logger) << tooltip_text() << " active now " << (active ? "true" : "false"); |
210 | 178 | SetQuirk(Quirk::ACTIVE, active); | 156 | SetQuirk(Quirk::ACTIVE, active); |
211 | 179 | })); | 157 | })); |
212 | @@ -185,8 +163,8 @@ | |||
213 | 185 | 163 | ||
214 | 186 | signals_conn_.Add(app_->title.changed.connect([this](std::string const& name) { | 164 | signals_conn_.Add(app_->title.changed.connect([this](std::string const& name) { |
215 | 187 | LOG_DEBUG(logger) << tooltip_text() << " name now " << name; | 165 | LOG_DEBUG(logger) << tooltip_text() << " name now " << name; |
218 | 188 | if (_menu_items.size() == MenuItemType::SIZE) | 166 | if (menu_items_.size() == MenuItemType::SIZE) |
219 | 189 | _menu_items[MenuItemType::APP_NAME] = nullptr; | 167 | menu_items_[MenuItemType::APP_NAME] = nullptr; |
220 | 190 | tooltip_text = name; | 168 | tooltip_text = name; |
221 | 191 | })); | 169 | })); |
222 | 192 | 170 | ||
223 | @@ -195,7 +173,7 @@ | |||
224 | 195 | icon_name = (icon.empty() ? DEFAULT_ICON : icon); | 173 | icon_name = (icon.empty() ? DEFAULT_ICON : icon); |
225 | 196 | })); | 174 | })); |
226 | 197 | 175 | ||
228 | 198 | signals_conn_.Add(app_->running.changed.connect([this](bool const& running) { | 176 | signals_conn_.Add(app_->running.changed.connect([this](bool running) { |
229 | 199 | LOG_DEBUG(logger) << tooltip_text() << " running now " << (running ? "true" : "false"); | 177 | LOG_DEBUG(logger) << tooltip_text() << " running now " << (running ? "true" : "false"); |
230 | 200 | SetQuirk(Quirk::RUNNING, running); | 178 | SetQuirk(Quirk::RUNNING, running); |
231 | 201 | 179 | ||
232 | @@ -208,35 +186,47 @@ | |||
233 | 208 | } | 186 | } |
234 | 209 | })); | 187 | })); |
235 | 210 | 188 | ||
237 | 211 | signals_conn_.Add(app_->visible.changed.connect([this](bool const& visible) { | 189 | signals_conn_.Add(app_->visible.changed.connect([this](bool visible) { |
238 | 212 | SetQuirk(Quirk::VISIBLE, IsSticky() ? true : visible); | 190 | SetQuirk(Quirk::VISIBLE, IsSticky() ? true : visible); |
239 | 213 | })); | 191 | })); |
240 | 214 | 192 | ||
258 | 215 | signals_conn_.Add(app_->closed.connect([this]() { | 193 | signals_conn_.Add(app_->closed.connect([this] { |
259 | 216 | if (!IsSticky()) | 194 | LOG_DEBUG(logger) << tooltip_text() << " closed"; |
260 | 217 | { | 195 | OnApplicationClosed(); |
244 | 218 | SetQuirk(Quirk::VISIBLE, false); | ||
245 | 219 | HideTooltip(); | ||
246 | 220 | |||
247 | 221 | /* Use a timeout to remove the icon, this avoids | ||
248 | 222 | * that we remove an application that is going | ||
249 | 223 | * to be reopened soon. So applications that | ||
250 | 224 | * have a splash screen won't be removed from | ||
251 | 225 | * the launcher while the splash is closed and | ||
252 | 226 | * a new window is opened. */ | ||
253 | 227 | _source_manager.AddTimeoutSeconds(1, [this] { | ||
254 | 228 | Remove(); | ||
255 | 229 | return false; | ||
256 | 230 | }, ICON_REMOVE_TIMEOUT); | ||
257 | 231 | } | ||
261 | 232 | })); | 196 | })); |
262 | 233 | } | 197 | } |
263 | 234 | 198 | ||
264 | 199 | WindowList ApplicationLauncherIcon::GetManagedWindows() const | ||
265 | 200 | { | ||
266 | 201 | return app_ ? app_->GetWindows() : WindowList(); | ||
267 | 202 | } | ||
268 | 203 | |||
269 | 204 | void ApplicationLauncherIcon::OnApplicationClosed() | ||
270 | 205 | { | ||
271 | 206 | if (IsSticky()) | ||
272 | 207 | return; | ||
273 | 208 | |||
274 | 209 | SetQuirk(Quirk::VISIBLE, false); | ||
275 | 210 | HideTooltip(); | ||
276 | 211 | |||
277 | 212 | /* Use a timeout to remove the icon, this avoids | ||
278 | 213 | * that we remove an application that is going | ||
279 | 214 | * to be reopened soon. So applications that | ||
280 | 215 | * have a splash screen won't be removed from | ||
281 | 216 | * the launcher while the splash is closed and | ||
282 | 217 | * a new window is opened. */ | ||
283 | 218 | _source_manager.AddTimeoutSeconds(1, [this] { | ||
284 | 219 | Remove(); | ||
285 | 220 | return false; | ||
286 | 221 | }, ICON_REMOVE_TIMEOUT); | ||
287 | 222 | } | ||
288 | 223 | |||
289 | 224 | // Move to WindowedLauncherIcon?! | ||
290 | 235 | bool ApplicationLauncherIcon::GetQuirk(AbstractLauncherIcon::Quirk quirk, int monitor) const | 225 | bool ApplicationLauncherIcon::GetQuirk(AbstractLauncherIcon::Quirk quirk, int monitor) const |
291 | 236 | { | 226 | { |
292 | 237 | if (quirk == Quirk::ACTIVE) | 227 | if (quirk == Quirk::ACTIVE) |
293 | 238 | { | 228 | { |
295 | 239 | if (!SimpleLauncherIcon::GetQuirk(Quirk::ACTIVE, monitor)) | 229 | if (!WindowedLauncherIcon::GetQuirk(Quirk::ACTIVE, monitor)) |
296 | 240 | return false; | 230 | return false; |
297 | 241 | 231 | ||
298 | 242 | if (app_->type() == AppType::WEBAPP) | 232 | if (app_->type() == AppType::WEBAPP) |
299 | @@ -248,304 +238,35 @@ | |||
300 | 248 | return app_->OwnsWindow(WindowManager::Default().GetActiveWindow()); | 238 | return app_->OwnsWindow(WindowManager::Default().GetActiveWindow()); |
301 | 249 | } | 239 | } |
302 | 250 | 240 | ||
304 | 251 | return SimpleLauncherIcon::GetQuirk(quirk, monitor); | 241 | return WindowedLauncherIcon::GetQuirk(quirk, monitor); |
305 | 252 | } | 242 | } |
306 | 253 | 243 | ||
307 | 254 | void ApplicationLauncherIcon::Remove() | 244 | void ApplicationLauncherIcon::Remove() |
308 | 255 | { | 245 | { |
309 | 256 | LogUnityEvent(ApplicationEventType::LEAVE); | 246 | LogUnityEvent(ApplicationEventType::LEAVE); |
310 | 257 | UnsetApplication(); | 247 | UnsetApplication(); |
312 | 258 | SimpleLauncherIcon::Remove(); | 248 | WindowedLauncherIcon::Remove(); |
313 | 259 | } | 249 | } |
314 | 260 | 250 | ||
315 | 261 | bool ApplicationLauncherIcon::IsSticky() const | 251 | bool ApplicationLauncherIcon::IsSticky() const |
316 | 262 | { | 252 | { |
317 | 263 | if (app_) | 253 | if (app_) |
319 | 264 | return app_->sticky() && SimpleLauncherIcon::IsSticky(); | 254 | return app_->sticky() && WindowedLauncherIcon::IsSticky(); |
320 | 265 | 255 | ||
321 | 266 | return false; | 256 | return false; |
322 | 267 | } | 257 | } |
323 | 268 | 258 | ||
596 | 269 | bool ApplicationLauncherIcon::IsActive() const | 259 | bool ApplicationLauncherIcon::IsUserVisible() const |
597 | 270 | { | 260 | { |
598 | 271 | return GetQuirk(Quirk::ACTIVE); | 261 | return app_ ? app_->visible() : false; |
327 | 272 | } | ||
328 | 273 | |||
329 | 274 | bool ApplicationLauncherIcon::IsRunning() const | ||
330 | 275 | { | ||
331 | 276 | return GetQuirk(Quirk::RUNNING); | ||
332 | 277 | } | ||
333 | 278 | |||
334 | 279 | bool ApplicationLauncherIcon::IsUrgent() const | ||
335 | 280 | { | ||
336 | 281 | return GetQuirk(Quirk::URGENT); | ||
337 | 282 | } | ||
338 | 283 | |||
339 | 284 | void ApplicationLauncherIcon::ActivateLauncherIcon(ActionArg arg) | ||
340 | 285 | { | ||
341 | 286 | SimpleLauncherIcon::ActivateLauncherIcon(arg); | ||
342 | 287 | WindowManager& wm = WindowManager::Default(); | ||
343 | 288 | |||
344 | 289 | // This is a little awkward as the target is only set from the switcher. | ||
345 | 290 | if (arg.target) | ||
346 | 291 | { | ||
347 | 292 | // thumper: should we Raise too? should the WM raise? | ||
348 | 293 | wm.Activate(arg.target); | ||
349 | 294 | return; | ||
350 | 295 | } | ||
351 | 296 | |||
352 | 297 | bool scale_was_active = wm.IsScaleActive(); | ||
353 | 298 | bool active = IsActive(); | ||
354 | 299 | bool user_visible = IsRunning(); | ||
355 | 300 | /* We should check each child to see if there is | ||
356 | 301 | * an unmapped (!= minimized) window around and | ||
357 | 302 | * if so force "Focus" behaviour */ | ||
358 | 303 | |||
359 | 304 | if (arg.source != ActionArg::Source::SWITCHER) | ||
360 | 305 | { | ||
361 | 306 | user_visible = app_->visible(); | ||
362 | 307 | |||
363 | 308 | if (active) | ||
364 | 309 | { | ||
365 | 310 | bool any_visible = false; | ||
366 | 311 | bool any_mapped = false; | ||
367 | 312 | bool any_on_top = false; | ||
368 | 313 | bool any_on_monitor = (arg.monitor < 0); | ||
369 | 314 | int active_monitor = arg.monitor; | ||
370 | 315 | |||
371 | 316 | for (auto const& window : app_->GetWindows()) | ||
372 | 317 | { | ||
373 | 318 | Window xid = window->window_id(); | ||
374 | 319 | |||
375 | 320 | if (!any_visible && wm.IsWindowOnCurrentDesktop(xid)) | ||
376 | 321 | { | ||
377 | 322 | any_visible = true; | ||
378 | 323 | } | ||
379 | 324 | |||
380 | 325 | if (!any_mapped && wm.IsWindowMapped(xid)) | ||
381 | 326 | { | ||
382 | 327 | any_mapped = true; | ||
383 | 328 | } | ||
384 | 329 | |||
385 | 330 | if (!any_on_top && wm.IsWindowOnTop(xid)) | ||
386 | 331 | { | ||
387 | 332 | any_on_top = true; | ||
388 | 333 | } | ||
389 | 334 | |||
390 | 335 | if (!any_on_monitor && window->monitor() == arg.monitor && | ||
391 | 336 | wm.IsWindowMapped(xid) && wm.IsWindowVisible(xid)) | ||
392 | 337 | { | ||
393 | 338 | any_on_monitor = true; | ||
394 | 339 | } | ||
395 | 340 | |||
396 | 341 | if (window->active()) | ||
397 | 342 | { | ||
398 | 343 | active_monitor = window->monitor(); | ||
399 | 344 | } | ||
400 | 345 | } | ||
401 | 346 | |||
402 | 347 | if (!any_visible || !any_mapped || !any_on_top) | ||
403 | 348 | active = false; | ||
404 | 349 | |||
405 | 350 | if (any_on_monitor && arg.monitor >= 0 && active_monitor != arg.monitor) | ||
406 | 351 | active = false; | ||
407 | 352 | } | ||
408 | 353 | |||
409 | 354 | if (user_visible && IsSticky() && IsFileManager()) | ||
410 | 355 | { | ||
411 | 356 | // See bug #753938 | ||
412 | 357 | unsigned minimum_windows = 0; | ||
413 | 358 | auto const& file_manager = GnomeFileManager::Get(); | ||
414 | 359 | |||
415 | 360 | if (file_manager->IsTrashOpened()) | ||
416 | 361 | ++minimum_windows; | ||
417 | 362 | |||
418 | 363 | if (file_manager->IsDeviceOpened()) | ||
419 | 364 | ++minimum_windows; | ||
420 | 365 | |||
421 | 366 | if (minimum_windows > 0) | ||
422 | 367 | { | ||
423 | 368 | if (file_manager->OpenedLocations().size() == minimum_windows && | ||
424 | 369 | GetWindows(WindowFilter::USER_VISIBLE|WindowFilter::MAPPED).size() == minimum_windows) | ||
425 | 370 | { | ||
426 | 371 | user_visible = false; | ||
427 | 372 | } | ||
428 | 373 | } | ||
429 | 374 | } | ||
430 | 375 | } | ||
431 | 376 | |||
432 | 377 | /* Behaviour: | ||
433 | 378 | * 1) Nothing running, or nothing visible -> launch application | ||
434 | 379 | * 2) Running and active -> spread application | ||
435 | 380 | * 3) Running and not active -> focus application | ||
436 | 381 | * 4) Spread is active and different icon pressed -> change spread | ||
437 | 382 | * 5) Spread is active -> Spread de-activated, and fall through | ||
438 | 383 | */ | ||
439 | 384 | |||
440 | 385 | if (!IsRunning() || (IsRunning() && !user_visible)) // #1 above | ||
441 | 386 | { | ||
442 | 387 | if (GetQuirk(Quirk::STARTING, arg.monitor)) | ||
443 | 388 | return; | ||
444 | 389 | |||
445 | 390 | wm.TerminateScale(); | ||
446 | 391 | SetQuirk(Quirk::STARTING, true, arg.monitor); | ||
447 | 392 | OpenInstanceLauncherIcon(arg.timestamp); | ||
448 | 393 | } | ||
449 | 394 | else // app is running | ||
450 | 395 | { | ||
451 | 396 | if (active) | ||
452 | 397 | { | ||
453 | 398 | if (scale_was_active) // #5 above | ||
454 | 399 | { | ||
455 | 400 | wm.TerminateScale(); | ||
456 | 401 | |||
457 | 402 | if (minimize_window_on_click()) | ||
458 | 403 | { | ||
459 | 404 | for (auto const& win : GetWindows(WindowFilter::ON_CURRENT_DESKTOP)) | ||
460 | 405 | wm.Minimize(win->window_id()); | ||
461 | 406 | } | ||
462 | 407 | else | ||
463 | 408 | { | ||
464 | 409 | Focus(arg); | ||
465 | 410 | } | ||
466 | 411 | } | ||
467 | 412 | else // #2 above | ||
468 | 413 | { | ||
469 | 414 | if (arg.source != ActionArg::Source::SWITCHER) | ||
470 | 415 | { | ||
471 | 416 | bool minimized = false; | ||
472 | 417 | |||
473 | 418 | if (minimize_window_on_click()) | ||
474 | 419 | { | ||
475 | 420 | WindowList const& windows = GetWindows(WindowFilter::ON_CURRENT_DESKTOP); | ||
476 | 421 | |||
477 | 422 | if (windows.size() == 1) | ||
478 | 423 | { | ||
479 | 424 | wm.Minimize(windows[0]->window_id()); | ||
480 | 425 | minimized = true; | ||
481 | 426 | } | ||
482 | 427 | } | ||
483 | 428 | |||
484 | 429 | if (!minimized) | ||
485 | 430 | { | ||
486 | 431 | Spread(true, 0, false); | ||
487 | 432 | } | ||
488 | 433 | } | ||
489 | 434 | } | ||
490 | 435 | } | ||
491 | 436 | else | ||
492 | 437 | { | ||
493 | 438 | if (scale_was_active) // #4 above | ||
494 | 439 | { | ||
495 | 440 | if (GetWindows(WindowFilter::ON_CURRENT_DESKTOP).size() <= 1) | ||
496 | 441 | wm.TerminateScale(); | ||
497 | 442 | |||
498 | 443 | Focus(arg); | ||
499 | 444 | |||
500 | 445 | if (arg.source != ActionArg::Source::SWITCHER) | ||
501 | 446 | Spread(true, 0, false); | ||
502 | 447 | } | ||
503 | 448 | else // #3 above | ||
504 | 449 | { | ||
505 | 450 | Focus(arg); | ||
506 | 451 | } | ||
507 | 452 | } | ||
508 | 453 | } | ||
509 | 454 | } | ||
510 | 455 | |||
511 | 456 | WindowList ApplicationLauncherIcon::GetWindows(WindowFilterMask filter, int monitor) | ||
512 | 457 | { | ||
513 | 458 | WindowManager& wm = WindowManager::Default(); | ||
514 | 459 | WindowList results; | ||
515 | 460 | |||
516 | 461 | monitor = (filter & WindowFilter::ON_ALL_MONITORS) ? -1 : monitor; | ||
517 | 462 | bool mapped = (filter & WindowFilter::MAPPED); | ||
518 | 463 | bool user_visible = (filter & WindowFilter::USER_VISIBLE); | ||
519 | 464 | bool current_desktop = (filter & WindowFilter::ON_CURRENT_DESKTOP); | ||
520 | 465 | |||
521 | 466 | for (auto& window : app_->GetWindows()) | ||
522 | 467 | { | ||
523 | 468 | if ((monitor >= 0 && window->monitor() == monitor) || monitor < 0) | ||
524 | 469 | { | ||
525 | 470 | if ((user_visible && window->visible()) || !user_visible) | ||
526 | 471 | { | ||
527 | 472 | Window xid = window->window_id(); | ||
528 | 473 | |||
529 | 474 | if ((mapped && wm.IsWindowMapped(xid)) || !mapped) | ||
530 | 475 | { | ||
531 | 476 | if ((current_desktop && wm.IsWindowOnCurrentDesktop(xid)) || !current_desktop) | ||
532 | 477 | { | ||
533 | 478 | results.push_back(window); | ||
534 | 479 | } | ||
535 | 480 | } | ||
536 | 481 | } | ||
537 | 482 | } | ||
538 | 483 | } | ||
539 | 484 | |||
540 | 485 | return results; | ||
541 | 486 | } | ||
542 | 487 | |||
543 | 488 | WindowList ApplicationLauncherIcon::Windows() | ||
544 | 489 | { | ||
545 | 490 | return GetWindows(WindowFilter::MAPPED|WindowFilter::ON_ALL_MONITORS); | ||
546 | 491 | } | ||
547 | 492 | |||
548 | 493 | std::vector<Window> ApplicationLauncherIcon::WindowsOnViewport() | ||
549 | 494 | { | ||
550 | 495 | WindowFilterMask filter = 0; | ||
551 | 496 | filter |= WindowFilter::MAPPED; | ||
552 | 497 | filter |= WindowFilter::USER_VISIBLE; | ||
553 | 498 | filter |= WindowFilter::ON_CURRENT_DESKTOP; | ||
554 | 499 | filter |= WindowFilter::ON_ALL_MONITORS; | ||
555 | 500 | |||
556 | 501 | std::vector<Window> windows; | ||
557 | 502 | for (auto& window : GetWindows(filter)) | ||
558 | 503 | { | ||
559 | 504 | windows.push_back(window->window_id()); | ||
560 | 505 | } | ||
561 | 506 | return windows; | ||
562 | 507 | } | ||
563 | 508 | |||
564 | 509 | std::vector<Window> ApplicationLauncherIcon::WindowsForMonitor(int monitor) | ||
565 | 510 | { | ||
566 | 511 | WindowFilterMask filter = 0; | ||
567 | 512 | filter |= WindowFilter::MAPPED; | ||
568 | 513 | filter |= WindowFilter::USER_VISIBLE; | ||
569 | 514 | filter |= WindowFilter::ON_CURRENT_DESKTOP; | ||
570 | 515 | |||
571 | 516 | std::vector<Window> windows; | ||
572 | 517 | for (auto& window : GetWindows(filter, monitor)) | ||
573 | 518 | { | ||
574 | 519 | windows.push_back(window->window_id()); | ||
575 | 520 | } | ||
576 | 521 | return windows; | ||
577 | 522 | } | ||
578 | 523 | |||
579 | 524 | void ApplicationLauncherIcon::OnWindowMinimized(guint32 xid) | ||
580 | 525 | { | ||
581 | 526 | for (auto const& window: app_->GetWindows()) | ||
582 | 527 | { | ||
583 | 528 | if (xid == window->window_id()) | ||
584 | 529 | { | ||
585 | 530 | int monitor = GetCenterForMonitor(window->monitor()).first; | ||
586 | 531 | |||
587 | 532 | if (monitor >= 0) | ||
588 | 533 | { | ||
589 | 534 | Present(0.5f, 600, monitor); | ||
590 | 535 | FullyAnimateQuirkDelayed(300, Quirk::SHIMMER, monitor); | ||
591 | 536 | } | ||
592 | 537 | |||
593 | 538 | break; | ||
594 | 539 | } | ||
595 | 540 | } | ||
599 | 541 | } | 262 | } |
600 | 542 | 263 | ||
601 | 543 | void ApplicationLauncherIcon::UpdateDesktopFile() | 264 | void ApplicationLauncherIcon::UpdateDesktopFile() |
602 | 544 | { | 265 | { |
603 | 545 | std::string const& filename = app_->desktop_file(); | 266 | std::string const& filename = app_->desktop_file(); |
604 | 546 | 267 | ||
607 | 547 | if (_desktop_file_monitor) | 268 | if (desktop_file_monitor_) |
608 | 548 | _gsignals.Disconnect(_desktop_file_monitor, "changed"); | 269 | glib_signals_.Disconnect(desktop_file_monitor_, "changed"); |
609 | 549 | 270 | ||
610 | 550 | auto old_uri = RemoteUri(); | 271 | auto old_uri = RemoteUri(); |
611 | 551 | UpdateRemoteUri(); | 272 | UpdateRemoteUri(); |
612 | @@ -559,11 +280,11 @@ | |||
613 | 559 | // we can remove ourself from the launcher and when it's changed | 280 | // we can remove ourself from the launcher and when it's changed |
614 | 560 | // we can update the quicklist. | 281 | // we can update the quicklist. |
615 | 561 | glib::Object<GFile> desktop_file(g_file_new_for_path(filename.c_str())); | 282 | glib::Object<GFile> desktop_file(g_file_new_for_path(filename.c_str())); |
617 | 562 | _desktop_file_monitor = g_file_monitor_file(desktop_file, G_FILE_MONITOR_NONE, | 283 | desktop_file_monitor_ = g_file_monitor_file(desktop_file, G_FILE_MONITOR_NONE, |
618 | 563 | nullptr, nullptr); | 284 | nullptr, nullptr); |
620 | 564 | g_file_monitor_set_rate_limit(_desktop_file_monitor, 2000); | 285 | g_file_monitor_set_rate_limit(desktop_file_monitor_, 2000); |
621 | 565 | 286 | ||
623 | 566 | _gsignals.Add<void, GFileMonitor*, GFile*, GFile*, GFileMonitorEvent>(_desktop_file_monitor, "changed", | 287 | glib_signals_.Add<void, GFileMonitor*, GFile*, GFile*, GFileMonitorEvent>(desktop_file_monitor_, "changed", |
624 | 567 | [this, desktop_file] (GFileMonitor*, GFile*, GFile*, GFileMonitorEvent event_type) { | 288 | [this, desktop_file] (GFileMonitor*, GFile*, GFile*, GFileMonitorEvent event_type) { |
625 | 568 | switch (event_type) | 289 | switch (event_type) |
626 | 569 | { | 290 | { |
627 | @@ -600,7 +321,7 @@ | |||
628 | 600 | bool update_saved_uri = (!filename.empty() && app_->sticky()); | 321 | bool update_saved_uri = (!filename.empty() && app_->sticky()); |
629 | 601 | 322 | ||
630 | 602 | if (update_saved_uri) | 323 | if (update_saved_uri) |
632 | 603 | SimpleLauncherIcon::UnStick(); | 324 | WindowedLauncherIcon::UnStick(); |
633 | 604 | 325 | ||
634 | 605 | uri_changed.emit(new_uri); | 326 | uri_changed.emit(new_uri); |
635 | 606 | 327 | ||
636 | @@ -614,22 +335,6 @@ | |||
637 | 614 | return app_->desktop_file(); | 335 | return app_->desktop_file(); |
638 | 615 | } | 336 | } |
639 | 616 | 337 | ||
640 | 617 | void ApplicationLauncherIcon::AddProperties(debug::IntrospectionData& introspection) | ||
641 | 618 | { | ||
642 | 619 | SimpleLauncherIcon::AddProperties(introspection); | ||
643 | 620 | |||
644 | 621 | std::vector<Window> xids; | ||
645 | 622 | for (auto const& window : GetWindows()) | ||
646 | 623 | xids.push_back(window->window_id()); | ||
647 | 624 | |||
648 | 625 | introspection | ||
649 | 626 | .add("desktop_file", DesktopFile()) | ||
650 | 627 | .add("desktop_id", app_->desktop_id()) | ||
651 | 628 | .add("xids", glib::Variant::FromVector(xids)) | ||
652 | 629 | .add("sticky", IsSticky()) | ||
653 | 630 | .add("startup_notification_timestamp", _startup_notification_timestamp); | ||
654 | 631 | } | ||
655 | 632 | |||
656 | 633 | void ApplicationLauncherIcon::OpenInstanceWithUris(std::set<std::string> const& uris, Time timestamp) | 338 | void ApplicationLauncherIcon::OpenInstanceWithUris(std::set<std::string> const& uris, Time timestamp) |
657 | 634 | { | 339 | { |
658 | 635 | glib::Error error; | 340 | glib::Error error; |
659 | @@ -639,9 +344,9 @@ | |||
660 | 639 | GdkDisplay* display = gdk_display_get_default(); | 344 | GdkDisplay* display = gdk_display_get_default(); |
661 | 640 | glib::Object<GdkAppLaunchContext> app_launch_context(gdk_display_get_app_launch_context(display)); | 345 | glib::Object<GdkAppLaunchContext> app_launch_context(gdk_display_get_app_launch_context(display)); |
662 | 641 | 346 | ||
666 | 642 | _startup_notification_timestamp = timestamp; | 347 | startup_notification_timestamp_ = timestamp; |
667 | 643 | if (_startup_notification_timestamp > 0) | 348 | if (startup_notification_timestamp_ > 0) |
668 | 644 | gdk_app_launch_context_set_timestamp(app_launch_context, _startup_notification_timestamp); | 349 | gdk_app_launch_context_set_timestamp(app_launch_context, startup_notification_timestamp_); |
669 | 645 | 350 | ||
670 | 646 | if (g_app_info_supports_uris(appInfo)) | 351 | if (g_app_info_supports_uris(appInfo)) |
671 | 647 | { | 352 | { |
672 | @@ -705,83 +410,40 @@ | |||
673 | 705 | app_->Focus(show_only_visible, arg.monitor); | 410 | app_->Focus(show_only_visible, arg.monitor); |
674 | 706 | } | 411 | } |
675 | 707 | 412 | ||
676 | 708 | bool ApplicationLauncherIcon::Spread(bool current_desktop, int state, bool force) | ||
677 | 709 | { | ||
678 | 710 | std::vector<Window> windows; | ||
679 | 711 | for (auto& window : GetWindows(current_desktop ? WindowFilter::ON_CURRENT_DESKTOP : 0)) | ||
680 | 712 | windows.push_back(window->window_id()); | ||
681 | 713 | |||
682 | 714 | return WindowManager::Default().ScaleWindowGroup(windows, state, force); | ||
683 | 715 | } | ||
684 | 716 | |||
685 | 717 | void ApplicationLauncherIcon::EnsureWindowState() | ||
686 | 718 | { | ||
687 | 719 | std::vector<int> number_of_windows_on_monitor(monitors::MAX); | ||
688 | 720 | |||
689 | 721 | for (auto& window: app_->GetWindows()) | ||
690 | 722 | { | ||
691 | 723 | int monitor = window->monitor(); | ||
692 | 724 | Window window_id = window->window_id(); | ||
693 | 725 | |||
694 | 726 | if (WindowManager::Default().IsWindowOnCurrentDesktop(window_id)) | ||
695 | 727 | { | ||
696 | 728 | // If monitor is -1 (or negative), show on all monitors. | ||
697 | 729 | if (monitor < 0) | ||
698 | 730 | { | ||
699 | 731 | for (unsigned j; j < monitors::MAX; ++j) | ||
700 | 732 | ++number_of_windows_on_monitor[j]; | ||
701 | 733 | } | ||
702 | 734 | else | ||
703 | 735 | { | ||
704 | 736 | ++number_of_windows_on_monitor[monitor]; | ||
705 | 737 | } | ||
706 | 738 | } | ||
707 | 739 | } | ||
708 | 740 | |||
709 | 741 | for (unsigned i = 0; i < monitors::MAX; ++i) | ||
710 | 742 | SetNumberOfWindowsVisibleOnMonitor(number_of_windows_on_monitor[i], i); | ||
711 | 743 | } | ||
712 | 744 | |||
713 | 745 | void ApplicationLauncherIcon::EnsureWindowsLocation() | ||
714 | 746 | { | ||
715 | 747 | EnsureWindowState(); | ||
716 | 748 | UpdateIconGeometries(GetCenters()); | ||
717 | 749 | } | ||
718 | 750 | |||
719 | 751 | void ApplicationLauncherIcon::UpdateDesktopQuickList() | 413 | void ApplicationLauncherIcon::UpdateDesktopQuickList() |
720 | 752 | { | 414 | { |
721 | 753 | std::string const& desktop_file = DesktopFile(); | 415 | std::string const& desktop_file = DesktopFile(); |
722 | 754 | 416 | ||
724 | 755 | if (_menu_desktop_shortcuts) | 417 | if (menu_desktop_shortcuts_) |
725 | 756 | { | 418 | { |
727 | 757 | for (GList *l = dbusmenu_menuitem_get_children(_menu_desktop_shortcuts); l; l = l->next) | 419 | for (GList *l = dbusmenu_menuitem_get_children(menu_desktop_shortcuts_); l; l = l->next) |
728 | 758 | { | 420 | { |
730 | 759 | _gsignals.Disconnect(l->data, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED); | 421 | glib_signals_.Disconnect(l->data, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED); |
731 | 760 | } | 422 | } |
732 | 761 | 423 | ||
734 | 762 | _menu_desktop_shortcuts = nullptr; | 424 | menu_desktop_shortcuts_ = nullptr; |
735 | 763 | } | 425 | } |
736 | 764 | 426 | ||
737 | 765 | if (desktop_file.empty()) | 427 | if (desktop_file.empty()) |
738 | 766 | return; | 428 | return; |
739 | 767 | 429 | ||
742 | 768 | _menu_desktop_shortcuts = dbusmenu_menuitem_new(); | 430 | menu_desktop_shortcuts_ = dbusmenu_menuitem_new(); |
743 | 769 | dbusmenu_menuitem_set_root(_menu_desktop_shortcuts, TRUE); | 431 | dbusmenu_menuitem_set_root(menu_desktop_shortcuts_, TRUE); |
744 | 770 | 432 | ||
745 | 771 | // Build a desktop shortcuts object and tell it that our | 433 | // Build a desktop shortcuts object and tell it that our |
746 | 772 | // environment is Unity to handle the filtering | 434 | // environment is Unity to handle the filtering |
748 | 773 | _desktop_shortcuts = indicator_desktop_shortcuts_new(desktop_file.c_str(), "Unity"); | 435 | desktop_shortcuts_ = indicator_desktop_shortcuts_new(desktop_file.c_str(), "Unity"); |
749 | 774 | // This will get us a list of the nicks available, it should | 436 | // This will get us a list of the nicks available, it should |
750 | 775 | // always be at least one entry of NULL if there either aren't | 437 | // always be at least one entry of NULL if there either aren't |
751 | 776 | // any or they're filtered for the environment we're in | 438 | // any or they're filtered for the environment we're in |
753 | 777 | const gchar** nicks = indicator_desktop_shortcuts_get_nicks(_desktop_shortcuts); | 439 | const gchar** nicks = indicator_desktop_shortcuts_get_nicks(desktop_shortcuts_); |
754 | 778 | 440 | ||
755 | 779 | for (int index = 0; nicks[index]; ++index) | 441 | for (int index = 0; nicks[index]; ++index) |
756 | 780 | { | 442 | { |
757 | 781 | // Build a dbusmenu item for each nick that is the desktop | 443 | // Build a dbusmenu item for each nick that is the desktop |
758 | 782 | // file that is built from it's name and includes a callback | 444 | // file that is built from it's name and includes a callback |
759 | 783 | // to the desktop shortcuts object to execute the nick | 445 | // to the desktop shortcuts object to execute the nick |
761 | 784 | glib::String name(indicator_desktop_shortcuts_nick_get_name(_desktop_shortcuts, | 446 | glib::String name(indicator_desktop_shortcuts_nick_get_name(desktop_shortcuts_, |
762 | 785 | nicks[index])); | 447 | nicks[index])); |
763 | 786 | glib::Object<DbusmenuMenuitem> item(dbusmenu_menuitem_new()); | 448 | glib::Object<DbusmenuMenuitem> item(dbusmenu_menuitem_new()); |
764 | 787 | dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_LABEL, name); | 449 | dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_LABEL, name); |
765 | @@ -789,16 +451,16 @@ | |||
766 | 789 | dbusmenu_menuitem_property_set_bool(item, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); | 451 | dbusmenu_menuitem_property_set_bool(item, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); |
767 | 790 | auto nick = glib::gchar_to_string(nicks[index]); | 452 | auto nick = glib::gchar_to_string(nicks[index]); |
768 | 791 | 453 | ||
770 | 792 | _gsignals.Add<void, DbusmenuMenuitem*, gint>(item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, | 454 | glib_signals_.Add<void, DbusmenuMenuitem*, gint>(item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, |
771 | 793 | [this, nick] (DbusmenuMenuitem* item, unsigned timestamp) { | 455 | [this, nick] (DbusmenuMenuitem* item, unsigned timestamp) { |
772 | 794 | GdkDisplay* display = gdk_display_get_default(); | 456 | GdkDisplay* display = gdk_display_get_default(); |
773 | 795 | glib::Object<GdkAppLaunchContext> context(gdk_display_get_app_launch_context(display)); | 457 | glib::Object<GdkAppLaunchContext> context(gdk_display_get_app_launch_context(display)); |
774 | 796 | gdk_app_launch_context_set_timestamp(context, timestamp); | 458 | gdk_app_launch_context_set_timestamp(context, timestamp); |
775 | 797 | auto gcontext = glib::object_cast<GAppLaunchContext>(context); | 459 | auto gcontext = glib::object_cast<GAppLaunchContext>(context); |
777 | 798 | indicator_desktop_shortcuts_nick_exec_with_context(_desktop_shortcuts, nick.c_str(), gcontext); | 460 | indicator_desktop_shortcuts_nick_exec_with_context(desktop_shortcuts_, nick.c_str(), gcontext); |
778 | 799 | }); | 461 | }); |
779 | 800 | 462 | ||
781 | 801 | dbusmenu_menuitem_child_append(_menu_desktop_shortcuts, item); | 463 | dbusmenu_menuitem_child_append(menu_desktop_shortcuts_, item); |
782 | 802 | } | 464 | } |
783 | 803 | } | 465 | } |
784 | 804 | 466 | ||
785 | @@ -821,60 +483,16 @@ | |||
786 | 821 | } | 483 | } |
787 | 822 | } | 484 | } |
788 | 823 | 485 | ||
789 | 824 | void ApplicationLauncherIcon::EnsureMenuItemsWindowsReady() | ||
790 | 825 | { | ||
791 | 826 | // delete all menu items for windows | ||
792 | 827 | _menu_items_windows.clear(); | ||
793 | 828 | |||
794 | 829 | auto const& windows = Windows(); | ||
795 | 830 | |||
796 | 831 | // We only add quicklist menu-items for windows if we have more than one window | ||
797 | 832 | if (windows.size() < 2) | ||
798 | 833 | return; | ||
799 | 834 | |||
800 | 835 | // add menu items for all open windows | ||
801 | 836 | for (auto const& w : windows) | ||
802 | 837 | { | ||
803 | 838 | auto const& title = w->title(); | ||
804 | 839 | |||
805 | 840 | if (title.empty()) | ||
806 | 841 | continue; | ||
807 | 842 | |||
808 | 843 | glib::Object<DbusmenuMenuitem> menu_item(dbusmenu_menuitem_new()); | ||
809 | 844 | dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_LABEL, title.c_str()); | ||
810 | 845 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true); | ||
811 | 846 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); | ||
812 | 847 | dbusmenu_menuitem_property_set_bool(menu_item, QuicklistMenuItem::MARKUP_ACCEL_DISABLED_PROPERTY, true); | ||
813 | 848 | dbusmenu_menuitem_property_set_int(menu_item, QuicklistMenuItem::MAXIMUM_LABEL_WIDTH_PROPERTY, MAXIMUM_QUICKLIST_WIDTH); | ||
814 | 849 | |||
815 | 850 | Window xid = w->window_id(); | ||
816 | 851 | _gsignals.Add<void, DbusmenuMenuitem*, unsigned>(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, | ||
817 | 852 | [xid] (DbusmenuMenuitem*, unsigned) { | ||
818 | 853 | WindowManager& wm = WindowManager::Default(); | ||
819 | 854 | wm.Activate(xid); | ||
820 | 855 | wm.Raise(xid); | ||
821 | 856 | }); | ||
822 | 857 | |||
823 | 858 | if (w->active()) | ||
824 | 859 | { | ||
825 | 860 | dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE, DBUSMENU_MENUITEM_TOGGLE_RADIO); | ||
826 | 861 | dbusmenu_menuitem_property_set_int(menu_item, DBUSMENU_MENUITEM_PROP_TOGGLE_STATE, DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED); | ||
827 | 862 | } | ||
828 | 863 | |||
829 | 864 | _menu_items_windows.push_back(menu_item); | ||
830 | 865 | } | ||
831 | 866 | } | ||
832 | 867 | |||
833 | 868 | void ApplicationLauncherIcon::EnsureMenuItemsStaticQuicklist() | 486 | void ApplicationLauncherIcon::EnsureMenuItemsStaticQuicklist() |
834 | 869 | { | 487 | { |
835 | 870 | // make a client for desktop file actions | 488 | // make a client for desktop file actions |
837 | 871 | if (!_menu_desktop_shortcuts.IsType(DBUSMENU_TYPE_MENUITEM)) | 489 | if (!menu_desktop_shortcuts_.IsType(DBUSMENU_TYPE_MENUITEM)) |
838 | 872 | { | 490 | { |
839 | 873 | UpdateDesktopQuickList(); | 491 | UpdateDesktopQuickList(); |
840 | 874 | } | 492 | } |
841 | 875 | } | 493 | } |
842 | 876 | 494 | ||
844 | 877 | void ApplicationLauncherIcon::Quit() | 495 | void ApplicationLauncherIcon::Quit() const |
845 | 878 | { | 496 | { |
846 | 879 | app_->Quit(); | 497 | app_->Quit(); |
847 | 880 | } | 498 | } |
848 | @@ -899,7 +517,7 @@ | |||
849 | 899 | } | 517 | } |
850 | 900 | else | 518 | else |
851 | 901 | { | 519 | { |
853 | 902 | SimpleLauncherIcon::Stick(save); | 520 | WindowedLauncherIcon::Stick(save); |
854 | 903 | 521 | ||
855 | 904 | if (save) | 522 | if (save) |
856 | 905 | LogUnityEvent(ApplicationEventType::ACCESS); | 523 | LogUnityEvent(ApplicationEventType::ACCESS); |
857 | @@ -912,11 +530,11 @@ | |||
858 | 912 | return; | 530 | return; |
859 | 913 | 531 | ||
860 | 914 | LogUnityEvent(ApplicationEventType::ACCESS); | 532 | LogUnityEvent(ApplicationEventType::ACCESS); |
862 | 915 | SimpleLauncherIcon::UnStick(); | 533 | WindowedLauncherIcon::UnStick(); |
863 | 916 | SetQuirk(Quirk::VISIBLE, app_->visible()); | 534 | SetQuirk(Quirk::VISIBLE, app_->visible()); |
864 | 917 | app_->sticky = false; | 535 | app_->sticky = false; |
865 | 918 | 536 | ||
867 | 919 | if (!app_->running()) | 537 | if (!IsRunning()) |
868 | 920 | Remove(); | 538 | Remove(); |
869 | 921 | } | 539 | } |
870 | 922 | 540 | ||
871 | @@ -956,10 +574,10 @@ | |||
872 | 956 | 574 | ||
873 | 957 | void ApplicationLauncherIcon::EnsureMenuItemsDefaultReady() | 575 | void ApplicationLauncherIcon::EnsureMenuItemsDefaultReady() |
874 | 958 | { | 576 | { |
876 | 959 | if (_menu_items.size() == MenuItemType::SIZE) | 577 | if (menu_items_.size() == MenuItemType::SIZE) |
877 | 960 | return; | 578 | return; |
878 | 961 | 579 | ||
880 | 962 | _menu_items.resize(MenuItemType::SIZE); | 580 | menu_items_.resize(MenuItemType::SIZE); |
881 | 963 | 581 | ||
882 | 964 | /* (Un)Stick to Launcher */ | 582 | /* (Un)Stick to Launcher */ |
883 | 965 | glib::Object<DbusmenuMenuitem> menu_item(dbusmenu_menuitem_new()); | 583 | glib::Object<DbusmenuMenuitem> menu_item(dbusmenu_menuitem_new()); |
884 | @@ -968,12 +586,12 @@ | |||
885 | 968 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true); | 586 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true); |
886 | 969 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); | 587 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); |
887 | 970 | 588 | ||
889 | 971 | _gsignals.Add<void, DbusmenuMenuitem*, unsigned>(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, | 589 | glib_signals_.Add<void, DbusmenuMenuitem*, unsigned>(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, |
890 | 972 | [this] (DbusmenuMenuitem*, unsigned) { | 590 | [this] (DbusmenuMenuitem*, unsigned) { |
891 | 973 | ToggleSticky(); | 591 | ToggleSticky(); |
892 | 974 | }); | 592 | }); |
893 | 975 | 593 | ||
895 | 976 | _menu_items[MenuItemType::STICK] = menu_item; | 594 | menu_items_[MenuItemType::STICK] = menu_item; |
896 | 977 | 595 | ||
897 | 978 | /* Quit */ | 596 | /* Quit */ |
898 | 979 | menu_item = dbusmenu_menuitem_new(); | 597 | menu_item = dbusmenu_menuitem_new(); |
899 | @@ -981,17 +599,17 @@ | |||
900 | 981 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true); | 599 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true); |
901 | 982 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); | 600 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); |
902 | 983 | 601 | ||
904 | 984 | _gsignals.Add<void, DbusmenuMenuitem*, unsigned>(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, | 602 | glib_signals_.Add<void, DbusmenuMenuitem*, unsigned>(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, |
905 | 985 | [this] (DbusmenuMenuitem*, unsigned) { | 603 | [this] (DbusmenuMenuitem*, unsigned) { |
906 | 986 | Quit(); | 604 | Quit(); |
907 | 987 | }); | 605 | }); |
908 | 988 | 606 | ||
910 | 989 | _menu_items[MenuItemType::QUIT] = menu_item; | 607 | menu_items_[MenuItemType::QUIT] = menu_item; |
911 | 990 | 608 | ||
912 | 991 | /* Separator */ | 609 | /* Separator */ |
913 | 992 | menu_item = dbusmenu_menuitem_new(); | 610 | menu_item = dbusmenu_menuitem_new(); |
914 | 993 | dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); | 611 | dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); |
916 | 994 | _menu_items[MenuItemType::SEPARATOR] = menu_item; | 612 | menu_items_[MenuItemType::SEPARATOR] = menu_item; |
917 | 995 | } | 613 | } |
918 | 996 | 614 | ||
919 | 997 | AbstractLauncherIcon::MenuItemsVector ApplicationLauncherIcon::GetMenus() | 615 | AbstractLauncherIcon::MenuItemsVector ApplicationLauncherIcon::GetMenus() |
920 | @@ -1003,7 +621,7 @@ | |||
921 | 1003 | EnsureMenuItemsDefaultReady(); | 621 | EnsureMenuItemsDefaultReady(); |
922 | 1004 | EnsureMenuItemsStaticQuicklist(); | 622 | EnsureMenuItemsStaticQuicklist(); |
923 | 1005 | 623 | ||
925 | 1006 | for (auto const& menus : {GetRemoteMenus(), _menu_desktop_shortcuts}) | 624 | for (auto const& menus : {GetRemoteMenus(), menu_desktop_shortcuts_}) |
926 | 1007 | { | 625 | { |
927 | 1008 | if (!menus.IsType(DBUSMENU_TYPE_MENUITEM)) | 626 | if (!menus.IsType(DBUSMENU_TYPE_MENUITEM)) |
928 | 1009 | continue; | 627 | continue; |
929 | @@ -1049,11 +667,11 @@ | |||
930 | 1049 | 667 | ||
931 | 1050 | if (separator_needed) | 668 | if (separator_needed) |
932 | 1051 | { | 669 | { |
934 | 1052 | result.push_back(_menu_items[MenuItemType::SEPARATOR]); | 670 | result.push_back(menu_items_[MenuItemType::SEPARATOR]); |
935 | 1053 | separator_needed = false; | 671 | separator_needed = false; |
936 | 1054 | } | 672 | } |
937 | 1055 | 673 | ||
939 | 1056 | if (!_menu_items[MenuItemType::APP_NAME]) | 674 | if (!menu_items_[MenuItemType::APP_NAME]) |
940 | 1057 | { | 675 | { |
941 | 1058 | glib::String app_name(g_markup_escape_text(app_->title().c_str(), -1)); | 676 | glib::String app_name(g_markup_escape_text(app_->title().c_str(), -1)); |
942 | 1059 | std::string bold_app_name("<b>"+app_name.Str()+"</b>"); | 677 | std::string bold_app_name("<b>"+app_name.Str()+"</b>"); |
943 | @@ -1064,7 +682,7 @@ | |||
944 | 1064 | dbusmenu_menuitem_property_set_bool(item, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); | 682 | dbusmenu_menuitem_property_set_bool(item, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); |
945 | 1065 | dbusmenu_menuitem_property_set_bool(item, QuicklistMenuItem::MARKUP_ENABLED_PROPERTY, TRUE); | 683 | dbusmenu_menuitem_property_set_bool(item, QuicklistMenuItem::MARKUP_ENABLED_PROPERTY, TRUE); |
946 | 1066 | 684 | ||
948 | 1067 | _gsignals.Add<void, DbusmenuMenuitem*, unsigned>(item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, | 685 | glib_signals_.Add<void, DbusmenuMenuitem*, unsigned>(item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, |
949 | 1068 | [this] (DbusmenuMenuitem*, unsigned timestamp) { | 686 | [this] (DbusmenuMenuitem*, unsigned timestamp) { |
950 | 1069 | _source_manager.AddIdle([this, timestamp] { | 687 | _source_manager.AddIdle([this, timestamp] { |
951 | 1070 | ActivateLauncherIcon(ActionArg(ActionArg::Source::LAUNCHER, 0, timestamp)); | 688 | ActivateLauncherIcon(ActionArg(ActionArg::Source::LAUNCHER, 0, timestamp)); |
952 | @@ -1072,25 +690,23 @@ | |||
953 | 1072 | }); | 690 | }); |
954 | 1073 | }); | 691 | }); |
955 | 1074 | 692 | ||
957 | 1075 | _menu_items[MenuItemType::APP_NAME] = item; | 693 | menu_items_[MenuItemType::APP_NAME] = item; |
958 | 1076 | } | 694 | } |
959 | 1077 | 695 | ||
966 | 1078 | result.push_back(_menu_items[MenuItemType::APP_NAME]); | 696 | result.push_back(menu_items_[MenuItemType::APP_NAME]); |
967 | 1079 | result.push_back(_menu_items[MenuItemType::SEPARATOR]); | 697 | result.push_back(menu_items_[MenuItemType::SEPARATOR]); |
968 | 1080 | 698 | ||
969 | 1081 | EnsureMenuItemsWindowsReady(); | 699 | auto const& windows_menu_items = GetWindowsMenuItems(); |
970 | 1082 | 700 | ||
971 | 1083 | if (!_menu_items_windows.empty()) | 701 | if (!windows_menu_items.empty()) |
972 | 1084 | { | 702 | { |
977 | 1085 | for (auto const& it : _menu_items_windows) | 703 | result.insert(end(result), begin(windows_menu_items), end(windows_menu_items)); |
978 | 1086 | result.push_back(it); | 704 | result.push_back(menu_items_[MenuItemType::SEPARATOR]); |
975 | 1087 | |||
976 | 1088 | result.push_back(_menu_items[MenuItemType::SEPARATOR]); | ||
979 | 1089 | } | 705 | } |
980 | 1090 | 706 | ||
981 | 1091 | const char* label = !IsSticky() ? _("Lock to Launcher") : _("Unlock from Launcher"); | 707 | const char* label = !IsSticky() ? _("Lock to Launcher") : _("Unlock from Launcher"); |
984 | 1092 | dbusmenu_menuitem_property_set(_menu_items[MenuItemType::STICK], DBUSMENU_MENUITEM_PROP_LABEL, label); | 708 | dbusmenu_menuitem_property_set(menu_items_[MenuItemType::STICK], DBUSMENU_MENUITEM_PROP_LABEL, label); |
985 | 1093 | result.push_back(_menu_items[MenuItemType::STICK]); | 709 | result.push_back(menu_items_[MenuItemType::STICK]); |
986 | 1094 | 710 | ||
987 | 1095 | if (IsRunning()) | 711 | if (IsRunning()) |
988 | 1096 | { | 712 | { |
989 | @@ -1102,7 +718,7 @@ | |||
990 | 1102 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true); | 718 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true); |
991 | 1103 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); | 719 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); |
992 | 1104 | 720 | ||
994 | 1105 | _gsignals.Add<void, DbusmenuMenuitem*, unsigned>(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, | 721 | glib_signals_.Add<void, DbusmenuMenuitem*, unsigned>(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, |
995 | 1106 | [this] (DbusmenuMenuitem*, unsigned) { | 722 | [this] (DbusmenuMenuitem*, unsigned) { |
996 | 1107 | app_->CreateLocalDesktopFile(); | 723 | app_->CreateLocalDesktopFile(); |
997 | 1108 | }); | 724 | }); |
998 | @@ -1111,7 +727,7 @@ | |||
999 | 1111 | } | 727 | } |
1000 | 1112 | 728 | ||
1001 | 1113 | if (!quit_item) | 729 | if (!quit_item) |
1003 | 1114 | quit_item = _menu_items[MenuItemType::QUIT]; | 730 | quit_item = menu_items_[MenuItemType::QUIT]; |
1004 | 1115 | 731 | ||
1005 | 1116 | dbusmenu_menuitem_property_set(quit_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Quit")); | 732 | dbusmenu_menuitem_property_set(quit_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Quit")); |
1006 | 1117 | result.push_back(quit_item); | 733 | result.push_back(quit_item); |
1007 | @@ -1125,28 +741,7 @@ | |||
1008 | 1125 | if (app_->type() == AppType::WEBAPP) | 741 | if (app_->type() == AppType::WEBAPP) |
1009 | 1126 | return; | 742 | return; |
1010 | 1127 | 743 | ||
1033 | 1128 | nux::Geometry geo(0, 0, icon_size, icon_size); | 744 | return WindowedLauncherIcon::UpdateIconGeometries(centers); |
1012 | 1129 | |||
1013 | 1130 | for (auto& window : app_->GetWindows()) | ||
1014 | 1131 | { | ||
1015 | 1132 | Window xid = window->window_id(); | ||
1016 | 1133 | int monitor = GetCenterForMonitor(window->monitor()).first; | ||
1017 | 1134 | |||
1018 | 1135 | if (monitor < 0) | ||
1019 | 1136 | { | ||
1020 | 1137 | WindowManager::Default().SetWindowIconGeometry(xid, nux::Geometry()); | ||
1021 | 1138 | continue; | ||
1022 | 1139 | } | ||
1023 | 1140 | |||
1024 | 1141 | geo.x = centers[monitor].x - icon_size / 2; | ||
1025 | 1142 | geo.y = centers[monitor].y - icon_size / 2; | ||
1026 | 1143 | WindowManager::Default().SetWindowIconGeometry(xid, geo); | ||
1027 | 1144 | } | ||
1028 | 1145 | } | ||
1029 | 1146 | |||
1030 | 1147 | void ApplicationLauncherIcon::OnCenterStabilized(std::vector<nux::Point3> const& centers) | ||
1031 | 1148 | { | ||
1032 | 1149 | UpdateIconGeometries(centers); | ||
1034 | 1150 | } | 745 | } |
1035 | 1151 | 746 | ||
1036 | 1152 | void ApplicationLauncherIcon::UpdateRemoteUri() | 747 | void ApplicationLauncherIcon::UpdateRemoteUri() |
1037 | @@ -1155,69 +750,21 @@ | |||
1038 | 1155 | 750 | ||
1039 | 1156 | if (!desktop_id.empty()) | 751 | if (!desktop_id.empty()) |
1040 | 1157 | { | 752 | { |
1042 | 1158 | _remote_uri = FavoriteStore::URI_PREFIX_APP + desktop_id; | 753 | remote_uri_ = FavoriteStore::URI_PREFIX_APP + desktop_id; |
1043 | 1159 | } | 754 | } |
1044 | 1160 | else | 755 | else |
1045 | 1161 | { | 756 | { |
1047 | 1162 | _remote_uri.clear(); | 757 | remote_uri_.clear(); |
1048 | 1163 | } | 758 | } |
1049 | 1164 | } | 759 | } |
1050 | 1165 | 760 | ||
1051 | 1166 | std::string ApplicationLauncherIcon::GetRemoteUri() const | 761 | std::string ApplicationLauncherIcon::GetRemoteUri() const |
1052 | 1167 | { | 762 | { |
1092 | 1168 | return _remote_uri; | 763 | return remote_uri_; |
1054 | 1169 | } | ||
1055 | 1170 | |||
1056 | 1171 | void ApplicationLauncherIcon::OnDndEnter() | ||
1057 | 1172 | { | ||
1058 | 1173 | auto timestamp = nux::GetGraphicsDisplay()->GetCurrentEvent().x11_timestamp; | ||
1059 | 1174 | |||
1060 | 1175 | _source_manager.AddTimeout(1000, [this, timestamp] { | ||
1061 | 1176 | bool to_spread = GetWindows(WindowFilter::ON_CURRENT_DESKTOP).size() > 1; | ||
1062 | 1177 | |||
1063 | 1178 | if (!to_spread) | ||
1064 | 1179 | WindowManager::Default().TerminateScale(); | ||
1065 | 1180 | |||
1066 | 1181 | if (!IsRunning()) | ||
1067 | 1182 | return false; | ||
1068 | 1183 | |||
1069 | 1184 | UBusManager::SendMessage(UBUS_OVERLAY_CLOSE_REQUEST); | ||
1070 | 1185 | Focus(ActionArg(ActionArg::Source::LAUNCHER, 1, timestamp)); | ||
1071 | 1186 | |||
1072 | 1187 | if (to_spread) | ||
1073 | 1188 | Spread(true, COMPIZ_SCALE_DND_SPREAD, false); | ||
1074 | 1189 | |||
1075 | 1190 | return false; | ||
1076 | 1191 | }, ICON_DND_OVER_TIMEOUT); | ||
1077 | 1192 | } | ||
1078 | 1193 | |||
1079 | 1194 | void ApplicationLauncherIcon::OnDndLeave() | ||
1080 | 1195 | { | ||
1081 | 1196 | _source_manager.Remove(ICON_DND_OVER_TIMEOUT); | ||
1082 | 1197 | } | ||
1083 | 1198 | |||
1084 | 1199 | bool ApplicationLauncherIcon::IsFileManager() | ||
1085 | 1200 | { | ||
1086 | 1201 | auto const& desktop_file = DesktopFile(); | ||
1087 | 1202 | |||
1088 | 1203 | return boost::algorithm::ends_with(desktop_file, "org.gnome.Nautilus.desktop") || | ||
1089 | 1204 | boost::algorithm::ends_with(desktop_file, "nautilus.desktop") || | ||
1090 | 1205 | boost::algorithm::ends_with(desktop_file, "nautilus-folder-handler.desktop") || | ||
1091 | 1206 | boost::algorithm::ends_with(desktop_file, "nautilus-home.desktop"); | ||
1093 | 1207 | } | 764 | } |
1094 | 1208 | 765 | ||
1095 | 1209 | bool ApplicationLauncherIcon::OnShouldHighlightOnDrag(DndData const& dnd_data) | 766 | bool ApplicationLauncherIcon::OnShouldHighlightOnDrag(DndData const& dnd_data) |
1096 | 1210 | { | 767 | { |
1097 | 1211 | if (IsFileManager()) | ||
1098 | 1212 | { | ||
1099 | 1213 | for (auto const& uri : dnd_data.Uris()) | ||
1100 | 1214 | { | ||
1101 | 1215 | if (boost::algorithm::starts_with(uri, "file://")) | ||
1102 | 1216 | return true; | ||
1103 | 1217 | } | ||
1104 | 1218 | return false; | ||
1105 | 1219 | } | ||
1106 | 1220 | |||
1107 | 1221 | for (auto type : dnd_data.Types()) | 768 | for (auto type : dnd_data.Types()) |
1108 | 1222 | { | 769 | { |
1109 | 1223 | for (auto supported_type : GetSupportedTypes()) | 770 | for (auto supported_type : GetSupportedTypes()) |
1110 | @@ -1248,28 +795,6 @@ | |||
1111 | 1248 | OpenInstanceWithUris(dnd_data.Uris(), timestamp); | 795 | OpenInstanceWithUris(dnd_data.Uris(), timestamp); |
1112 | 1249 | } | 796 | } |
1113 | 1250 | 797 | ||
1114 | 1251 | bool ApplicationLauncherIcon::ShowInSwitcher(bool current) | ||
1115 | 1252 | { | ||
1116 | 1253 | if (!removed() && IsRunning() && IsVisible()) | ||
1117 | 1254 | { | ||
1118 | 1255 | // If current is true, we only want to show the current workspace. | ||
1119 | 1256 | if (!current) | ||
1120 | 1257 | { | ||
1121 | 1258 | return true; | ||
1122 | 1259 | } | ||
1123 | 1260 | else | ||
1124 | 1261 | { | ||
1125 | 1262 | for (unsigned i = 0; i < monitors::MAX; ++i) | ||
1126 | 1263 | { | ||
1127 | 1264 | if (WindowVisibleOnMonitor(i)) | ||
1128 | 1265 | return true; | ||
1129 | 1266 | } | ||
1130 | 1267 | } | ||
1131 | 1268 | } | ||
1132 | 1269 | |||
1133 | 1270 | return false; | ||
1134 | 1271 | } | ||
1135 | 1272 | |||
1136 | 1273 | bool ApplicationLauncherIcon::AllowDetailViewInSwitcher() const | 798 | bool ApplicationLauncherIcon::AllowDetailViewInSwitcher() const |
1137 | 1274 | { | 799 | { |
1138 | 1275 | return app_->type() != AppType::WEBAPP; | 800 | return app_->type() != AppType::WEBAPP; |
1139 | @@ -1277,18 +802,11 @@ | |||
1140 | 1277 | 802 | ||
1141 | 1278 | uint64_t ApplicationLauncherIcon::SwitcherPriority() | 803 | uint64_t ApplicationLauncherIcon::SwitcherPriority() |
1142 | 1279 | { | 804 | { |
1143 | 1280 | uint64_t result = 0; | ||
1144 | 1281 | // Webapps always go at the back. | 805 | // Webapps always go at the back. |
1145 | 1282 | if (app_->type() == AppType::WEBAPP) | 806 | if (app_->type() == AppType::WEBAPP) |
1155 | 1283 | return result; | 807 | return 0; |
1156 | 1284 | 808 | ||
1157 | 1285 | for (auto& window : app_->GetWindows()) | 809 | return WindowedLauncherIcon::SwitcherPriority(); |
1149 | 1286 | { | ||
1150 | 1287 | Window xid = window->window_id(); | ||
1151 | 1288 | result = std::max(result, WindowManager::Default().GetWindowActiveNumber(xid)); | ||
1152 | 1289 | } | ||
1153 | 1290 | |||
1154 | 1291 | return result; | ||
1158 | 1292 | } | 810 | } |
1159 | 1293 | 811 | ||
1160 | 1294 | nux::Color ApplicationLauncherIcon::BackgroundColor() const | 812 | nux::Color ApplicationLauncherIcon::BackgroundColor() const |
1161 | @@ -1296,7 +814,7 @@ | |||
1162 | 1296 | if (use_custom_bg_color_) | 814 | if (use_custom_bg_color_) |
1163 | 1297 | return bg_color_; | 815 | return bg_color_; |
1164 | 1298 | 816 | ||
1166 | 1299 | return SimpleLauncherIcon::BackgroundColor(); | 817 | return WindowedLauncherIcon::BackgroundColor(); |
1167 | 1300 | } | 818 | } |
1168 | 1301 | 819 | ||
1169 | 1302 | const std::set<std::string> ApplicationLauncherIcon::GetSupportedTypes() | 820 | const std::set<std::string> ApplicationLauncherIcon::GetSupportedTypes() |
1170 | @@ -1312,103 +830,18 @@ | |||
1171 | 1312 | return supported_types; | 830 | return supported_types; |
1172 | 1313 | } | 831 | } |
1173 | 1314 | 832 | ||
1174 | 1315 | void PerformScrollUp(WindowList const& windows, unsigned int progressive_scroll) | ||
1175 | 1316 | { | ||
1176 | 1317 | if (progressive_scroll == windows.size() - 1) | ||
1177 | 1318 | { | ||
1178 | 1319 | //RestackAbove to preserve Global Stacking Order | ||
1179 | 1320 | WindowManager::Default().RestackBelow(windows.at(0)->window_id(), windows.at(1)->window_id()); | ||
1180 | 1321 | WindowManager::Default().RestackBelow(windows.at(1)->window_id(), windows.at(0)->window_id()); | ||
1181 | 1322 | windows.back()->Focus(); | ||
1182 | 1323 | return; | ||
1183 | 1324 | } | ||
1184 | 1325 | |||
1185 | 1326 | WindowManager::Default().RestackBelow(windows.at(0)->window_id(), windows.at(progressive_scroll + 1)->window_id()); | ||
1186 | 1327 | windows.at(progressive_scroll + 1)->Focus(); | ||
1187 | 1328 | } | ||
1188 | 1329 | |||
1189 | 1330 | void PerformScrollDown(WindowList const& windows, unsigned int progressive_scroll) | ||
1190 | 1331 | { | ||
1191 | 1332 | if (!progressive_scroll) | ||
1192 | 1333 | { | ||
1193 | 1334 | WindowManager::Default().RestackBelow(windows.at(0)->window_id(), windows.back()->window_id()); | ||
1194 | 1335 | windows.at(1)->Focus(); | ||
1195 | 1336 | return; | ||
1196 | 1337 | } | ||
1197 | 1338 | |||
1198 | 1339 | WindowManager::Default().RestackBelow(windows.at(0)->window_id(), windows.at(progressive_scroll)->window_id()); | ||
1199 | 1340 | windows.at(progressive_scroll)->Focus(); | ||
1200 | 1341 | } | ||
1201 | 1342 | |||
1202 | 1343 | void ApplicationLauncherIcon::PerformScroll(ScrollDirection direction, Time timestamp) | ||
1203 | 1344 | { | ||
1204 | 1345 | if (timestamp - _last_scroll_timestamp < 150) | ||
1205 | 1346 | return; | ||
1206 | 1347 | else if (timestamp - _last_scroll_timestamp > 1500) | ||
1207 | 1348 | _progressive_scroll = 0; | ||
1208 | 1349 | |||
1209 | 1350 | _last_scroll_timestamp = timestamp; | ||
1210 | 1351 | |||
1211 | 1352 | auto const& windows = GetWindowsOnCurrentDesktopInStackingOrder(); | ||
1212 | 1353 | |||
1213 | 1354 | if (windows.empty()) | ||
1214 | 1355 | return; | ||
1215 | 1356 | |||
1216 | 1357 | if (scroll_inactive_icons && !IsActive()) | ||
1217 | 1358 | { | ||
1218 | 1359 | windows.at(0)->Focus(); | ||
1219 | 1360 | return; | ||
1220 | 1361 | } | ||
1221 | 1362 | |||
1222 | 1363 | if (!scroll_inactive_icons && !IsActive()) | ||
1223 | 1364 | return; | ||
1224 | 1365 | |||
1225 | 1366 | if (windows.size() <= 1) | ||
1226 | 1367 | return; | ||
1227 | 1368 | |||
1228 | 1369 | if (direction == ScrollDirection::DOWN) | ||
1229 | 1370 | ++_progressive_scroll; | ||
1230 | 1371 | else | ||
1231 | 1372 | //--_progressive_scroll; but roll to the top of windows | ||
1232 | 1373 | _progressive_scroll += windows.size() - 1; | ||
1233 | 1374 | _progressive_scroll %= windows.size(); | ||
1234 | 1375 | |||
1235 | 1376 | switch(direction) | ||
1236 | 1377 | { | ||
1237 | 1378 | case ScrollDirection::UP: | ||
1238 | 1379 | PerformScrollUp(windows, _progressive_scroll); | ||
1239 | 1380 | break; | ||
1240 | 1381 | case ScrollDirection::DOWN: | ||
1241 | 1382 | PerformScrollDown(windows, _progressive_scroll); | ||
1242 | 1383 | break; | ||
1243 | 1384 | } | ||
1244 | 1385 | } | ||
1245 | 1386 | |||
1246 | 1387 | WindowList ApplicationLauncherIcon::GetWindowsOnCurrentDesktopInStackingOrder() | ||
1247 | 1388 | { | ||
1248 | 1389 | auto windows = GetWindows(WindowFilter::ON_CURRENT_DESKTOP | WindowFilter::ON_ALL_MONITORS); | ||
1249 | 1390 | auto sorted_windows = WindowManager::Default().GetWindowsInStackingOrder(); | ||
1250 | 1391 | |||
1251 | 1392 | // Order the windows | ||
1252 | 1393 | std::sort(windows.begin(), windows.end(), [&sorted_windows] (ApplicationWindowPtr const& win1, ApplicationWindowPtr const& win2) { | ||
1253 | 1394 | for (auto const& window : sorted_windows) | ||
1254 | 1395 | { | ||
1255 | 1396 | if (window == win1->window_id()) | ||
1256 | 1397 | return false; | ||
1257 | 1398 | else if (window == win2->window_id()) | ||
1258 | 1399 | return true; | ||
1259 | 1400 | } | ||
1260 | 1401 | |||
1261 | 1402 | return true; | ||
1262 | 1403 | }); | ||
1263 | 1404 | |||
1264 | 1405 | return windows; | ||
1265 | 1406 | } | ||
1266 | 1407 | |||
1267 | 1408 | std::string ApplicationLauncherIcon::GetName() const | 833 | std::string ApplicationLauncherIcon::GetName() const |
1268 | 1409 | { | 834 | { |
1269 | 1410 | return "ApplicationLauncherIcon"; | 835 | return "ApplicationLauncherIcon"; |
1270 | 1411 | } | 836 | } |
1271 | 1412 | 837 | ||
1272 | 838 | void ApplicationLauncherIcon::AddProperties(debug::IntrospectionData& introspection) | ||
1273 | 839 | { | ||
1274 | 840 | WindowedLauncherIcon::AddProperties(introspection); | ||
1275 | 841 | |||
1276 | 842 | introspection.add("desktop_file", DesktopFile()) | ||
1277 | 843 | .add("desktop_id", app_->desktop_id()); | ||
1278 | 844 | } | ||
1279 | 845 | |||
1280 | 1413 | } // namespace launcher | 846 | } // namespace launcher |
1281 | 1414 | } // namespace unity | 847 | } // namespace unity |
1282 | 1415 | 848 | ||
1283 | === modified file 'launcher/ApplicationLauncherIcon.h' | |||
1284 | --- launcher/ApplicationLauncherIcon.h 2015-11-18 15:25:31 +0000 | |||
1285 | +++ launcher/ApplicationLauncherIcon.h 2016-02-09 10:44:04 +0000 | |||
1286 | @@ -1,6 +1,6 @@ | |||
1287 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
1288 | 2 | /* | 2 | /* |
1290 | 3 | * Copyright (C) 2010-2012 Canonical Ltd | 3 | * Copyright (C) 2010-2015 Canonical Ltd |
1291 | 4 | * | 4 | * |
1292 | 5 | * This program is free software: you can redistribute it and/or modify | 5 | * This program is free software: you can redistribute it and/or modify |
1293 | 6 | * it under the terms of the GNU General Public License version 3 as | 6 | * it under the terms of the GNU General Public License version 3 as |
1294 | @@ -18,17 +18,15 @@ | |||
1295 | 18 | * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> | 18 | * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> |
1296 | 19 | */ | 19 | */ |
1297 | 20 | 20 | ||
1300 | 21 | #ifndef APPLICATIONLAUNCHERICON_H | 21 | #ifndef APPLICATION_LAUNCHER_ICON_H |
1301 | 22 | #define APPLICATIONLAUNCHERICON_H | 22 | #define APPLICATION_LAUNCHER_ICON_H |
1302 | 23 | 23 | ||
1303 | 24 | #include <UnityCore/GLibSignal.h> | ||
1304 | 25 | #include <UnityCore/GLibWrapper.h> | ||
1305 | 26 | #include <UnityCore/ConnectionManager.h> | 24 | #include <UnityCore/ConnectionManager.h> |
1306 | 27 | #include <UnityCore/Variant.h> | 25 | #include <UnityCore/Variant.h> |
1307 | 28 | 26 | ||
1308 | 29 | #include <libindicator/indicator-desktop-shortcuts.h> | 27 | #include <libindicator/indicator-desktop-shortcuts.h> |
1309 | 30 | 28 | ||
1311 | 31 | #include "SimpleLauncherIcon.h" | 29 | #include "WindowedLauncherIcon.h" |
1312 | 32 | 30 | ||
1313 | 33 | namespace unity | 31 | namespace unity |
1314 | 34 | { | 32 | { |
1315 | @@ -37,115 +35,74 @@ | |||
1316 | 37 | 35 | ||
1317 | 38 | class Launcher; | 36 | class Launcher; |
1318 | 39 | 37 | ||
1320 | 40 | class ApplicationLauncherIcon : public SimpleLauncherIcon | 38 | class ApplicationLauncherIcon : public virtual WindowedLauncherIcon |
1321 | 41 | { | 39 | { |
1323 | 42 | NUX_DECLARE_OBJECT_TYPE(ApplicationLauncherIcon, SimpleLauncherIcon); | 40 | NUX_DECLARE_OBJECT_TYPE(ApplicationLauncherIcon, WindowedLauncherIcon); |
1324 | 43 | public: | 41 | public: |
1326 | 44 | ApplicationLauncherIcon(ApplicationPtr const& app); | 42 | ApplicationLauncherIcon(ApplicationPtr const&); |
1327 | 45 | virtual ~ApplicationLauncherIcon(); | 43 | virtual ~ApplicationLauncherIcon(); |
1328 | 46 | 44 | ||
1329 | 47 | virtual void ActivateLauncherIcon(ActionArg arg); | ||
1330 | 48 | |||
1331 | 49 | std::string DesktopFile() const; | 45 | std::string DesktopFile() const; |
1332 | 50 | 46 | ||
1357 | 51 | bool IsSticky() const; | 47 | bool IsSticky() const override; |
1358 | 52 | bool IsActive() const; | 48 | bool IsUserVisible() const override; |
1359 | 53 | bool IsRunning() const; | 49 | bool GetQuirk(Quirk quirk, int monitor = 0) const override; |
1360 | 54 | bool IsUrgent() const; | 50 | |
1361 | 55 | 51 | void Quit() const override; | |
1362 | 56 | virtual bool GetQuirk(Quirk quirk, int monitor = 0) const override; | 52 | |
1363 | 57 | 53 | void Stick(bool save = true) override; | |
1364 | 58 | virtual void Quit(); | 54 | void UnStick() override; |
1341 | 59 | virtual void AboutToRemove(); | ||
1342 | 60 | |||
1343 | 61 | virtual void Stick(bool save = true); | ||
1344 | 62 | virtual void UnStick(); | ||
1345 | 63 | |||
1346 | 64 | virtual bool ShowInSwitcher(bool current); | ||
1347 | 65 | virtual bool AllowDetailViewInSwitcher() const override; | ||
1348 | 66 | virtual uint64_t SwitcherPriority(); | ||
1349 | 67 | |||
1350 | 68 | virtual nux::Color BackgroundColor() const; | ||
1351 | 69 | |||
1352 | 70 | WindowList Windows(); | ||
1353 | 71 | std::vector<Window> WindowsOnViewport(); | ||
1354 | 72 | std::vector<Window> WindowsForMonitor(int monitor); | ||
1355 | 73 | |||
1356 | 74 | void PerformScroll(ScrollDirection direction, Time timestamp) override; | ||
1365 | 75 | 55 | ||
1366 | 76 | protected: | 56 | protected: |
1367 | 77 | void SetApplication(ApplicationPtr const& app); | 57 | void SetApplication(ApplicationPtr const& app); |
1368 | 78 | ApplicationPtr GetApplication() const; | 58 | ApplicationPtr GetApplication() const; |
1369 | 79 | 59 | ||
1370 | 60 | WindowList GetManagedWindows() const override; | ||
1371 | 61 | |||
1372 | 62 | void LogUnityEvent(ApplicationEventType); | ||
1373 | 80 | void Remove(); | 63 | void Remove(); |
1380 | 81 | void UpdateIconGeometries(std::vector<nux::Point3> const& centers); | 64 | |
1381 | 82 | void OnCenterStabilized(std::vector<nux::Point3> const& centers); | 65 | void AboutToRemove() override; |
1382 | 83 | void AddProperties(debug::IntrospectionData&); | 66 | bool AllowDetailViewInSwitcher() const override; |
1383 | 84 | void OnAcceptDrop(DndData const& dnd_data); | 67 | uint64_t SwitcherPriority() override; |
1384 | 85 | void OnDndEnter(); | 68 | void UpdateIconGeometries(std::vector<nux::Point3> const& centers) override; |
1385 | 86 | void OnDndLeave(); | 69 | nux::Color BackgroundColor() const override; |
1386 | 70 | MenuItemsVector GetMenus() override; | ||
1387 | 71 | std::string GetRemoteUri() const override; | ||
1388 | 72 | |||
1389 | 87 | void OpenInstanceLauncherIcon(Time timestamp) override; | 73 | void OpenInstanceLauncherIcon(Time timestamp) override; |
1417 | 88 | void ToggleSticky(); | 74 | void OpenInstanceWithUris(std::set<std::string> const& uris, Time timestamp); |
1418 | 89 | void LogUnityEvent(ApplicationEventType); | 75 | void Focus(ActionArg arg) override; |
1419 | 90 | bool IsFileManager(); | 76 | |
1420 | 91 | 77 | void OnAcceptDrop(DndData const&) override; | |
1421 | 92 | bool OnShouldHighlightOnDrag(DndData const& dnd_data); | 78 | bool OnShouldHighlightOnDrag(DndData const&) override; |
1422 | 93 | nux::DndAction OnQueryAcceptDrop(DndData const& dnd_data); | 79 | nux::DndAction OnQueryAcceptDrop(DndData const&) override; |
1423 | 94 | 80 | ||
1424 | 95 | MenuItemsVector GetMenus(); | 81 | std::string GetName() const override; |
1425 | 96 | 82 | void AddProperties(debug::IntrospectionData&) override; | |
1399 | 97 | std::string GetRemoteUri() const; | ||
1400 | 98 | |||
1401 | 99 | bool HandlesSpread() { return true; } | ||
1402 | 100 | std::string GetName() const; | ||
1403 | 101 | |||
1404 | 102 | void UpdateDesktopFile(); | ||
1405 | 103 | void UpdateRemoteUri(); | ||
1406 | 104 | std::string _desktop_file; | ||
1407 | 105 | |||
1408 | 106 | private: | ||
1409 | 107 | typedef unsigned long int WindowFilterMask; | ||
1410 | 108 | enum WindowFilter | ||
1411 | 109 | { | ||
1412 | 110 | MAPPED = (1 << 0), | ||
1413 | 111 | USER_VISIBLE = (1 << 1), | ||
1414 | 112 | ON_CURRENT_DESKTOP = (1 << 2), | ||
1415 | 113 | ON_ALL_MONITORS = (1 << 3), | ||
1416 | 114 | }; | ||
1426 | 115 | 83 | ||
1427 | 116 | void UnsetApplication(); | 84 | void UnsetApplication(); |
1428 | 117 | void SetupApplicationSignalsConnections(); | 85 | void SetupApplicationSignalsConnections(); |
1429 | 118 | void EnsureWindowState(); | ||
1430 | 119 | void EnsureWindowsLocation(); | ||
1431 | 120 | void EnsureMenuItemsWindowsReady(); | ||
1432 | 121 | void EnsureMenuItemsDefaultReady(); | 86 | void EnsureMenuItemsDefaultReady(); |
1433 | 122 | void EnsureMenuItemsStaticQuicklist(); | 87 | void EnsureMenuItemsStaticQuicklist(); |
1434 | 123 | void UpdateBackgroundColor(); | 88 | void UpdateBackgroundColor(); |
1435 | 124 | void UpdateDesktopQuickList(); | 89 | void UpdateDesktopQuickList(); |
1444 | 125 | 90 | void UpdateDesktopFile(); | |
1445 | 126 | void OpenInstanceWithUris(std::set<std::string> const& uris, Time timestamp); | 91 | void UpdateRemoteUri(); |
1446 | 127 | void Focus(ActionArg arg); | 92 | void ToggleSticky(); |
1447 | 128 | bool Spread(bool current_desktop, int state, bool force); | 93 | void OnApplicationClosed(); |
1448 | 129 | 94 | ||
1441 | 130 | void OnWindowMinimized(guint32 xid); | ||
1442 | 131 | |||
1443 | 132 | WindowList GetWindows(WindowFilterMask filter = 0, int monitor = -1); | ||
1449 | 133 | const std::set<std::string> GetSupportedTypes(); | 95 | const std::set<std::string> GetSupportedTypes(); |
1450 | 134 | WindowList GetWindowsOnCurrentDesktopInStackingOrder(); | ||
1451 | 135 | ApplicationSubjectPtr GetSubject(); | 96 | ApplicationSubjectPtr GetSubject(); |
1452 | 136 | 97 | ||
1453 | 137 | ApplicationPtr app_; | 98 | ApplicationPtr app_; |
1465 | 138 | std::string _remote_uri; | 99 | std::string remote_uri_; |
1466 | 139 | Time _startup_notification_timestamp; | 100 | Time startup_notification_timestamp_; |
1467 | 140 | Time _last_scroll_timestamp; | 101 | std::set<std::string> supported_types_; |
1468 | 141 | unsigned int _progressive_scroll; | 102 | MenuItemsVector menu_items_; |
1469 | 142 | std::set<std::string> _supported_types; | 103 | glib::Object<IndicatorDesktopShortcuts> desktop_shortcuts_; |
1470 | 143 | std::vector<glib::Object<DbusmenuMenuitem>> _menu_items; | 104 | glib::Object<DbusmenuMenuitem> menu_desktop_shortcuts_; |
1471 | 144 | std::vector<glib::Object<DbusmenuMenuitem>> _menu_items_windows; | 105 | glib::Object<GFileMonitor> desktop_file_monitor_; |
1461 | 145 | glib::Object<IndicatorDesktopShortcuts> _desktop_shortcuts; | ||
1462 | 146 | glib::Object<DbusmenuMenuitem> _menu_desktop_shortcuts; | ||
1463 | 147 | glib::Object<GFileMonitor> _desktop_file_monitor; | ||
1464 | 148 | glib::SignalManager _gsignals; | ||
1472 | 149 | 106 | ||
1473 | 150 | bool use_custom_bg_color_; | 107 | bool use_custom_bg_color_; |
1474 | 151 | nux::Color bg_color_; | 108 | nux::Color bg_color_; |
1475 | @@ -153,7 +110,7 @@ | |||
1476 | 153 | connection::Manager signals_conn_; | 110 | connection::Manager signals_conn_; |
1477 | 154 | }; | 111 | }; |
1478 | 155 | 112 | ||
1481 | 156 | } | 113 | } // namespace launcher |
1482 | 157 | } | 114 | } // namespace unity |
1483 | 158 | 115 | ||
1485 | 159 | #endif // BAMFLAUNCHERICON_H | 116 | #endif // APPLICATION_LAUNCHER_ICON_H |
1486 | 160 | 117 | ||
1487 | === modified file 'launcher/CMakeLists.txt' | |||
1488 | --- launcher/CMakeLists.txt 2013-09-11 18:39:27 +0000 | |||
1489 | +++ launcher/CMakeLists.txt 2016-02-09 10:44:04 +0000 | |||
1490 | @@ -32,6 +32,7 @@ | |||
1491 | 32 | FavoriteStore.cpp | 32 | FavoriteStore.cpp |
1492 | 33 | FavoriteStoreGSettings.cpp | 33 | FavoriteStoreGSettings.cpp |
1493 | 34 | FavoriteStorePrivate.cpp | 34 | FavoriteStorePrivate.cpp |
1494 | 35 | FileManagerLauncherIcon.cpp | ||
1495 | 35 | HudLauncherIcon.cpp | 36 | HudLauncherIcon.cpp |
1496 | 36 | Launcher.cpp | 37 | Launcher.cpp |
1497 | 37 | LauncherController.cpp | 38 | LauncherController.cpp |
1498 | @@ -55,12 +56,14 @@ | |||
1499 | 55 | SingleMonitorLauncherIcon.cpp | 56 | SingleMonitorLauncherIcon.cpp |
1500 | 56 | SoftwareCenterLauncherIcon.cpp | 57 | SoftwareCenterLauncherIcon.cpp |
1501 | 57 | SpacerLauncherIcon.cpp | 58 | SpacerLauncherIcon.cpp |
1502 | 59 | StorageLauncherIcon.cpp | ||
1503 | 58 | Tooltip.cpp | 60 | Tooltip.cpp |
1504 | 59 | TooltipManager.cpp | 61 | TooltipManager.cpp |
1505 | 60 | TrashLauncherIcon.cpp | 62 | TrashLauncherIcon.cpp |
1506 | 61 | VolumeImp.cpp | 63 | VolumeImp.cpp |
1507 | 62 | VolumeLauncherIcon.cpp | 64 | VolumeLauncherIcon.cpp |
1508 | 63 | VolumeMonitorWrapper.cpp | 65 | VolumeMonitorWrapper.cpp |
1509 | 66 | WindowedLauncherIcon.cpp | ||
1510 | 64 | XdndCollectionWindowImp.cpp | 67 | XdndCollectionWindowImp.cpp |
1511 | 65 | XdndManagerImp.cpp | 68 | XdndManagerImp.cpp |
1512 | 66 | XdndStartStopNotifier.cpp | 69 | XdndStartStopNotifier.cpp |
1513 | 67 | 70 | ||
1514 | === modified file 'launcher/DesktopLauncherIcon.cpp' | |||
1515 | --- launcher/DesktopLauncherIcon.cpp 2014-08-13 23:32:39 +0000 | |||
1516 | +++ launcher/DesktopLauncherIcon.cpp 2016-02-09 10:44:04 +0000 | |||
1517 | @@ -77,5 +77,10 @@ | |||
1518 | 77 | return show_in_switcher_; | 77 | return show_in_switcher_; |
1519 | 78 | } | 78 | } |
1520 | 79 | 79 | ||
1521 | 80 | uint64_t DesktopLauncherIcon::SwitcherPriority() | ||
1522 | 81 | { | ||
1523 | 82 | return std::numeric_limits<uint64_t>::max(); | ||
1524 | 83 | } | ||
1525 | 84 | |||
1526 | 80 | } // namespace launcher | 85 | } // namespace launcher |
1527 | 81 | } // namespace unity | 86 | } // namespace unity |
1528 | 82 | 87 | ||
1529 | === modified file 'launcher/DesktopLauncherIcon.h' | |||
1530 | --- launcher/DesktopLauncherIcon.h 2014-08-13 23:32:39 +0000 | |||
1531 | +++ launcher/DesktopLauncherIcon.h 2016-02-09 10:44:04 +0000 | |||
1532 | @@ -37,6 +37,7 @@ | |||
1533 | 37 | 37 | ||
1534 | 38 | protected: | 38 | protected: |
1535 | 39 | void ActivateLauncherIcon(ActionArg arg); | 39 | void ActivateLauncherIcon(ActionArg arg); |
1536 | 40 | uint64_t SwitcherPriority() override; | ||
1537 | 40 | std::string GetName() const; | 41 | std::string GetName() const; |
1538 | 41 | std::string GetRemoteUri() const; | 42 | std::string GetRemoteUri() const; |
1539 | 42 | 43 | ||
1540 | 43 | 44 | ||
1541 | === modified file 'launcher/DeviceLauncherSection.h' | |||
1542 | --- launcher/DeviceLauncherSection.h 2013-10-07 14:13:45 +0000 | |||
1543 | +++ launcher/DeviceLauncherSection.h 2016-02-09 10:44:04 +0000 | |||
1544 | @@ -37,10 +37,14 @@ | |||
1545 | 37 | class DeviceLauncherSection : public sigc::trackable | 37 | class DeviceLauncherSection : public sigc::trackable |
1546 | 38 | { | 38 | { |
1547 | 39 | public: | 39 | public: |
1548 | 40 | typedef std::shared_ptr<DeviceLauncherSection> Ptr; | ||
1549 | 41 | |||
1550 | 40 | DeviceLauncherSection(AbstractVolumeMonitorWrapper::Ptr const& volume_monitor = nullptr, | 42 | DeviceLauncherSection(AbstractVolumeMonitorWrapper::Ptr const& volume_monitor = nullptr, |
1551 | 41 | DevicesSettings::Ptr const& devices_settings = nullptr, | 43 | DevicesSettings::Ptr const& devices_settings = nullptr, |
1552 | 42 | DeviceNotificationDisplay::Ptr const& notifications = nullptr); | 44 | DeviceNotificationDisplay::Ptr const& notifications = nullptr); |
1553 | 43 | 45 | ||
1554 | 46 | virtual ~DeviceLauncherSection() = default; | ||
1555 | 47 | |||
1556 | 44 | std::vector<VolumeLauncherIcon::Ptr> GetIcons() const; | 48 | std::vector<VolumeLauncherIcon::Ptr> GetIcons() const; |
1557 | 45 | 49 | ||
1558 | 46 | sigc::signal<void, AbstractLauncherIcon::Ptr const&> icon_added; | 50 | sigc::signal<void, AbstractLauncherIcon::Ptr const&> icon_added; |
1559 | 47 | 51 | ||
1560 | === added file 'launcher/FileManagerLauncherIcon.cpp' | |||
1561 | --- launcher/FileManagerLauncherIcon.cpp 1970-01-01 00:00:00 +0000 | |||
1562 | +++ launcher/FileManagerLauncherIcon.cpp 2016-02-09 10:44:04 +0000 | |||
1563 | @@ -0,0 +1,128 @@ | |||
1564 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
1565 | 2 | /* | ||
1566 | 3 | * Copyright (C) 2015 Canonical Ltd | ||
1567 | 4 | * | ||
1568 | 5 | * This program is free software: you can redistribute it and/or modify | ||
1569 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
1570 | 7 | * published by the Free Software Foundation. | ||
1571 | 8 | * | ||
1572 | 9 | * This program is distributed in the hope that it will be useful, | ||
1573 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1574 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1575 | 12 | * GNU General Public License for more details. | ||
1576 | 13 | * | ||
1577 | 14 | * You should have received a copy of the GNU General Public License | ||
1578 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1579 | 16 | * | ||
1580 | 17 | * Authored by: Marco Trevisan <marco.trevisan@canonical.com> | ||
1581 | 18 | */ | ||
1582 | 19 | |||
1583 | 20 | #include "FileManagerLauncherIcon.h" | ||
1584 | 21 | |||
1585 | 22 | #include <boost/algorithm/string.hpp> | ||
1586 | 23 | #include <NuxCore/Logger.h> | ||
1587 | 24 | #include <UnityCore/DesktopUtilities.h> | ||
1588 | 25 | |||
1589 | 26 | #include "unity-shared/GnomeFileManager.h" | ||
1590 | 27 | |||
1591 | 28 | namespace unity | ||
1592 | 29 | { | ||
1593 | 30 | namespace launcher | ||
1594 | 31 | { | ||
1595 | 32 | namespace | ||
1596 | 33 | { | ||
1597 | 34 | DECLARE_LOGGER(logger, "unity.launcher.icon.filemanager"); | ||
1598 | 35 | const std::string TRASH_URI = "trash:"; | ||
1599 | 36 | const std::string TRASH_PATH = "file://" + DesktopUtilities::GetUserTrashDirectory(); | ||
1600 | 37 | const std::string DEFAULT_ICON = "system-file-manager"; | ||
1601 | 38 | } | ||
1602 | 39 | |||
1603 | 40 | FileManagerLauncherIcon::FileManagerLauncherIcon(ApplicationPtr const& app, DeviceLauncherSection::Ptr const& dev, FileManager::Ptr const& fm) | ||
1604 | 41 | : WindowedLauncherIcon(IconType::APPLICATION) | ||
1605 | 42 | , ApplicationLauncherIcon(app) | ||
1606 | 43 | , StorageLauncherIcon(GetIconType(), fm ? fm : GnomeFileManager::Get()) | ||
1607 | 44 | , devices_(dev) | ||
1608 | 45 | { | ||
1609 | 46 | // We disconnect from ApplicationLauncherIcon app signals, as we manage them manually | ||
1610 | 47 | signals_conn_.Clear(); | ||
1611 | 48 | |||
1612 | 49 | signals_conn_.Add(app_->desktop_file.changed.connect([this](std::string const& desktop_file) { | ||
1613 | 50 | LOG_DEBUG(logger) << tooltip_text() << " desktop_file now " << desktop_file; | ||
1614 | 51 | UpdateDesktopFile(); | ||
1615 | 52 | })); | ||
1616 | 53 | |||
1617 | 54 | signals_conn_.Add(app_->closed.connect([this] { | ||
1618 | 55 | LOG_DEBUG(logger) << tooltip_text() << " closed"; | ||
1619 | 56 | OnApplicationClosed(); | ||
1620 | 57 | })); | ||
1621 | 58 | |||
1622 | 59 | signals_conn_.Add(app_->title.changed.connect([this](std::string const& name) { | ||
1623 | 60 | LOG_DEBUG(logger) << tooltip_text() << " name now " << name; | ||
1624 | 61 | menu_items_.clear(); | ||
1625 | 62 | tooltip_text = name; | ||
1626 | 63 | })); | ||
1627 | 64 | |||
1628 | 65 | signals_conn_.Add(app_->icon.changed.connect([this](std::string const& icon) { | ||
1629 | 66 | LOG_DEBUG(logger) << tooltip_text() << " icon now " << icon; | ||
1630 | 67 | icon_name = (icon.empty() ? DEFAULT_ICON : icon); | ||
1631 | 68 | })); | ||
1632 | 69 | |||
1633 | 70 | UpdateStorageWindows(); | ||
1634 | 71 | } | ||
1635 | 72 | |||
1636 | 73 | void FileManagerLauncherIcon::Focus(ActionArg arg) | ||
1637 | 74 | { | ||
1638 | 75 | WindowedLauncherIcon::Focus(arg); | ||
1639 | 76 | } | ||
1640 | 77 | |||
1641 | 78 | void FileManagerLauncherIcon::Quit() const | ||
1642 | 79 | { | ||
1643 | 80 | WindowedLauncherIcon::Quit(); | ||
1644 | 81 | } | ||
1645 | 82 | |||
1646 | 83 | bool FileManagerLauncherIcon::IsLocationManaged(std::string const& location) const | ||
1647 | 84 | { | ||
1648 | 85 | if (location.empty()) | ||
1649 | 86 | return true; | ||
1650 | 87 | |||
1651 | 88 | if (boost::algorithm::starts_with(location, TRASH_URI)) | ||
1652 | 89 | return false; | ||
1653 | 90 | |||
1654 | 91 | if (boost::algorithm::starts_with(location, TRASH_PATH)) | ||
1655 | 92 | return false; | ||
1656 | 93 | |||
1657 | 94 | for (auto const& volume_icon : devices_->GetIcons()) | ||
1658 | 95 | { | ||
1659 | 96 | auto const& volume_uri = volume_icon->GetVolumeUri(); | ||
1660 | 97 | if (!volume_uri.empty() && boost::algorithm::starts_with(location, volume_uri)) | ||
1661 | 98 | return false; | ||
1662 | 99 | } | ||
1663 | 100 | |||
1664 | 101 | return true; | ||
1665 | 102 | } | ||
1666 | 103 | |||
1667 | 104 | WindowList FileManagerLauncherIcon::GetManagedWindows() const | ||
1668 | 105 | { | ||
1669 | 106 | return StorageLauncherIcon::GetManagedWindows(); | ||
1670 | 107 | } | ||
1671 | 108 | |||
1672 | 109 | WindowList FileManagerLauncherIcon::GetStorageWindows() const | ||
1673 | 110 | { | ||
1674 | 111 | WindowList fm_windows; | ||
1675 | 112 | |||
1676 | 113 | for (auto const& app_win : ApplicationLauncherIcon::GetManagedWindows()) | ||
1677 | 114 | { | ||
1678 | 115 | if (IsLocationManaged(file_manager_->LocationForWindow(app_win))) | ||
1679 | 116 | fm_windows.push_back(app_win); | ||
1680 | 117 | } | ||
1681 | 118 | |||
1682 | 119 | return fm_windows; | ||
1683 | 120 | } | ||
1684 | 121 | |||
1685 | 122 | bool FileManagerLauncherIcon::OnShouldHighlightOnDrag(DndData const& dnd_data) | ||
1686 | 123 | { | ||
1687 | 124 | return StorageLauncherIcon::OnShouldHighlightOnDrag(dnd_data); | ||
1688 | 125 | } | ||
1689 | 126 | |||
1690 | 127 | } // namespace launcher | ||
1691 | 128 | } // namespace unity | ||
1692 | 0 | 129 | ||
1693 | === added file 'launcher/FileManagerLauncherIcon.h' | |||
1694 | --- launcher/FileManagerLauncherIcon.h 1970-01-01 00:00:00 +0000 | |||
1695 | +++ launcher/FileManagerLauncherIcon.h 2016-02-09 10:44:04 +0000 | |||
1696 | @@ -0,0 +1,52 @@ | |||
1697 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
1698 | 2 | /* | ||
1699 | 3 | * Copyright (C) 2015 Canonical Ltd | ||
1700 | 4 | * | ||
1701 | 5 | * This program is free software: you can redistribute it and/or modify | ||
1702 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
1703 | 7 | * published by the Free Software Foundation. | ||
1704 | 8 | * | ||
1705 | 9 | * This program is distributed in the hope that it will be useful, | ||
1706 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1707 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1708 | 12 | * GNU General Public License for more details. | ||
1709 | 13 | * | ||
1710 | 14 | * You should have received a copy of the GNU General Public License | ||
1711 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1712 | 16 | * | ||
1713 | 17 | * Authored by: Marco Trevisan <marco.trevisan@canonical.com> | ||
1714 | 18 | */ | ||
1715 | 19 | |||
1716 | 20 | #ifndef FILEMANAGER_LAUNCHER_ICON_H | ||
1717 | 21 | #define FILEMANAGER_LAUNCHER_ICON_H | ||
1718 | 22 | |||
1719 | 23 | #include "ApplicationLauncherIcon.h" | ||
1720 | 24 | #include "StorageLauncherIcon.h" | ||
1721 | 25 | #include "DeviceLauncherSection.h" | ||
1722 | 26 | |||
1723 | 27 | namespace unity | ||
1724 | 28 | { | ||
1725 | 29 | namespace launcher | ||
1726 | 30 | { | ||
1727 | 31 | |||
1728 | 32 | class FileManagerLauncherIcon : public ApplicationLauncherIcon, public StorageLauncherIcon | ||
1729 | 33 | { | ||
1730 | 34 | public: | ||
1731 | 35 | FileManagerLauncherIcon(ApplicationPtr const&, DeviceLauncherSection::Ptr const&, FileManager::Ptr const& = nullptr); | ||
1732 | 36 | |||
1733 | 37 | private: | ||
1734 | 38 | WindowList GetManagedWindows() const override; | ||
1735 | 39 | WindowList GetStorageWindows() const override; | ||
1736 | 40 | void Focus(ActionArg arg) override; | ||
1737 | 41 | void Quit() const override; | ||
1738 | 42 | bool OnShouldHighlightOnDrag(DndData const& dnd_data) override; | ||
1739 | 43 | |||
1740 | 44 | bool IsLocationManaged(std::string const&) const; | ||
1741 | 45 | |||
1742 | 46 | DeviceLauncherSection::Ptr devices_; | ||
1743 | 47 | }; | ||
1744 | 48 | |||
1745 | 49 | } // namespace launcher | ||
1746 | 50 | } // namespace unity | ||
1747 | 51 | |||
1748 | 52 | #endif // FILEMANAGER_LAUNCHER_ICON_H | ||
1749 | 0 | 53 | ||
1750 | === modified file 'launcher/Launcher.cpp' | |||
1751 | --- launcher/Launcher.cpp 2015-07-07 16:54:46 +0000 | |||
1752 | +++ launcher/Launcher.cpp 2016-02-09 10:44:04 +0000 | |||
1753 | @@ -578,16 +578,9 @@ | |||
1754 | 578 | else | 578 | else |
1755 | 579 | { | 579 | { |
1756 | 580 | if (options()->show_for_all) | 580 | if (options()->show_for_all) |
1758 | 581 | arg.window_indicators = std::max<int> (icon->WindowsOnViewport().size(), 1); | 581 | arg.window_indicators = std::max<int>(icon->WindowsVisibleOnViewport(), 1); |
1759 | 582 | else | 582 | else |
1768 | 583 | arg.window_indicators = std::max<int> (icon->WindowsForMonitor(monitor).size(), 1); | 583 | arg.window_indicators = std::max<int>(icon->WindowsVisibleOnMonitor(monitor), 1); |
1761 | 584 | |||
1762 | 585 | if (icon->GetIconType() == AbstractLauncherIcon::IconType::TRASH || | ||
1763 | 586 | icon->GetIconType() == AbstractLauncherIcon::IconType::DEVICE) | ||
1764 | 587 | { | ||
1765 | 588 | // TODO: also these icons should respect the actual windows they have | ||
1766 | 589 | arg.window_indicators = 0; | ||
1767 | 590 | } | ||
1769 | 591 | } | 584 | } |
1770 | 592 | 585 | ||
1771 | 593 | arg.backlight_intensity = IconBackgroundIntensity(icon); | 586 | arg.backlight_intensity = IconBackgroundIntensity(icon); |
1772 | 594 | 587 | ||
1773 | === modified file 'launcher/LauncherController.cpp' | |||
1774 | --- launcher/LauncherController.cpp 2015-12-11 12:44:27 +0000 | |||
1775 | +++ launcher/LauncherController.cpp 2016-02-09 10:44:04 +0000 | |||
1776 | @@ -21,6 +21,7 @@ | |||
1777 | 21 | 21 | ||
1778 | 22 | #include "config.h" | 22 | #include "config.h" |
1779 | 23 | #include <glib/gi18n-lib.h> | 23 | #include <glib/gi18n-lib.h> |
1780 | 24 | #include <boost/algorithm/string.hpp> | ||
1781 | 24 | 25 | ||
1782 | 25 | #include <Nux/Nux.h> | 26 | #include <Nux/Nux.h> |
1783 | 26 | #include <Nux/HLayout.h> | 27 | #include <Nux/HLayout.h> |
1784 | @@ -32,6 +33,7 @@ | |||
1785 | 32 | #include "DesktopLauncherIcon.h" | 33 | #include "DesktopLauncherIcon.h" |
1786 | 33 | #include "VolumeLauncherIcon.h" | 34 | #include "VolumeLauncherIcon.h" |
1787 | 34 | #include "FavoriteStore.h" | 35 | #include "FavoriteStore.h" |
1788 | 36 | #include "FileManagerLauncherIcon.h" | ||
1789 | 35 | #include "HudLauncherIcon.h" | 37 | #include "HudLauncherIcon.h" |
1790 | 36 | #include "LauncherController.h" | 38 | #include "LauncherController.h" |
1791 | 37 | #include "LauncherControllerPrivate.h" | 39 | #include "LauncherControllerPrivate.h" |
1792 | @@ -102,13 +104,13 @@ | |||
1793 | 102 | 104 | ||
1794 | 103 | return FavoriteStore::URI_PREFIX_APP + DesktopUtilities::GetDesktopID(desktop_path); | 105 | return FavoriteStore::URI_PREFIX_APP + DesktopUtilities::GetDesktopID(desktop_path); |
1795 | 104 | } | 106 | } |
1796 | 105 | |||
1797 | 106 | } | 107 | } |
1798 | 107 | 108 | ||
1799 | 108 | Controller::Impl::Impl(Controller* parent, XdndManager::Ptr const& xdnd_manager, ui::EdgeBarrierController::Ptr const& edge_barriers) | 109 | Controller::Impl::Impl(Controller* parent, XdndManager::Ptr const& xdnd_manager, ui::EdgeBarrierController::Ptr const& edge_barriers) |
1800 | 109 | : parent_(parent) | 110 | : parent_(parent) |
1801 | 110 | , model_(std::make_shared<LauncherModel>()) | 111 | , model_(std::make_shared<LauncherModel>()) |
1802 | 111 | , xdnd_manager_(xdnd_manager) | 112 | , xdnd_manager_(xdnd_manager) |
1803 | 113 | , device_section_(std::make_shared<DeviceLauncherSection>()) | ||
1804 | 112 | , expo_icon_(new ExpoLauncherIcon()) | 114 | , expo_icon_(new ExpoLauncherIcon()) |
1805 | 113 | , desktop_icon_(new DesktopLauncherIcon()) | 115 | , desktop_icon_(new DesktopLauncherIcon()) |
1806 | 114 | , edge_barriers_(edge_barriers) | 116 | , edge_barriers_(edge_barriers) |
1807 | @@ -342,6 +344,21 @@ | |||
1808 | 342 | return launcher; | 344 | return launcher; |
1809 | 343 | } | 345 | } |
1810 | 344 | 346 | ||
1811 | 347 | ApplicationLauncherIcon* Controller::Impl::CreateAppLauncherIcon(ApplicationPtr const& app) | ||
1812 | 348 | { | ||
1813 | 349 | auto const& desktop_file = app->desktop_file(); | ||
1814 | 350 | |||
1815 | 351 | if (boost::algorithm::ends_with(desktop_file, "org.gnome.Nautilus.desktop") || | ||
1816 | 352 | boost::algorithm::ends_with(desktop_file, "nautilus.desktop") || | ||
1817 | 353 | boost::algorithm::ends_with(desktop_file, "nautilus-folder-handler.desktop") || | ||
1818 | 354 | boost::algorithm::ends_with(desktop_file, "nautilus-home.desktop")) | ||
1819 | 355 | { | ||
1820 | 356 | return new FileManagerLauncherIcon(app, device_section_); | ||
1821 | 357 | } | ||
1822 | 358 | |||
1823 | 359 | return new ApplicationLauncherIcon(app); | ||
1824 | 360 | } | ||
1825 | 361 | |||
1826 | 345 | void Controller::Impl::OnLauncherAddRequest(std::string const& icon_uri, AbstractLauncherIcon::Ptr const& icon_before) | 362 | void Controller::Impl::OnLauncherAddRequest(std::string const& icon_uri, AbstractLauncherIcon::Ptr const& icon_before) |
1827 | 346 | { | 363 | { |
1828 | 347 | std::string app_uri; | 364 | std::string app_uri; |
1829 | @@ -838,7 +855,7 @@ | |||
1830 | 838 | if (app->sticky() || app->seen()) | 855 | if (app->sticky() || app->seen()) |
1831 | 839 | return; | 856 | return; |
1832 | 840 | 857 | ||
1834 | 841 | AbstractLauncherIcon::Ptr icon(new ApplicationLauncherIcon(app)); | 858 | AbstractLauncherIcon::Ptr icon(CreateAppLauncherIcon(app)); |
1835 | 842 | RegisterIcon(icon, GetLastIconPriority<ApplicationLauncherIcon>(local::RUNNING_APPS_URI)); | 859 | RegisterIcon(icon, GetLastIconPriority<ApplicationLauncherIcon>(local::RUNNING_APPS_URI)); |
1836 | 843 | } | 860 | } |
1837 | 844 | 861 | ||
1838 | @@ -875,11 +892,11 @@ | |||
1839 | 875 | if (!app || app->seen()) | 892 | if (!app || app->seen()) |
1840 | 876 | return result; | 893 | return result; |
1841 | 877 | 894 | ||
1843 | 878 | result = AbstractLauncherIcon::Ptr(new ApplicationLauncherIcon(app)); | 895 | result = AbstractLauncherIcon::Ptr(CreateAppLauncherIcon(app)); |
1844 | 879 | } | 896 | } |
1845 | 880 | else if (icon_uri.find(FavoriteStore::URI_PREFIX_DEVICE) == 0) | 897 | else if (icon_uri.find(FavoriteStore::URI_PREFIX_DEVICE) == 0) |
1846 | 881 | { | 898 | { |
1848 | 882 | auto const& devices = device_section_.GetIcons(); | 899 | auto const& devices = device_section_->GetIcons(); |
1849 | 883 | auto const& icon = std::find_if(devices.begin(), devices.end(), | 900 | auto const& icon = std::find_if(devices.begin(), devices.end(), |
1850 | 884 | [&icon_uri](AbstractLauncherIcon::Ptr const& i) { return (i->RemoteUri() == icon_uri); }); | 901 | [&icon_uri](AbstractLauncherIcon::Ptr const& i) { return (i->RemoteUri() == icon_uri); }); |
1851 | 885 | 902 | ||
1852 | @@ -954,7 +971,7 @@ | |||
1853 | 954 | << (app->seen() ? "yes" : "no"); | 971 | << (app->seen() ? "yes" : "no"); |
1854 | 955 | if (!app->seen()) | 972 | if (!app->seen()) |
1855 | 956 | { | 973 | { |
1857 | 957 | AbstractLauncherIcon::Ptr icon(new ApplicationLauncherIcon(app)); | 974 | AbstractLauncherIcon::Ptr icon(CreateAppLauncherIcon(app)); |
1858 | 958 | icon->SkipQuirkAnimation(AbstractLauncherIcon::Quirk::VISIBLE); | 975 | icon->SkipQuirkAnimation(AbstractLauncherIcon::Quirk::VISIBLE); |
1859 | 959 | RegisterIcon(icon, ++sort_priority_); | 976 | RegisterIcon(icon, ++sort_priority_); |
1860 | 960 | } | 977 | } |
1861 | @@ -964,7 +981,7 @@ | |||
1862 | 964 | void Controller::Impl::AddDevices() | 981 | void Controller::Impl::AddDevices() |
1863 | 965 | { | 982 | { |
1864 | 966 | auto& fav_store = FavoriteStore::Instance(); | 983 | auto& fav_store = FavoriteStore::Instance(); |
1866 | 967 | for (auto const& icon : device_section_.GetIcons()) | 984 | for (auto const& icon : device_section_->GetIcons()) |
1867 | 968 | { | 985 | { |
1868 | 969 | if (!icon->IsSticky() && !fav_store.IsFavorite(icon->RemoteUri())) | 986 | if (!icon->IsSticky() && !fav_store.IsFavorite(icon->RemoteUri())) |
1869 | 970 | { | 987 | { |
1870 | @@ -1044,7 +1061,7 @@ | |||
1871 | 1044 | ApplicationManager::Default().application_started | 1061 | ApplicationManager::Default().application_started |
1872 | 1045 | .connect(sigc::mem_fun(this, &Impl::OnApplicationStarted)); | 1062 | .connect(sigc::mem_fun(this, &Impl::OnApplicationStarted)); |
1873 | 1046 | 1063 | ||
1875 | 1047 | device_section_.icon_added.connect(sigc::mem_fun(this, &Impl::OnDeviceIconAdded)); | 1064 | device_section_->icon_added.connect(sigc::mem_fun(this, &Impl::OnDeviceIconAdded)); |
1876 | 1048 | favorite_store.favorite_added.connect(sigc::mem_fun(this, &Impl::OnFavoriteStoreFavoriteAdded)); | 1065 | favorite_store.favorite_added.connect(sigc::mem_fun(this, &Impl::OnFavoriteStoreFavoriteAdded)); |
1877 | 1049 | favorite_store.favorite_removed.connect(sigc::mem_fun(this, &Impl::OnFavoriteStoreFavoriteRemoved)); | 1066 | favorite_store.favorite_removed.connect(sigc::mem_fun(this, &Impl::OnFavoriteStoreFavoriteRemoved)); |
1878 | 1050 | favorite_store.reordered.connect(sigc::mem_fun(this, &Impl::ResetIconPriorities)); | 1067 | favorite_store.reordered.connect(sigc::mem_fun(this, &Impl::ResetIconPriorities)); |
1879 | 1051 | 1068 | ||
1880 | === modified file 'launcher/LauncherControllerPrivate.h' | |||
1881 | --- launcher/LauncherControllerPrivate.h 2015-04-16 14:38:54 +0000 | |||
1882 | +++ launcher/LauncherControllerPrivate.h 2016-02-09 10:44:04 +0000 | |||
1883 | @@ -87,6 +87,7 @@ | |||
1884 | 87 | 87 | ||
1885 | 88 | void RegisterIcon(AbstractLauncherIcon::Ptr const& icon, int priority = std::numeric_limits<int>::min()); | 88 | void RegisterIcon(AbstractLauncherIcon::Ptr const& icon, int priority = std::numeric_limits<int>::min()); |
1886 | 89 | 89 | ||
1887 | 90 | ApplicationLauncherIcon* CreateAppLauncherIcon(ApplicationPtr const&); | ||
1888 | 90 | AbstractLauncherIcon::Ptr CreateFavoriteIcon(std::string const& icon_uri, bool emit_signal = false); | 91 | AbstractLauncherIcon::Ptr CreateFavoriteIcon(std::string const& icon_uri, bool emit_signal = false); |
1889 | 91 | AbstractLauncherIcon::Ptr GetIconByUri(std::string const& icon_uri); | 92 | AbstractLauncherIcon::Ptr GetIconByUri(std::string const& icon_uri); |
1890 | 92 | SoftwareCenterLauncherIcon::Ptr CreateSCLauncherIcon(std::string const& file_path, std::string const& aptdaemon_trans_id, std::string const& icon_path); | 93 | SoftwareCenterLauncherIcon::Ptr CreateSCLauncherIcon(std::string const& file_path, std::string const& aptdaemon_trans_id, std::string const& icon_path); |
1891 | @@ -122,7 +123,7 @@ | |||
1892 | 122 | nux::ObjectPtr<Launcher> launcher_; | 123 | nux::ObjectPtr<Launcher> launcher_; |
1893 | 123 | nux::ObjectPtr<Launcher> keyboard_launcher_; | 124 | nux::ObjectPtr<Launcher> keyboard_launcher_; |
1894 | 124 | XdndManager::Ptr xdnd_manager_; | 125 | XdndManager::Ptr xdnd_manager_; |
1896 | 125 | DeviceLauncherSection device_section_; | 126 | DeviceLauncherSection::Ptr device_section_; |
1897 | 126 | LauncherEntryRemoteModel remote_model_; | 127 | LauncherEntryRemoteModel remote_model_; |
1898 | 127 | AbstractLauncherIcon::Ptr expo_icon_; | 128 | AbstractLauncherIcon::Ptr expo_icon_; |
1899 | 128 | AbstractLauncherIcon::Ptr desktop_icon_; | 129 | AbstractLauncherIcon::Ptr desktop_icon_; |
1900 | 129 | 130 | ||
1901 | === modified file 'launcher/LauncherIcon.cpp' | |||
1902 | --- launcher/LauncherIcon.cpp 2015-11-02 18:08:08 +0000 | |||
1903 | +++ launcher/LauncherIcon.cpp 2016-02-09 10:44:04 +0000 | |||
1904 | @@ -150,16 +150,26 @@ | |||
1905 | 150 | QuicklistManager::Default()->RegisterQuicklist(_quicklist); | 150 | QuicklistManager::Default()->RegisterQuicklist(_quicklist); |
1906 | 151 | } | 151 | } |
1907 | 152 | 152 | ||
1909 | 153 | const bool LauncherIcon::WindowVisibleOnMonitor(int monitor) | 153 | bool LauncherIcon::WindowVisibleOnMonitor(int monitor) const |
1910 | 154 | { | 154 | { |
1911 | 155 | return _has_visible_window[monitor]; | 155 | return _has_visible_window[monitor]; |
1912 | 156 | } | 156 | } |
1913 | 157 | 157 | ||
1915 | 158 | const bool LauncherIcon::WindowVisibleOnViewport() | 158 | bool LauncherIcon::WindowVisibleOnViewport() const |
1916 | 159 | { | 159 | { |
1917 | 160 | return _has_visible_window.any(); | 160 | return _has_visible_window.any(); |
1918 | 161 | } | 161 | } |
1919 | 162 | 162 | ||
1920 | 163 | size_t LauncherIcon::WindowsVisibleOnMonitor(int monitor) const | ||
1921 | 164 | { | ||
1922 | 165 | return _number_of_visible_windows[monitor]; | ||
1923 | 166 | } | ||
1924 | 167 | |||
1925 | 168 | size_t LauncherIcon::WindowsVisibleOnViewport() const | ||
1926 | 169 | { | ||
1927 | 170 | return std::accumulate(begin(_number_of_visible_windows), end(_number_of_visible_windows), 0); | ||
1928 | 171 | } | ||
1929 | 172 | |||
1930 | 163 | std::string | 173 | std::string |
1931 | 164 | LauncherIcon::GetName() const | 174 | LauncherIcon::GetName() const |
1932 | 165 | { | 175 | { |
1933 | 166 | 176 | ||
1934 | === modified file 'launcher/LauncherIcon.h' | |||
1935 | --- launcher/LauncherIcon.h 2015-11-02 18:08:08 +0000 | |||
1936 | +++ launcher/LauncherIcon.h 2016-02-09 10:44:04 +0000 | |||
1937 | @@ -82,7 +82,7 @@ | |||
1938 | 82 | 82 | ||
1939 | 83 | nux::Point3 GetCenter(int monitor); | 83 | nux::Point3 GetCenter(int monitor); |
1940 | 84 | 84 | ||
1942 | 85 | virtual void Activate(ActionArg arg); | 85 | void Activate(ActionArg arg); |
1943 | 86 | 86 | ||
1944 | 87 | void OpenInstance(ActionArg arg); | 87 | void OpenInstance(ActionArg arg); |
1945 | 88 | 88 | ||
1946 | @@ -94,15 +94,19 @@ | |||
1947 | 94 | 94 | ||
1948 | 95 | void SetOrder(int order); | 95 | void SetOrder(int order); |
1949 | 96 | 96 | ||
1959 | 97 | virtual WindowList Windows() { return WindowList(); } | 97 | WindowList Windows() { return WindowList(); } |
1960 | 98 | 98 | ||
1961 | 99 | virtual std::vector<Window> WindowsOnViewport() { return std::vector<Window> (); } | 99 | WindowList WindowsOnViewport() { return WindowList(); } |
1962 | 100 | 100 | ||
1963 | 101 | virtual std::vector<Window> WindowsForMonitor(int monitor) { return std::vector<Window> (); } | 101 | WindowList WindowsForMonitor(int monitor) { return WindowList(); } |
1964 | 102 | 102 | ||
1965 | 103 | const bool WindowVisibleOnMonitor(int monitor); | 103 | bool WindowVisibleOnMonitor(int monitor) const; |
1966 | 104 | 104 | ||
1967 | 105 | const bool WindowVisibleOnViewport(); | 105 | bool WindowVisibleOnViewport() const; |
1968 | 106 | |||
1969 | 107 | size_t WindowsVisibleOnMonitor(int monitor) const; | ||
1970 | 108 | |||
1971 | 109 | size_t WindowsVisibleOnViewport() const; | ||
1972 | 106 | 110 | ||
1973 | 107 | float PresentUrgency(); | 111 | float PresentUrgency(); |
1974 | 108 | 112 | ||
1975 | 109 | 113 | ||
1976 | === modified file 'launcher/MockLauncherIcon.h' | |||
1977 | --- launcher/MockLauncherIcon.h 2015-10-05 16:52:24 +0000 | |||
1978 | +++ launcher/MockLauncherIcon.h 2016-02-09 10:44:04 +0000 | |||
1979 | @@ -112,34 +112,34 @@ | |||
1980 | 112 | return result; | 112 | return result; |
1981 | 113 | } | 113 | } |
1982 | 114 | 114 | ||
1984 | 115 | std::vector<Window> WindowsOnViewport () | 115 | WindowList WindowsOnViewport() |
1985 | 116 | { | 116 | { |
1987 | 117 | std::vector<Window> result; | 117 | WindowList result; |
1988 | 118 | 118 | ||
1997 | 119 | result.push_back ((100 << 16) + 200); | 119 | result.push_back(std::make_shared<MockApplicationWindow>((100 << 16) + 200)); |
1998 | 120 | result.push_back ((500 << 16) + 200); | 120 | result.push_back(std::make_shared<MockApplicationWindow>((500 << 16) + 200)); |
1999 | 121 | result.push_back ((300 << 16) + 200); | 121 | result.push_back(std::make_shared<MockApplicationWindow>((300 << 16) + 200)); |
2000 | 122 | result.push_back ((200 << 16) + 200); | 122 | result.push_back(std::make_shared<MockApplicationWindow>((200 << 16) + 200)); |
2001 | 123 | result.push_back ((300 << 16) + 200); | 123 | result.push_back(std::make_shared<MockApplicationWindow>((300 << 16) + 200)); |
2002 | 124 | result.push_back ((100 << 16) + 200); | 124 | result.push_back(std::make_shared<MockApplicationWindow>((100 << 16) + 200)); |
2003 | 125 | result.push_back ((300 << 16) + 200); | 125 | result.push_back(std::make_shared<MockApplicationWindow>((300 << 16) + 200)); |
2004 | 126 | result.push_back ((600 << 16) + 200); | 126 | result.push_back(std::make_shared<MockApplicationWindow>((600 << 16) + 200)); |
2005 | 127 | 127 | ||
2006 | 128 | return result; | 128 | return result; |
2007 | 129 | } | 129 | } |
2008 | 130 | 130 | ||
2010 | 131 | std::vector<Window> WindowsForMonitor (int monitor) | 131 | WindowList WindowsForMonitor(int monitor) |
2011 | 132 | { | 132 | { |
2013 | 133 | std::vector<Window> result; | 133 | WindowList result; |
2014 | 134 | 134 | ||
2023 | 135 | result.push_back ((100 << 16) + 200); | 135 | result.push_back(std::make_shared<MockApplicationWindow>((100 << 16) + 200)); |
2024 | 136 | result.push_back ((500 << 16) + 200); | 136 | result.push_back(std::make_shared<MockApplicationWindow>((500 << 16) + 200)); |
2025 | 137 | result.push_back ((300 << 16) + 200); | 137 | result.push_back(std::make_shared<MockApplicationWindow>((300 << 16) + 200)); |
2026 | 138 | result.push_back ((200 << 16) + 200); | 138 | result.push_back(std::make_shared<MockApplicationWindow>((200 << 16) + 200)); |
2027 | 139 | result.push_back ((300 << 16) + 200); | 139 | result.push_back(std::make_shared<MockApplicationWindow>((300 << 16) + 200)); |
2028 | 140 | result.push_back ((100 << 16) + 200); | 140 | result.push_back(std::make_shared<MockApplicationWindow>((100 << 16) + 200)); |
2029 | 141 | result.push_back ((300 << 16) + 200); | 141 | result.push_back(std::make_shared<MockApplicationWindow>((300 << 16) + 200)); |
2030 | 142 | result.push_back ((600 << 16) + 200); | 142 | result.push_back(std::make_shared<MockApplicationWindow>((600 << 16) + 200)); |
2031 | 143 | 143 | ||
2032 | 144 | return result; | 144 | return result; |
2033 | 145 | } | 145 | } |
2034 | @@ -194,14 +194,24 @@ | |||
2035 | 194 | return 7; | 194 | return 7; |
2036 | 195 | } | 195 | } |
2037 | 196 | 196 | ||
2046 | 197 | const bool WindowVisibleOnViewport() | 197 | bool WindowVisibleOnViewport() const |
2047 | 198 | { | 198 | { |
2048 | 199 | return false; | 199 | return false; |
2049 | 200 | } | 200 | } |
2050 | 201 | 201 | ||
2051 | 202 | const bool WindowVisibleOnMonitor(int monitor) | 202 | bool WindowVisibleOnMonitor(int monitor) const |
2052 | 203 | { | 203 | { |
2053 | 204 | return false; | 204 | return false; |
2054 | 205 | } | ||
2055 | 206 | |||
2056 | 207 | size_t WindowsVisibleOnMonitor(int monitor) const | ||
2057 | 208 | { | ||
2058 | 209 | return 0; | ||
2059 | 210 | } | ||
2060 | 211 | |||
2061 | 212 | size_t WindowsVisibleOnViewport() const | ||
2062 | 213 | { | ||
2063 | 214 | return 0; | ||
2064 | 205 | } | 215 | } |
2065 | 206 | 216 | ||
2066 | 207 | void SetVisibleOnMonitor(int monitor, bool visible) {} | 217 | void SetVisibleOnMonitor(int monitor, bool visible) {} |
2067 | 208 | 218 | ||
2068 | === modified file 'launcher/SoftwareCenterLauncherIcon.cpp' | |||
2069 | --- launcher/SoftwareCenterLauncherIcon.cpp 2013-10-29 22:33:02 +0000 | |||
2070 | +++ launcher/SoftwareCenterLauncherIcon.cpp 2016-02-09 10:44:04 +0000 | |||
2071 | @@ -46,7 +46,8 @@ | |||
2072 | 46 | SoftwareCenterLauncherIcon::SoftwareCenterLauncherIcon(ApplicationPtr const& app, | 46 | SoftwareCenterLauncherIcon::SoftwareCenterLauncherIcon(ApplicationPtr const& app, |
2073 | 47 | std::string const& aptdaemon_trans_id, | 47 | std::string const& aptdaemon_trans_id, |
2074 | 48 | std::string const& icon_path) | 48 | std::string const& icon_path) |
2076 | 49 | : ApplicationLauncherIcon(app) | 49 | : WindowedLauncherIcon(IconType::APPLICATION) |
2077 | 50 | , ApplicationLauncherIcon(app) | ||
2078 | 50 | , aptdaemon_trans_(std::make_shared<glib::DBusProxy>("org.debian.apt", | 51 | , aptdaemon_trans_(std::make_shared<glib::DBusProxy>("org.debian.apt", |
2079 | 51 | aptdaemon_trans_id, | 52 | aptdaemon_trans_id, |
2080 | 52 | "org.debian.apt.transaction", | 53 | "org.debian.apt.transaction", |
2081 | 53 | 54 | ||
2082 | === added file 'launcher/StorageLauncherIcon.cpp' | |||
2083 | --- launcher/StorageLauncherIcon.cpp 1970-01-01 00:00:00 +0000 | |||
2084 | +++ launcher/StorageLauncherIcon.cpp 2016-02-09 10:44:04 +0000 | |||
2085 | @@ -0,0 +1,119 @@ | |||
2086 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
2087 | 2 | /* | ||
2088 | 3 | * Copyright (C) 2015 Canonical Ltd | ||
2089 | 4 | * | ||
2090 | 5 | * This program is free software: you can redistribute it and/or modify | ||
2091 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
2092 | 7 | * published by the Free Software Foundation. | ||
2093 | 8 | * | ||
2094 | 9 | * This program is distributed in the hope that it will be useful, | ||
2095 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2096 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2097 | 12 | * GNU General Public License for more details. | ||
2098 | 13 | * | ||
2099 | 14 | * You should have received a copy of the GNU General Public License | ||
2100 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2101 | 16 | * | ||
2102 | 17 | * Authored by: Marco Trevisan <marco.trevisan@canonical.com> | ||
2103 | 18 | */ | ||
2104 | 19 | |||
2105 | 20 | #include "StorageLauncherIcon.h" | ||
2106 | 21 | |||
2107 | 22 | namespace unity | ||
2108 | 23 | { | ||
2109 | 24 | namespace launcher | ||
2110 | 25 | { | ||
2111 | 26 | |||
2112 | 27 | StorageLauncherIcon::StorageLauncherIcon(AbstractLauncherIcon::IconType icon_type, FileManager::Ptr const& fm) | ||
2113 | 28 | : WindowedLauncherIcon(icon_type) | ||
2114 | 29 | , file_manager_(fm) | ||
2115 | 30 | { | ||
2116 | 31 | file_manager_->locations_changed.connect(sigc::mem_fun(this, &StorageLauncherIcon::UpdateStorageWindows)); | ||
2117 | 32 | } | ||
2118 | 33 | |||
2119 | 34 | void StorageLauncherIcon::UpdateStorageWindows() | ||
2120 | 35 | { | ||
2121 | 36 | bool active = false; | ||
2122 | 37 | bool urgent = false; | ||
2123 | 38 | bool check_visibility = (GetIconType() == IconType::APPLICATION); | ||
2124 | 39 | bool visible = IsSticky(); | ||
2125 | 40 | |||
2126 | 41 | managed_windows_ = GetStorageWindows(); | ||
2127 | 42 | windows_connections_.Clear(); | ||
2128 | 43 | |||
2129 | 44 | for (auto const& win : managed_windows_) | ||
2130 | 45 | { | ||
2131 | 46 | windows_connections_.Add(win->monitor.changed.connect([this] (int) { EnsureWindowsLocation(); })); | ||
2132 | 47 | windows_connections_.Add(win->urgent.changed.connect([this] (bool) { OnWindowStateChanged(); })); | ||
2133 | 48 | windows_connections_.Add(win->active.changed.connect([this] (bool) { OnWindowStateChanged(); })); | ||
2134 | 49 | windows_connections_.Add(win->closed.connect([this] { UpdateStorageWindows(); })); | ||
2135 | 50 | |||
2136 | 51 | if (!active && win->active()) | ||
2137 | 52 | active = true; | ||
2138 | 53 | |||
2139 | 54 | if (!urgent && win->urgent()) | ||
2140 | 55 | urgent = true; | ||
2141 | 56 | |||
2142 | 57 | if (check_visibility) | ||
2143 | 58 | { | ||
2144 | 59 | windows_connections_.Add(win->visible.changed.connect([this] (bool) { OnWindowStateChanged(); })); | ||
2145 | 60 | |||
2146 | 61 | if (!visible && win->visible()) | ||
2147 | 62 | visible = true; | ||
2148 | 63 | } | ||
2149 | 64 | } | ||
2150 | 65 | |||
2151 | 66 | SetQuirk(Quirk::RUNNING, !managed_windows_.empty()); | ||
2152 | 67 | SetQuirk(Quirk::ACTIVE, active); | ||
2153 | 68 | SetQuirk(Quirk::URGENT, urgent); | ||
2154 | 69 | |||
2155 | 70 | if (check_visibility) | ||
2156 | 71 | SetQuirk(Quirk::VISIBLE, visible); | ||
2157 | 72 | |||
2158 | 73 | EnsureWindowsLocation(); | ||
2159 | 74 | } | ||
2160 | 75 | |||
2161 | 76 | WindowList StorageLauncherIcon::GetManagedWindows() const | ||
2162 | 77 | { | ||
2163 | 78 | return managed_windows_; | ||
2164 | 79 | } | ||
2165 | 80 | |||
2166 | 81 | void StorageLauncherIcon::OnWindowStateChanged() | ||
2167 | 82 | { | ||
2168 | 83 | bool active = false; | ||
2169 | 84 | bool urgent = false; | ||
2170 | 85 | bool check_visibility = (GetIconType() == IconType::APPLICATION); | ||
2171 | 86 | bool visible = IsSticky(); | ||
2172 | 87 | |||
2173 | 88 | for (auto const& win : managed_windows_) | ||
2174 | 89 | { | ||
2175 | 90 | if (!active && win->active()) | ||
2176 | 91 | active = true; | ||
2177 | 92 | |||
2178 | 93 | if (!urgent && win->urgent()) | ||
2179 | 94 | urgent = true; | ||
2180 | 95 | |||
2181 | 96 | if (check_visibility && !visible && win->visible()) | ||
2182 | 97 | visible = true; | ||
2183 | 98 | } | ||
2184 | 99 | |||
2185 | 100 | SetQuirk(Quirk::ACTIVE, active); | ||
2186 | 101 | SetQuirk(Quirk::URGENT, urgent); | ||
2187 | 102 | |||
2188 | 103 | if (check_visibility) | ||
2189 | 104 | SetQuirk(Quirk::VISIBLE, visible); | ||
2190 | 105 | } | ||
2191 | 106 | |||
2192 | 107 | bool StorageLauncherIcon::OnShouldHighlightOnDrag(DndData const& dnd_data) | ||
2193 | 108 | { | ||
2194 | 109 | for (auto const& uri : dnd_data.Uris()) | ||
2195 | 110 | { | ||
2196 | 111 | if (uri.find("file://") == 0) | ||
2197 | 112 | return true; | ||
2198 | 113 | } | ||
2199 | 114 | |||
2200 | 115 | return false; | ||
2201 | 116 | } | ||
2202 | 117 | |||
2203 | 118 | } // namespace launcher | ||
2204 | 119 | } // namespace unity | ||
2205 | 0 | 120 | ||
2206 | === added file 'launcher/StorageLauncherIcon.h' | |||
2207 | --- launcher/StorageLauncherIcon.h 1970-01-01 00:00:00 +0000 | |||
2208 | +++ launcher/StorageLauncherIcon.h 2016-02-09 10:44:04 +0000 | |||
2209 | @@ -0,0 +1,55 @@ | |||
2210 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
2211 | 2 | /* | ||
2212 | 3 | * Copyright (C) 2015 Canonical Ltd | ||
2213 | 4 | * | ||
2214 | 5 | * This program is free software: you can redistribute it and/or modify | ||
2215 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
2216 | 7 | * published by the Free Software Foundation. | ||
2217 | 8 | * | ||
2218 | 9 | * This program is distributed in the hope that it will be useful, | ||
2219 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2220 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2221 | 12 | * GNU General Public License for more details. | ||
2222 | 13 | * | ||
2223 | 14 | * You should have received a copy of the GNU General Public License | ||
2224 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2225 | 16 | * | ||
2226 | 17 | * Authored by: Marco Trevisan <marco.trevisan@canonical.com> | ||
2227 | 18 | */ | ||
2228 | 19 | |||
2229 | 20 | #ifndef STORAGE_LAUNCHER_ICON_H | ||
2230 | 21 | #define STORAGE_LAUNCHER_ICON_H | ||
2231 | 22 | |||
2232 | 23 | #include "WindowedLauncherIcon.h" | ||
2233 | 24 | #include "unity-shared/FileManager.h" | ||
2234 | 25 | |||
2235 | 26 | namespace unity | ||
2236 | 27 | { | ||
2237 | 28 | namespace launcher | ||
2238 | 29 | { | ||
2239 | 30 | |||
2240 | 31 | class StorageLauncherIcon : public virtual WindowedLauncherIcon | ||
2241 | 32 | { | ||
2242 | 33 | public: | ||
2243 | 34 | StorageLauncherIcon(AbstractLauncherIcon::IconType, FileManager::Ptr const&); | ||
2244 | 35 | |||
2245 | 36 | protected: | ||
2246 | 37 | void UpdateStorageWindows(); | ||
2247 | 38 | WindowList GetManagedWindows() const override; | ||
2248 | 39 | virtual WindowList GetStorageWindows() const = 0; | ||
2249 | 40 | |||
2250 | 41 | bool OnShouldHighlightOnDrag(DndData const& dnd_data) override; | ||
2251 | 42 | |||
2252 | 43 | private: | ||
2253 | 44 | void OnWindowStateChanged(); | ||
2254 | 45 | |||
2255 | 46 | protected: | ||
2256 | 47 | FileManager::Ptr file_manager_; | ||
2257 | 48 | WindowList managed_windows_; | ||
2258 | 49 | connection::Manager windows_connections_; | ||
2259 | 50 | }; | ||
2260 | 51 | |||
2261 | 52 | } // namespace launcher | ||
2262 | 53 | } // namespace unity | ||
2263 | 54 | |||
2264 | 55 | #endif // STORAGE_LAUNCHER_ICON_H | ||
2265 | 0 | 56 | ||
2266 | === modified file 'launcher/SwitcherController.cpp' | |||
2267 | --- launcher/SwitcherController.cpp 2015-12-16 02:16:57 +0000 | |||
2268 | +++ launcher/SwitcherController.cpp 2016-02-09 10:44:04 +0000 | |||
2269 | @@ -720,14 +720,11 @@ | |||
2270 | 720 | uint64_t second_first = 0; // second icons first highest active | 720 | uint64_t second_first = 0; // second icons first highest active |
2271 | 721 | 721 | ||
2272 | 722 | WindowManager& wm = WindowManager::Default(); | 722 | WindowManager& wm = WindowManager::Default(); |
2274 | 723 | for (auto& window : first->Windows()) | 723 | auto const& windows = (model_->only_apps_on_viewport) ? first->WindowsOnViewport() : first->Windows(); |
2275 | 724 | |||
2276 | 725 | for (auto& window : windows) | ||
2277 | 724 | { | 726 | { |
2284 | 725 | Window xid = window->window_id(); | 727 | uint64_t num = wm.GetWindowActiveNumber(window->window_id()); |
2279 | 726 | |||
2280 | 727 | if (model_->only_apps_on_viewport && !wm.IsWindowOnCurrentDesktop(xid)) | ||
2281 | 728 | continue; | ||
2282 | 729 | |||
2283 | 730 | uint64_t num = wm.GetWindowActiveNumber(xid); | ||
2285 | 731 | 728 | ||
2286 | 732 | if (num > first_highest) | 729 | if (num > first_highest) |
2287 | 733 | { | 730 | { |
2288 | 734 | 731 | ||
2289 | === modified file 'launcher/SwitcherModel.cpp' | |||
2290 | --- launcher/SwitcherModel.cpp 2015-12-16 02:16:57 +0000 | |||
2291 | +++ launcher/SwitcherModel.cpp 2016-02-09 10:44:04 +0000 | |||
2292 | @@ -37,16 +37,7 @@ | |||
2293 | 37 | bool CompareSwitcherItemsPriority(AbstractLauncherIcon::Ptr const& first, | 37 | bool CompareSwitcherItemsPriority(AbstractLauncherIcon::Ptr const& first, |
2294 | 38 | AbstractLauncherIcon::Ptr const& second) | 38 | AbstractLauncherIcon::Ptr const& second) |
2295 | 39 | { | 39 | { |
2306 | 40 | if (first->GetIconType() == second->GetIconType()) | 40 | return first->SwitcherPriority() > second->SwitcherPriority(); |
2297 | 41 | return first->SwitcherPriority() > second->SwitcherPriority(); | ||
2298 | 42 | |||
2299 | 43 | if (first->GetIconType() == AbstractLauncherIcon::IconType::DESKTOP) | ||
2300 | 44 | return true; | ||
2301 | 45 | |||
2302 | 46 | if (second->GetIconType() == AbstractLauncherIcon::IconType::DESKTOP) | ||
2303 | 47 | return false; | ||
2304 | 48 | |||
2305 | 49 | return first->GetIconType() < second->GetIconType(); | ||
2307 | 50 | } | 41 | } |
2308 | 51 | } | 42 | } |
2309 | 52 | 43 | ||
2310 | @@ -174,7 +165,7 @@ | |||
2311 | 174 | 165 | ||
2312 | 175 | void SwitcherModel::AddIcon(AbstractLauncherIcon::Ptr const& icon) | 166 | void SwitcherModel::AddIcon(AbstractLauncherIcon::Ptr const& icon) |
2313 | 176 | { | 167 | { |
2315 | 177 | if (!icon || icon->GetIconType() != AbstractLauncherIcon::IconType::APPLICATION) | 168 | if (!icon) |
2316 | 178 | return; | 169 | return; |
2317 | 179 | 170 | ||
2318 | 180 | if (icon->ShowInSwitcher(only_apps_on_viewport)) | 171 | if (icon->ShowInSwitcher(only_apps_on_viewport)) |
2319 | 181 | 172 | ||
2320 | === modified file 'launcher/SwitcherView.cpp' | |||
2321 | --- launcher/SwitcherView.cpp 2015-12-15 16:11:09 +0000 | |||
2322 | +++ launcher/SwitcherView.cpp 2016-02-09 10:44:04 +0000 | |||
2323 | @@ -538,7 +538,7 @@ | |||
2324 | 538 | // tells the renderer to render arrows by number | 538 | // tells the renderer to render arrows by number |
2325 | 539 | arg.running_on_viewport = true; | 539 | arg.running_on_viewport = true; |
2326 | 540 | 540 | ||
2328 | 541 | arg.window_indicators = icon->WindowsForMonitor(monitor).size(); | 541 | arg.window_indicators = icon->WindowsVisibleOnMonitor(monitor); |
2329 | 542 | if (arg.window_indicators > 1) | 542 | if (arg.window_indicators > 1) |
2330 | 543 | arg.running_arrow = true; | 543 | arg.running_arrow = true; |
2331 | 544 | else | 544 | else |
2332 | 545 | 545 | ||
2333 | === modified file 'launcher/TrashLauncherIcon.cpp' | |||
2334 | --- launcher/TrashLauncherIcon.cpp 2014-04-16 01:24:47 +0000 | |||
2335 | +++ launcher/TrashLauncherIcon.cpp 2016-02-09 10:44:04 +0000 | |||
2336 | @@ -1,6 +1,6 @@ | |||
2337 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
2338 | 2 | /* | 2 | /* |
2340 | 3 | * Copyright (C) 2010-2013 Canonical Ltd | 3 | * Copyright (C) 2010-2015 Canonical Ltd |
2341 | 4 | * | 4 | * |
2342 | 5 | * This program is free software: you can redistribute it and/or modify | 5 | * This program is free software: you can redistribute it and/or modify |
2343 | 6 | * it under the terms of the GNU General Public License version 3 as | 6 | * it under the terms of the GNU General Public License version 3 as |
2344 | @@ -24,6 +24,7 @@ | |||
2345 | 24 | #include "config.h" | 24 | #include "config.h" |
2346 | 25 | #include <glib/gi18n-lib.h> | 25 | #include <glib/gi18n-lib.h> |
2347 | 26 | #include <NuxCore/Logger.h> | 26 | #include <NuxCore/Logger.h> |
2348 | 27 | #include <UnityCore/DesktopUtilities.h> | ||
2349 | 27 | #include <zeitgeist.h> | 28 | #include <zeitgeist.h> |
2350 | 28 | 29 | ||
2351 | 29 | #include "QuicklistMenuItemLabel.h" | 30 | #include "QuicklistMenuItemLabel.h" |
2352 | @@ -39,20 +40,19 @@ | |||
2353 | 39 | DECLARE_LOGGER(logger, "unity.launcher.icon.trash"); | 40 | DECLARE_LOGGER(logger, "unity.launcher.icon.trash"); |
2354 | 40 | const std::string ZEITGEIST_UNITY_ACTOR = "application://compiz.desktop"; | 41 | const std::string ZEITGEIST_UNITY_ACTOR = "application://compiz.desktop"; |
2355 | 41 | const std::string TRASH_URI = "trash:"; | 42 | const std::string TRASH_URI = "trash:"; |
2356 | 43 | const std::string TRASH_PATH = "file://" + DesktopUtilities::GetUserTrashDirectory(); | ||
2357 | 42 | } | 44 | } |
2358 | 43 | 45 | ||
2361 | 44 | TrashLauncherIcon::TrashLauncherIcon(FileManager::Ptr const& fmo) | 46 | TrashLauncherIcon::TrashLauncherIcon(FileManager::Ptr const& fm) |
2362 | 45 | : SimpleLauncherIcon(IconType::TRASH) | 47 | : WindowedLauncherIcon(IconType::TRASH) |
2363 | 48 | , StorageLauncherIcon(GetIconType(), fm ? fm : GnomeFileManager::Get()) | ||
2364 | 46 | , empty_(true) | 49 | , empty_(true) |
2365 | 47 | , file_manager_(fmo ? fmo : GnomeFileManager::Get()) | ||
2366 | 48 | { | 50 | { |
2367 | 49 | tooltip_text = _("Trash"); | 51 | tooltip_text = _("Trash"); |
2368 | 50 | icon_name = "user-trash"; | 52 | icon_name = "user-trash"; |
2369 | 51 | position = Position::END; | 53 | position = Position::END; |
2370 | 52 | SetQuirk(Quirk::VISIBLE, true); | 54 | SetQuirk(Quirk::VISIBLE, true); |
2371 | 53 | SkipQuirkAnimation(Quirk::VISIBLE); | 55 | SkipQuirkAnimation(Quirk::VISIBLE); |
2372 | 54 | |||
2373 | 55 | SetQuirk(Quirk::RUNNING, file_manager_->IsTrashOpened()); | ||
2374 | 56 | SetShortcut('t'); | 56 | SetShortcut('t'); |
2375 | 57 | 57 | ||
2376 | 58 | glib::Object<GFile> location(g_file_new_for_uri(TRASH_URI.c_str())); | 58 | glib::Object<GFile> location(g_file_new_for_uri(TRASH_URI.c_str())); |
2377 | @@ -67,20 +67,27 @@ | |||
2378 | 67 | } | 67 | } |
2379 | 68 | else | 68 | else |
2380 | 69 | { | 69 | { |
2382 | 70 | trash_changed_signal_.Connect(trash_monitor_, "changed", | 70 | glib_signals_.Add<void, GFileMonitor*, GFile*, GFile*, GFileMonitorEvent>(trash_monitor_, "changed", |
2383 | 71 | [this] (GFileMonitor*, GFile*, GFile*, GFileMonitorEvent) { | 71 | [this] (GFileMonitor*, GFile*, GFile*, GFileMonitorEvent) { |
2384 | 72 | UpdateTrashIcon(); | 72 | UpdateTrashIcon(); |
2385 | 73 | }); | 73 | }); |
2386 | 74 | } | 74 | } |
2387 | 75 | 75 | ||
2388 | 76 | file_manager_->locations_changed.connect(sigc::mem_fun(this, &TrashLauncherIcon::OnOpenedLocationsChanged)); | ||
2389 | 77 | |||
2390 | 78 | UpdateTrashIcon(); | 76 | UpdateTrashIcon(); |
2396 | 79 | } | 77 | UpdateStorageWindows(); |
2397 | 80 | 78 | } | |
2398 | 81 | void TrashLauncherIcon::OnOpenedLocationsChanged() | 79 | |
2399 | 82 | { | 80 | WindowList TrashLauncherIcon::GetStorageWindows() const |
2400 | 83 | SetQuirk(Quirk::RUNNING, file_manager_->IsTrashOpened()); | 81 | { |
2401 | 82 | auto windows = file_manager_->WindowsForLocation(TRASH_URI); | ||
2402 | 83 | auto const& path_wins = file_manager_->WindowsForLocation(TRASH_PATH); | ||
2403 | 84 | windows.insert(end(windows), begin(path_wins), end(path_wins)); | ||
2404 | 85 | return windows; | ||
2405 | 86 | } | ||
2406 | 87 | |||
2407 | 88 | void TrashLauncherIcon::OpenInstanceLauncherIcon(Time timestamp) | ||
2408 | 89 | { | ||
2409 | 90 | file_manager_->OpenTrash(timestamp); | ||
2410 | 84 | } | 91 | } |
2411 | 85 | 92 | ||
2412 | 86 | AbstractLauncherIcon::MenuItemsVector TrashLauncherIcon::GetMenus() | 93 | AbstractLauncherIcon::MenuItemsVector TrashLauncherIcon::GetMenus() |
2413 | @@ -92,22 +99,43 @@ | |||
2414 | 92 | dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Empty Trash…")); | 99 | dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Empty Trash…")); |
2415 | 93 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, !empty_); | 100 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, !empty_); |
2416 | 94 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); | 101 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); |
2418 | 95 | empty_activated_signal_.Connect(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, | 102 | glib_signals_.Add<void, DbusmenuMenuitem*, unsigned>(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, |
2419 | 96 | [this] (DbusmenuMenuitem*, unsigned timestamp) { | 103 | [this] (DbusmenuMenuitem*, unsigned timestamp) { |
2420 | 97 | file_manager_->EmptyTrash(timestamp); | 104 | file_manager_->EmptyTrash(timestamp); |
2421 | 98 | }); | 105 | }); |
2422 | 99 | 106 | ||
2423 | 100 | result.push_back(menu_item); | 107 | result.push_back(menu_item); |
2424 | 101 | 108 | ||
2425 | 109 | if (IsRunning()) | ||
2426 | 110 | { | ||
2427 | 111 | auto const& windows_items = GetWindowsMenuItems(); | ||
2428 | 112 | if (!windows_items.empty()) | ||
2429 | 113 | { | ||
2430 | 114 | menu_item = dbusmenu_menuitem_new(); | ||
2431 | 115 | dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); | ||
2432 | 116 | result.push_back(menu_item); | ||
2433 | 117 | |||
2434 | 118 | result.insert(end(result), begin(windows_items), end(windows_items)); | ||
2435 | 119 | } | ||
2436 | 120 | |||
2437 | 121 | menu_item = dbusmenu_menuitem_new(); | ||
2438 | 122 | dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); | ||
2439 | 123 | result.push_back(menu_item); | ||
2440 | 124 | |||
2441 | 125 | menu_item = dbusmenu_menuitem_new(); | ||
2442 | 126 | dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Quit")); | ||
2443 | 127 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true); | ||
2444 | 128 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); | ||
2445 | 129 | result.push_back(menu_item); | ||
2446 | 130 | |||
2447 | 131 | glib_signals_.Add<void, DbusmenuMenuitem*, unsigned>(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, [this] (DbusmenuMenuitem*, int) { | ||
2448 | 132 | Quit(); | ||
2449 | 133 | }); | ||
2450 | 134 | } | ||
2451 | 135 | |||
2452 | 102 | return result; | 136 | return result; |
2453 | 103 | } | 137 | } |
2454 | 104 | 138 | ||
2455 | 105 | void TrashLauncherIcon::ActivateLauncherIcon(ActionArg arg) | ||
2456 | 106 | { | ||
2457 | 107 | SimpleLauncherIcon::ActivateLauncherIcon(arg); | ||
2458 | 108 | file_manager_->OpenTrash(arg.timestamp); | ||
2459 | 109 | } | ||
2460 | 110 | |||
2461 | 111 | void TrashLauncherIcon::UpdateTrashIcon() | 139 | void TrashLauncherIcon::UpdateTrashIcon() |
2462 | 112 | { | 140 | { |
2463 | 113 | glib::Object<GFile> location(g_file_new_for_uri(TRASH_URI.c_str())); | 141 | glib::Object<GFile> location(g_file_new_for_uri(TRASH_URI.c_str())); |
2464 | 114 | 142 | ||
2465 | === modified file 'launcher/TrashLauncherIcon.h' | |||
2466 | --- launcher/TrashLauncherIcon.h 2013-04-03 20:45:58 +0000 | |||
2467 | +++ launcher/TrashLauncherIcon.h 2016-02-09 10:44:04 +0000 | |||
2468 | @@ -23,9 +23,10 @@ | |||
2469 | 23 | #include <gio/gio.h> | 23 | #include <gio/gio.h> |
2470 | 24 | #include <UnityCore/GLibWrapper.h> | 24 | #include <UnityCore/GLibWrapper.h> |
2471 | 25 | #include <UnityCore/GLibSignal.h> | 25 | #include <UnityCore/GLibSignal.h> |
2472 | 26 | #include <UnityCore/ConnectionManager.h> | ||
2473 | 26 | 27 | ||
2474 | 27 | #include "DndData.h" | 28 | #include "DndData.h" |
2476 | 28 | #include "SimpleLauncherIcon.h" | 29 | #include "StorageLauncherIcon.h" |
2477 | 29 | #include "unity-shared/FileManager.h" | 30 | #include "unity-shared/FileManager.h" |
2478 | 30 | 31 | ||
2479 | 31 | namespace unity | 32 | namespace unity |
2480 | @@ -33,7 +34,7 @@ | |||
2481 | 33 | namespace launcher | 34 | namespace launcher |
2482 | 34 | { | 35 | { |
2483 | 35 | 36 | ||
2485 | 36 | class TrashLauncherIcon : public SimpleLauncherIcon | 37 | class TrashLauncherIcon : public StorageLauncherIcon |
2486 | 37 | { | 38 | { |
2487 | 38 | public: | 39 | public: |
2488 | 39 | TrashLauncherIcon(FileManager::Ptr const& = nullptr); | 40 | TrashLauncherIcon(FileManager::Ptr const& = nullptr); |
2489 | @@ -45,21 +46,18 @@ | |||
2490 | 45 | bool OnShouldHighlightOnDrag(DndData const& dnd_data); | 46 | bool OnShouldHighlightOnDrag(DndData const& dnd_data); |
2491 | 46 | void OnAcceptDrop(DndData const& dnd_data); | 47 | void OnAcceptDrop(DndData const& dnd_data); |
2492 | 47 | 48 | ||
2493 | 49 | WindowList GetStorageWindows() const override; | ||
2494 | 48 | std::string GetName() const; | 50 | std::string GetName() const; |
2495 | 49 | 51 | ||
2496 | 50 | private: | 52 | private: |
2499 | 51 | void ActivateLauncherIcon(ActionArg arg); | 53 | void OpenInstanceLauncherIcon(Time timestamp) override; |
2498 | 52 | void OnOpenedLocationsChanged(); | ||
2500 | 53 | MenuItemsVector GetMenus(); | 54 | MenuItemsVector GetMenus(); |
2501 | 54 | 55 | ||
2502 | 55 | static void UpdateTrashIconCb(GObject* source, GAsyncResult* res, gpointer data); | 56 | static void UpdateTrashIconCb(GObject* source, GAsyncResult* res, gpointer data); |
2503 | 56 | 57 | ||
2504 | 57 | bool empty_; | 58 | bool empty_; |
2505 | 58 | FileManager::Ptr file_manager_; | ||
2506 | 59 | glib::Cancellable cancellable_; | 59 | glib::Cancellable cancellable_; |
2507 | 60 | glib::Object<GFileMonitor> trash_monitor_; | 60 | glib::Object<GFileMonitor> trash_monitor_; |
2508 | 61 | glib::Signal<void, GFileMonitor*, GFile*, GFile*, GFileMonitorEvent> trash_changed_signal_; | ||
2509 | 62 | glib::Signal<void, DbusmenuMenuitem*, unsigned> empty_activated_signal_; | ||
2510 | 63 | }; | 61 | }; |
2511 | 64 | 62 | ||
2512 | 65 | } | 63 | } |
2513 | 66 | 64 | ||
2514 | === modified file 'launcher/VolumeLauncherIcon.cpp' | |||
2515 | --- launcher/VolumeLauncherIcon.cpp 2015-01-22 15:05:34 +0000 | |||
2516 | +++ launcher/VolumeLauncherIcon.cpp 2016-02-09 10:44:04 +0000 | |||
2517 | @@ -49,7 +49,7 @@ | |||
2518 | 49 | , volume_(volume) | 49 | , volume_(volume) |
2519 | 50 | , devices_settings_(devices_settings) | 50 | , devices_settings_(devices_settings) |
2520 | 51 | , notification_(notification) | 51 | , notification_(notification) |
2522 | 52 | , file_manager_(fm) | 52 | , file_manager_(parent_->file_manager_) |
2523 | 53 | { | 53 | { |
2524 | 54 | UpdateIcon(); | 54 | UpdateIcon(); |
2525 | 55 | UpdateVisibility(); | 55 | UpdateVisibility(); |
2526 | @@ -60,48 +60,41 @@ | |||
2527 | 60 | { | 60 | { |
2528 | 61 | parent_->tooltip_text = volume_->GetName(); | 61 | parent_->tooltip_text = volume_->GetName(); |
2529 | 62 | parent_->icon_name = volume_->GetIconName(); | 62 | parent_->icon_name = volume_->GetIconName(); |
2530 | 63 | parent_->SetQuirk(Quirk::RUNNING, file_manager_->IsPrefixOpened(volume_->GetUri())); | ||
2531 | 64 | } | 63 | } |
2532 | 65 | 64 | ||
2533 | 66 | void UpdateVisibility() | 65 | void UpdateVisibility() |
2534 | 67 | { | 66 | { |
2543 | 68 | UpdateKeepInLauncher(); | 67 | parent_->SetQuirk(Quirk::VISIBLE, IsVisible()); |
2544 | 69 | parent_->SetQuirk(Quirk::VISIBLE, keep_in_launcher_); | 68 | } |
2545 | 70 | } | 69 | |
2546 | 71 | 70 | bool IsBlackListed() | |
2547 | 72 | void UpdateKeepInLauncher() | 71 | { |
2548 | 73 | { | 72 | return devices_settings_->IsABlacklistedDevice(volume_->GetIdentifier()); |
2549 | 74 | auto const& identifier = volume_->GetIdentifier(); | 73 | } |
2550 | 75 | keep_in_launcher_ = !devices_settings_->IsABlacklistedDevice(identifier); | 74 | |
2551 | 75 | bool IsVisible() | ||
2552 | 76 | { | ||
2553 | 77 | if (IsBlackListed() && parent_->GetManagedWindows().empty()) | ||
2554 | 78 | return false; | ||
2555 | 79 | |||
2556 | 80 | return true; | ||
2557 | 76 | } | 81 | } |
2558 | 77 | 82 | ||
2559 | 78 | void ConnectSignals() | 83 | void ConnectSignals() |
2560 | 79 | { | 84 | { |
2562 | 80 | connections_.Add(volume_->changed.connect(sigc::mem_fun(this, &Impl::OnVolumeChanged))); | 85 | connections_.Add(volume_->changed.connect([this] { UpdateIcon(); })); |
2563 | 81 | connections_.Add(volume_->removed.connect(sigc::mem_fun(this, &Impl::OnVolumeRemoved))); | 86 | connections_.Add(volume_->removed.connect(sigc::mem_fun(this, &Impl::OnVolumeRemoved))); |
2571 | 82 | connections_.Add(devices_settings_->changed.connect(sigc::mem_fun(this, &Impl::OnSettingsChanged))); | 87 | connections_.Add(devices_settings_->changed.connect([this] { UpdateVisibility(); })); |
2572 | 83 | connections_.Add(file_manager_->locations_changed.connect(sigc::mem_fun(this, &Impl::UpdateIcon))); | 88 | connections_.Add(parent_->windows_changed.connect([this] (int) { UpdateVisibility(); })); |
2566 | 84 | } | ||
2567 | 85 | |||
2568 | 86 | void OnVolumeChanged() | ||
2569 | 87 | { | ||
2570 | 88 | UpdateIcon(); | ||
2573 | 89 | } | 89 | } |
2574 | 90 | 90 | ||
2575 | 91 | void OnVolumeRemoved() | 91 | void OnVolumeRemoved() |
2576 | 92 | { | 92 | { |
2580 | 93 | if (devices_settings_->IsABlacklistedDevice(volume_->GetIdentifier())) | 93 | devices_settings_->TryToUnblacklist(volume_->GetIdentifier()); |
2578 | 94 | devices_settings_->TryToUnblacklist(volume_->GetIdentifier()); | ||
2579 | 95 | |||
2581 | 96 | parent_->UnStick(); | 94 | parent_->UnStick(); |
2582 | 97 | parent_->Remove(); | 95 | parent_->Remove(); |
2583 | 98 | } | 96 | } |
2584 | 99 | 97 | ||
2585 | 100 | void OnSettingsChanged() | ||
2586 | 101 | { | ||
2587 | 102 | UpdateVisibility(); | ||
2588 | 103 | } | ||
2589 | 104 | |||
2590 | 105 | bool CanEject() const | 98 | bool CanEject() const |
2591 | 106 | { | 99 | { |
2592 | 107 | return volume_->CanBeEjected(); | 100 | return volume_->CanBeEjected(); |
2593 | @@ -152,7 +145,7 @@ | |||
2594 | 152 | void OpenInFileManager(uint64_t timestamp) | 145 | void OpenInFileManager(uint64_t timestamp) |
2595 | 153 | { | 146 | { |
2596 | 154 | DoActionWhenMounted([this, timestamp] { | 147 | DoActionWhenMounted([this, timestamp] { |
2598 | 155 | file_manager_->OpenActiveChild(volume_->GetUri(), timestamp); | 148 | file_manager_->Open(volume_->GetUri(), timestamp); |
2599 | 156 | }); | 149 | }); |
2600 | 157 | } | 150 | } |
2601 | 158 | 151 | ||
2602 | @@ -171,29 +164,38 @@ | |||
2603 | 171 | AppendSeparatorItem(result); | 164 | AppendSeparatorItem(result); |
2604 | 172 | AppendNameItem(result); | 165 | AppendNameItem(result); |
2605 | 173 | AppendSeparatorItem(result); | 166 | AppendSeparatorItem(result); |
2607 | 174 | AppendUnlockFromLauncherItem(result); | 167 | AppendWindowsItems(result); |
2608 | 168 | AppendToggleLockFromLauncherItem(result); | ||
2609 | 175 | AppendEjectItem(result); | 169 | AppendEjectItem(result); |
2610 | 176 | AppendSafelyRemoveItem(result); | 170 | AppendSafelyRemoveItem(result); |
2611 | 177 | AppendUnmountItem(result); | 171 | AppendUnmountItem(result); |
2612 | 172 | AppendQuitItem(result); | ||
2613 | 178 | 173 | ||
2614 | 179 | return result; | 174 | return result; |
2615 | 180 | } | 175 | } |
2616 | 181 | 176 | ||
2618 | 182 | void AppendUnlockFromLauncherItem(MenuItemsVector& menu) | 177 | void AppendToggleLockFromLauncherItem(MenuItemsVector& menu) |
2619 | 183 | { | 178 | { |
2620 | 184 | if (volume_->GetIdentifier().empty()) | 179 | if (volume_->GetIdentifier().empty()) |
2621 | 185 | return; | 180 | return; |
2622 | 186 | 181 | ||
2623 | 187 | glib::Object<DbusmenuMenuitem> menu_item(dbusmenu_menuitem_new()); | 182 | glib::Object<DbusmenuMenuitem> menu_item(dbusmenu_menuitem_new()); |
2624 | 188 | 183 | ||
2626 | 189 | dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Unlock from Launcher")); | 184 | const char* label = IsBlackListed() ? _("Lock to Launcher") : _("Unlock from Launcher"); |
2627 | 185 | dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_LABEL, label); | ||
2628 | 190 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true); | 186 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true); |
2629 | 191 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); | 187 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); |
2630 | 192 | 188 | ||
2635 | 193 | gsignals_.Add(new ItemSignal(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, [this] (DbusmenuMenuitem*, int) { | 189 | parent_->glib_signals_.Add(new ItemSignal(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, [this] (DbusmenuMenuitem*, int) { |
2636 | 194 | auto const& identifier = volume_->GetIdentifier(); | 190 | if (!IsBlackListed()) |
2637 | 195 | parent_->UnStick(); | 191 | { |
2638 | 196 | devices_settings_->TryToBlacklist(identifier); | 192 | parent_->UnStick(); |
2639 | 193 | devices_settings_->TryToBlacklist(volume_->GetIdentifier()); | ||
2640 | 194 | } | ||
2641 | 195 | else | ||
2642 | 196 | { | ||
2643 | 197 | devices_settings_->TryToUnblacklist(volume_->GetIdentifier()); | ||
2644 | 198 | } | ||
2645 | 197 | })); | 199 | })); |
2646 | 198 | 200 | ||
2647 | 199 | menu.push_back(menu_item); | 201 | menu.push_back(menu_item); |
2648 | @@ -220,13 +222,26 @@ | |||
2649 | 220 | dbusmenu_menuitem_property_set_bool(menu_item, QuicklistMenuItem::MARKUP_ENABLED_PROPERTY, true); | 222 | dbusmenu_menuitem_property_set_bool(menu_item, QuicklistMenuItem::MARKUP_ENABLED_PROPERTY, true); |
2650 | 221 | dbusmenu_menuitem_property_set_bool(menu_item, QuicklistMenuItem::MARKUP_ACCEL_DISABLED_PROPERTY, true); | 223 | dbusmenu_menuitem_property_set_bool(menu_item, QuicklistMenuItem::MARKUP_ACCEL_DISABLED_PROPERTY, true); |
2651 | 222 | 224 | ||
2653 | 223 | gsignals_.Add(new ItemSignal(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, [this] (DbusmenuMenuitem*, unsigned timestamp) { | 225 | parent_->glib_signals_.Add(new ItemSignal(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, [this] (DbusmenuMenuitem*, unsigned timestamp) { |
2654 | 224 | OpenInFileManager(timestamp); | 226 | OpenInFileManager(timestamp); |
2655 | 225 | })); | 227 | })); |
2656 | 226 | 228 | ||
2657 | 227 | menu.push_back(menu_item); | 229 | menu.push_back(menu_item); |
2658 | 228 | } | 230 | } |
2659 | 229 | 231 | ||
2660 | 232 | void AppendWindowsItems(MenuItemsVector& menu) | ||
2661 | 233 | { | ||
2662 | 234 | if (!parent_->IsRunning()) | ||
2663 | 235 | return; | ||
2664 | 236 | |||
2665 | 237 | auto const& windows_items = parent_->GetWindowsMenuItems(); | ||
2666 | 238 | if (!windows_items.empty()) | ||
2667 | 239 | { | ||
2668 | 240 | menu.insert(end(menu), begin(windows_items), end(windows_items)); | ||
2669 | 241 | AppendSeparatorItem(menu); | ||
2670 | 242 | } | ||
2671 | 243 | } | ||
2672 | 244 | |||
2673 | 230 | void AppendOpenItem(MenuItemsVector& menu) | 245 | void AppendOpenItem(MenuItemsVector& menu) |
2674 | 231 | { | 246 | { |
2675 | 232 | glib::Object<DbusmenuMenuitem> menu_item(dbusmenu_menuitem_new()); | 247 | glib::Object<DbusmenuMenuitem> menu_item(dbusmenu_menuitem_new()); |
2676 | @@ -235,7 +250,7 @@ | |||
2677 | 235 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true); | 250 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true); |
2678 | 236 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); | 251 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); |
2679 | 237 | 252 | ||
2681 | 238 | gsignals_.Add(new ItemSignal(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, [this] (DbusmenuMenuitem*, unsigned timestamp) { | 253 | parent_->glib_signals_.Add(new ItemSignal(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, [this] (DbusmenuMenuitem*, unsigned timestamp) { |
2682 | 239 | OpenInFileManager(timestamp); | 254 | OpenInFileManager(timestamp); |
2683 | 240 | })); | 255 | })); |
2684 | 241 | 256 | ||
2685 | @@ -253,7 +268,8 @@ | |||
2686 | 253 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true); | 268 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true); |
2687 | 254 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); | 269 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); |
2688 | 255 | 270 | ||
2690 | 256 | gsignals_.Add(new ItemSignal(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, [this] (DbusmenuMenuitem*, int) { | 271 | parent_->glib_signals_.Add(new ItemSignal(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, [this] (DbusmenuMenuitem*, int) { |
2691 | 272 | parent_->Quit(); | ||
2692 | 257 | EjectAndShowNotification(); | 273 | EjectAndShowNotification(); |
2693 | 258 | })); | 274 | })); |
2694 | 259 | 275 | ||
2695 | @@ -271,8 +287,9 @@ | |||
2696 | 271 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true); | 287 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true); |
2697 | 272 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); | 288 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); |
2698 | 273 | 289 | ||
2701 | 274 | gsignals_.Add(new ItemSignal(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, [this] (DbusmenuMenuitem*, int) { | 290 | parent_->glib_signals_.Add(new ItemSignal(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, [this] (DbusmenuMenuitem*, int) { |
2702 | 275 | volume_->StopDrive(); | 291 | parent_->Quit(); |
2703 | 292 | volume_->StopDrive(); | ||
2704 | 276 | })); | 293 | })); |
2705 | 277 | 294 | ||
2706 | 278 | menu.push_back(menu_item); | 295 | menu.push_back(menu_item); |
2707 | @@ -289,8 +306,29 @@ | |||
2708 | 289 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true); | 306 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true); |
2709 | 290 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); | 307 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); |
2710 | 291 | 308 | ||
2713 | 292 | gsignals_.Add(new ItemSignal(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, [this] (DbusmenuMenuitem*, int) { | 309 | parent_->glib_signals_.Add(new ItemSignal(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, [this] (DbusmenuMenuitem*, int) { |
2714 | 293 | volume_->Unmount(); | 310 | volume_->Unmount(); |
2715 | 311 | })); | ||
2716 | 312 | |||
2717 | 313 | menu.push_back(menu_item); | ||
2718 | 314 | } | ||
2719 | 315 | |||
2720 | 316 | void AppendQuitItem(MenuItemsVector& menu) | ||
2721 | 317 | { | ||
2722 | 318 | if (!parent_->IsRunning()) | ||
2723 | 319 | return; | ||
2724 | 320 | |||
2725 | 321 | if (!menu.empty()) | ||
2726 | 322 | AppendSeparatorItem(menu); | ||
2727 | 323 | |||
2728 | 324 | glib::Object<DbusmenuMenuitem> menu_item(dbusmenu_menuitem_new()); | ||
2729 | 325 | |||
2730 | 326 | dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Quit")); | ||
2731 | 327 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true); | ||
2732 | 328 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); | ||
2733 | 329 | |||
2734 | 330 | parent_->glib_signals_.Add(new ItemSignal(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, [this] (DbusmenuMenuitem*, int) { | ||
2735 | 331 | parent_->Quit(); | ||
2736 | 294 | })); | 332 | })); |
2737 | 295 | 333 | ||
2738 | 296 | menu.push_back(menu_item); | 334 | menu.push_back(menu_item); |
2739 | @@ -307,13 +345,10 @@ | |||
2740 | 307 | } | 345 | } |
2741 | 308 | 346 | ||
2742 | 309 | VolumeLauncherIcon* parent_; | 347 | VolumeLauncherIcon* parent_; |
2743 | 310 | bool keep_in_launcher_; | ||
2744 | 311 | Volume::Ptr volume_; | 348 | Volume::Ptr volume_; |
2745 | 312 | DevicesSettings::Ptr devices_settings_; | 349 | DevicesSettings::Ptr devices_settings_; |
2746 | 313 | DeviceNotificationDisplay::Ptr notification_; | 350 | DeviceNotificationDisplay::Ptr notification_; |
2747 | 314 | FileManager::Ptr file_manager_; | 351 | FileManager::Ptr file_manager_; |
2748 | 315 | |||
2749 | 316 | glib::SignalManager gsignals_; | ||
2750 | 317 | connection::Manager connections_; | 352 | connection::Manager connections_; |
2751 | 318 | }; | 353 | }; |
2752 | 319 | 354 | ||
2753 | @@ -325,15 +360,20 @@ | |||
2754 | 325 | DevicesSettings::Ptr const& devices_settings, | 360 | DevicesSettings::Ptr const& devices_settings, |
2755 | 326 | DeviceNotificationDisplay::Ptr const& notification, | 361 | DeviceNotificationDisplay::Ptr const& notification, |
2756 | 327 | FileManager::Ptr const& fm) | 362 | FileManager::Ptr const& fm) |
2758 | 328 | : SimpleLauncherIcon(IconType::DEVICE) | 363 | : WindowedLauncherIcon(IconType::DEVICE) |
2759 | 364 | , StorageLauncherIcon(GetIconType(), fm) | ||
2760 | 329 | , pimpl_(new Impl(volume, devices_settings, notification, fm, this)) | 365 | , pimpl_(new Impl(volume, devices_settings, notification, fm, this)) |
2762 | 330 | {} | 366 | { |
2763 | 367 | UpdateStorageWindows(); | ||
2764 | 368 | } | ||
2765 | 331 | 369 | ||
2766 | 332 | VolumeLauncherIcon::~VolumeLauncherIcon() | 370 | VolumeLauncherIcon::~VolumeLauncherIcon() |
2767 | 333 | {} | 371 | {} |
2768 | 334 | 372 | ||
2769 | 335 | void VolumeLauncherIcon::AboutToRemove() | 373 | void VolumeLauncherIcon::AboutToRemove() |
2770 | 336 | { | 374 | { |
2771 | 375 | StorageLauncherIcon::AboutToRemove(); | ||
2772 | 376 | |||
2773 | 337 | if (CanEject()) | 377 | if (CanEject()) |
2774 | 338 | EjectAndShowNotification(); | 378 | EjectAndShowNotification(); |
2775 | 339 | else if (CanStop()) | 379 | else if (CanStop()) |
2776 | @@ -360,12 +400,6 @@ | |||
2777 | 360 | return pimpl_->StopDrive(); | 400 | return pimpl_->StopDrive(); |
2778 | 361 | } | 401 | } |
2779 | 362 | 402 | ||
2780 | 363 | void VolumeLauncherIcon::ActivateLauncherIcon(ActionArg arg) | ||
2781 | 364 | { | ||
2782 | 365 | SimpleLauncherIcon::ActivateLauncherIcon(arg); | ||
2783 | 366 | pimpl_->OpenInFileManager(arg.timestamp); | ||
2784 | 367 | } | ||
2785 | 368 | |||
2786 | 369 | AbstractLauncherIcon::MenuItemsVector VolumeLauncherIcon::GetMenus() | 403 | AbstractLauncherIcon::MenuItemsVector VolumeLauncherIcon::GetMenus() |
2787 | 370 | { | 404 | { |
2788 | 371 | return pimpl_->GetMenus(); | 405 | return pimpl_->GetMenus(); |
2789 | @@ -388,17 +422,6 @@ | |||
2790 | 388 | SetQuirk(Quirk::VISIBLE, true); | 422 | SetQuirk(Quirk::VISIBLE, true); |
2791 | 389 | } | 423 | } |
2792 | 390 | 424 | ||
2793 | 391 | bool VolumeLauncherIcon::OnShouldHighlightOnDrag(DndData const& dnd_data) | ||
2794 | 392 | { | ||
2795 | 393 | for (auto const& uri : dnd_data.Uris()) | ||
2796 | 394 | { | ||
2797 | 395 | if (uri.find("file://") == 0) | ||
2798 | 396 | return true; | ||
2799 | 397 | } | ||
2800 | 398 | |||
2801 | 399 | return false; | ||
2802 | 400 | } | ||
2803 | 401 | |||
2804 | 402 | nux::DndAction VolumeLauncherIcon::OnQueryAcceptDrop(DndData const& dnd_data) | 425 | nux::DndAction VolumeLauncherIcon::OnQueryAcceptDrop(DndData const& dnd_data) |
2805 | 403 | { | 426 | { |
2806 | 404 | return dnd_data.Uris().empty() ? nux::DNDACTION_NONE : nux::DNDACTION_COPY; | 427 | return dnd_data.Uris().empty() ? nux::DNDACTION_NONE : nux::DNDACTION_COPY; |
2807 | @@ -412,6 +435,21 @@ | |||
2808 | 412 | FullyAnimateQuirkDelayed(100, LauncherIcon::Quirk::SHIMMER); | 435 | FullyAnimateQuirkDelayed(100, LauncherIcon::Quirk::SHIMMER); |
2809 | 413 | } | 436 | } |
2810 | 414 | 437 | ||
2811 | 438 | std::string VolumeLauncherIcon::GetVolumeUri() const | ||
2812 | 439 | { | ||
2813 | 440 | return pimpl_->volume_->GetUri(); | ||
2814 | 441 | } | ||
2815 | 442 | |||
2816 | 443 | WindowList VolumeLauncherIcon::GetStorageWindows() const | ||
2817 | 444 | { | ||
2818 | 445 | return file_manager_->WindowsForLocation(GetVolumeUri()); | ||
2819 | 446 | } | ||
2820 | 447 | |||
2821 | 448 | void VolumeLauncherIcon::OpenInstanceLauncherIcon(Time timestamp) | ||
2822 | 449 | { | ||
2823 | 450 | pimpl_->OpenInFileManager(timestamp); | ||
2824 | 451 | } | ||
2825 | 452 | |||
2826 | 415 | // | 453 | // |
2827 | 416 | // Introspection | 454 | // Introspection |
2828 | 417 | // | 455 | // |
2829 | 418 | 456 | ||
2830 | === modified file 'launcher/VolumeLauncherIcon.h' | |||
2831 | --- launcher/VolumeLauncherIcon.h 2013-10-07 18:33:47 +0000 | |||
2832 | +++ launcher/VolumeLauncherIcon.h 2016-02-09 10:44:04 +0000 | |||
2833 | @@ -24,7 +24,7 @@ | |||
2834 | 24 | #include "Volume.h" | 24 | #include "Volume.h" |
2835 | 25 | #include "DevicesSettings.h" | 25 | #include "DevicesSettings.h" |
2836 | 26 | #include "DeviceNotificationDisplay.h" | 26 | #include "DeviceNotificationDisplay.h" |
2838 | 27 | #include "SimpleLauncherIcon.h" | 27 | #include "StorageLauncherIcon.h" |
2839 | 28 | #include "unity-shared/FileManager.h" | 28 | #include "unity-shared/FileManager.h" |
2840 | 29 | 29 | ||
2841 | 30 | namespace unity | 30 | namespace unity |
2842 | @@ -32,7 +32,7 @@ | |||
2843 | 32 | namespace launcher | 32 | namespace launcher |
2844 | 33 | { | 33 | { |
2845 | 34 | 34 | ||
2847 | 35 | class VolumeLauncherIcon : public SimpleLauncherIcon | 35 | class VolumeLauncherIcon : public StorageLauncherIcon |
2848 | 36 | { | 36 | { |
2849 | 37 | public: | 37 | public: |
2850 | 38 | typedef nux::ObjectPtr<VolumeLauncherIcon> Ptr; | 38 | typedef nux::ObjectPtr<VolumeLauncherIcon> Ptr; |
2851 | @@ -41,7 +41,7 @@ | |||
2852 | 41 | DeviceNotificationDisplay::Ptr const&, FileManager::Ptr const&); | 41 | DeviceNotificationDisplay::Ptr const&, FileManager::Ptr const&); |
2853 | 42 | virtual ~VolumeLauncherIcon(); | 42 | virtual ~VolumeLauncherIcon(); |
2854 | 43 | 43 | ||
2856 | 44 | virtual void AboutToRemove(); | 44 | void AboutToRemove() override; |
2857 | 45 | 45 | ||
2858 | 46 | bool CanEject() const; // TODO: rename to public virtual bool IsTrashable(); | 46 | bool CanEject() const; // TODO: rename to public virtual bool IsTrashable(); |
2859 | 47 | void EjectAndShowNotification(); // TODO: rename to private virtual void DoDropToTrash(); | 47 | void EjectAndShowNotification(); // TODO: rename to private virtual void DoDropToTrash(); |
2860 | @@ -49,14 +49,16 @@ | |||
2861 | 49 | void StopDrive(); | 49 | void StopDrive(); |
2862 | 50 | void Stick(bool save = true); | 50 | void Stick(bool save = true); |
2863 | 51 | void UnStick(); | 51 | void UnStick(); |
2864 | 52 | |||
2865 | 52 | MenuItemsVector GetMenus(); | 53 | MenuItemsVector GetMenus(); |
2866 | 53 | std::string GetRemoteUri() const; | 54 | std::string GetRemoteUri() const; |
2867 | 55 | std::string GetVolumeUri() const; | ||
2868 | 54 | 56 | ||
2869 | 55 | protected: | 57 | protected: |
2870 | 56 | void ActivateLauncherIcon(ActionArg arg); | ||
2871 | 57 | bool OnShouldHighlightOnDrag(DndData const&); | ||
2872 | 58 | void OnAcceptDrop(DndData const&); | 58 | void OnAcceptDrop(DndData const&); |
2873 | 59 | nux::DndAction OnQueryAcceptDrop(DndData const&); | 59 | nux::DndAction OnQueryAcceptDrop(DndData const&); |
2874 | 60 | WindowList GetStorageWindows() const override; | ||
2875 | 61 | void OpenInstanceLauncherIcon(Time timestamp) override; | ||
2876 | 60 | 62 | ||
2877 | 61 | // Introspection | 63 | // Introspection |
2878 | 62 | virtual std::string GetName() const; | 64 | virtual std::string GetName() const; |
2879 | 63 | 65 | ||
2880 | === added file 'launcher/WindowedLauncherIcon.cpp' | |||
2881 | --- launcher/WindowedLauncherIcon.cpp 1970-01-01 00:00:00 +0000 | |||
2882 | +++ launcher/WindowedLauncherIcon.cpp 2016-02-09 10:44:04 +0000 | |||
2883 | @@ -0,0 +1,618 @@ | |||
2884 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
2885 | 2 | /* | ||
2886 | 3 | * Copyright (C) 2015 Canonical Ltd | ||
2887 | 4 | * | ||
2888 | 5 | * This program is free software: you can redistribute it and/or modify | ||
2889 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
2890 | 7 | * published by the Free Software Foundation. | ||
2891 | 8 | * | ||
2892 | 9 | * This program is distributed in the hope that it will be useful, | ||
2893 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2894 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2895 | 12 | * GNU General Public License for more details. | ||
2896 | 13 | * | ||
2897 | 14 | * You should have received a copy of the GNU General Public License | ||
2898 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2899 | 16 | * | ||
2900 | 17 | * Authored by: Marco Trevisan <marco.trevisan@canonical.com> | ||
2901 | 18 | */ | ||
2902 | 19 | |||
2903 | 20 | #include <Nux/Nux.h> | ||
2904 | 21 | |||
2905 | 22 | #include "WindowedLauncherIcon.h" | ||
2906 | 23 | #include "MultiMonitor.h" | ||
2907 | 24 | #include "unity-shared/UBusWrapper.h" | ||
2908 | 25 | #include "unity-shared/UBusMessages.h" | ||
2909 | 26 | #include "unity-shared/UScreen.h" | ||
2910 | 27 | |||
2911 | 28 | namespace unity | ||
2912 | 29 | { | ||
2913 | 30 | namespace launcher | ||
2914 | 31 | { | ||
2915 | 32 | namespace | ||
2916 | 33 | { | ||
2917 | 34 | const std::string ICON_DND_OVER_TIMEOUT = "windowed-icon-dnd-over"; | ||
2918 | 35 | const int COMPIZ_SCALE_DND_SPREAD = 1 << 7; | ||
2919 | 36 | const int MAXIMUM_QUICKLIST_WIDTH = 300; | ||
2920 | 37 | } | ||
2921 | 38 | |||
2922 | 39 | NUX_IMPLEMENT_OBJECT_TYPE(WindowedLauncherIcon); | ||
2923 | 40 | |||
2924 | 41 | WindowedLauncherIcon::WindowedLauncherIcon(AbstractLauncherIcon::IconType icon_type) | ||
2925 | 42 | : SimpleLauncherIcon(icon_type) | ||
2926 | 43 | , last_scroll_timestamp_(0) | ||
2927 | 44 | , progressive_scroll_(0) | ||
2928 | 45 | { | ||
2929 | 46 | WindowManager& wm = WindowManager::Default(); | ||
2930 | 47 | wm.window_minimized.connect(sigc::mem_fun(this, &WindowedLauncherIcon::OnWindowMinimized)); | ||
2931 | 48 | wm.screen_viewport_switch_ended.connect(sigc::mem_fun(this, &WindowedLauncherIcon::EnsureWindowState)); | ||
2932 | 49 | wm.terminate_expo.connect(sigc::mem_fun(this, &WindowedLauncherIcon::EnsureWindowState)); | ||
2933 | 50 | UScreen::GetDefault()->changed.connect(sigc::hide(sigc::hide(sigc::mem_fun(this, &WindowedLauncherIcon::EnsureWindowsLocation)))); | ||
2934 | 51 | |||
2935 | 52 | windows_changed.connect([this] (int) { | ||
2936 | 53 | if (WindowManager::Default().IsScaleActiveForGroup() && IsActive()) | ||
2937 | 54 | Spread(true, 0, false); | ||
2938 | 55 | }); | ||
2939 | 56 | } | ||
2940 | 57 | |||
2941 | 58 | bool WindowedLauncherIcon::IsActive() const | ||
2942 | 59 | { | ||
2943 | 60 | return GetQuirk(Quirk::ACTIVE); | ||
2944 | 61 | } | ||
2945 | 62 | |||
2946 | 63 | bool WindowedLauncherIcon::IsRunning() const | ||
2947 | 64 | { | ||
2948 | 65 | return GetQuirk(Quirk::RUNNING); | ||
2949 | 66 | } | ||
2950 | 67 | |||
2951 | 68 | bool WindowedLauncherIcon::IsUrgent() const | ||
2952 | 69 | { | ||
2953 | 70 | return GetQuirk(Quirk::URGENT); | ||
2954 | 71 | } | ||
2955 | 72 | |||
2956 | 73 | bool WindowedLauncherIcon::IsUserVisible() const | ||
2957 | 74 | { | ||
2958 | 75 | return IsRunning(); | ||
2959 | 76 | } | ||
2960 | 77 | |||
2961 | 78 | void WindowedLauncherIcon::ActivateLauncherIcon(ActionArg arg) | ||
2962 | 79 | { | ||
2963 | 80 | SimpleLauncherIcon::ActivateLauncherIcon(arg); | ||
2964 | 81 | WindowManager& wm = WindowManager::Default(); | ||
2965 | 82 | |||
2966 | 83 | // This is a little awkward as the target is only set from the switcher. | ||
2967 | 84 | if (arg.target) | ||
2968 | 85 | { | ||
2969 | 86 | // thumper: should we Raise too? should the WM raise? | ||
2970 | 87 | wm.Activate(arg.target); | ||
2971 | 88 | return; | ||
2972 | 89 | } | ||
2973 | 90 | |||
2974 | 91 | bool scale_was_active = wm.IsScaleActive(); | ||
2975 | 92 | bool active = IsActive(); | ||
2976 | 93 | bool user_visible = IsRunning(); | ||
2977 | 94 | /* We should check each child to see if there is | ||
2978 | 95 | * an unmapped (!= minimized) window around and | ||
2979 | 96 | * if so force "Focus" behaviour */ | ||
2980 | 97 | |||
2981 | 98 | if (arg.source != ActionArg::Source::SWITCHER) | ||
2982 | 99 | { | ||
2983 | 100 | user_visible = IsUserVisible(); | ||
2984 | 101 | |||
2985 | 102 | if (active) | ||
2986 | 103 | { | ||
2987 | 104 | bool any_visible = false; | ||
2988 | 105 | bool any_mapped = false; | ||
2989 | 106 | bool any_on_top = false; | ||
2990 | 107 | bool any_on_monitor = (arg.monitor < 0); | ||
2991 | 108 | int active_monitor = arg.monitor; | ||
2992 | 109 | |||
2993 | 110 | for (auto const& window : GetManagedWindows()) | ||
2994 | 111 | { | ||
2995 | 112 | Window xid = window->window_id(); | ||
2996 | 113 | |||
2997 | 114 | if (!any_visible && wm.IsWindowOnCurrentDesktop(xid)) | ||
2998 | 115 | { | ||
2999 | 116 | any_visible = true; | ||
3000 | 117 | } | ||
3001 | 118 | |||
3002 | 119 | if (!any_mapped && wm.IsWindowMapped(xid)) | ||
3003 | 120 | { | ||
3004 | 121 | any_mapped = true; | ||
3005 | 122 | } | ||
3006 | 123 | |||
3007 | 124 | if (!any_on_top && wm.IsWindowOnTop(xid)) | ||
3008 | 125 | { | ||
3009 | 126 | any_on_top = true; | ||
3010 | 127 | } | ||
3011 | 128 | |||
3012 | 129 | if (!any_on_monitor && window->monitor() == arg.monitor && | ||
3013 | 130 | wm.IsWindowMapped(xid) && wm.IsWindowVisible(xid)) | ||
3014 | 131 | { | ||
3015 | 132 | any_on_monitor = true; | ||
3016 | 133 | } | ||
3017 | 134 | |||
3018 | 135 | if (window->active()) | ||
3019 | 136 | { | ||
3020 | 137 | active_monitor = window->monitor(); | ||
3021 | 138 | } | ||
3022 | 139 | } | ||
3023 | 140 | |||
3024 | 141 | if (!any_visible || !any_mapped || !any_on_top) | ||
3025 | 142 | active = false; | ||
3026 | 143 | |||
3027 | 144 | if (any_on_monitor && arg.monitor >= 0 && active_monitor != arg.monitor) | ||
3028 | 145 | active = false; | ||
3029 | 146 | } | ||
3030 | 147 | } | ||
3031 | 148 | |||
3032 | 149 | /* Behaviour: | ||
3033 | 150 | * 1) Nothing running, or nothing visible -> launch application | ||
3034 | 151 | * 2) Running and active -> spread application | ||
3035 | 152 | * 3) Running and not active -> focus application | ||
3036 | 153 | * 4) Spread is active and different icon pressed -> change spread | ||
3037 | 154 | * 5) Spread is active -> Spread de-activated, and fall through | ||
3038 | 155 | */ | ||
3039 | 156 | |||
3040 | 157 | if (!IsRunning() || (IsRunning() && !user_visible)) // #1 above | ||
3041 | 158 | { | ||
3042 | 159 | if (GetQuirk(Quirk::STARTING, arg.monitor)) | ||
3043 | 160 | return; | ||
3044 | 161 | |||
3045 | 162 | wm.TerminateScale(); | ||
3046 | 163 | SetQuirk(Quirk::STARTING, true, arg.monitor); | ||
3047 | 164 | OpenInstanceLauncherIcon(arg.timestamp); | ||
3048 | 165 | } | ||
3049 | 166 | else // container is running | ||
3050 | 167 | { | ||
3051 | 168 | if (active) | ||
3052 | 169 | { | ||
3053 | 170 | if (scale_was_active) // #5 above | ||
3054 | 171 | { | ||
3055 | 172 | wm.TerminateScale(); | ||
3056 | 173 | |||
3057 | 174 | if (minimize_window_on_click()) | ||
3058 | 175 | { | ||
3059 | 176 | for (auto const& win : GetWindows(WindowFilter::ON_CURRENT_DESKTOP)) | ||
3060 | 177 | wm.Minimize(win->window_id()); | ||
3061 | 178 | } | ||
3062 | 179 | else | ||
3063 | 180 | { | ||
3064 | 181 | Focus(arg); | ||
3065 | 182 | } | ||
3066 | 183 | } | ||
3067 | 184 | else // #2 above | ||
3068 | 185 | { | ||
3069 | 186 | if (arg.source != ActionArg::Source::SWITCHER) | ||
3070 | 187 | { | ||
3071 | 188 | bool minimized = false; | ||
3072 | 189 | |||
3073 | 190 | if (minimize_window_on_click()) | ||
3074 | 191 | { | ||
3075 | 192 | WindowList const& windows = GetWindows(WindowFilter::ON_CURRENT_DESKTOP); | ||
3076 | 193 | |||
3077 | 194 | if (windows.size() == 1) | ||
3078 | 195 | { | ||
3079 | 196 | wm.Minimize(windows[0]->window_id()); | ||
3080 | 197 | minimized = true; | ||
3081 | 198 | } | ||
3082 | 199 | } | ||
3083 | 200 | |||
3084 | 201 | if (!minimized) | ||
3085 | 202 | { | ||
3086 | 203 | Spread(true, 0, false); | ||
3087 | 204 | } | ||
3088 | 205 | } | ||
3089 | 206 | } | ||
3090 | 207 | } | ||
3091 | 208 | else | ||
3092 | 209 | { | ||
3093 | 210 | if (scale_was_active) // #4 above | ||
3094 | 211 | { | ||
3095 | 212 | if (GetWindows(WindowFilter::ON_CURRENT_DESKTOP).size() <= 1) | ||
3096 | 213 | wm.TerminateScale(); | ||
3097 | 214 | |||
3098 | 215 | Focus(arg); | ||
3099 | 216 | |||
3100 | 217 | if (arg.source != ActionArg::Source::SWITCHER) | ||
3101 | 218 | Spread(true, 0, false); | ||
3102 | 219 | } | ||
3103 | 220 | else // #3 above | ||
3104 | 221 | { | ||
3105 | 222 | Focus(arg); | ||
3106 | 223 | } | ||
3107 | 224 | } | ||
3108 | 225 | } | ||
3109 | 226 | } | ||
3110 | 227 | |||
3111 | 228 | WindowList WindowedLauncherIcon::GetWindows(WindowFilterMask filter, int monitor) | ||
3112 | 229 | { | ||
3113 | 230 | if ((!filter && monitor < 0) || (filter == WindowFilter::ON_ALL_MONITORS)) | ||
3114 | 231 | return GetManagedWindows(); | ||
3115 | 232 | |||
3116 | 233 | WindowManager& wm = WindowManager::Default(); | ||
3117 | 234 | WindowList results; | ||
3118 | 235 | |||
3119 | 236 | monitor = (filter & WindowFilter::ON_ALL_MONITORS) ? -1 : monitor; | ||
3120 | 237 | bool mapped = (filter & WindowFilter::MAPPED); | ||
3121 | 238 | bool user_visible = (filter & WindowFilter::USER_VISIBLE); | ||
3122 | 239 | bool current_desktop = (filter & WindowFilter::ON_CURRENT_DESKTOP); | ||
3123 | 240 | |||
3124 | 241 | for (auto& window : GetManagedWindows()) | ||
3125 | 242 | { | ||
3126 | 243 | if ((monitor >= 0 && window->monitor() == monitor) || monitor < 0) | ||
3127 | 244 | { | ||
3128 | 245 | if ((user_visible && window->visible()) || !user_visible) | ||
3129 | 246 | { | ||
3130 | 247 | Window xid = window->window_id(); | ||
3131 | 248 | |||
3132 | 249 | if ((mapped && wm.IsWindowMapped(xid)) || !mapped) | ||
3133 | 250 | { | ||
3134 | 251 | if ((current_desktop && wm.IsWindowOnCurrentDesktop(xid)) || !current_desktop) | ||
3135 | 252 | { | ||
3136 | 253 | results.push_back(window); | ||
3137 | 254 | } | ||
3138 | 255 | } | ||
3139 | 256 | } | ||
3140 | 257 | } | ||
3141 | 258 | } | ||
3142 | 259 | |||
3143 | 260 | return results; | ||
3144 | 261 | } | ||
3145 | 262 | |||
3146 | 263 | WindowList WindowedLauncherIcon::Windows() | ||
3147 | 264 | { | ||
3148 | 265 | return GetWindows(WindowFilter::MAPPED|WindowFilter::ON_ALL_MONITORS); | ||
3149 | 266 | } | ||
3150 | 267 | |||
3151 | 268 | WindowList WindowedLauncherIcon::WindowsOnViewport() | ||
3152 | 269 | { | ||
3153 | 270 | WindowFilterMask filter = 0; | ||
3154 | 271 | filter |= WindowFilter::MAPPED; | ||
3155 | 272 | filter |= WindowFilter::USER_VISIBLE; | ||
3156 | 273 | filter |= WindowFilter::ON_CURRENT_DESKTOP; | ||
3157 | 274 | filter |= WindowFilter::ON_ALL_MONITORS; | ||
3158 | 275 | |||
3159 | 276 | return GetWindows(filter); | ||
3160 | 277 | } | ||
3161 | 278 | |||
3162 | 279 | WindowList WindowedLauncherIcon::WindowsForMonitor(int monitor) | ||
3163 | 280 | { | ||
3164 | 281 | WindowFilterMask filter = 0; | ||
3165 | 282 | filter |= WindowFilter::MAPPED; | ||
3166 | 283 | filter |= WindowFilter::USER_VISIBLE; | ||
3167 | 284 | filter |= WindowFilter::ON_CURRENT_DESKTOP; | ||
3168 | 285 | |||
3169 | 286 | return GetWindows(filter, monitor); | ||
3170 | 287 | } | ||
3171 | 288 | |||
3172 | 289 | void WindowedLauncherIcon::OnWindowMinimized(Window xid) | ||
3173 | 290 | { | ||
3174 | 291 | for (auto const& window : GetManagedWindows()) | ||
3175 | 292 | { | ||
3176 | 293 | if (xid == window->window_id()) | ||
3177 | 294 | { | ||
3178 | 295 | int monitor = GetCenterForMonitor(window->monitor()).first; | ||
3179 | 296 | |||
3180 | 297 | if (monitor >= 0) | ||
3181 | 298 | { | ||
3182 | 299 | Present(0.5f, 600, monitor); | ||
3183 | 300 | FullyAnimateQuirkDelayed(300, Quirk::SHIMMER, monitor); | ||
3184 | 301 | } | ||
3185 | 302 | |||
3186 | 303 | break; | ||
3187 | 304 | } | ||
3188 | 305 | } | ||
3189 | 306 | } | ||
3190 | 307 | |||
3191 | 308 | void WindowedLauncherIcon::Focus(ActionArg arg) | ||
3192 | 309 | { | ||
3193 | 310 | bool show_only_visible = (arg.source == ActionArg::Source::SWITCHER); | ||
3194 | 311 | ApplicationManager::Default().FocusWindowGroup(GetManagedWindows(), show_only_visible, arg.monitor); | ||
3195 | 312 | } | ||
3196 | 313 | |||
3197 | 314 | bool WindowedLauncherIcon::Spread(bool current_desktop, int state, bool force) | ||
3198 | 315 | { | ||
3199 | 316 | std::vector<Window> windows; | ||
3200 | 317 | for (auto& window : GetWindows(current_desktop ? WindowFilter::ON_CURRENT_DESKTOP : 0)) | ||
3201 | 318 | windows.push_back(window->window_id()); | ||
3202 | 319 | |||
3203 | 320 | return WindowManager::Default().ScaleWindowGroup(windows, state, force); | ||
3204 | 321 | } | ||
3205 | 322 | |||
3206 | 323 | void WindowedLauncherIcon::EnsureWindowState() | ||
3207 | 324 | { | ||
3208 | 325 | std::vector<int> number_of_windows_on_monitor(monitors::MAX); | ||
3209 | 326 | |||
3210 | 327 | for (auto const& window : WindowsOnViewport()) | ||
3211 | 328 | { | ||
3212 | 329 | int monitor = window->monitor(); | ||
3213 | 330 | |||
3214 | 331 | // If monitor is -1 (or negative), show on all monitors. | ||
3215 | 332 | if (monitor < 0) | ||
3216 | 333 | { | ||
3217 | 334 | for (unsigned j; j < monitors::MAX; ++j) | ||
3218 | 335 | ++number_of_windows_on_monitor[j]; | ||
3219 | 336 | } | ||
3220 | 337 | else | ||
3221 | 338 | { | ||
3222 | 339 | ++number_of_windows_on_monitor[monitor]; | ||
3223 | 340 | } | ||
3224 | 341 | } | ||
3225 | 342 | |||
3226 | 343 | for (unsigned i = 0; i < monitors::MAX; ++i) | ||
3227 | 344 | SetNumberOfWindowsVisibleOnMonitor(number_of_windows_on_monitor[i], i); | ||
3228 | 345 | } | ||
3229 | 346 | |||
3230 | 347 | void WindowedLauncherIcon::EnsureWindowsLocation() | ||
3231 | 348 | { | ||
3232 | 349 | EnsureWindowState(); | ||
3233 | 350 | UpdateIconGeometries(GetCenters()); | ||
3234 | 351 | } | ||
3235 | 352 | |||
3236 | 353 | void WindowedLauncherIcon::UpdateIconGeometries(std::vector<nux::Point3> const& centers) | ||
3237 | 354 | { | ||
3238 | 355 | nux::Geometry geo(0, 0, icon_size, icon_size); | ||
3239 | 356 | |||
3240 | 357 | for (auto& window : GetManagedWindows()) | ||
3241 | 358 | { | ||
3242 | 359 | Window xid = window->window_id(); | ||
3243 | 360 | int monitor = GetCenterForMonitor(window->monitor()).first; | ||
3244 | 361 | |||
3245 | 362 | if (monitor < 0) | ||
3246 | 363 | { | ||
3247 | 364 | WindowManager::Default().SetWindowIconGeometry(xid, nux::Geometry()); | ||
3248 | 365 | continue; | ||
3249 | 366 | } | ||
3250 | 367 | |||
3251 | 368 | geo.x = centers[monitor].x - icon_size / 2; | ||
3252 | 369 | geo.y = centers[monitor].y - icon_size / 2; | ||
3253 | 370 | WindowManager::Default().SetWindowIconGeometry(xid, geo); | ||
3254 | 371 | } | ||
3255 | 372 | } | ||
3256 | 373 | |||
3257 | 374 | void WindowedLauncherIcon::OnCenterStabilized(std::vector<nux::Point3> const& centers) | ||
3258 | 375 | { | ||
3259 | 376 | UpdateIconGeometries(centers); | ||
3260 | 377 | } | ||
3261 | 378 | |||
3262 | 379 | void WindowedLauncherIcon::OnDndEnter() | ||
3263 | 380 | { | ||
3264 | 381 | auto timestamp = nux::GetGraphicsDisplay()->GetCurrentEvent().x11_timestamp; | ||
3265 | 382 | |||
3266 | 383 | _source_manager.AddTimeout(1000, [this, timestamp] { | ||
3267 | 384 | bool to_spread = GetWindows(WindowFilter::ON_CURRENT_DESKTOP).size() > 1; | ||
3268 | 385 | |||
3269 | 386 | if (!to_spread) | ||
3270 | 387 | WindowManager::Default().TerminateScale(); | ||
3271 | 388 | |||
3272 | 389 | if (!IsRunning()) | ||
3273 | 390 | return false; | ||
3274 | 391 | |||
3275 | 392 | UBusManager::SendMessage(UBUS_OVERLAY_CLOSE_REQUEST); | ||
3276 | 393 | Focus(ActionArg(ActionArg::Source::LAUNCHER, 1, timestamp)); | ||
3277 | 394 | |||
3278 | 395 | if (to_spread) | ||
3279 | 396 | Spread(true, COMPIZ_SCALE_DND_SPREAD, false); | ||
3280 | 397 | |||
3281 | 398 | return false; | ||
3282 | 399 | }, ICON_DND_OVER_TIMEOUT); | ||
3283 | 400 | } | ||
3284 | 401 | |||
3285 | 402 | void WindowedLauncherIcon::OnDndLeave() | ||
3286 | 403 | { | ||
3287 | 404 | _source_manager.Remove(ICON_DND_OVER_TIMEOUT); | ||
3288 | 405 | } | ||
3289 | 406 | |||
3290 | 407 | bool WindowedLauncherIcon::HandlesSpread() | ||
3291 | 408 | { | ||
3292 | 409 | return true; | ||
3293 | 410 | } | ||
3294 | 411 | |||
3295 | 412 | bool WindowedLauncherIcon::ShowInSwitcher(bool current) | ||
3296 | 413 | { | ||
3297 | 414 | if (!removed() && IsRunning() && IsVisible()) | ||
3298 | 415 | { | ||
3299 | 416 | // If current is true, we only want to show the current workspace. | ||
3300 | 417 | if (!current) | ||
3301 | 418 | { | ||
3302 | 419 | return true; | ||
3303 | 420 | } | ||
3304 | 421 | else | ||
3305 | 422 | { | ||
3306 | 423 | for (unsigned i = 0; i < monitors::MAX; ++i) | ||
3307 | 424 | { | ||
3308 | 425 | if (WindowVisibleOnMonitor(i)) | ||
3309 | 426 | return true; | ||
3310 | 427 | } | ||
3311 | 428 | } | ||
3312 | 429 | } | ||
3313 | 430 | |||
3314 | 431 | return false; | ||
3315 | 432 | } | ||
3316 | 433 | |||
3317 | 434 | bool WindowedLauncherIcon::AllowDetailViewInSwitcher() const | ||
3318 | 435 | { | ||
3319 | 436 | return true; | ||
3320 | 437 | } | ||
3321 | 438 | |||
3322 | 439 | uint64_t WindowedLauncherIcon::SwitcherPriority() | ||
3323 | 440 | { | ||
3324 | 441 | uint64_t result = 0; | ||
3325 | 442 | |||
3326 | 443 | for (auto& window : GetManagedWindows()) | ||
3327 | 444 | { | ||
3328 | 445 | Window xid = window->window_id(); | ||
3329 | 446 | result = std::max(result, WindowManager::Default().GetWindowActiveNumber(xid)); | ||
3330 | 447 | } | ||
3331 | 448 | |||
3332 | 449 | return result; | ||
3333 | 450 | } | ||
3334 | 451 | |||
3335 | 452 | void PerformScrollUp(WindowList const& windows, unsigned int progressive_scroll) | ||
3336 | 453 | { | ||
3337 | 454 | if (progressive_scroll == windows.size() - 1) | ||
3338 | 455 | { | ||
3339 | 456 | //RestackAbove to preserve Global Stacking Order | ||
3340 | 457 | WindowManager::Default().RestackBelow(windows.at(0)->window_id(), windows.at(1)->window_id()); | ||
3341 | 458 | WindowManager::Default().RestackBelow(windows.at(1)->window_id(), windows.at(0)->window_id()); | ||
3342 | 459 | windows.back()->Focus(); | ||
3343 | 460 | return; | ||
3344 | 461 | } | ||
3345 | 462 | |||
3346 | 463 | WindowManager::Default().RestackBelow(windows.at(0)->window_id(), windows.at(progressive_scroll + 1)->window_id()); | ||
3347 | 464 | windows.at(progressive_scroll + 1)->Focus(); | ||
3348 | 465 | } | ||
3349 | 466 | |||
3350 | 467 | void PerformScrollDown(WindowList const& windows, unsigned int progressive_scroll) | ||
3351 | 468 | { | ||
3352 | 469 | if (!progressive_scroll) | ||
3353 | 470 | { | ||
3354 | 471 | WindowManager::Default().RestackBelow(windows.at(0)->window_id(), windows.back()->window_id()); | ||
3355 | 472 | windows.at(1)->Focus(); | ||
3356 | 473 | return; | ||
3357 | 474 | } | ||
3358 | 475 | |||
3359 | 476 | WindowManager::Default().RestackBelow(windows.at(0)->window_id(), windows.at(progressive_scroll)->window_id()); | ||
3360 | 477 | windows.at(progressive_scroll)->Focus(); | ||
3361 | 478 | } | ||
3362 | 479 | |||
3363 | 480 | void WindowedLauncherIcon::PerformScroll(ScrollDirection direction, Time timestamp) | ||
3364 | 481 | { | ||
3365 | 482 | if (timestamp - last_scroll_timestamp_ < 150) | ||
3366 | 483 | return; | ||
3367 | 484 | else if (timestamp - last_scroll_timestamp_ > 1500) | ||
3368 | 485 | progressive_scroll_ = 0; | ||
3369 | 486 | |||
3370 | 487 | last_scroll_timestamp_ = timestamp; | ||
3371 | 488 | |||
3372 | 489 | auto const& windows = GetWindowsOnCurrentDesktopInStackingOrder(); | ||
3373 | 490 | |||
3374 | 491 | if (windows.empty()) | ||
3375 | 492 | return; | ||
3376 | 493 | |||
3377 | 494 | if (scroll_inactive_icons && !IsActive()) | ||
3378 | 495 | { | ||
3379 | 496 | windows.at(0)->Focus(); | ||
3380 | 497 | return; | ||
3381 | 498 | } | ||
3382 | 499 | |||
3383 | 500 | if (!scroll_inactive_icons && !IsActive()) | ||
3384 | 501 | return; | ||
3385 | 502 | |||
3386 | 503 | if (windows.size() <= 1) | ||
3387 | 504 | return; | ||
3388 | 505 | |||
3389 | 506 | if (direction == ScrollDirection::DOWN) | ||
3390 | 507 | ++progressive_scroll_; | ||
3391 | 508 | else | ||
3392 | 509 | //--progressive_scroll_; but roll to the top of windows | ||
3393 | 510 | progressive_scroll_ += windows.size() - 1; | ||
3394 | 511 | progressive_scroll_ %= windows.size(); | ||
3395 | 512 | |||
3396 | 513 | switch(direction) | ||
3397 | 514 | { | ||
3398 | 515 | case ScrollDirection::UP: | ||
3399 | 516 | PerformScrollUp(windows, progressive_scroll_); | ||
3400 | 517 | break; | ||
3401 | 518 | case ScrollDirection::DOWN: | ||
3402 | 519 | PerformScrollDown(windows, progressive_scroll_); | ||
3403 | 520 | break; | ||
3404 | 521 | } | ||
3405 | 522 | } | ||
3406 | 523 | |||
3407 | 524 | WindowList WindowedLauncherIcon::GetWindowsOnCurrentDesktopInStackingOrder() | ||
3408 | 525 | { | ||
3409 | 526 | auto windows = GetWindows(WindowFilter::ON_CURRENT_DESKTOP | WindowFilter::ON_ALL_MONITORS); | ||
3410 | 527 | auto sorted_windows = WindowManager::Default().GetWindowsInStackingOrder(); | ||
3411 | 528 | |||
3412 | 529 | // Order the windows | ||
3413 | 530 | std::sort(windows.begin(), windows.end(), [&sorted_windows] (ApplicationWindowPtr const& win1, ApplicationWindowPtr const& win2) { | ||
3414 | 531 | for (auto const& window : sorted_windows) | ||
3415 | 532 | { | ||
3416 | 533 | if (window == win1->window_id()) | ||
3417 | 534 | return false; | ||
3418 | 535 | else if (window == win2->window_id()) | ||
3419 | 536 | return true; | ||
3420 | 537 | } | ||
3421 | 538 | |||
3422 | 539 | return true; | ||
3423 | 540 | }); | ||
3424 | 541 | |||
3425 | 542 | return windows; | ||
3426 | 543 | } | ||
3427 | 544 | |||
3428 | 545 | void WindowedLauncherIcon::Quit() const | ||
3429 | 546 | { | ||
3430 | 547 | for (auto& window : GetManagedWindows()) | ||
3431 | 548 | window->Quit(); | ||
3432 | 549 | } | ||
3433 | 550 | |||
3434 | 551 | void WindowedLauncherIcon::AboutToRemove() | ||
3435 | 552 | { | ||
3436 | 553 | Quit(); | ||
3437 | 554 | } | ||
3438 | 555 | |||
3439 | 556 | AbstractLauncherIcon::MenuItemsVector WindowedLauncherIcon::GetWindowsMenuItems() | ||
3440 | 557 | { | ||
3441 | 558 | auto const& windows = Windows(); | ||
3442 | 559 | MenuItemsVector menu_items; | ||
3443 | 560 | |||
3444 | 561 | // We only add quicklist menu-items for windows if we have more than one window | ||
3445 | 562 | if (windows.size() < 2) | ||
3446 | 563 | return menu_items; | ||
3447 | 564 | |||
3448 | 565 | // add menu items for all open windows | ||
3449 | 566 | for (auto const& w : windows) | ||
3450 | 567 | { | ||
3451 | 568 | auto const& title = w->title(); | ||
3452 | 569 | |||
3453 | 570 | if (title.empty()) | ||
3454 | 571 | continue; | ||
3455 | 572 | |||
3456 | 573 | glib::Object<DbusmenuMenuitem> menu_item(dbusmenu_menuitem_new()); | ||
3457 | 574 | dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_LABEL, title.c_str()); | ||
3458 | 575 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true); | ||
3459 | 576 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); | ||
3460 | 577 | dbusmenu_menuitem_property_set_bool(menu_item, QuicklistMenuItem::MARKUP_ACCEL_DISABLED_PROPERTY, true); | ||
3461 | 578 | dbusmenu_menuitem_property_set_int(menu_item, QuicklistMenuItem::MAXIMUM_LABEL_WIDTH_PROPERTY, MAXIMUM_QUICKLIST_WIDTH); | ||
3462 | 579 | |||
3463 | 580 | Window xid = w->window_id(); | ||
3464 | 581 | glib_signals_.Add<void, DbusmenuMenuitem*, unsigned>(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, | ||
3465 | 582 | [xid] (DbusmenuMenuitem*, unsigned) { | ||
3466 | 583 | WindowManager& wm = WindowManager::Default(); | ||
3467 | 584 | wm.Activate(xid); | ||
3468 | 585 | wm.Raise(xid); | ||
3469 | 586 | }); | ||
3470 | 587 | |||
3471 | 588 | if (w->active()) | ||
3472 | 589 | { | ||
3473 | 590 | dbusmenu_menuitem_property_set(menu_item, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE, DBUSMENU_MENUITEM_TOGGLE_RADIO); | ||
3474 | 591 | dbusmenu_menuitem_property_set_int(menu_item, DBUSMENU_MENUITEM_PROP_TOGGLE_STATE, DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED); | ||
3475 | 592 | } | ||
3476 | 593 | |||
3477 | 594 | menu_items.push_back(menu_item); | ||
3478 | 595 | } | ||
3479 | 596 | |||
3480 | 597 | return menu_items; | ||
3481 | 598 | } | ||
3482 | 599 | |||
3483 | 600 | std::string WindowedLauncherIcon::GetName() const | ||
3484 | 601 | { | ||
3485 | 602 | return "WindowedLauncherIcon"; | ||
3486 | 603 | } | ||
3487 | 604 | |||
3488 | 605 | void WindowedLauncherIcon::AddProperties(debug::IntrospectionData& introspection) | ||
3489 | 606 | { | ||
3490 | 607 | SimpleLauncherIcon::AddProperties(introspection); | ||
3491 | 608 | |||
3492 | 609 | std::vector<Window> xids; | ||
3493 | 610 | for (auto const& window : GetManagedWindows()) | ||
3494 | 611 | xids.push_back(window->window_id()); | ||
3495 | 612 | |||
3496 | 613 | introspection.add("xids", glib::Variant::FromVector(xids)) | ||
3497 | 614 | .add("sticky", IsSticky()); | ||
3498 | 615 | } | ||
3499 | 616 | |||
3500 | 617 | } // namespace launcher | ||
3501 | 618 | } // namespace unity | ||
3502 | 0 | 619 | ||
3503 | === added file 'launcher/WindowedLauncherIcon.h' | |||
3504 | --- launcher/WindowedLauncherIcon.h 1970-01-01 00:00:00 +0000 | |||
3505 | +++ launcher/WindowedLauncherIcon.h 2016-02-09 10:44:04 +0000 | |||
3506 | @@ -0,0 +1,100 @@ | |||
3507 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
3508 | 2 | /* | ||
3509 | 3 | * Copyright (C) 2015 Canonical Ltd | ||
3510 | 4 | * | ||
3511 | 5 | * This program is free software: you can redistribute it and/or modify | ||
3512 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
3513 | 7 | * published by the Free Software Foundation. | ||
3514 | 8 | * | ||
3515 | 9 | * This program is distributed in the hope that it will be useful, | ||
3516 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3517 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3518 | 12 | * GNU General Public License for more details. | ||
3519 | 13 | * | ||
3520 | 14 | * You should have received a copy of the GNU General Public License | ||
3521 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3522 | 16 | * | ||
3523 | 17 | * Authored by: Marco Trevisan <marco.trevisan@canonical.com> | ||
3524 | 18 | */ | ||
3525 | 19 | |||
3526 | 20 | #ifndef WINDOWED_LAUNCHER_ICON_H | ||
3527 | 21 | #define WINDOWED_LAUNCHER_ICON_H | ||
3528 | 22 | |||
3529 | 23 | #include <UnityCore/GLibSignal.h> | ||
3530 | 24 | |||
3531 | 25 | #include "SimpleLauncherIcon.h" | ||
3532 | 26 | |||
3533 | 27 | namespace unity | ||
3534 | 28 | { | ||
3535 | 29 | namespace launcher | ||
3536 | 30 | { | ||
3537 | 31 | |||
3538 | 32 | class WindowedLauncherIcon : public SimpleLauncherIcon | ||
3539 | 33 | { | ||
3540 | 34 | NUX_DECLARE_OBJECT_TYPE(WindowedLauncherIcon, SimpleLauncherIcon); | ||
3541 | 35 | public: | ||
3542 | 36 | WindowedLauncherIcon(AbstractLauncherIcon::IconType); | ||
3543 | 37 | |||
3544 | 38 | WindowList Windows() override; | ||
3545 | 39 | WindowList WindowsOnViewport() override; | ||
3546 | 40 | WindowList WindowsForMonitor(int monitor) override; | ||
3547 | 41 | |||
3548 | 42 | virtual bool IsActive() const; | ||
3549 | 43 | virtual bool IsRunning() const; | ||
3550 | 44 | virtual bool IsUrgent() const; | ||
3551 | 45 | virtual bool IsUserVisible() const; | ||
3552 | 46 | |||
3553 | 47 | virtual void Quit() const; | ||
3554 | 48 | |||
3555 | 49 | protected: | ||
3556 | 50 | virtual WindowList GetManagedWindows() const = 0; | ||
3557 | 51 | void EnsureWindowState(); | ||
3558 | 52 | void EnsureWindowsLocation(); | ||
3559 | 53 | |||
3560 | 54 | virtual void UpdateIconGeometries(std::vector<nux::Point3> const& centers); | ||
3561 | 55 | |||
3562 | 56 | std::string GetName() const override; | ||
3563 | 57 | void AddProperties(debug::IntrospectionData&) override; | ||
3564 | 58 | |||
3565 | 59 | bool HandlesSpread() override; | ||
3566 | 60 | bool ShowInSwitcher(bool current) override; | ||
3567 | 61 | bool AllowDetailViewInSwitcher() const override; | ||
3568 | 62 | uint64_t SwitcherPriority() override; | ||
3569 | 63 | void AboutToRemove() override; | ||
3570 | 64 | |||
3571 | 65 | void ActivateLauncherIcon(ActionArg arg) override; | ||
3572 | 66 | void PerformScroll(ScrollDirection direction, Time timestamp) override; | ||
3573 | 67 | virtual void Focus(ActionArg arg); | ||
3574 | 68 | virtual bool Spread(bool current_desktop, int state, bool force); | ||
3575 | 69 | |||
3576 | 70 | typedef unsigned long int WindowFilterMask; | ||
3577 | 71 | enum WindowFilter | ||
3578 | 72 | { | ||
3579 | 73 | MAPPED = (1 << 0), | ||
3580 | 74 | USER_VISIBLE = (1 << 1), | ||
3581 | 75 | ON_CURRENT_DESKTOP = (1 << 2), | ||
3582 | 76 | ON_ALL_MONITORS = (1 << 3), | ||
3583 | 77 | }; | ||
3584 | 78 | |||
3585 | 79 | WindowList GetWindows(WindowFilterMask filter = 0, int monitor = -1); | ||
3586 | 80 | WindowList GetWindowsOnCurrentDesktopInStackingOrder(); | ||
3587 | 81 | |||
3588 | 82 | MenuItemsVector GetWindowsMenuItems(); | ||
3589 | 83 | |||
3590 | 84 | private: | ||
3591 | 85 | void OnCenterStabilized(std::vector<nux::Point3> const& centers) override; | ||
3592 | 86 | void OnWindowMinimized(Window); | ||
3593 | 87 | void OnDndEnter(); | ||
3594 | 88 | void OnDndLeave(); | ||
3595 | 89 | |||
3596 | 90 | Time last_scroll_timestamp_; | ||
3597 | 91 | unsigned int progressive_scroll_; | ||
3598 | 92 | |||
3599 | 93 | protected: | ||
3600 | 94 | glib::SignalManager glib_signals_; | ||
3601 | 95 | }; | ||
3602 | 96 | |||
3603 | 97 | } // namespace launcher | ||
3604 | 98 | } // namespace unity | ||
3605 | 99 | |||
3606 | 100 | #endif // WINDOWED_LAUNCHER_ICON_H | ||
3607 | 0 | 101 | ||
3608 | === modified file 'tests/CMakeLists.txt' | |||
3609 | --- tests/CMakeLists.txt 2015-12-11 12:45:49 +0000 | |||
3610 | +++ tests/CMakeLists.txt 2016-02-09 10:44:04 +0000 | |||
3611 | @@ -80,6 +80,7 @@ | |||
3612 | 80 | set (GTEST_SLOW_SOURCES | 80 | set (GTEST_SLOW_SOURCES |
3613 | 81 | test_main.cpp | 81 | test_main.cpp |
3614 | 82 | logger_helper.cpp | 82 | logger_helper.cpp |
3615 | 83 | mock-application.cpp | ||
3616 | 83 | test_switcher_controller_slow.cpp | 84 | test_switcher_controller_slow.cpp |
3617 | 84 | test_switcher_controller_class.cpp | 85 | test_switcher_controller_class.cpp |
3618 | 85 | test_tooltip_manager.cpp | 86 | test_tooltip_manager.cpp |
3619 | 86 | 87 | ||
3620 | === modified file 'tests/mock-application.h' | |||
3621 | --- tests/mock-application.h 2015-07-09 17:11:53 +0000 | |||
3622 | +++ tests/mock-application.h 2016-02-09 10:44:04 +0000 | |||
3623 | @@ -91,7 +91,7 @@ | |||
3624 | 91 | return; | 91 | return; |
3625 | 92 | 92 | ||
3626 | 93 | title_ = new_title; | 93 | title_ = new_title; |
3628 | 94 | title.changed(title_); | 94 | title.changed.emit(title_); |
3629 | 95 | } | 95 | } |
3630 | 96 | 96 | ||
3631 | 97 | void SetIcon(std::string const& new_icon) | 97 | void SetIcon(std::string const& new_icon) |
3632 | @@ -100,7 +100,16 @@ | |||
3633 | 100 | return; | 100 | return; |
3634 | 101 | 101 | ||
3635 | 102 | icon_ = new_icon; | 102 | icon_ = new_icon; |
3637 | 103 | icon.changed(icon_); | 103 | icon.changed.emit(icon_); |
3638 | 104 | } | ||
3639 | 105 | |||
3640 | 106 | void SetMonitor(int new_monitor) | ||
3641 | 107 | { | ||
3642 | 108 | if (monitor_ == new_monitor) | ||
3643 | 109 | return; | ||
3644 | 110 | |||
3645 | 111 | monitor_ = new_monitor; | ||
3646 | 112 | monitor.changed.emit(monitor_); | ||
3647 | 104 | } | 113 | } |
3648 | 105 | }; | 114 | }; |
3649 | 106 | 115 | ||
3650 | @@ -329,6 +338,7 @@ | |||
3651 | 329 | MOCK_CONST_METHOD0(GetActiveApplication, unity::ApplicationPtr()); | 338 | MOCK_CONST_METHOD0(GetActiveApplication, unity::ApplicationPtr()); |
3652 | 330 | MOCK_CONST_METHOD1(GetWindowsForMonitor, unity::WindowList(int)); | 339 | MOCK_CONST_METHOD1(GetWindowsForMonitor, unity::WindowList(int)); |
3653 | 331 | MOCK_CONST_METHOD1(GetWindowForId, unity::ApplicationWindowPtr(Window)); | 340 | MOCK_CONST_METHOD1(GetWindowForId, unity::ApplicationWindowPtr(Window)); |
3654 | 341 | MOCK_CONST_METHOD3(FocusWindowGroup, void(unity::WindowList const&, bool, int)); | ||
3655 | 332 | 342 | ||
3656 | 333 | unity::ApplicationPtr LocalGetApplicationForDesktopFile(std::string const& desktop_file) | 343 | unity::ApplicationPtr LocalGetApplicationForDesktopFile(std::string const& desktop_file) |
3657 | 334 | { | 344 | { |
3658 | 335 | 345 | ||
3659 | === modified file 'tests/test_application_launcher_icon.cpp' | |||
3660 | --- tests/test_application_launcher_icon.cpp 2015-05-22 16:04:12 +0000 | |||
3661 | +++ tests/test_application_launcher_icon.cpp 2016-02-09 10:44:04 +0000 | |||
3662 | @@ -50,7 +50,8 @@ | |||
3663 | 50 | typedef nux::ObjectPtr<MockApplicationLauncherIcon> Ptr; | 50 | typedef nux::ObjectPtr<MockApplicationLauncherIcon> Ptr; |
3664 | 51 | 51 | ||
3665 | 52 | MockApplicationLauncherIcon(ApplicationPtr const& app) | 52 | MockApplicationLauncherIcon(ApplicationPtr const& app) |
3667 | 53 | : ApplicationLauncherIcon(app) | 53 | : WindowedLauncherIcon(IconType::APPLICATION) |
3668 | 54 | , ApplicationLauncherIcon(app) | ||
3669 | 54 | { | 55 | { |
3670 | 55 | ON_CALL(*this, Stick(_)).WillByDefault(Invoke([this] (bool save) { ApplicationLauncherIcon::Stick(save); })); | 56 | ON_CALL(*this, Stick(_)).WillByDefault(Invoke([this] (bool save) { ApplicationLauncherIcon::Stick(save); })); |
3671 | 56 | ON_CALL(*this, Stick()).WillByDefault(Invoke([this] { ApplicationLauncherIcon::Stick(); })); | 57 | ON_CALL(*this, Stick()).WillByDefault(Invoke([this] { ApplicationLauncherIcon::Stick(); })); |
3672 | @@ -67,11 +68,14 @@ | |||
3673 | 67 | bool LauncherIconIsSticky() const { return LauncherIcon::IsSticky(); } | 68 | bool LauncherIconIsSticky() const { return LauncherIcon::IsSticky(); } |
3674 | 68 | void LocalActivate(ActionArg a) { ApplicationLauncherIcon::ActivateLauncherIcon(a); } | 69 | void LocalActivate(ActionArg a) { ApplicationLauncherIcon::ActivateLauncherIcon(a); } |
3675 | 69 | 70 | ||
3676 | 70 | using ApplicationLauncherIcon::IsFileManager; | ||
3677 | 71 | using ApplicationLauncherIcon::LogUnityEvent; | 71 | using ApplicationLauncherIcon::LogUnityEvent; |
3678 | 72 | using ApplicationLauncherIcon::Remove; | 72 | using ApplicationLauncherIcon::Remove; |
3679 | 73 | using ApplicationLauncherIcon::SetApplication; | 73 | using ApplicationLauncherIcon::SetApplication; |
3680 | 74 | using ApplicationLauncherIcon::GetApplication; | 74 | using ApplicationLauncherIcon::GetApplication; |
3681 | 75 | using ApplicationLauncherIcon::PerformScroll; | ||
3682 | 76 | using LauncherIcon::BackgroundColor; | ||
3683 | 77 | using LauncherIcon::GetRemoteUri; | ||
3684 | 78 | using LauncherIcon::AllowDetailViewInSwitcher; | ||
3685 | 75 | }; | 79 | }; |
3686 | 76 | 80 | ||
3687 | 77 | MATCHER_P(AreArgsEqual, a, "") | 81 | MATCHER_P(AreArgsEqual, a, "") |
3688 | @@ -90,15 +94,15 @@ | |||
3689 | 90 | virtual void SetUp() override | 94 | virtual void SetUp() override |
3690 | 91 | { | 95 | { |
3691 | 92 | usc_app = std::make_shared<MockApplication::Nice>(USC_DESKTOP, "softwarecenter"); | 96 | usc_app = std::make_shared<MockApplication::Nice>(USC_DESKTOP, "softwarecenter"); |
3693 | 93 | usc_icon = new NiceMock<MockApplicationLauncherIcon>(usc_app); | 97 | usc_icon = new MockApplicationLauncherIcon(usc_app); |
3694 | 94 | ASSERT_EQ(usc_icon->DesktopFile(), USC_DESKTOP); | 98 | ASSERT_EQ(usc_icon->DesktopFile(), USC_DESKTOP); |
3695 | 95 | 99 | ||
3696 | 96 | empty_app = std::make_shared<MockApplication::Nice>(NO_ICON_DESKTOP); | 100 | empty_app = std::make_shared<MockApplication::Nice>(NO_ICON_DESKTOP); |
3698 | 97 | empty_icon = new NiceMock<MockApplicationLauncherIcon>(empty_app); | 101 | empty_icon = new MockApplicationLauncherIcon(empty_app); |
3699 | 98 | ASSERT_EQ(empty_icon->DesktopFile(), NO_ICON_DESKTOP); | 102 | ASSERT_EQ(empty_icon->DesktopFile(), NO_ICON_DESKTOP); |
3700 | 99 | 103 | ||
3701 | 100 | mock_app = std::make_shared<MockApplication::Nice>(); | 104 | mock_app = std::make_shared<MockApplication::Nice>(); |
3703 | 101 | mock_icon = new NiceMock<MockApplicationLauncherIcon>(mock_app); | 105 | mock_icon = new MockApplicationLauncherIcon(mock_app); |
3704 | 102 | ASSERT_TRUE(mock_icon->DesktopFile().empty()); | 106 | ASSERT_TRUE(mock_icon->DesktopFile().empty()); |
3705 | 103 | } | 107 | } |
3706 | 104 | 108 | ||
3707 | @@ -173,7 +177,7 @@ | |||
3708 | 173 | { | 177 | { |
3709 | 174 | std::shared_ptr<MockApplication> app = std::make_shared<MockApplication::Nice>(USC_DESKTOP); | 178 | std::shared_ptr<MockApplication> app = std::make_shared<MockApplication::Nice>(USC_DESKTOP); |
3710 | 175 | { | 179 | { |
3712 | 176 | MockApplicationLauncherIcon::Ptr icon(new NiceMock<MockApplicationLauncherIcon>(app)); | 180 | MockApplicationLauncherIcon::Ptr icon(new MockApplicationLauncherIcon(app)); |
3713 | 177 | EXPECT_FALSE(app->closed.empty()); | 181 | EXPECT_FALSE(app->closed.empty()); |
3714 | 178 | } | 182 | } |
3715 | 179 | 183 | ||
3716 | @@ -266,7 +270,7 @@ | |||
3717 | 266 | auto app = std::make_shared<MockApplication::Nice>(USC_DESKTOP); | 270 | auto app = std::make_shared<MockApplication::Nice>(USC_DESKTOP); |
3718 | 267 | app->sticky = true; | 271 | app->sticky = true; |
3719 | 268 | app->desktop_file_ = UM_DESKTOP; | 272 | app->desktop_file_ = UM_DESKTOP; |
3721 | 269 | MockApplicationLauncherIcon::Ptr icon(new NiceMock<MockApplicationLauncherIcon>(app)); | 273 | MockApplicationLauncherIcon::Ptr icon(new MockApplicationLauncherIcon(app)); |
3722 | 270 | ASSERT_TRUE(icon->IsSticky()); | 274 | ASSERT_TRUE(icon->IsSticky()); |
3723 | 271 | EXPECT_TRUE(icon->LauncherIconIsSticky()); | 275 | EXPECT_TRUE(icon->LauncherIconIsSticky()); |
3724 | 272 | } | 276 | } |
3725 | @@ -275,7 +279,7 @@ | |||
3726 | 275 | { | 279 | { |
3727 | 276 | auto app = std::make_shared<MockApplication::Nice>(); | 280 | auto app = std::make_shared<MockApplication::Nice>(); |
3728 | 277 | app->sticky = true; | 281 | app->sticky = true; |
3730 | 278 | MockApplicationLauncherIcon::Ptr icon(new NiceMock<MockApplicationLauncherIcon>(app)); | 282 | MockApplicationLauncherIcon::Ptr icon(new MockApplicationLauncherIcon(app)); |
3731 | 279 | ASSERT_FALSE(icon->IsSticky()); | 283 | ASSERT_FALSE(icon->IsSticky()); |
3732 | 280 | EXPECT_FALSE(icon->LauncherIconIsSticky()); | 284 | EXPECT_FALSE(icon->LauncherIconIsSticky()); |
3733 | 281 | } | 285 | } |
3734 | @@ -291,7 +295,7 @@ | |||
3735 | 291 | TEST_F(TestApplicationLauncherIcon, StickAndSaveDesktopLessAppCreatesNewDesktop) | 295 | TEST_F(TestApplicationLauncherIcon, StickAndSaveDesktopLessAppCreatesNewDesktop) |
3736 | 292 | { | 296 | { |
3737 | 293 | auto app = std::make_shared<MockApplication::Nice>(); | 297 | auto app = std::make_shared<MockApplication::Nice>(); |
3739 | 294 | MockApplicationLauncherIcon::Ptr icon(new NiceMock<MockApplicationLauncherIcon>(app)); | 298 | MockApplicationLauncherIcon::Ptr icon(new MockApplicationLauncherIcon(app)); |
3740 | 295 | 299 | ||
3741 | 296 | EXPECT_CALL(*app, CreateLocalDesktopFile()); | 300 | EXPECT_CALL(*app, CreateLocalDesktopFile()); |
3742 | 297 | icon->Stick(true); | 301 | icon->Stick(true); |
3743 | @@ -354,7 +358,7 @@ | |||
3744 | 354 | TEST_F(TestApplicationLauncherIcon, UnstickDesktopLessAppLogEvent) | 358 | TEST_F(TestApplicationLauncherIcon, UnstickDesktopLessAppLogEvent) |
3745 | 355 | { | 359 | { |
3746 | 356 | auto app = std::make_shared<MockApplication::Nice>(); | 360 | auto app = std::make_shared<MockApplication::Nice>(); |
3748 | 357 | MockApplicationLauncherIcon::Ptr icon(new NiceMock<MockApplicationLauncherIcon>(app)); | 361 | MockApplicationLauncherIcon::Ptr icon(new MockApplicationLauncherIcon(app)); |
3749 | 358 | 362 | ||
3750 | 359 | EXPECT_CALL(*unity_app_, LogEvent(ApplicationEventType::ACCESS, _)).Times(0); | 363 | EXPECT_CALL(*unity_app_, LogEvent(ApplicationEventType::ACCESS, _)).Times(0); |
3751 | 360 | icon->UnStick(); | 364 | icon->UnStick(); |
3752 | @@ -1103,25 +1107,6 @@ | |||
3753 | 1103 | dbusmenu_menuitem_handle_event(item, DBUSMENU_MENUITEM_EVENT_ACTIVATED, nullptr, 0); | 1107 | dbusmenu_menuitem_handle_event(item, DBUSMENU_MENUITEM_EVENT_ACTIVATED, nullptr, 0); |
3754 | 1104 | } | 1108 | } |
3755 | 1105 | 1109 | ||
3756 | 1106 | TEST_F(TestApplicationLauncherIcon, IsFileManager) | ||
3757 | 1107 | { | ||
3758 | 1108 | EXPECT_FALSE(usc_icon->IsFileManager()); | ||
3759 | 1109 | EXPECT_FALSE(empty_icon->IsFileManager()); | ||
3760 | 1110 | EXPECT_FALSE(mock_icon->IsFileManager()); | ||
3761 | 1111 | |||
3762 | 1112 | auto app = std::make_shared<MockApplication::Nice>("/any/path/org.gnome.Nautilus.desktop", "Nautilus"); | ||
3763 | 1113 | MockApplicationLauncherIcon::Ptr icon(new NiceMock<MockApplicationLauncherIcon>(app)); | ||
3764 | 1114 | EXPECT_TRUE(icon->IsFileManager()); | ||
3765 | 1115 | |||
3766 | 1116 | app = std::make_shared<MockApplication::Nice>("/any/path/nautilus-folder-handler.desktop", "Nautilus"); | ||
3767 | 1117 | icon = new NiceMock<MockApplicationLauncherIcon>(app); | ||
3768 | 1118 | EXPECT_TRUE(icon->IsFileManager()); | ||
3769 | 1119 | |||
3770 | 1120 | app = std::make_shared<MockApplication::Nice>("/any/path/nautilus-home.desktop", "Nautilus"); | ||
3771 | 1121 | icon = new NiceMock<MockApplicationLauncherIcon>(app); | ||
3772 | 1122 | EXPECT_TRUE(icon->IsFileManager()); | ||
3773 | 1123 | } | ||
3774 | 1124 | |||
3775 | 1125 | TEST_F(TestApplicationLauncherIcon, AllowDetailViewInSwitcher) | 1110 | TEST_F(TestApplicationLauncherIcon, AllowDetailViewInSwitcher) |
3776 | 1126 | { | 1111 | { |
3777 | 1127 | mock_app->type_ = AppType::NORMAL; | 1112 | mock_app->type_ = AppType::NORMAL; |
3778 | @@ -1232,7 +1217,7 @@ | |||
3779 | 1232 | mock_icon->Remove(); | 1217 | mock_icon->Remove(); |
3780 | 1233 | ASSERT_FALSE(mock_app->seen); | 1218 | ASSERT_FALSE(mock_app->seen); |
3781 | 1234 | 1219 | ||
3783 | 1235 | MockApplicationLauncherIcon::Ptr new_icon(new NiceMock<MockApplicationLauncherIcon>(mock_app)); | 1220 | MockApplicationLauncherIcon::Ptr new_icon(new MockApplicationLauncherIcon(mock_app)); |
3784 | 1236 | mock_icon = nullptr; | 1221 | mock_icon = nullptr; |
3785 | 1237 | 1222 | ||
3786 | 1238 | EXPECT_TRUE(mock_app->seen); | 1223 | EXPECT_TRUE(mock_app->seen); |
3787 | 1239 | 1224 | ||
3788 | === modified file 'tests/test_launcher_controller.cpp' | |||
3789 | --- tests/test_launcher_controller.cpp 2015-04-16 14:38:54 +0000 | |||
3790 | +++ tests/test_launcher_controller.cpp 2016-02-09 10:44:04 +0000 | |||
3791 | @@ -136,8 +136,10 @@ | |||
3792 | 136 | 136 | ||
3793 | 137 | struct MockApplicationLauncherIcon : ApplicationLauncherIcon | 137 | struct MockApplicationLauncherIcon : ApplicationLauncherIcon |
3794 | 138 | { | 138 | { |
3797 | 139 | typedef NiceMock<MockApplicationLauncherIcon> Nice; | 139 | // NiceMock doesn't work well with Virtual Inheritance, so we need to disable it |
3798 | 140 | typedef nux::ObjectPtr<MockApplicationLauncherIcon::Nice> Ptr; | 140 | //typedef NiceMock<MockApplicationLauncherIcon> Nice; |
3799 | 141 | typedef MockApplicationLauncherIcon Nice; | ||
3800 | 142 | typedef nux::ObjectPtr<MockApplicationLauncherIcon> Ptr; | ||
3801 | 141 | typedef bool Fake; | 143 | typedef bool Fake; |
3802 | 142 | 144 | ||
3803 | 143 | MockApplicationLauncherIcon(Fake = true, std::string const& remote_uri = "") | 145 | MockApplicationLauncherIcon(Fake = true, std::string const& remote_uri = "") |
3804 | @@ -154,7 +156,8 @@ | |||
3805 | 154 | } | 156 | } |
3806 | 155 | 157 | ||
3807 | 156 | explicit MockApplicationLauncherIcon(ApplicationPtr const& app) | 158 | explicit MockApplicationLauncherIcon(ApplicationPtr const& app) |
3809 | 157 | : ApplicationLauncherIcon(app) | 159 | : WindowedLauncherIcon(IconType::APPLICATION) |
3810 | 160 | , ApplicationLauncherIcon(app) | ||
3811 | 158 | { | 161 | { |
3812 | 159 | ON_CALL(*this, Stick(_)).WillByDefault(Invoke([this] (bool save) { ApplicationLauncherIcon::Stick(save); })); | 162 | ON_CALL(*this, Stick(_)).WillByDefault(Invoke([this] (bool save) { ApplicationLauncherIcon::Stick(save); })); |
3813 | 160 | ON_CALL(*this, UnStick()).WillByDefault(Invoke([this] { ApplicationLauncherIcon::UnStick(); })); | 163 | ON_CALL(*this, UnStick()).WillByDefault(Invoke([this] { ApplicationLauncherIcon::UnStick(); })); |
3814 | @@ -170,15 +173,18 @@ | |||
3815 | 170 | MOCK_CONST_METHOD0(GetRemoteUri, std::string()); | 173 | MOCK_CONST_METHOD0(GetRemoteUri, std::string()); |
3816 | 171 | MOCK_METHOD1(Stick, void(bool)); | 174 | MOCK_METHOD1(Stick, void(bool)); |
3817 | 172 | MOCK_METHOD0(UnStick, void()); | 175 | MOCK_METHOD0(UnStick, void()); |
3819 | 173 | MOCK_METHOD0(Quit, void()); | 176 | MOCK_CONST_METHOD0(Quit, void()); |
3820 | 174 | }; | 177 | }; |
3821 | 175 | 178 | ||
3822 | 176 | struct MockVolumeLauncherIcon : public VolumeLauncherIcon | 179 | struct MockVolumeLauncherIcon : public VolumeLauncherIcon |
3823 | 177 | { | 180 | { |
3824 | 178 | typedef nux::ObjectPtr<MockVolumeLauncherIcon> Ptr; | 181 | typedef nux::ObjectPtr<MockVolumeLauncherIcon> Ptr; |
3825 | 182 | // typedef NiceMock<MockVolumeLauncherIcon> Nice; | ||
3826 | 183 | typedef MockVolumeLauncherIcon Nice; | ||
3827 | 179 | 184 | ||
3828 | 180 | MockVolumeLauncherIcon() | 185 | MockVolumeLauncherIcon() |
3830 | 181 | : VolumeLauncherIcon(Volume::Ptr(volume_ = new NiceMock<MockVolume>()), | 186 | : WindowedLauncherIcon(IconType::DEVICE) |
3831 | 187 | , VolumeLauncherIcon(Volume::Ptr(volume_ = new NiceMock<MockVolume>()), | ||
3832 | 182 | std::make_shared<MockDevicesSettings::Nice>(), | 188 | std::make_shared<MockDevicesSettings::Nice>(), |
3833 | 183 | std::make_shared<MockDeviceNotificationDisplay::Nice>(), | 189 | std::make_shared<MockDeviceNotificationDisplay::Nice>(), |
3834 | 184 | std::make_shared<MockFileManager::Nice>()) | 190 | std::make_shared<MockFileManager::Nice>()) |
3835 | @@ -269,7 +275,7 @@ | |||
3836 | 269 | void DisconnectSignals() | 275 | void DisconnectSignals() |
3837 | 270 | { | 276 | { |
3838 | 271 | ApplicationManager::Default().application_started.clear(); | 277 | ApplicationManager::Default().application_started.clear(); |
3840 | 272 | Impl()->device_section_.icon_added.clear(); | 278 | Impl()->device_section_->icon_added.clear(); |
3841 | 273 | Impl()->model_->icon_removed.clear(); | 279 | Impl()->model_->icon_removed.clear(); |
3842 | 274 | Impl()->model_->saved.clear(); | 280 | Impl()->model_->saved.clear(); |
3843 | 275 | Impl()->model_->order_changed.clear(); | 281 | Impl()->model_->order_changed.clear(); |
3844 | @@ -640,8 +646,8 @@ | |||
3845 | 640 | 646 | ||
3846 | 641 | TEST_F(TestLauncherController, CreateFavoriteDevice) | 647 | TEST_F(TestLauncherController, CreateFavoriteDevice) |
3847 | 642 | { | 648 | { |
3850 | 643 | lc.Impl()->device_section_ = MockDeviceLauncherSection(); | 649 | lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>(); |
3851 | 644 | auto const& icons = lc.Impl()->device_section_.GetIcons(); | 650 | auto const& icons = lc.Impl()->device_section_->GetIcons(); |
3852 | 645 | auto const& device_icon = icons.front(); | 651 | auto const& device_icon = icons.front(); |
3853 | 646 | 652 | ||
3854 | 647 | ASSERT_TRUE(device_icon.IsValid()); | 653 | ASSERT_TRUE(device_icon.IsValid()); |
3855 | @@ -903,8 +909,8 @@ | |||
3856 | 903 | { | 909 | { |
3857 | 904 | lc.ClearModel(); | 910 | lc.ClearModel(); |
3858 | 905 | lc.DisconnectSignals(); | 911 | lc.DisconnectSignals(); |
3861 | 906 | lc.Impl()->device_section_ = MockDeviceLauncherSection(); | 912 | lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>(); |
3862 | 907 | auto const& icons = lc.Impl()->device_section_.GetIcons(); | 913 | auto const& icons = lc.Impl()->device_section_->GetIcons(); |
3863 | 908 | auto const& device_icon1 = icons.front(); | 914 | auto const& device_icon1 = icons.front(); |
3864 | 909 | auto const& device_icon2 = *(std::next(icons.begin())); | 915 | auto const& device_icon2 = *(std::next(icons.begin())); |
3865 | 910 | 916 | ||
3866 | @@ -949,7 +955,7 @@ | |||
3867 | 949 | TEST_F(TestLauncherController, SetupIcons) | 955 | TEST_F(TestLauncherController, SetupIcons) |
3868 | 950 | { | 956 | { |
3869 | 951 | lc.ClearModel(); | 957 | lc.ClearModel(); |
3871 | 952 | lc.Impl()->device_section_ = MockDeviceLauncherSection(); | 958 | lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>(); |
3872 | 953 | lc.Impl()->expo_icon_->UnStick(); | 959 | lc.Impl()->expo_icon_->UnStick(); |
3873 | 954 | lc.Impl()->desktop_icon_->UnStick(); | 960 | lc.Impl()->desktop_icon_->UnStick(); |
3874 | 955 | auto const& model = lc.Impl()->model_; | 961 | auto const& model = lc.Impl()->model_; |
3875 | @@ -970,7 +976,7 @@ | |||
3876 | 970 | fav = lc.Impl()->GetIconByUri(FavoriteStore::URI_PREFIX_APP + app::SW_CENTER); | 976 | fav = lc.Impl()->GetIconByUri(FavoriteStore::URI_PREFIX_APP + app::SW_CENTER); |
3877 | 971 | EXPECT_EQ(model->IconIndex(fav), ++icon_index); | 977 | EXPECT_EQ(model->IconIndex(fav), ++icon_index); |
3878 | 972 | 978 | ||
3880 | 973 | for (auto const& device : lc.Impl()->device_section_.GetIcons()) | 979 | for (auto const& device : lc.Impl()->device_section_->GetIcons()) |
3881 | 974 | ASSERT_EQ(model->IconIndex(device), ++icon_index); | 980 | ASSERT_EQ(model->IconIndex(device), ++icon_index); |
3882 | 975 | 981 | ||
3883 | 976 | fav = lc.Impl()->GetIconByUri(FavoriteStore::URI_PREFIX_APP + app::UPDATE_MANAGER); | 982 | fav = lc.Impl()->GetIconByUri(FavoriteStore::URI_PREFIX_APP + app::UPDATE_MANAGER); |
3884 | @@ -995,7 +1001,7 @@ | |||
3885 | 995 | TEST_F(TestLauncherController, ResetIconPriorities) | 1001 | TEST_F(TestLauncherController, ResetIconPriorities) |
3886 | 996 | { | 1002 | { |
3887 | 997 | lc.ClearModel(); | 1003 | lc.ClearModel(); |
3889 | 998 | lc.Impl()->device_section_ = MockDeviceLauncherSection(); | 1004 | lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>(); |
3890 | 999 | auto const& model = lc.Impl()->model_; | 1005 | auto const& model = lc.Impl()->model_; |
3891 | 1000 | 1006 | ||
3892 | 1001 | favorite_store.AddFavorite(places::APPS_URI, -1); | 1007 | favorite_store.AddFavorite(places::APPS_URI, -1); |
3893 | @@ -1012,7 +1018,7 @@ | |||
3894 | 1012 | 1018 | ||
3895 | 1013 | int icon_index = -1; | 1019 | int icon_index = -1; |
3896 | 1014 | 1020 | ||
3898 | 1015 | for (auto const& device : lc.Impl()->device_section_.GetIcons()) | 1021 | for (auto const& device : lc.Impl()->device_section_->GetIcons()) |
3899 | 1016 | ASSERT_EQ(model->IconIndex(device), ++icon_index); | 1022 | ASSERT_EQ(model->IconIndex(device), ++icon_index); |
3900 | 1017 | 1023 | ||
3901 | 1018 | auto fav = lc.Impl()->GetIconByUri(FavoriteStore::URI_PREFIX_APP + app::SW_CENTER); | 1024 | auto fav = lc.Impl()->GetIconByUri(FavoriteStore::URI_PREFIX_APP + app::SW_CENTER); |
3902 | @@ -1043,8 +1049,8 @@ | |||
3903 | 1043 | TEST_F(TestLauncherController, GetLastIconPriorityUnSticky) | 1049 | TEST_F(TestLauncherController, GetLastIconPriorityUnSticky) |
3904 | 1044 | { | 1050 | { |
3905 | 1045 | lc.ClearModel(); | 1051 | lc.ClearModel(); |
3908 | 1046 | lc.Impl()->device_section_ = MockDeviceLauncherSection(3); | 1052 | lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>(3); |
3909 | 1047 | auto const& device_icons = lc.Impl()->device_section_.GetIcons(); | 1053 | auto const& device_icons = lc.Impl()->device_section_->GetIcons(); |
3910 | 1048 | auto const& last_device = device_icons.back(); | 1054 | auto const& last_device = device_icons.back(); |
3911 | 1049 | 1055 | ||
3912 | 1050 | favorite_store.SetFavorites({ places::DEVICES_URI, | 1056 | favorite_store.SetFavorites({ places::DEVICES_URI, |
3913 | @@ -1060,8 +1066,8 @@ | |||
3914 | 1060 | TEST_F(TestLauncherController, GetLastIconPriorityUnStickyWithAllStickyIcons) | 1066 | TEST_F(TestLauncherController, GetLastIconPriorityUnStickyWithAllStickyIcons) |
3915 | 1061 | { | 1067 | { |
3916 | 1062 | lc.ClearModel(); | 1068 | lc.ClearModel(); |
3919 | 1063 | lc.Impl()->device_section_ = MockDeviceLauncherSection(3); | 1069 | lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>(3); |
3920 | 1064 | auto const& device_icons = lc.Impl()->device_section_.GetIcons(); | 1070 | auto const& device_icons = lc.Impl()->device_section_->GetIcons(); |
3921 | 1065 | auto const& last_device = device_icons.back(); | 1071 | auto const& last_device = device_icons.back(); |
3922 | 1066 | 1072 | ||
3923 | 1067 | favorite_store.SetFavorites({ places::DEVICES_URI, | 1073 | favorite_store.SetFavorites({ places::DEVICES_URI, |
3924 | @@ -1080,8 +1086,8 @@ | |||
3925 | 1080 | TEST_F(TestLauncherController, GetLastIconPriorityUnStickyWithSomeStickyIcons) | 1086 | TEST_F(TestLauncherController, GetLastIconPriorityUnStickyWithSomeStickyIcons) |
3926 | 1081 | { | 1087 | { |
3927 | 1082 | lc.ClearModel(); | 1088 | lc.ClearModel(); |
3930 | 1083 | lc.Impl()->device_section_ = MockDeviceLauncherSection(3); | 1089 | lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>(3); |
3931 | 1084 | auto const& device_icons = lc.Impl()->device_section_.GetIcons(); | 1090 | auto const& device_icons = lc.Impl()->device_section_->GetIcons(); |
3932 | 1085 | auto const& first_device = *(std::next(device_icons.rbegin())); | 1091 | auto const& first_device = *(std::next(device_icons.rbegin())); |
3933 | 1086 | auto const& last_device = device_icons.back(); | 1092 | auto const& last_device = device_icons.back(); |
3934 | 1087 | 1093 | ||
3935 | @@ -1100,7 +1106,7 @@ | |||
3936 | 1100 | TEST_F(TestLauncherController, GetLastIconPriorityUnStickyWithNoIcons) | 1106 | TEST_F(TestLauncherController, GetLastIconPriorityUnStickyWithNoIcons) |
3937 | 1101 | { | 1107 | { |
3938 | 1102 | lc.ClearModel(); | 1108 | lc.ClearModel(); |
3940 | 1103 | lc.Impl()->device_section_ = MockDeviceLauncherSection(0); | 1109 | lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>(0); |
3941 | 1104 | lc.Impl()->SetupIcons(); | 1110 | lc.Impl()->SetupIcons(); |
3942 | 1105 | lc.DisconnectSignals(); | 1111 | lc.DisconnectSignals(); |
3943 | 1106 | 1112 | ||
3944 | @@ -1111,7 +1117,7 @@ | |||
3945 | 1111 | TEST_F(TestLauncherController, GetLastIconPriorityUnStickyWithNoIconsAndUri) | 1117 | TEST_F(TestLauncherController, GetLastIconPriorityUnStickyWithNoIconsAndUri) |
3946 | 1112 | { | 1118 | { |
3947 | 1113 | lc.ClearModel(); | 1119 | lc.ClearModel(); |
3949 | 1114 | lc.Impl()->device_section_ = MockDeviceLauncherSection(0); | 1120 | lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>(0); |
3950 | 1115 | 1121 | ||
3951 | 1116 | favorite_store.SetFavorites({ places::DEVICES_URI, | 1122 | favorite_store.SetFavorites({ places::DEVICES_URI, |
3952 | 1117 | FavoriteStore::URI_PREFIX_APP + app::SW_CENTER }); | 1123 | FavoriteStore::URI_PREFIX_APP + app::SW_CENTER }); |
3953 | @@ -1136,11 +1142,11 @@ | |||
3954 | 1136 | TEST_F(TestLauncherController, GetLastIconPrioritySticky) | 1142 | TEST_F(TestLauncherController, GetLastIconPrioritySticky) |
3955 | 1137 | { | 1143 | { |
3956 | 1138 | lc.ClearModel(); | 1144 | lc.ClearModel(); |
3958 | 1139 | lc.Impl()->device_section_ = MockDeviceLauncherSection(3); | 1145 | lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>(3); |
3959 | 1140 | lc.Impl()->SetupIcons(); | 1146 | lc.Impl()->SetupIcons(); |
3960 | 1141 | lc.DisconnectSignals(); | 1147 | lc.DisconnectSignals(); |
3961 | 1142 | 1148 | ||
3963 | 1143 | auto const& device_icons = lc.Impl()->device_section_.GetIcons(); | 1149 | auto const& device_icons = lc.Impl()->device_section_->GetIcons(); |
3964 | 1144 | auto const& first_device = device_icons.front(); | 1150 | auto const& first_device = device_icons.front(); |
3965 | 1145 | 1151 | ||
3966 | 1146 | int last_priority = lc.Impl()->GetLastIconPriority<VolumeLauncherIcon>("", true); | 1152 | int last_priority = lc.Impl()->GetLastIconPriority<VolumeLauncherIcon>("", true); |
3967 | @@ -1150,8 +1156,8 @@ | |||
3968 | 1150 | TEST_F(TestLauncherController, GetLastIconPriorityStickyWithAllStickyIcons) | 1156 | TEST_F(TestLauncherController, GetLastIconPriorityStickyWithAllStickyIcons) |
3969 | 1151 | { | 1157 | { |
3970 | 1152 | lc.ClearModel(); | 1158 | lc.ClearModel(); |
3973 | 1153 | lc.Impl()->device_section_ = MockDeviceLauncherSection(3); | 1159 | lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>(3); |
3974 | 1154 | auto const& device_icons = lc.Impl()->device_section_.GetIcons(); | 1160 | auto const& device_icons = lc.Impl()->device_section_->GetIcons(); |
3975 | 1155 | auto const& last_device = device_icons.back(); | 1161 | auto const& last_device = device_icons.back(); |
3976 | 1156 | 1162 | ||
3977 | 1157 | favorite_store.SetFavorites({ places::DEVICES_URI, | 1163 | favorite_store.SetFavorites({ places::DEVICES_URI, |
3978 | @@ -1170,8 +1176,8 @@ | |||
3979 | 1170 | TEST_F(TestLauncherController, GetLastIconPriorityStickyWithSomeStickyIcons) | 1176 | TEST_F(TestLauncherController, GetLastIconPriorityStickyWithSomeStickyIcons) |
3980 | 1171 | { | 1177 | { |
3981 | 1172 | lc.ClearModel(); | 1178 | lc.ClearModel(); |
3984 | 1173 | lc.Impl()->device_section_ = MockDeviceLauncherSection(3); | 1179 | lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>(3); |
3985 | 1174 | auto const& device_icons = lc.Impl()->device_section_.GetIcons(); | 1180 | auto const& device_icons = lc.Impl()->device_section_->GetIcons(); |
3986 | 1175 | auto const& first_device = *(std::next(device_icons.rbegin())); | 1181 | auto const& first_device = *(std::next(device_icons.rbegin())); |
3987 | 1176 | 1182 | ||
3988 | 1177 | favorite_store.SetFavorites({ places::DEVICES_URI, | 1183 | favorite_store.SetFavorites({ places::DEVICES_URI, |
3989 | @@ -1189,7 +1195,7 @@ | |||
3990 | 1189 | TEST_F(TestLauncherController, GetLastIconPriorityStickyWithNoIcons) | 1195 | TEST_F(TestLauncherController, GetLastIconPriorityStickyWithNoIcons) |
3991 | 1190 | { | 1196 | { |
3992 | 1191 | lc.ClearModel(); | 1197 | lc.ClearModel(); |
3994 | 1192 | lc.Impl()->device_section_ = MockDeviceLauncherSection(0); | 1198 | lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>(0); |
3995 | 1193 | lc.Impl()->SetupIcons(); | 1199 | lc.Impl()->SetupIcons(); |
3996 | 1194 | lc.DisconnectSignals(); | 1200 | lc.DisconnectSignals(); |
3997 | 1195 | 1201 | ||
3998 | @@ -1240,8 +1246,8 @@ | |||
3999 | 1240 | TEST_F(TestLauncherController, LauncherAddRequestDeviceAdd) | 1246 | TEST_F(TestLauncherController, LauncherAddRequestDeviceAdd) |
4000 | 1241 | { | 1247 | { |
4001 | 1242 | auto const& model = lc.Impl()->model_; | 1248 | auto const& model = lc.Impl()->model_; |
4004 | 1243 | lc.Impl()->device_section_ = MockDeviceLauncherSection(); | 1249 | lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>(); |
4005 | 1244 | auto const& icons = lc.Impl()->device_section_.GetIcons(); | 1250 | auto const& icons = lc.Impl()->device_section_->GetIcons(); |
4006 | 1245 | auto const& device_icon = icons.front(); | 1251 | auto const& device_icon = icons.front(); |
4007 | 1246 | auto const& icon_uri = device_icon->RemoteUri(); | 1252 | auto const& icon_uri = device_icon->RemoteUri(); |
4008 | 1247 | 1253 | ||
4009 | @@ -1262,7 +1268,7 @@ | |||
4010 | 1262 | TEST_F(TestLauncherController, LauncherAddRequestDeviceStick) | 1268 | TEST_F(TestLauncherController, LauncherAddRequestDeviceStick) |
4011 | 1263 | { | 1269 | { |
4012 | 1264 | auto const& model = lc.Impl()->model_; | 1270 | auto const& model = lc.Impl()->model_; |
4014 | 1265 | MockVolumeLauncherIcon::Ptr device_icon(new NiceMock<MockVolumeLauncherIcon>()); | 1271 | MockVolumeLauncherIcon::Ptr device_icon(new MockVolumeLauncherIcon::Nice()); |
4015 | 1266 | lc.Impl()->RegisterIcon(device_icon, std::numeric_limits<int>::max()); | 1272 | lc.Impl()->RegisterIcon(device_icon, std::numeric_limits<int>::max()); |
4016 | 1267 | 1273 | ||
4017 | 1268 | auto app_icons = model->GetSublist<ApplicationLauncherIcon>(); | 1274 | auto app_icons = model->GetSublist<ApplicationLauncherIcon>(); |
4018 | @@ -1287,7 +1293,7 @@ | |||
4019 | 1287 | 1293 | ||
4020 | 1288 | TEST_F(TestLauncherController, LauncherRemoveRequestDeviceEjects) | 1294 | TEST_F(TestLauncherController, LauncherRemoveRequestDeviceEjects) |
4021 | 1289 | { | 1295 | { |
4023 | 1290 | MockVolumeLauncherIcon::Ptr device_icon(new NiceMock<MockVolumeLauncherIcon>()); | 1296 | MockVolumeLauncherIcon::Ptr device_icon(new MockVolumeLauncherIcon::Nice()); |
4024 | 1291 | 1297 | ||
4025 | 1292 | EXPECT_CALL(*(device_icon->volume_), CanBeEjected()) | 1298 | EXPECT_CALL(*(device_icon->volume_), CanBeEjected()) |
4026 | 1293 | .WillRepeatedly(Return(true)); | 1299 | .WillRepeatedly(Return(true)); |
4027 | @@ -1302,7 +1308,7 @@ | |||
4028 | 1302 | 1308 | ||
4029 | 1303 | TEST_F(TestLauncherController, LauncherRemoveRequestDeviceStops) | 1309 | TEST_F(TestLauncherController, LauncherRemoveRequestDeviceStops) |
4030 | 1304 | { | 1310 | { |
4032 | 1305 | MockVolumeLauncherIcon::Ptr device_icon(new NiceMock<MockVolumeLauncherIcon>()); | 1311 | MockVolumeLauncherIcon::Ptr device_icon(new MockVolumeLauncherIcon::Nice()); |
4033 | 1306 | 1312 | ||
4034 | 1307 | EXPECT_CALL(*(device_icon->volume_), CanBeEjected()) | 1313 | EXPECT_CALL(*(device_icon->volume_), CanBeEjected()) |
4035 | 1308 | .WillRepeatedly(Return(false)); | 1314 | .WillRepeatedly(Return(false)); |
4036 | @@ -1362,7 +1368,7 @@ | |||
4037 | 1362 | invisible_app->SetQuirk(AbstractLauncherIcon::Quirk::VISIBLE, false); | 1368 | invisible_app->SetQuirk(AbstractLauncherIcon::Quirk::VISIBLE, false); |
4038 | 1363 | lc.Impl()->RegisterIcon(invisible_app, ++priority); | 1369 | lc.Impl()->RegisterIcon(invisible_app, ++priority); |
4039 | 1364 | 1370 | ||
4041 | 1365 | MockVolumeLauncherIcon::Ptr sticky_device(new NiceMock<MockVolumeLauncherIcon>()); | 1371 | MockVolumeLauncherIcon::Ptr sticky_device(new MockVolumeLauncherIcon::Nice()); |
4042 | 1366 | sticky_device->Stick(false); | 1372 | sticky_device->Stick(false); |
4043 | 1367 | lc.Impl()->RegisterIcon(sticky_device, ++priority); | 1373 | lc.Impl()->RegisterIcon(sticky_device, ++priority); |
4044 | 1368 | 1374 | ||
4045 | @@ -1393,7 +1399,7 @@ | |||
4046 | 1393 | sticky_app->Stick(false); | 1399 | sticky_app->Stick(false); |
4047 | 1394 | lc.Impl()->RegisterIcon(sticky_app, ++priority); | 1400 | lc.Impl()->RegisterIcon(sticky_app, ++priority); |
4048 | 1395 | 1401 | ||
4050 | 1396 | MockVolumeLauncherIcon::Ptr sticky_device(new NiceMock<MockVolumeLauncherIcon>()); | 1402 | MockVolumeLauncherIcon::Ptr sticky_device(new MockVolumeLauncherIcon::Nice()); |
4051 | 1397 | sticky_device->Stick(false); | 1403 | sticky_device->Stick(false); |
4052 | 1398 | lc.Impl()->RegisterIcon(sticky_device, ++priority); | 1404 | lc.Impl()->RegisterIcon(sticky_device, ++priority); |
4053 | 1399 | 1405 | ||
4054 | @@ -1422,7 +1428,7 @@ | |||
4055 | 1422 | sticky_app->Stick(false); | 1428 | sticky_app->Stick(false); |
4056 | 1423 | lc.Impl()->RegisterIcon(sticky_app, ++priority); | 1429 | lc.Impl()->RegisterIcon(sticky_app, ++priority); |
4057 | 1424 | 1430 | ||
4059 | 1425 | MockVolumeLauncherIcon::Ptr sticky_device(new NiceMock<MockVolumeLauncherIcon>()); | 1431 | MockVolumeLauncherIcon::Ptr sticky_device(new MockVolumeLauncherIcon::Nice()); |
4060 | 1426 | sticky_device->Stick(false); | 1432 | sticky_device->Stick(false); |
4061 | 1427 | lc.Impl()->RegisterIcon(sticky_device, ++priority); | 1433 | lc.Impl()->RegisterIcon(sticky_device, ++priority); |
4062 | 1428 | 1434 | ||
4063 | @@ -1447,7 +1453,7 @@ | |||
4064 | 1447 | sticky_app->Stick(false); | 1453 | sticky_app->Stick(false); |
4065 | 1448 | lc.Impl()->RegisterIcon(sticky_app, ++priority); | 1454 | lc.Impl()->RegisterIcon(sticky_app, ++priority); |
4066 | 1449 | 1455 | ||
4068 | 1450 | MockVolumeLauncherIcon::Ptr sticky_device(new NiceMock<MockVolumeLauncherIcon>()); | 1456 | MockVolumeLauncherIcon::Ptr sticky_device(new MockVolumeLauncherIcon::Nice()); |
4069 | 1451 | sticky_device->Stick(false); | 1457 | sticky_device->Stick(false); |
4070 | 1452 | lc.Impl()->RegisterIcon(sticky_device, ++priority); | 1458 | lc.Impl()->RegisterIcon(sticky_device, ++priority); |
4071 | 1453 | 1459 | ||
4072 | @@ -1597,9 +1603,9 @@ | |||
4073 | 1597 | TEST_F(TestLauncherController, OnFavoriteStoreFavoriteAddedDeviceSection) | 1603 | TEST_F(TestLauncherController, OnFavoriteStoreFavoriteAddedDeviceSection) |
4074 | 1598 | { | 1604 | { |
4075 | 1599 | lc.ClearModel(); | 1605 | lc.ClearModel(); |
4077 | 1600 | lc.Impl()->device_section_ = MockDeviceLauncherSection(); | 1606 | lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>(); |
4078 | 1601 | auto const& model = lc.Impl()->model_; | 1607 | auto const& model = lc.Impl()->model_; |
4080 | 1602 | auto const& icons = lc.Impl()->device_section_.GetIcons(); | 1608 | auto const& icons = lc.Impl()->device_section_->GetIcons(); |
4081 | 1603 | auto const& device_icon1(icons.front()); | 1609 | auto const& device_icon1(icons.front()); |
4082 | 1604 | auto const& device_icon2(*(std::next(icons.begin()))); | 1610 | auto const& device_icon2(*(std::next(icons.begin()))); |
4083 | 1605 | 1611 | ||
4084 | @@ -1634,10 +1640,10 @@ | |||
4085 | 1634 | TEST_F(TestLauncherController, OnFavoriteStoreFavoriteRemovedDevice) | 1640 | TEST_F(TestLauncherController, OnFavoriteStoreFavoriteRemovedDevice) |
4086 | 1635 | { | 1641 | { |
4087 | 1636 | lc.ClearModel(); | 1642 | lc.ClearModel(); |
4089 | 1637 | lc.Impl()->device_section_ = MockDeviceLauncherSection(); | 1643 | lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>(); |
4090 | 1638 | auto const& model = lc.Impl()->model_; | 1644 | auto const& model = lc.Impl()->model_; |
4091 | 1639 | 1645 | ||
4093 | 1640 | auto const& icons = lc.Impl()->device_section_.GetIcons(); | 1646 | auto const& icons = lc.Impl()->device_section_->GetIcons(); |
4094 | 1641 | auto const& device_icon(icons.front()); | 1647 | auto const& device_icon(icons.front()); |
4095 | 1642 | 1648 | ||
4096 | 1643 | favorite_store.SetFavorites({ lc.Impl()->expo_icon_->RemoteUri(), | 1649 | favorite_store.SetFavorites({ lc.Impl()->expo_icon_->RemoteUri(), |
4097 | @@ -1660,10 +1666,10 @@ | |||
4098 | 1660 | TEST_F(TestLauncherController, OnFavoriteStoreFavoriteRemovedDeviceSection) | 1666 | TEST_F(TestLauncherController, OnFavoriteStoreFavoriteRemovedDeviceSection) |
4099 | 1661 | { | 1667 | { |
4100 | 1662 | lc.ClearModel(); | 1668 | lc.ClearModel(); |
4102 | 1663 | lc.Impl()->device_section_ = MockDeviceLauncherSection(); | 1669 | lc.Impl()->device_section_ = std::make_shared<MockDeviceLauncherSection>(); |
4103 | 1664 | auto const& model = lc.Impl()->model_; | 1670 | auto const& model = lc.Impl()->model_; |
4104 | 1665 | 1671 | ||
4106 | 1666 | auto const& icons = lc.Impl()->device_section_.GetIcons(); | 1672 | auto const& icons = lc.Impl()->device_section_->GetIcons(); |
4107 | 1667 | auto const& device_icon1(icons.front()); | 1673 | auto const& device_icon1(icons.front()); |
4108 | 1668 | auto const& device_icon2(*(std::next(icons.begin()))); | 1674 | auto const& device_icon2(*(std::next(icons.begin()))); |
4109 | 1669 | 1675 | ||
4110 | @@ -1958,10 +1964,9 @@ | |||
4111 | 1958 | unity::glib::Object<BamfMockApplication> bamf_mock_application(bamf_mock_application_new()); | 1964 | unity::glib::Object<BamfMockApplication> bamf_mock_application(bamf_mock_application_new()); |
4112 | 1959 | ApplicationPtr app(new unity::bamf::Application(mock_manager, unity::glib::object_cast<BamfApplication>(bamf_mock_application))); | 1965 | ApplicationPtr app(new unity::bamf::Application(mock_manager, unity::glib::object_cast<BamfApplication>(bamf_mock_application))); |
4113 | 1960 | 1966 | ||
4116 | 1961 | MockApplicationLauncherIcon::Ptr our_icon; | 1967 | AbstractLauncherIcon::Ptr our_icon; |
4115 | 1962 | |||
4117 | 1963 | mock_manager.Default().application_started.emit(app); | 1968 | mock_manager.Default().application_started.emit(app); |
4119 | 1964 | 1969 | ||
4120 | 1965 | app->title.changed.emit("Hello"); | 1970 | app->title.changed.emit("Hello"); |
4121 | 1966 | auto app_icons = lc.Impl()->model_->GetSublist<ApplicationLauncherIcon>(); | 1971 | auto app_icons = lc.Impl()->model_->GetSublist<ApplicationLauncherIcon>(); |
4122 | 1967 | 1972 | ||
4123 | @@ -1971,7 +1976,7 @@ | |||
4124 | 1971 | { | 1976 | { |
4125 | 1972 | our_icon = icon; | 1977 | our_icon = icon; |
4126 | 1973 | break; | 1978 | break; |
4128 | 1974 | } | 1979 | } |
4129 | 1975 | } | 1980 | } |
4130 | 1976 | ASSERT_TRUE(our_icon); | 1981 | ASSERT_TRUE(our_icon); |
4131 | 1977 | EXPECT_FALSE(our_icon->removed); | 1982 | EXPECT_FALSE(our_icon->removed); |
4132 | 1978 | 1983 | ||
4133 | === modified file 'tests/test_mock_filemanager.h' | |||
4134 | --- tests/test_mock_filemanager.h 2013-10-07 18:10:17 +0000 | |||
4135 | +++ tests/test_mock_filemanager.h 2016-02-09 10:44:04 +0000 | |||
4136 | @@ -32,15 +32,18 @@ | |||
4137 | 32 | typedef testing::NiceMock<MockFileManager> Nice; | 32 | typedef testing::NiceMock<MockFileManager> Nice; |
4138 | 33 | 33 | ||
4139 | 34 | MOCK_METHOD2(Open, void(std::string const& uri, uint64_t time)); | 34 | MOCK_METHOD2(Open, void(std::string const& uri, uint64_t time)); |
4140 | 35 | MOCK_METHOD2(OpenActiveChild, void(std::string const& uri, uint64_t time)); | ||
4141 | 36 | MOCK_METHOD1(OpenTrash, void(uint64_t time)); | 35 | MOCK_METHOD1(OpenTrash, void(uint64_t time)); |
4142 | 37 | MOCK_METHOD1(TrashFile, bool(std::string const& uri)); | 36 | MOCK_METHOD1(TrashFile, bool(std::string const& uri)); |
4143 | 38 | MOCK_METHOD1(EmptyTrash, void(uint64_t time)); | 37 | MOCK_METHOD1(EmptyTrash, void(uint64_t time)); |
4144 | 39 | MOCK_METHOD3(CopyFiles, void(std::set<std::string> const& files, std::string const& dest, uint64_t time)); | 38 | MOCK_METHOD3(CopyFiles, void(std::set<std::string> const& files, std::string const& dest, uint64_t time)); |
4149 | 40 | MOCK_CONST_METHOD0(OpenedLocations, std::vector<std::string>()); | 39 | MOCK_CONST_METHOD1(WindowsForLocation, WindowList(std::string const&)); |
4150 | 41 | MOCK_CONST_METHOD1(IsPrefixOpened, bool(std::string const& uri)); | 40 | MOCK_CONST_METHOD1(LocationForWindow, std::string(ApplicationWindowPtr const&)); |
4151 | 42 | MOCK_CONST_METHOD0(IsTrashOpened, bool()); | 41 | |
4152 | 43 | MOCK_CONST_METHOD0(IsDeviceOpened, bool()); | 42 | MockFileManager() |
4153 | 43 | { | ||
4154 | 44 | using namespace testing; | ||
4155 | 45 | ON_CALL(*this, WindowsForLocation(_)).WillByDefault(Return(WindowList())); | ||
4156 | 46 | } | ||
4157 | 44 | }; | 47 | }; |
4158 | 45 | 48 | ||
4159 | 46 | } | 49 | } |
4160 | 47 | 50 | ||
4161 | === modified file 'tests/test_software_center_launcher_icon.cpp' | |||
4162 | --- tests/test_software_center_launcher_icon.cpp 2015-03-13 13:49:16 +0000 | |||
4163 | +++ tests/test_software_center_launcher_icon.cpp 2016-02-09 10:44:04 +0000 | |||
4164 | @@ -62,16 +62,17 @@ | |||
4165 | 62 | MockSoftwareCenterLauncherIcon(ApplicationPtr const& app, | 62 | MockSoftwareCenterLauncherIcon(ApplicationPtr const& app, |
4166 | 63 | std::string const& aptdaemon_trans_id, | 63 | std::string const& aptdaemon_trans_id, |
4167 | 64 | std::string const& icon_path) | 64 | std::string const& icon_path) |
4169 | 65 | : SoftwareCenterLauncherIcon(app, aptdaemon_trans_id, icon_path) | 65 | : WindowedLauncherIcon(IconType::APPLICATION) |
4170 | 66 | , SoftwareCenterLauncherIcon(app, aptdaemon_trans_id, icon_path) | ||
4171 | 66 | {} | 67 | {} |
4172 | 67 | 68 | ||
4173 | 68 | void LauncherIconUnstick() { LauncherIcon::UnStick(); } | 69 | void LauncherIconUnstick() { LauncherIcon::UnStick(); } |
4174 | 69 | 70 | ||
4175 | 70 | using SoftwareCenterLauncherIcon::GetActualDesktopFileAfterInstall; | 71 | using SoftwareCenterLauncherIcon::GetActualDesktopFileAfterInstall; |
4176 | 71 | using SoftwareCenterLauncherIcon::GetRemoteUri; | ||
4177 | 72 | using SoftwareCenterLauncherIcon::OnFinished; | 72 | using SoftwareCenterLauncherIcon::OnFinished; |
4178 | 73 | using SoftwareCenterLauncherIcon::OnPropertyChanged; | 73 | using SoftwareCenterLauncherIcon::OnPropertyChanged; |
4179 | 74 | using SoftwareCenterLauncherIcon::drag_window_; | 74 | using SoftwareCenterLauncherIcon::drag_window_; |
4180 | 75 | using LauncherIcon::GetRemoteUri; | ||
4181 | 75 | }; | 76 | }; |
4182 | 76 | 77 | ||
4183 | 77 | nux::ObjectPtr<Launcher> CreateLauncher() | 78 | nux::ObjectPtr<Launcher> CreateLauncher() |
4184 | 78 | 79 | ||
4185 | === modified file 'tests/test_switcher_controller.h' | |||
4186 | --- tests/test_switcher_controller.h 2015-11-04 09:42:55 +0000 | |||
4187 | +++ tests/test_switcher_controller.h 2016-02-09 10:44:04 +0000 | |||
4188 | @@ -27,10 +27,11 @@ | |||
4189 | 27 | 27 | ||
4190 | 28 | #include "test_utils.h" | 28 | #include "test_utils.h" |
4191 | 29 | #include "DesktopLauncherIcon.h" | 29 | #include "DesktopLauncherIcon.h" |
4193 | 30 | #include "SimpleLauncherIcon.h" | 30 | #include "WindowedLauncherIcon.h" |
4194 | 31 | #include "SwitcherController.h" | 31 | #include "SwitcherController.h" |
4195 | 32 | #include "SwitcherView.h" | 32 | #include "SwitcherView.h" |
4196 | 33 | #include "TimeUtil.h" | 33 | #include "TimeUtil.h" |
4197 | 34 | #include "mock-application.h" | ||
4198 | 34 | #include "mock-base-window.h" | 35 | #include "mock-base-window.h" |
4199 | 35 | #include "test_standalone_wm.h" | 36 | #include "test_standalone_wm.h" |
4200 | 36 | 37 | ||
4201 | @@ -48,35 +49,24 @@ | |||
4202 | 48 | /** | 49 | /** |
4203 | 49 | * A fake ApplicationWindow for verifying selection of the switcher. | 50 | * A fake ApplicationWindow for verifying selection of the switcher. |
4204 | 50 | */ | 51 | */ |
4206 | 51 | class FakeApplicationWindow : public unity::ApplicationWindow | 52 | struct FakeApplicationWindow : public ::testmocks::MockApplicationWindow::Nice |
4207 | 52 | { | 53 | { |
4209 | 53 | public: | 54 | typedef NiceMock<FakeApplicationWindow> Nice; |
4210 | 54 | FakeApplicationWindow(Window xid, uint64_t active_number = 0); | 55 | FakeApplicationWindow(Window xid, uint64_t active_number = 0); |
4211 | 55 | ~FakeApplicationWindow(); | 56 | ~FakeApplicationWindow(); |
4212 | 56 | |||
4213 | 57 | virtual WindowType type() const; | ||
4214 | 58 | |||
4215 | 59 | virtual Window window_id() const; | ||
4216 | 60 | virtual int monitor() const; | ||
4217 | 61 | virtual unity::ApplicationPtr application() const; | ||
4218 | 62 | virtual bool Focus() const; | ||
4219 | 63 | virtual void Quit() const; | ||
4220 | 64 | |||
4221 | 65 | private: | ||
4222 | 66 | Window xid_; | ||
4223 | 67 | }; | 57 | }; |
4224 | 68 | 58 | ||
4225 | 69 | /** | 59 | /** |
4226 | 70 | * A fake LauncherIcon for verifying selection operations of the switcher. | 60 | * A fake LauncherIcon for verifying selection operations of the switcher. |
4227 | 71 | */ | 61 | */ |
4229 | 72 | struct FakeLauncherIcon : unity::launcher::SimpleLauncherIcon | 62 | struct FakeLauncherIcon : unity::launcher::WindowedLauncherIcon |
4230 | 73 | { | 63 | { |
4231 | 74 | FakeLauncherIcon(std::string const& app_name, bool allow_detail_view, uint64_t priority); | 64 | FakeLauncherIcon(std::string const& app_name, bool allow_detail_view, uint64_t priority); |
4232 | 75 | 65 | ||
4233 | 76 | unity::WindowList Windows() override; | ||
4234 | 77 | bool AllowDetailViewInSwitcher() const override; | 66 | bool AllowDetailViewInSwitcher() const override; |
4235 | 78 | bool ShowInSwitcher(bool) override; | 67 | bool ShowInSwitcher(bool) override; |
4236 | 79 | uint64_t SwitcherPriority() override; | 68 | uint64_t SwitcherPriority() override; |
4237 | 69 | WindowList GetManagedWindows() const override; | ||
4238 | 80 | 70 | ||
4239 | 81 | bool allow_detail_view_; | 71 | bool allow_detail_view_; |
4240 | 82 | uint64_t priority_; | 72 | uint64_t priority_; |
4241 | 83 | 73 | ||
4242 | === modified file 'tests/test_switcher_controller_class.cpp' | |||
4243 | --- tests/test_switcher_controller_class.cpp 2015-11-04 09:42:55 +0000 | |||
4244 | +++ tests/test_switcher_controller_class.cpp 2016-02-09 10:44:04 +0000 | |||
4245 | @@ -26,14 +26,13 @@ | |||
4246 | 26 | using namespace std::chrono; | 26 | using namespace std::chrono; |
4247 | 27 | 27 | ||
4248 | 28 | FakeApplicationWindow::FakeApplicationWindow(Window xid, uint64_t active_number) | 28 | FakeApplicationWindow::FakeApplicationWindow(Window xid, uint64_t active_number) |
4250 | 29 | : xid_(xid) | 29 | : MockApplicationWindow::Nice(xid) |
4251 | 30 | { | 30 | { |
4253 | 31 | auto standalone_window = std::make_shared<StandaloneWindow>(xid_); | 31 | SetMonitor(-1); |
4254 | 32 | auto standalone_window = std::make_shared<StandaloneWindow>(window_id()); | ||
4255 | 32 | standalone_window->active_number = active_number; | 33 | standalone_window->active_number = active_number; |
4256 | 33 | testwrapper::StandaloneWM::Get()->AddStandaloneWindow(standalone_window); | 34 | testwrapper::StandaloneWM::Get()->AddStandaloneWindow(standalone_window); |
4260 | 34 | 35 | ON_CALL(*this, Quit()).WillByDefault(Invoke([this] { WindowManager::Default().Close(window_id()); })); | |
4258 | 35 | title.SetGetterFunction([this] { return "FakeApplicationWindow"; }); | ||
4259 | 36 | icon.SetGetterFunction([this] { return ""; }); | ||
4261 | 37 | } | 36 | } |
4262 | 38 | 37 | ||
4263 | 39 | FakeApplicationWindow::~FakeApplicationWindow() | 38 | FakeApplicationWindow::~FakeApplicationWindow() |
4264 | @@ -41,25 +40,17 @@ | |||
4265 | 41 | testwrapper::StandaloneWM::Get()->Close(xid_); | 40 | testwrapper::StandaloneWM::Get()->Close(xid_); |
4266 | 42 | } | 41 | } |
4267 | 43 | 42 | ||
4268 | 44 | WindowType FakeApplicationWindow::type() const { return WindowType::MOCK; } | ||
4269 | 45 | |||
4270 | 46 | Window FakeApplicationWindow::window_id() const { return xid_; } | ||
4271 | 47 | int FakeApplicationWindow::monitor() const { return -1; } | ||
4272 | 48 | ApplicationPtr FakeApplicationWindow::application() const { return ApplicationPtr(); } | ||
4273 | 49 | bool FakeApplicationWindow::Focus() const { return false; } | ||
4274 | 50 | void FakeApplicationWindow::Quit() const { WindowManager::Default().Close(xid_); } | ||
4275 | 51 | |||
4276 | 52 | FakeLauncherIcon::FakeLauncherIcon(std::string const& app_name, bool allow_detail_view, uint64_t priority) | 43 | FakeLauncherIcon::FakeLauncherIcon(std::string const& app_name, bool allow_detail_view, uint64_t priority) |
4278 | 53 | : launcher::SimpleLauncherIcon(IconType::APPLICATION) | 44 | : launcher::WindowedLauncherIcon(IconType::APPLICATION) |
4279 | 54 | , allow_detail_view_(allow_detail_view) | 45 | , allow_detail_view_(allow_detail_view) |
4280 | 55 | , priority_(priority) | 46 | , priority_(priority) |
4283 | 56 | , window_list{ std::make_shared<FakeApplicationWindow>(priority_ | 0x0001, SwitcherPriority()), | 47 | , window_list{ std::make_shared<FakeApplicationWindow::Nice>(priority_ | 0x0001, SwitcherPriority()), |
4284 | 57 | std::make_shared<FakeApplicationWindow>(priority_ | 0x0002, priority_) } | 48 | std::make_shared<FakeApplicationWindow::Nice>(priority_ | 0x0002, priority_) } |
4285 | 58 | { | 49 | { |
4286 | 59 | tooltip_text = app_name; | 50 | tooltip_text = app_name; |
4287 | 60 | } | 51 | } |
4288 | 61 | 52 | ||
4290 | 62 | WindowList FakeLauncherIcon::Windows() | 53 | WindowList FakeLauncherIcon::GetManagedWindows() const |
4291 | 63 | { | 54 | { |
4292 | 64 | return window_list; | 55 | return window_list; |
4293 | 65 | } | 56 | } |
4294 | @@ -85,7 +76,7 @@ | |||
4295 | 85 | //class TestSwitcherController : public testing::Test | 76 | //class TestSwitcherController : public testing::Test |
4296 | 86 | TestSwitcherController::TestSwitcherController() | 77 | TestSwitcherController::TestSwitcherController() |
4297 | 87 | : animation_controller_(tick_source_) | 78 | : animation_controller_(tick_source_) |
4299 | 88 | , mock_window_(new NiceMock<testmocks::MockBaseWindow>()) | 79 | , mock_window_(new NiceMock<unity::testmocks::MockBaseWindow>()) |
4300 | 89 | , controller_(std::make_shared<Controller>([this] { return mock_window_; })) | 80 | , controller_(std::make_shared<Controller>([this] { return mock_window_; })) |
4301 | 90 | { | 81 | { |
4302 | 91 | controller_->timeout_length = 0; | 82 | controller_->timeout_length = 0; |
4303 | 92 | 83 | ||
4304 | === modified file 'tests/test_trash_launcher_icon.cpp' | |||
4305 | --- tests/test_trash_launcher_icon.cpp 2014-02-28 05:48:21 +0000 | |||
4306 | +++ tests/test_trash_launcher_icon.cpp 2016-02-09 10:44:04 +0000 | |||
4307 | @@ -27,9 +27,11 @@ | |||
4308 | 27 | using namespace unity; | 27 | using namespace unity; |
4309 | 28 | using namespace unity::launcher; | 28 | using namespace unity::launcher; |
4310 | 29 | using namespace testing; | 29 | using namespace testing; |
4311 | 30 | using namespace testmocks; | ||
4312 | 30 | 31 | ||
4313 | 31 | namespace | 32 | namespace |
4314 | 32 | { | 33 | { |
4315 | 34 | const std::string TRASH_URI = "trash:"; | ||
4316 | 33 | 35 | ||
4317 | 34 | struct TestTrashLauncherIcon : testmocks::TestUnityAppBase | 36 | struct TestTrashLauncherIcon : testmocks::TestUnityAppBase |
4318 | 35 | { | 37 | { |
4319 | @@ -42,6 +44,12 @@ | |||
4320 | 42 | TrashLauncherIcon icon; | 44 | TrashLauncherIcon icon; |
4321 | 43 | }; | 45 | }; |
4322 | 44 | 46 | ||
4323 | 47 | TEST_F(TestTrashLauncherIcon, InitState) | ||
4324 | 48 | { | ||
4325 | 49 | EXPECT_FALSE(icon.GetQuirk(AbstractLauncherIcon::Quirk::RUNNING)); | ||
4326 | 50 | EXPECT_FALSE(icon.GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE)); | ||
4327 | 51 | } | ||
4328 | 52 | |||
4329 | 45 | TEST_F(TestTrashLauncherIcon, Position) | 53 | TEST_F(TestTrashLauncherIcon, Position) |
4330 | 46 | { | 54 | { |
4331 | 47 | EXPECT_EQ(icon.position(), AbstractLauncherIcon::Position::END); | 55 | EXPECT_EQ(icon.position(), AbstractLauncherIcon::Position::END); |
4332 | @@ -74,15 +82,77 @@ | |||
4333 | 74 | 82 | ||
4334 | 75 | TEST_F(TestTrashLauncherIcon, RunningState) | 83 | TEST_F(TestTrashLauncherIcon, RunningState) |
4335 | 76 | { | 84 | { |
4337 | 77 | EXPECT_CALL(*fm_, IsTrashOpened()).WillRepeatedly(Return(true)); | 85 | auto win1 = std::make_shared<MockApplicationWindow::Nice>(g_random_int()); |
4338 | 86 | auto win2 = std::make_shared<MockApplicationWindow::Nice>(g_random_int()); | ||
4339 | 87 | |||
4340 | 88 | ON_CALL(*fm_, WindowsForLocation(TRASH_URI)).WillByDefault(Return(WindowList({win1, win2}))); | ||
4341 | 78 | fm_->locations_changed.emit(); | 89 | fm_->locations_changed.emit(); |
4342 | 79 | EXPECT_TRUE(icon.GetQuirk(AbstractLauncherIcon::Quirk::RUNNING)); | 90 | EXPECT_TRUE(icon.GetQuirk(AbstractLauncherIcon::Quirk::RUNNING)); |
4343 | 80 | 91 | ||
4345 | 81 | EXPECT_CALL(*fm_, IsTrashOpened()).WillRepeatedly(Return(false)); | 92 | ON_CALL(*fm_, WindowsForLocation(TRASH_URI)).WillByDefault(Return(WindowList())); |
4346 | 82 | fm_->locations_changed.emit(); | 93 | fm_->locations_changed.emit(); |
4347 | 83 | EXPECT_FALSE(icon.GetQuirk(AbstractLauncherIcon::Quirk::RUNNING)); | 94 | EXPECT_FALSE(icon.GetQuirk(AbstractLauncherIcon::Quirk::RUNNING)); |
4348 | 84 | } | 95 | } |
4349 | 85 | 96 | ||
4350 | 97 | TEST_F(TestTrashLauncherIcon, ActiveState) | ||
4351 | 98 | { | ||
4352 | 99 | auto win1 = std::make_shared<MockApplicationWindow::Nice>(g_random_int()); | ||
4353 | 100 | auto win2 = std::make_shared<MockApplicationWindow::Nice>(g_random_int()); | ||
4354 | 101 | |||
4355 | 102 | ON_CALL(*fm_, WindowsForLocation(TRASH_URI)).WillByDefault(Return(WindowList({win1, win2}))); | ||
4356 | 103 | fm_->locations_changed.emit(); | ||
4357 | 104 | ASSERT_FALSE(icon.GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE)); | ||
4358 | 105 | |||
4359 | 106 | win2->LocalFocus(); | ||
4360 | 107 | EXPECT_TRUE(icon.GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE)); | ||
4361 | 108 | |||
4362 | 109 | ON_CALL(*fm_, WindowsForLocation(TRASH_URI)).WillByDefault(Return(WindowList())); | ||
4363 | 110 | fm_->locations_changed.emit(); | ||
4364 | 111 | EXPECT_FALSE(icon.GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE)); | ||
4365 | 112 | } | ||
4366 | 113 | |||
4367 | 114 | TEST_F(TestTrashLauncherIcon, WindowsCount) | ||
4368 | 115 | { | ||
4369 | 116 | WindowList windows((g_random_int() % 10) + 5); | ||
4370 | 117 | for (unsigned i = 0; i < windows.capacity(); ++i) | ||
4371 | 118 | windows[i] = std::make_shared<MockApplicationWindow::Nice>(g_random_int()); | ||
4372 | 119 | |||
4373 | 120 | ON_CALL(*fm_, WindowsForLocation(TRASH_URI)).WillByDefault(Return(windows)); | ||
4374 | 121 | fm_->locations_changed.emit(); | ||
4375 | 122 | EXPECT_EQ(icon.Windows().size(), windows.size()); | ||
4376 | 123 | } | ||
4377 | 124 | |||
4378 | 125 | TEST_F(TestTrashLauncherIcon, WindowsPerMonitor) | ||
4379 | 126 | { | ||
4380 | 127 | WindowList windows((g_random_int() % 10) + 5); | ||
4381 | 128 | for (unsigned i = 0; i < windows.capacity(); ++i) | ||
4382 | 129 | { | ||
4383 | 130 | auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int()); | ||
4384 | 131 | win->monitor_ = i % 2; | ||
4385 | 132 | windows[i] = win; | ||
4386 | 133 | } | ||
4387 | 134 | |||
4388 | 135 | ON_CALL(*fm_, WindowsForLocation(TRASH_URI)).WillByDefault(Return(windows)); | ||
4389 | 136 | fm_->locations_changed.emit(); | ||
4390 | 137 | |||
4391 | 138 | EXPECT_EQ(icon.WindowsVisibleOnMonitor(0), (windows.size() / 2) + (windows.size() % 2)); | ||
4392 | 139 | EXPECT_EQ(icon.WindowsVisibleOnMonitor(1), windows.size() / 2); | ||
4393 | 140 | } | ||
4394 | 141 | |||
4395 | 142 | TEST_F(TestTrashLauncherIcon, WindowsOnMonitorChanges) | ||
4396 | 143 | { | ||
4397 | 144 | auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int()); | ||
4398 | 145 | ON_CALL(*fm_, WindowsForLocation(TRASH_URI)).WillByDefault(Return(WindowList({win}))); | ||
4399 | 146 | fm_->locations_changed.emit(); | ||
4400 | 147 | |||
4401 | 148 | EXPECT_EQ(icon.WindowsVisibleOnMonitor(0), 1); | ||
4402 | 149 | EXPECT_EQ(icon.WindowsVisibleOnMonitor(1), 0); | ||
4403 | 150 | |||
4404 | 151 | win->SetMonitor(1); | ||
4405 | 152 | EXPECT_EQ(icon.WindowsVisibleOnMonitor(0), 0); | ||
4406 | 153 | EXPECT_EQ(icon.WindowsVisibleOnMonitor(1), 1); | ||
4407 | 154 | } | ||
4408 | 155 | |||
4409 | 86 | TEST_F(TestTrashLauncherIcon, FilemanagerSignalDisconnection) | 156 | TEST_F(TestTrashLauncherIcon, FilemanagerSignalDisconnection) |
4410 | 87 | { | 157 | { |
4411 | 88 | auto file_manager = std::make_shared<NiceMock<MockFileManager>>(); | 158 | auto file_manager = std::make_shared<NiceMock<MockFileManager>>(); |
4412 | 89 | 159 | ||
4413 | === modified file 'tests/test_volume_launcher_icon.cpp' | |||
4414 | --- tests/test_volume_launcher_icon.cpp 2015-01-22 15:05:34 +0000 | |||
4415 | +++ tests/test_volume_launcher_icon.cpp 2016-02-09 10:44:04 +0000 | |||
4416 | @@ -27,8 +27,11 @@ | |||
4417 | 27 | #include "test_utils.h" | 27 | #include "test_utils.h" |
4418 | 28 | #include "test_mock_devices.h" | 28 | #include "test_mock_devices.h" |
4419 | 29 | #include "test_mock_filemanager.h" | 29 | #include "test_mock_filemanager.h" |
4420 | 30 | #include "mock-application.h" | ||
4421 | 31 | |||
4422 | 30 | using namespace unity; | 32 | using namespace unity; |
4423 | 31 | using namespace unity::launcher; | 33 | using namespace unity::launcher; |
4424 | 34 | using namespace testmocks; | ||
4425 | 32 | 35 | ||
4426 | 33 | namespace | 36 | namespace |
4427 | 34 | { | 37 | { |
4428 | @@ -43,7 +46,7 @@ | |||
4429 | 43 | { | 46 | { |
4430 | 44 | SetupVolumeDefaultBehavior(); | 47 | SetupVolumeDefaultBehavior(); |
4431 | 45 | SetupSettingsDefaultBehavior(); | 48 | SetupSettingsDefaultBehavior(); |
4433 | 46 | icon_ = new NiceMock<VolumeLauncherIcon>(volume_, settings_, notifications_, file_manager_); | 49 | icon_ = new VolumeLauncherIcon(volume_, settings_, notifications_, file_manager_); |
4434 | 47 | } | 50 | } |
4435 | 48 | 51 | ||
4436 | 49 | void SetupSettingsDefaultBehavior() | 52 | void SetupSettingsDefaultBehavior() |
4437 | @@ -94,7 +97,7 @@ | |||
4438 | 94 | 97 | ||
4439 | 95 | void CreateIcon() | 98 | void CreateIcon() |
4440 | 96 | { | 99 | { |
4442 | 97 | icon_ = new NiceMock<VolumeLauncherIcon>(volume_, settings_, notifications_, file_manager_); | 100 | icon_ = new VolumeLauncherIcon(volume_, settings_, notifications_, file_manager_); |
4443 | 98 | } | 101 | } |
4444 | 99 | }; | 102 | }; |
4445 | 100 | 103 | ||
4446 | @@ -105,7 +108,7 @@ | |||
4447 | 105 | 108 | ||
4448 | 106 | TEST_F(TestVolumeLauncherIconDelayedConstruction, TestRunningOnClosed) | 109 | TEST_F(TestVolumeLauncherIconDelayedConstruction, TestRunningOnClosed) |
4449 | 107 | { | 110 | { |
4451 | 108 | ON_CALL(*file_manager_, IsPrefixOpened(volume_->GetUri())).WillByDefault(Return(false)); | 111 | ON_CALL(*file_manager_, WindowsForLocation(_)).WillByDefault(Return(WindowList())); |
4452 | 109 | CreateIcon(); | 112 | CreateIcon(); |
4453 | 110 | 113 | ||
4454 | 111 | EXPECT_FALSE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING)); | 114 | EXPECT_FALSE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING)); |
4455 | @@ -113,7 +116,8 @@ | |||
4456 | 113 | 116 | ||
4457 | 114 | TEST_F(TestVolumeLauncherIconDelayedConstruction, TestRunningOnOpened) | 117 | TEST_F(TestVolumeLauncherIconDelayedConstruction, TestRunningOnOpened) |
4458 | 115 | { | 118 | { |
4460 | 116 | ON_CALL(*file_manager_, IsPrefixOpened(volume_->GetUri())).WillByDefault(Return(true)); | 119 | auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int()); |
4461 | 120 | ON_CALL(*file_manager_, WindowsForLocation(volume_->GetUri())).WillByDefault(Return(WindowList({win}))); | ||
4462 | 117 | CreateIcon(); | 121 | CreateIcon(); |
4463 | 118 | 122 | ||
4464 | 119 | EXPECT_TRUE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING)); | 123 | EXPECT_TRUE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING)); |
4465 | @@ -128,16 +132,91 @@ | |||
4466 | 128 | 132 | ||
4467 | 129 | TEST_F(TestVolumeLauncherIcon, TestRunningStateOnLocationChangedClosed) | 133 | TEST_F(TestVolumeLauncherIcon, TestRunningStateOnLocationChangedClosed) |
4468 | 130 | { | 134 | { |
4470 | 131 | ON_CALL(*file_manager_, IsPrefixOpened(volume_->GetUri())).WillByDefault(Return(false)); | 135 | ON_CALL(*file_manager_, WindowsForLocation(volume_->GetUri())).WillByDefault(Return(WindowList())); |
4471 | 132 | file_manager_->locations_changed.emit(); | 136 | file_manager_->locations_changed.emit(); |
4472 | 133 | EXPECT_FALSE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING)); | 137 | EXPECT_FALSE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING)); |
4473 | 134 | } | 138 | } |
4474 | 135 | 139 | ||
4475 | 136 | TEST_F(TestVolumeLauncherIcon, TestRunningStateOnLocationChangedOpened) | 140 | TEST_F(TestVolumeLauncherIcon, TestRunningStateOnLocationChangedOpened) |
4476 | 137 | { | 141 | { |
4480 | 138 | ON_CALL(*file_manager_, IsPrefixOpened(volume_->GetUri())).WillByDefault(Return(true)); | 142 | auto win1 = std::make_shared<MockApplicationWindow::Nice>(g_random_int()); |
4481 | 139 | file_manager_->locations_changed.emit(); | 143 | auto win2 = std::make_shared<MockApplicationWindow::Nice>(g_random_int()); |
4482 | 140 | EXPECT_TRUE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING)); | 144 | ON_CALL(*file_manager_, WindowsForLocation(volume_->GetUri())).WillByDefault(Return(WindowList({win1, win2}))); |
4483 | 145 | file_manager_->locations_changed.emit(); | ||
4484 | 146 | EXPECT_TRUE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING)); | ||
4485 | 147 | } | ||
4486 | 148 | |||
4487 | 149 | TEST_F(TestVolumeLauncherIcon, RunningState) | ||
4488 | 150 | { | ||
4489 | 151 | auto win1 = std::make_shared<MockApplicationWindow::Nice>(g_random_int()); | ||
4490 | 152 | auto win2 = std::make_shared<MockApplicationWindow::Nice>(g_random_int()); | ||
4491 | 153 | |||
4492 | 154 | ON_CALL(*file_manager_, WindowsForLocation(volume_->GetUri())).WillByDefault(Return(WindowList({win1, win2}))); | ||
4493 | 155 | file_manager_->locations_changed.emit(); | ||
4494 | 156 | EXPECT_TRUE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING)); | ||
4495 | 157 | |||
4496 | 158 | ON_CALL(*file_manager_, WindowsForLocation(volume_->GetUri())).WillByDefault(Return(WindowList())); | ||
4497 | 159 | file_manager_->locations_changed.emit(); | ||
4498 | 160 | EXPECT_FALSE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING)); | ||
4499 | 161 | } | ||
4500 | 162 | |||
4501 | 163 | TEST_F(TestVolumeLauncherIcon, ActiveState) | ||
4502 | 164 | { | ||
4503 | 165 | auto win1 = std::make_shared<MockApplicationWindow::Nice>(g_random_int()); | ||
4504 | 166 | auto win2 = std::make_shared<MockApplicationWindow::Nice>(g_random_int()); | ||
4505 | 167 | |||
4506 | 168 | ON_CALL(*file_manager_, WindowsForLocation(volume_->GetUri())).WillByDefault(Return(WindowList({win1, win2}))); | ||
4507 | 169 | file_manager_->locations_changed.emit(); | ||
4508 | 170 | ASSERT_FALSE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE)); | ||
4509 | 171 | |||
4510 | 172 | win2->LocalFocus(); | ||
4511 | 173 | EXPECT_TRUE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE)); | ||
4512 | 174 | |||
4513 | 175 | ON_CALL(*file_manager_, WindowsForLocation(volume_->GetUri())).WillByDefault(Return(WindowList())); | ||
4514 | 176 | file_manager_->locations_changed.emit(); | ||
4515 | 177 | EXPECT_FALSE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE)); | ||
4516 | 178 | } | ||
4517 | 179 | |||
4518 | 180 | TEST_F(TestVolumeLauncherIcon, WindowsCount) | ||
4519 | 181 | { | ||
4520 | 182 | WindowList windows((g_random_int() % 10) + 5); | ||
4521 | 183 | for (unsigned i = 0; i < windows.capacity(); ++i) | ||
4522 | 184 | windows[i] = std::make_shared<MockApplicationWindow::Nice>(g_random_int()); | ||
4523 | 185 | |||
4524 | 186 | ON_CALL(*file_manager_, WindowsForLocation(volume_->GetUri())).WillByDefault(Return(windows)); | ||
4525 | 187 | file_manager_->locations_changed.emit(); | ||
4526 | 188 | EXPECT_EQ(icon_->Windows().size(), windows.size()); | ||
4527 | 189 | } | ||
4528 | 190 | |||
4529 | 191 | TEST_F(TestVolumeLauncherIcon, WindowsPerMonitor) | ||
4530 | 192 | { | ||
4531 | 193 | WindowList windows((g_random_int() % 10) + 5); | ||
4532 | 194 | for (unsigned i = 0; i < windows.capacity(); ++i) | ||
4533 | 195 | { | ||
4534 | 196 | auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int()); | ||
4535 | 197 | win->monitor_ = i % 2; | ||
4536 | 198 | windows[i] = win; | ||
4537 | 199 | } | ||
4538 | 200 | |||
4539 | 201 | ON_CALL(*file_manager_, WindowsForLocation(volume_->GetUri())).WillByDefault(Return(windows)); | ||
4540 | 202 | file_manager_->locations_changed.emit(); | ||
4541 | 203 | |||
4542 | 204 | EXPECT_EQ(icon_->WindowsVisibleOnMonitor(0), (windows.size() / 2) + (windows.size() % 2)); | ||
4543 | 205 | EXPECT_EQ(icon_->WindowsVisibleOnMonitor(1), windows.size() / 2); | ||
4544 | 206 | } | ||
4545 | 207 | |||
4546 | 208 | TEST_F(TestVolumeLauncherIcon, WindowsOnMonitorChanges) | ||
4547 | 209 | { | ||
4548 | 210 | auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int()); | ||
4549 | 211 | ON_CALL(*file_manager_, WindowsForLocation(volume_->GetUri())).WillByDefault(Return(WindowList({win}))); | ||
4550 | 212 | file_manager_->locations_changed.emit(); | ||
4551 | 213 | |||
4552 | 214 | EXPECT_EQ(icon_->WindowsVisibleOnMonitor(0), 1); | ||
4553 | 215 | EXPECT_EQ(icon_->WindowsVisibleOnMonitor(1), 0); | ||
4554 | 216 | |||
4555 | 217 | win->SetMonitor(1); | ||
4556 | 218 | EXPECT_EQ(icon_->WindowsVisibleOnMonitor(0), 0); | ||
4557 | 219 | EXPECT_EQ(icon_->WindowsVisibleOnMonitor(1), 1); | ||
4558 | 141 | } | 220 | } |
4559 | 142 | 221 | ||
4560 | 143 | TEST_F(TestVolumeLauncherIcon, TestPosition) | 222 | TEST_F(TestVolumeLauncherIcon, TestPosition) |
4561 | @@ -240,6 +319,32 @@ | |||
4562 | 240 | EXPECT_FALSE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE)); | 319 | EXPECT_FALSE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE)); |
4563 | 241 | } | 320 | } |
4564 | 242 | 321 | ||
4565 | 322 | TEST_F(TestVolumeLauncherIcon, TestVisibilityWithWindows) | ||
4566 | 323 | { | ||
4567 | 324 | ON_CALL(*settings_, IsABlacklistedDevice(volume_->GetIdentifier())).WillByDefault(Return(false)); | ||
4568 | 325 | settings_->changed.emit(); | ||
4569 | 326 | ASSERT_TRUE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE)); | ||
4570 | 327 | |||
4571 | 328 | auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int()); | ||
4572 | 329 | ON_CALL(*file_manager_, WindowsForLocation(volume_->GetUri())).WillByDefault(Return(WindowList({win}))); | ||
4573 | 330 | file_manager_->locations_changed.emit(); | ||
4574 | 331 | |||
4575 | 332 | EXPECT_TRUE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE)); | ||
4576 | 333 | } | ||
4577 | 334 | |||
4578 | 335 | TEST_F(TestVolumeLauncherIcon, TestVisibilityWithWindows_Blacklisted) | ||
4579 | 336 | { | ||
4580 | 337 | ON_CALL(*settings_, IsABlacklistedDevice(volume_->GetIdentifier())).WillByDefault(Return(true)); | ||
4581 | 338 | settings_->changed.emit(); | ||
4582 | 339 | ASSERT_FALSE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE)); | ||
4583 | 340 | |||
4584 | 341 | auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int()); | ||
4585 | 342 | ON_CALL(*file_manager_, WindowsForLocation(volume_->GetUri())).WillByDefault(Return(WindowList({win}))); | ||
4586 | 343 | file_manager_->locations_changed.emit(); | ||
4587 | 344 | |||
4588 | 345 | EXPECT_TRUE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE)); | ||
4589 | 346 | } | ||
4590 | 347 | |||
4591 | 243 | TEST_F(TestVolumeLauncherIcon, TestUnlockFromLauncherMenuItem_VolumeWithoutIdentifier) | 348 | TEST_F(TestVolumeLauncherIcon, TestUnlockFromLauncherMenuItem_VolumeWithoutIdentifier) |
4592 | 244 | { | 349 | { |
4593 | 245 | EXPECT_CALL(*volume_, GetIdentifier()) | 350 | EXPECT_CALL(*volume_, GetIdentifier()) |
4594 | @@ -251,22 +356,22 @@ | |||
4595 | 251 | 356 | ||
4596 | 252 | TEST_F(TestVolumeLauncherIcon, TestUnlockFromLauncherMenuItem_Success) | 357 | TEST_F(TestVolumeLauncherIcon, TestUnlockFromLauncherMenuItem_Success) |
4597 | 253 | { | 358 | { |
4598 | 359 | ON_CALL(*settings_, IsABlacklistedDevice(volume_->GetIdentifier())).WillByDefault(Return(false)); | ||
4599 | 360 | settings_->changed.emit(); | ||
4600 | 361 | ASSERT_TRUE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE)); | ||
4601 | 254 | auto menuitem = GetMenuItemAtIndex(4); | 362 | auto menuitem = GetMenuItemAtIndex(4); |
4602 | 255 | 363 | ||
4603 | 256 | ASSERT_STREQ(dbusmenu_menuitem_property_get(menuitem, DBUSMENU_MENUITEM_PROP_LABEL), "Unlock from Launcher"); | 364 | ASSERT_STREQ(dbusmenu_menuitem_property_get(menuitem, DBUSMENU_MENUITEM_PROP_LABEL), "Unlock from Launcher"); |
4604 | 257 | EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE)); | 365 | EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE)); |
4605 | 258 | EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(menuitem, DBUSMENU_MENUITEM_PROP_ENABLED)); | 366 | EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(menuitem, DBUSMENU_MENUITEM_PROP_ENABLED)); |
4606 | 259 | 367 | ||
4613 | 260 | EXPECT_CALL(*settings_, TryToBlacklist(_)) | 368 | EXPECT_CALL(*settings_, TryToBlacklist(volume_->GetIdentifier())).Times(1); |
4608 | 261 | .Times(1); | ||
4609 | 262 | |||
4610 | 263 | EXPECT_CALL(*settings_, IsABlacklistedDevice(_)) | ||
4611 | 264 | .WillRepeatedly(Return(true)); | ||
4612 | 265 | |||
4614 | 266 | dbusmenu_menuitem_handle_event(menuitem, DBUSMENU_MENUITEM_EVENT_ACTIVATED, nullptr, 0); | 369 | dbusmenu_menuitem_handle_event(menuitem, DBUSMENU_MENUITEM_EVENT_ACTIVATED, nullptr, 0); |
4615 | 370 | |||
4616 | 371 | EXPECT_CALL(*settings_, IsABlacklistedDevice(volume_->GetIdentifier())).WillRepeatedly(Return(true)); | ||
4617 | 267 | settings_->changed.emit(); // TryToBlacklist() works if DevicesSettings emits a changed signal. | 372 | settings_->changed.emit(); // TryToBlacklist() works if DevicesSettings emits a changed signal. |
4618 | 268 | 373 | ||
4620 | 269 | ASSERT_FALSE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE)); | 374 | EXPECT_FALSE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE)); |
4621 | 270 | } | 375 | } |
4622 | 271 | 376 | ||
4623 | 272 | TEST_F(TestVolumeLauncherIcon, TestUnlockFromLauncherMenuItem_Failure) | 377 | TEST_F(TestVolumeLauncherIcon, TestUnlockFromLauncherMenuItem_Failure) |
4624 | @@ -277,12 +382,49 @@ | |||
4625 | 277 | EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE)); | 382 | EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE)); |
4626 | 278 | EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(menuitem, DBUSMENU_MENUITEM_PROP_ENABLED)); | 383 | EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(menuitem, DBUSMENU_MENUITEM_PROP_ENABLED)); |
4627 | 279 | 384 | ||
4634 | 280 | EXPECT_CALL(*settings_, TryToBlacklist(_)) | 385 | EXPECT_CALL(*settings_, TryToBlacklist(volume_->GetIdentifier())).Times(1); |
4635 | 281 | .Times(1); | 386 | dbusmenu_menuitem_handle_event(menuitem, DBUSMENU_MENUITEM_EVENT_ACTIVATED, nullptr, 0); |
4636 | 282 | 387 | ||
4637 | 283 | dbusmenu_menuitem_handle_event(menuitem, DBUSMENU_MENUITEM_EVENT_ACTIVATED, nullptr, 0); | 388 | EXPECT_TRUE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE)); |
4638 | 284 | 389 | } | |
4639 | 285 | ASSERT_TRUE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE)); | 390 | |
4640 | 391 | TEST_F(TestVolumeLauncherIcon, TestLockToLauncherMenuItem_Success) | ||
4641 | 392 | { | ||
4642 | 393 | ON_CALL(*settings_, IsABlacklistedDevice(volume_->GetIdentifier())).WillByDefault(Return(true)); | ||
4643 | 394 | settings_->changed.emit(); | ||
4644 | 395 | ASSERT_FALSE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE)); | ||
4645 | 396 | |||
4646 | 397 | auto menuitem = GetMenuItemAtIndex(4); | ||
4647 | 398 | |||
4648 | 399 | ASSERT_STREQ(dbusmenu_menuitem_property_get(menuitem, DBUSMENU_MENUITEM_PROP_LABEL), "Lock to Launcher"); | ||
4649 | 400 | EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE)); | ||
4650 | 401 | EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(menuitem, DBUSMENU_MENUITEM_PROP_ENABLED)); | ||
4651 | 402 | |||
4652 | 403 | EXPECT_CALL(*settings_, TryToUnblacklist(volume_->GetIdentifier())).Times(1); | ||
4653 | 404 | dbusmenu_menuitem_handle_event(menuitem, DBUSMENU_MENUITEM_EVENT_ACTIVATED, nullptr, 0); | ||
4654 | 405 | |||
4655 | 406 | EXPECT_CALL(*settings_, IsABlacklistedDevice(_)).WillRepeatedly(Return(false)); | ||
4656 | 407 | settings_->changed.emit(); // TryToBlacklist() works if DevicesSettings emits a changed signal. | ||
4657 | 408 | |||
4658 | 409 | EXPECT_TRUE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE)); | ||
4659 | 410 | } | ||
4660 | 411 | |||
4661 | 412 | TEST_F(TestVolumeLauncherIcon, TestLockToLauncherMenuItem_Failure) | ||
4662 | 413 | { | ||
4663 | 414 | ON_CALL(*settings_, IsABlacklistedDevice(volume_->GetIdentifier())).WillByDefault(Return(true)); | ||
4664 | 415 | settings_->changed.emit(); | ||
4665 | 416 | ASSERT_FALSE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE)); | ||
4666 | 417 | |||
4667 | 418 | auto menuitem = GetMenuItemAtIndex(4); | ||
4668 | 419 | |||
4669 | 420 | ASSERT_STREQ(dbusmenu_menuitem_property_get(menuitem, DBUSMENU_MENUITEM_PROP_LABEL), "Lock to Launcher"); | ||
4670 | 421 | EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE)); | ||
4671 | 422 | EXPECT_TRUE(dbusmenu_menuitem_property_get_bool(menuitem, DBUSMENU_MENUITEM_PROP_ENABLED)); | ||
4672 | 423 | |||
4673 | 424 | EXPECT_CALL(*settings_, TryToUnblacklist(volume_->GetIdentifier())).Times(1); | ||
4674 | 425 | dbusmenu_menuitem_handle_event(menuitem, DBUSMENU_MENUITEM_EVENT_ACTIVATED, nullptr, 0); | ||
4675 | 426 | |||
4676 | 427 | EXPECT_FALSE(icon_->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE)); | ||
4677 | 286 | } | 428 | } |
4678 | 287 | 429 | ||
4679 | 288 | TEST_F(TestVolumeLauncherIcon, TestOpenMenuItem) | 430 | TEST_F(TestVolumeLauncherIcon, TestOpenMenuItem) |
4680 | @@ -298,7 +440,7 @@ | |||
4681 | 298 | 440 | ||
4682 | 299 | InSequence seq; | 441 | InSequence seq; |
4683 | 300 | EXPECT_CALL(*volume_, Mount()); | 442 | EXPECT_CALL(*volume_, Mount()); |
4685 | 301 | EXPECT_CALL(*file_manager_, OpenActiveChild(volume_->GetUri(), time)); | 443 | EXPECT_CALL(*file_manager_, Open(volume_->GetUri(), time)); |
4686 | 302 | 444 | ||
4687 | 303 | dbusmenu_menuitem_handle_event(menuitem, DBUSMENU_MENUITEM_EVENT_ACTIVATED, nullptr, time); | 445 | dbusmenu_menuitem_handle_event(menuitem, DBUSMENU_MENUITEM_EVENT_ACTIVATED, nullptr, time); |
4688 | 304 | } | 446 | } |
4689 | @@ -318,7 +460,7 @@ | |||
4690 | 318 | 460 | ||
4691 | 319 | InSequence seq; | 461 | InSequence seq; |
4692 | 320 | EXPECT_CALL(*volume_, Mount()); | 462 | EXPECT_CALL(*volume_, Mount()); |
4694 | 321 | EXPECT_CALL(*file_manager_, OpenActiveChild(volume_->GetUri(), time)); | 463 | EXPECT_CALL(*file_manager_, Open(volume_->GetUri(), time)); |
4695 | 322 | 464 | ||
4696 | 323 | dbusmenu_menuitem_handle_event(menuitem, DBUSMENU_MENUITEM_EVENT_ACTIVATED, nullptr, time); | 465 | dbusmenu_menuitem_handle_event(menuitem, DBUSMENU_MENUITEM_EVENT_ACTIVATED, nullptr, time); |
4697 | 324 | } | 466 | } |
4698 | @@ -438,7 +580,7 @@ | |||
4699 | 438 | EXPECT_CALL(*settings_, TryToBlacklist(_)) | 580 | EXPECT_CALL(*settings_, TryToBlacklist(_)) |
4700 | 439 | .Times(0); | 581 | .Times(0); |
4701 | 440 | EXPECT_CALL(*settings_, TryToUnblacklist(_)) | 582 | EXPECT_CALL(*settings_, TryToUnblacklist(_)) |
4703 | 441 | .Times(0); | 583 | .Times(1); |
4704 | 442 | 584 | ||
4705 | 443 | volume_->removed.emit(); | 585 | volume_->removed.emit(); |
4706 | 444 | } | 586 | } |
4707 | @@ -451,7 +593,7 @@ | |||
4708 | 451 | EXPECT_CALL(*settings_, TryToBlacklist(_)) | 593 | EXPECT_CALL(*settings_, TryToBlacklist(_)) |
4709 | 452 | .Times(0); | 594 | .Times(0); |
4710 | 453 | EXPECT_CALL(*settings_, TryToUnblacklist(_)) | 595 | EXPECT_CALL(*settings_, TryToUnblacklist(_)) |
4712 | 454 | .Times(0); | 596 | .Times(1); |
4713 | 455 | 597 | ||
4714 | 456 | volume_->removed.emit(); | 598 | volume_->removed.emit(); |
4715 | 457 | } | 599 | } |
4716 | @@ -516,7 +658,7 @@ | |||
4717 | 516 | uint64_t time = g_random_int(); | 658 | uint64_t time = g_random_int(); |
4718 | 517 | InSequence seq; | 659 | InSequence seq; |
4719 | 518 | EXPECT_CALL(*volume_, Mount()).Times(0); | 660 | EXPECT_CALL(*volume_, Mount()).Times(0); |
4721 | 519 | EXPECT_CALL(*file_manager_, OpenActiveChild(volume_->GetUri(), time)); | 661 | EXPECT_CALL(*file_manager_, Open(volume_->GetUri(), time)); |
4722 | 520 | icon_->Activate(ActionArg(ActionArg::Source::LAUNCHER, 0, time)); | 662 | icon_->Activate(ActionArg(ActionArg::Source::LAUNCHER, 0, time)); |
4723 | 521 | } | 663 | } |
4724 | 522 | 664 | ||
4725 | @@ -526,7 +668,7 @@ | |||
4726 | 526 | ON_CALL(*volume_, IsMounted()).WillByDefault(Return(false)); | 668 | ON_CALL(*volume_, IsMounted()).WillByDefault(Return(false)); |
4727 | 527 | InSequence seq; | 669 | InSequence seq; |
4728 | 528 | EXPECT_CALL(*volume_, Mount()); | 670 | EXPECT_CALL(*volume_, Mount()); |
4730 | 529 | EXPECT_CALL(*file_manager_, OpenActiveChild(volume_->GetUri(), time)); | 671 | EXPECT_CALL(*file_manager_, Open(volume_->GetUri(), time)); |
4731 | 530 | icon_->Activate(ActionArg(ActionArg::Source::LAUNCHER, 0, time)); | 672 | icon_->Activate(ActionArg(ActionArg::Source::LAUNCHER, 0, time)); |
4732 | 531 | } | 673 | } |
4733 | 532 | 674 | ||
4734 | 533 | 675 | ||
4735 | === modified file 'unity-shared/ApplicationManager.h' | |||
4736 | --- unity-shared/ApplicationManager.h 2015-07-09 16:32:54 +0000 | |||
4737 | +++ unity-shared/ApplicationManager.h 2016-02-09 10:44:04 +0000 | |||
4738 | @@ -109,6 +109,8 @@ | |||
4739 | 109 | nux::ROProperty<bool> active; | 109 | nux::ROProperty<bool> active; |
4740 | 110 | nux::ROProperty<bool> urgent; | 110 | nux::ROProperty<bool> urgent; |
4741 | 111 | nux::ROProperty<bool> maximized; | 111 | nux::ROProperty<bool> maximized; |
4742 | 112 | |||
4743 | 113 | sigc::signal<void> closed; | ||
4744 | 112 | }; | 114 | }; |
4745 | 113 | 115 | ||
4746 | 114 | 116 | ||
4747 | @@ -219,6 +221,7 @@ | |||
4748 | 219 | virtual WindowList GetWindowsForMonitor(int monitor = -1) const = 0; | 221 | virtual WindowList GetWindowsForMonitor(int monitor = -1) const = 0; |
4749 | 220 | virtual ApplicationPtr GetApplicationForWindow(Window xid) const = 0; | 222 | virtual ApplicationPtr GetApplicationForWindow(Window xid) const = 0; |
4750 | 221 | virtual ApplicationWindowPtr GetWindowForId(Window xid) const = 0; | 223 | virtual ApplicationWindowPtr GetWindowForId(Window xid) const = 0; |
4751 | 224 | virtual void FocusWindowGroup(WindowList const&, bool show_on_visible, int monitor) const = 0; | ||
4752 | 222 | 225 | ||
4753 | 223 | sigc::signal<void, ApplicationPtr const&> application_started; | 226 | sigc::signal<void, ApplicationPtr const&> application_started; |
4754 | 224 | sigc::signal<void, ApplicationPtr const&> application_stopped; | 227 | sigc::signal<void, ApplicationPtr const&> application_stopped; |
4755 | 225 | 228 | ||
4756 | === modified file 'unity-shared/BamfApplicationManager.cpp' | |||
4757 | --- unity-shared/BamfApplicationManager.cpp 2015-10-28 15:41:17 +0000 | |||
4758 | +++ unity-shared/BamfApplicationManager.cpp 2016-02-09 10:44:04 +0000 | |||
4759 | @@ -147,6 +147,7 @@ | |||
4760 | 147 | }); | 147 | }); |
4761 | 148 | signals_.Add<void, BamfView*>(bamf_view_, "closed", | 148 | signals_.Add<void, BamfView*>(bamf_view_, "closed", |
4762 | 149 | [this] (BamfView* view) { | 149 | [this] (BamfView* view) { |
4763 | 150 | this->closed.emit(); | ||
4764 | 150 | pool::wins_.erase(view); | 151 | pool::wins_.erase(view); |
4765 | 151 | }); | 152 | }); |
4766 | 152 | } | 153 | } |
4767 | @@ -473,7 +474,7 @@ | |||
4768 | 473 | return pool::EnsureWindow(manager_, bamf_application_get_focusable_child(bamf_app_)); | 474 | return pool::EnsureWindow(manager_, bamf_application_get_focusable_child(bamf_app_)); |
4769 | 474 | } | 475 | } |
4770 | 475 | 476 | ||
4772 | 476 | void Application::Focus(bool show_only_visible, int monitor) const | 477 | void Manager::FocusWindowGroup(WindowList const& wins, bool show_only_visible, int monitor) const |
4773 | 477 | { | 478 | { |
4774 | 478 | WindowManager& wm = WindowManager::Default(); | 479 | WindowManager& wm = WindowManager::Default(); |
4775 | 479 | std::vector<Window> urgent_windows; | 480 | std::vector<Window> urgent_windows; |
4776 | @@ -481,7 +482,7 @@ | |||
4777 | 481 | std::vector<Window> non_visible_windows; | 482 | std::vector<Window> non_visible_windows; |
4778 | 482 | bool any_visible = false; | 483 | bool any_visible = false; |
4779 | 483 | 484 | ||
4781 | 484 | for (auto& window : GetWindows()) | 485 | for (auto& window : wins) |
4782 | 485 | { | 486 | { |
4783 | 486 | Window window_id = window->window_id(); | 487 | Window window_id = window->window_id(); |
4784 | 487 | if (window->urgent()) | 488 | if (window->urgent()) |
4785 | @@ -526,12 +527,15 @@ | |||
4786 | 526 | } | 527 | } |
4787 | 527 | } | 528 | } |
4788 | 528 | 529 | ||
4789 | 530 | void Application::Focus(bool show_only_visible, int monitor) const | ||
4790 | 531 | { | ||
4791 | 532 | manager_.FocusWindowGroup(GetWindows(), show_only_visible, monitor); | ||
4792 | 533 | } | ||
4793 | 534 | |||
4794 | 529 | void Application::Quit() const | 535 | void Application::Quit() const |
4795 | 530 | { | 536 | { |
4796 | 531 | for (auto& window : GetWindows()) | 537 | for (auto& window : GetWindows()) |
4797 | 532 | { | ||
4798 | 533 | window->Quit(); | 538 | window->Quit(); |
4799 | 534 | } | ||
4800 | 535 | } | 539 | } |
4801 | 536 | 540 | ||
4802 | 537 | bool Application::CreateLocalDesktopFile() const | 541 | bool Application::CreateLocalDesktopFile() const |
4803 | 538 | 542 | ||
4804 | === modified file 'unity-shared/BamfApplicationManager.h' | |||
4805 | --- unity-shared/BamfApplicationManager.h 2015-07-09 16:32:54 +0000 | |||
4806 | +++ unity-shared/BamfApplicationManager.h 2016-02-09 10:44:04 +0000 | |||
4807 | @@ -64,7 +64,7 @@ | |||
4808 | 64 | 64 | ||
4809 | 65 | bool operator==(unity::ApplicationWindow const& other) const override | 65 | bool operator==(unity::ApplicationWindow const& other) const override |
4810 | 66 | { | 66 | { |
4812 | 67 | return static_cast<WindowBase const*>(this)->bamf_view_ == static_cast<WindowBase const&>(other).bamf_view_; | 67 | return static_cast<WindowBase const*>(this)->bamf_view_ == static_cast<WindowBase const&>(other).bamf_view_; |
4813 | 68 | } | 68 | } |
4814 | 69 | bool operator!=(unity::ApplicationWindow const& other) const override { return !(operator==(other)); } | 69 | bool operator!=(unity::ApplicationWindow const& other) const override { return !(operator==(other)); } |
4815 | 70 | }; | 70 | }; |
4816 | @@ -175,6 +175,8 @@ | |||
4817 | 175 | ApplicationPtr EnsureApplication(BamfView*) const; | 175 | ApplicationPtr EnsureApplication(BamfView*) const; |
4818 | 176 | ApplicationWindowPtr EnsureWindow(BamfView*) const; | 176 | ApplicationWindowPtr EnsureWindow(BamfView*) const; |
4819 | 177 | 177 | ||
4820 | 178 | void FocusWindowGroup(WindowList const&, bool show_on_visible, int monitor) const; | ||
4821 | 179 | |||
4822 | 178 | private: | 180 | private: |
4823 | 179 | void OnViewOpened(BamfMatcher* matcher, BamfView* view); | 181 | void OnViewOpened(BamfMatcher* matcher, BamfView* view); |
4824 | 180 | void OnViewClosed(BamfMatcher* matcher, BamfView* view); | 182 | void OnViewClosed(BamfMatcher* matcher, BamfView* view); |
4825 | 181 | 183 | ||
4826 | === modified file 'unity-shared/FileManager.h' | |||
4827 | --- unity-shared/FileManager.h 2013-10-07 18:10:17 +0000 | |||
4828 | +++ unity-shared/FileManager.h 2016-02-09 10:44:04 +0000 | |||
4829 | @@ -27,6 +27,8 @@ | |||
4830 | 27 | #include <vector> | 27 | #include <vector> |
4831 | 28 | #include <set> | 28 | #include <set> |
4832 | 29 | #include <sigc++/sigc++.h> | 29 | #include <sigc++/sigc++.h> |
4833 | 30 | #include "ApplicationManager.h" | ||
4834 | 31 | |||
4835 | 30 | 32 | ||
4836 | 31 | namespace unity | 33 | namespace unity |
4837 | 32 | { | 34 | { |
4838 | @@ -40,15 +42,12 @@ | |||
4839 | 40 | virtual ~FileManager() = default; | 42 | virtual ~FileManager() = default; |
4840 | 41 | 43 | ||
4841 | 42 | virtual void Open(std::string const& uri, uint64_t timestamp = 0) = 0; | 44 | virtual void Open(std::string const& uri, uint64_t timestamp = 0) = 0; |
4842 | 43 | virtual void OpenActiveChild(std::string const& uri, uint64_t timestamp = 0) = 0; | ||
4843 | 44 | virtual void OpenTrash(uint64_t timestamp) = 0; | 45 | virtual void OpenTrash(uint64_t timestamp) = 0; |
4844 | 45 | virtual std::vector<std::string> OpenedLocations() const = 0; | ||
4845 | 46 | virtual bool IsPrefixOpened(std::string const& uri) const = 0; | ||
4846 | 47 | virtual bool IsTrashOpened() const = 0; | ||
4847 | 48 | virtual bool IsDeviceOpened() const = 0; | ||
4848 | 49 | virtual void CopyFiles(std::set<std::string> const& uris, std::string const& dest, uint64_t timestamp = 0) = 0; | 46 | virtual void CopyFiles(std::set<std::string> const& uris, std::string const& dest, uint64_t timestamp = 0) = 0; |
4849 | 50 | virtual bool TrashFile(std::string const& uri) = 0; | 47 | virtual bool TrashFile(std::string const& uri) = 0; |
4850 | 51 | virtual void EmptyTrash(uint64_t timestamp = 0) = 0; | 48 | virtual void EmptyTrash(uint64_t timestamp = 0) = 0; |
4851 | 49 | virtual WindowList WindowsForLocation(std::string const& location) const = 0; | ||
4852 | 50 | virtual std::string LocationForWindow(ApplicationWindowPtr const&) const = 0; | ||
4853 | 52 | 51 | ||
4854 | 53 | sigc::signal<void> locations_changed; | 52 | sigc::signal<void> locations_changed; |
4855 | 54 | 53 | ||
4856 | @@ -57,6 +56,6 @@ | |||
4857 | 57 | FileManager& operator=(FileManager const&) = delete; | 56 | FileManager& operator=(FileManager const&) = delete; |
4858 | 58 | }; | 57 | }; |
4859 | 59 | 58 | ||
4861 | 60 | } | 59 | } // namespace unity |
4862 | 61 | 60 | ||
4863 | 62 | #endif | 61 | #endif |
4864 | 63 | 62 | ||
4865 | === modified file 'unity-shared/GnomeFileManager.cpp' | |||
4866 | --- unity-shared/GnomeFileManager.cpp 2013-10-07 22:37:34 +0000 | |||
4867 | +++ unity-shared/GnomeFileManager.cpp 2016-02-09 10:44:04 +0000 | |||
4868 | @@ -21,8 +21,9 @@ | |||
4869 | 21 | #include "GnomeFileManager.h" | 21 | #include "GnomeFileManager.h" |
4870 | 22 | #include <NuxCore/Logger.h> | 22 | #include <NuxCore/Logger.h> |
4871 | 23 | #include <UnityCore/DesktopUtilities.h> | 23 | #include <UnityCore/DesktopUtilities.h> |
4872 | 24 | #include <UnityCore/GLibSource.h> | ||
4873 | 25 | #include <UnityCore/GLibDBusProxy.h> | ||
4874 | 24 | #include <UnityCore/GLibWrapper.h> | 26 | #include <UnityCore/GLibWrapper.h> |
4875 | 25 | #include <UnityCore/GLibDBusProxy.h> | ||
4876 | 26 | #include <gdk/gdk.h> | 27 | #include <gdk/gdk.h> |
4877 | 27 | #include <gio/gio.h> | 28 | #include <gio/gio.h> |
4878 | 28 | 29 | ||
4879 | @@ -33,10 +34,8 @@ | |||
4880 | 33 | { | 34 | { |
4881 | 34 | DECLARE_LOGGER(logger, "unity.filemanager.gnome"); | 35 | DECLARE_LOGGER(logger, "unity.filemanager.gnome"); |
4882 | 35 | 36 | ||
4884 | 36 | const std::string TRASH_URI = "trash:"; | 37 | const std::string TRASH_URI = "trash:///"; |
4885 | 37 | const std::string FILE_SCHEMA = "file://"; | 38 | const std::string FILE_SCHEMA = "file://"; |
4886 | 38 | const std::string TRASH_PATH = FILE_SCHEMA + DesktopUtilities::GetUserDataDirectory() + "/Trash/files"; | ||
4887 | 39 | const std::string DEVICES_PREFIX = FILE_SCHEMA + "/media/" + std::string(g_get_user_name()); | ||
4888 | 40 | 39 | ||
4889 | 41 | const std::string NAUTILUS_NAME = "org.gnome.Nautilus"; | 40 | const std::string NAUTILUS_NAME = "org.gnome.Nautilus"; |
4890 | 42 | const std::string NAUTILUS_PATH = "/org/gnome/Nautilus"; | 41 | const std::string NAUTILUS_PATH = "/org/gnome/Nautilus"; |
4891 | @@ -48,64 +47,83 @@ | |||
4892 | 48 | : parent_(parent) | 47 | : parent_(parent) |
4893 | 49 | , filemanager_proxy_("org.freedesktop.FileManager1", "/org/freedesktop/FileManager1", "org.freedesktop.FileManager1") | 48 | , filemanager_proxy_("org.freedesktop.FileManager1", "/org/freedesktop/FileManager1", "org.freedesktop.FileManager1") |
4894 | 50 | { | 49 | { |
4903 | 51 | auto callback = sigc::mem_fun(this, &Impl::OnOpenLocationsUpdated); | 50 | auto callback = sigc::mem_fun(this, &Impl::OnOpenLocationsXidsUpdated); |
4904 | 52 | filemanager_proxy_.GetProperty("OpenLocations", callback); | 51 | filemanager_proxy_.GetProperty("XUbuntuOpenLocationsXids", callback); |
4905 | 53 | filemanager_proxy_.ConnectProperty("OpenLocations", callback); | 52 | filemanager_proxy_.ConnectProperty("XUbuntuOpenLocationsXids", callback); |
4906 | 54 | } | 53 | } |
4907 | 55 | 54 | ||
4908 | 56 | void OnOpenLocationsUpdated(GVariant* value) | 55 | glib::DBusProxy::Ptr NautilusOperationsProxy() const |
4909 | 57 | { | 56 | { |
4910 | 58 | if (!g_variant_is_of_type(value, G_VARIANT_TYPE_STRING_ARRAY)) | 57 | return std::make_shared<glib::DBusProxy>(NAUTILUS_NAME, NAUTILUS_PATH, |
4911 | 58 | "org.gnome.Nautilus.FileOperations"); | ||
4912 | 59 | } | ||
4913 | 60 | |||
4914 | 61 | void OnOpenLocationsXidsUpdated(GVariant* value) | ||
4915 | 62 | { | ||
4916 | 63 | opened_location_for_xid_.clear(); | ||
4917 | 64 | |||
4918 | 65 | if (!value) | ||
4919 | 66 | { | ||
4920 | 67 | LOG_WARN(logger) << "Locations have been invalidated, maybe there's no filemanager around..."; | ||
4921 | 68 | parent_->locations_changed.emit(); | ||
4922 | 69 | return; | ||
4923 | 70 | } | ||
4924 | 71 | |||
4925 | 72 | if (!g_variant_is_of_type(value, G_VARIANT_TYPE("a{uas}"))) | ||
4926 | 59 | { | 73 | { |
4927 | 60 | LOG_ERROR(logger) << "Locations value type is not matching the expected one!"; | 74 | LOG_ERROR(logger) << "Locations value type is not matching the expected one!"; |
4928 | 75 | parent_->locations_changed.emit(); | ||
4929 | 61 | return; | 76 | return; |
4930 | 62 | } | 77 | } |
4931 | 63 | 78 | ||
4932 | 64 | opened_locations_.clear(); | ||
4933 | 65 | |||
4934 | 66 | GVariantIter iter; | 79 | GVariantIter iter; |
4936 | 67 | const char *str; | 80 | GVariantIter *str_iter; |
4937 | 81 | const char *loc; | ||
4938 | 82 | guint32 xid; | ||
4939 | 68 | 83 | ||
4940 | 69 | g_variant_iter_init(&iter, value); | 84 | g_variant_iter_init(&iter, value); |
4941 | 70 | 85 | ||
4975 | 71 | while (g_variant_iter_loop(&iter, "s", &str)) | 86 | while (g_variant_iter_loop(&iter, "{uas}", &xid, &str_iter)) |
4976 | 72 | { | 87 | { |
4977 | 73 | LOG_DEBUG(logger) << "Opened location " << str; | 88 | while (g_variant_iter_loop(str_iter, "s", &loc)) |
4978 | 74 | opened_locations_.push_back(str); | 89 | { |
4979 | 75 | } | 90 | /* We only care about the first mentioned location as per our "standard" |
4980 | 76 | 91 | * it's the active one */ | |
4981 | 77 | parent_->locations_changed.emit(); | 92 | LOG_DEBUG(logger) << xid << ": Opened location " << loc; |
4982 | 78 | } | 93 | opened_location_for_xid_[xid] = loc; |
4983 | 79 | 94 | break; | |
4984 | 80 | std::string GetOpenedPrefix(std::string const& uri, bool allow_equal = true) | 95 | } |
4985 | 81 | { | 96 | } |
4986 | 82 | glib::Object<GFile> uri_file(g_file_new_for_uri(uri.c_str())); | 97 | |
4987 | 83 | 98 | // We must ensure that we emit the locations_changed signal only when all | |
4988 | 84 | for (auto const& loc : opened_locations_) | 99 | // the parent windows have been registered on the app-manager |
4989 | 85 | { | 100 | auto app_manager_not_synced = [this] |
4990 | 86 | bool equal = false; | 101 | { |
4991 | 87 | 102 | auto& app_manager = ApplicationManager::Default(); | |
4992 | 88 | glib::Object<GFile> loc_file(g_file_new_for_uri(loc.c_str())); | 103 | bool synced = true; |
4993 | 89 | 104 | ||
4994 | 90 | if (allow_equal && g_file_equal(loc_file, uri_file)) | 105 | for (auto const& pair : opened_location_for_xid_) |
4995 | 91 | equal = true; | 106 | { |
4996 | 92 | 107 | synced = (app_manager.GetWindowForId(pair.first) != nullptr); | |
4997 | 93 | if (equal || g_file_has_prefix(loc_file, uri_file)) | 108 | |
4998 | 94 | return loc; | 109 | if (!synced) |
4999 | 95 | } | 110 | break; |
5000 | 96 | 111 | } | |
4968 | 97 | return ""; | ||
4969 | 98 | } | ||
4970 | 99 | |||
4971 | 100 | glib::DBusProxy::Ptr NautilusOperationsProxy() const | ||
4972 | 101 | { | ||
4973 | 102 | return std::make_shared<glib::DBusProxy>(NAUTILUS_NAME, NAUTILUS_PATH, | ||
4974 | 103 | "org.gnome.Nautilus.FileOperations"); |
FAILED: Continuous integration, rev:4100 jenkins. qa.ubuntu. com/job/ unity-ci/ 1367/ jenkins. qa.ubuntu. com/job/ unity-xenial- amd64-ci/ 19/console jenkins. qa.ubuntu. com/job/ unity-xenial- armhf-ci/ 19/console jenkins. qa.ubuntu. com/job/ unity-xenial- i386-ci/ 19/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/unity- ci/1367/ rebuild
http://