Merge lp:~3v1n0/unity/launcher-draggable-icons-6.0 into lp:unity/6.0
- launcher-draggable-icons-6.0
- Merge into 6.0
Status: | Merged |
---|---|
Approved by: | Marco Trevisan (Treviño) |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2692 |
Proposed branch: | lp:~3v1n0/unity/launcher-draggable-icons-6.0 |
Merge into: | lp:unity/6.0 |
Diff against target: |
7558 lines (+3857/-1097) 72 files modified
UnityCore/DesktopUtilities.cpp (+29/-9) UnityCore/DesktopUtilities.h (+1/-0) UnityCore/GLibDBusProxy.cpp (+0/-4) com.canonical.Unity.gschema.xml (+3/-3) launcher/AbstractLauncherIcon.h (+16/-2) launcher/BFBLauncherIcon.cpp (+1/-0) launcher/BamfLauncherIcon.cpp (+31/-48) launcher/BamfLauncherIcon.h (+0/-1) launcher/CMakeLists.txt (+1/-0) launcher/DesktopLauncherIcon.cpp (+19/-6) launcher/DesktopLauncherIcon.h (+4/-12) launcher/DeviceLauncherSection.cpp (+14/-7) launcher/DeviceLauncherSection.h (+3/-5) launcher/DndData.cpp (+5/-5) launcher/DndData.h (+1/-1) launcher/ExpoLauncherIcon.cpp (+64/-0) launcher/ExpoLauncherIcon.h (+45/-0) launcher/FavoriteStore.cpp (+93/-4) launcher/FavoriteStore.h (+21/-8) launcher/FavoriteStoreGSettings.cpp (+67/-68) launcher/FavoriteStoreGSettings.h (+7/-4) launcher/FavoriteStorePrivate.cpp (+14/-0) launcher/FavoriteStorePrivate.h (+3/-1) launcher/HudLauncherIcon.cpp (+2/-1) launcher/Launcher.cpp (+83/-108) launcher/Launcher.h (+5/-8) launcher/LauncherController.cpp (+526/-341) launcher/LauncherController.h (+1/-3) launcher/LauncherControllerPrivate.h (+28/-41) launcher/LauncherIcon.cpp (+31/-4) launcher/LauncherIcon.h (+5/-9) launcher/LauncherModel.cpp (+34/-32) launcher/MockLauncherIcon.h (+11/-15) launcher/SoftwareCenterLauncherIcon.cpp (+27/-38) launcher/SoftwareCenterLauncherIcon.h (+1/-1) launcher/SpacerLauncherIcon.cpp (+1/-1) launcher/SpacerLauncherIcon.h (+0/-4) launcher/StandaloneLauncher.cpp (+1/-1) launcher/TrashLauncherIcon.cpp (+1/-0) launcher/VolumeLauncherIcon.cpp (+34/-4) launcher/VolumeLauncherIcon.h (+3/-0) manual-tests/Launcher.txt (+15/-0) panel/PanelMenuView.h (+0/-1) plugins/unityshell/src/unityshell.cpp (+5/-7) plugins/unityshell/unityshell.xml.in (+0/-6) tests/CMakeLists.txt (+19/-11) tests/gmockvolume.c (+4/-3) tests/test_bamf_launcher_icon.cpp (+70/-2) tests/test_bfb_launcher_icon.cpp (+11/-8) tests/test_desktop_launcher_icon.cpp (+80/-0) tests/test_desktop_utilities.cpp (+52/-22) tests/test_device_launcher_section.cpp (+19/-54) tests/test_expo_launcher_icon.cpp (+58/-0) tests/test_favorite_store.cpp (+111/-0) tests/test_favorite_store_gsettings.cpp (+52/-29) tests/test_hud_launcher_icon.cpp (+53/-0) tests/test_launcher.cpp (+226/-15) tests/test_launcher_controller.cpp (+1246/-44) tests/test_launcher_icon.cpp (+113/-0) tests/test_launcher_model.cpp (+182/-40) tests/test_main.cpp (+1/-0) tests/test_main_xless.cpp (+1/-1) tests/test_mock_devices.h (+93/-0) tests/test_software_center_launcher_icon.cpp (+74/-0) tests/test_trash_launcher_icon.cpp (+39/-0) tests/test_volume_launcher_icon.cpp (+67/-46) unity-shared/PluginAdapter.h (+2/-0) unity-shared/PluginAdapterCompiz.cpp (+5/-0) unity-shared/PluginAdapterStandalone.cpp (+15/-7) unity-shared/WindowManager.cpp (+5/-0) unity-shared/WindowManager.h (+1/-0) unity-standalone/StandaloneUnity.cpp (+2/-2) |
To merge this branch: | bzr merge lp:~3v1n0/unity/launcher-draggable-icons-6.0 |
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Andrea Azzarone (community) | Approve | ||
Brandon Schaefer (community) | Approve | ||
Review via email: mp+124838@code.launchpad.net |
Commit message
LauncherController, FavoriteStore, Launcher, Icons: always use sort priority based on favorites to get positioned on launcher
This is the continuum of the work started in lp:~3v1n0/unity/keep-priority-launcher-model, here we use the launcher icons priority to correctly order the icons in the launcher, based on the position that they have in the favorite store.
The unity launcher favorite store now handles not only desktop paths or id but also (mostly) icons uris (such as application:
To do this, I had to change AbstractLaunche
The icons ordering has changed a lot: now the favorites control everything (except BFB and trash) and we add the icons based on their defined position. Added two special places: "unity:
When a new Device or Application icon is added to the launcher, we append it to the list of the non-sticky devices or applications.
Favorites reordering, removal or additions have been refactored to fit to our new system; when we save the favorites, the position of the "running-apps" or "attached-devices" is computed based on where the first icon of this type is placed.
The expo icon is handled differently, since it is not added if we have no workspaces available; it also updates its visibility based on the workspaces settings.
SoftwareCenterL
See other commit messages for more info, they should be quite comprehensive.
----
Testing: updated and added a lot of new unit tests to cover (hopefully) all the changes I've done (that's mostly why this diff is so big, since the real changes are less than the half of the changed code) and to test the areas that we never tested before, just few stats:
test-gtest: added 13 new test cases (+5%)
test-gtest-xless: added 94 new test cases (+56%)
Description of the change
lp:~3v1n0/unity/launcher-draggable-icons/+merge/123311 backported to unity-6.0
Andrea Azzarone (azzar1) wrote : | # |
Approve as discussed on IRC.
Unity Merger (unity-merger) wrote : | # |
The Jenkins job https:/
Not merging it.
Preview Diff
1 | === modified file 'UnityCore/DesktopUtilities.cpp' | |||
2 | --- UnityCore/DesktopUtilities.cpp 2012-06-01 09:33:15 +0000 | |||
3 | +++ UnityCore/DesktopUtilities.cpp 2012-09-18 15:52:46 +0000 | |||
4 | @@ -19,8 +19,10 @@ | |||
5 | 19 | */ | 19 | */ |
6 | 20 | 20 | ||
7 | 21 | #include <algorithm> | 21 | #include <algorithm> |
8 | 22 | #include <memory> | ||
9 | 22 | 23 | ||
10 | 23 | #include <glib.h> | 24 | #include <glib.h> |
11 | 25 | #include <gio/gdesktopappinfo.h> | ||
12 | 24 | 26 | ||
13 | 25 | #include "DesktopUtilities.h" | 27 | #include "DesktopUtilities.h" |
14 | 26 | #include "GLibWrapper.h" | 28 | #include "GLibWrapper.h" |
15 | @@ -119,23 +121,41 @@ | |||
16 | 119 | return GetDesktopID(data_dirs, desktop_path); | 121 | return GetDesktopID(data_dirs, desktop_path); |
17 | 120 | } | 122 | } |
18 | 121 | 123 | ||
19 | 124 | std::string DesktopUtilities::GetDesktopPathById(std::string const& desktop_id) | ||
20 | 125 | { | ||
21 | 126 | if (desktop_id.empty()) | ||
22 | 127 | return ""; | ||
23 | 128 | |||
24 | 129 | glib::Object<GDesktopAppInfo> info; | ||
25 | 130 | |||
26 | 131 | if (desktop_id.find(G_DIR_SEPARATOR_S) != std::string::npos) | ||
27 | 132 | info = g_desktop_app_info_new_from_filename(desktop_id.c_str()); | ||
28 | 133 | else | ||
29 | 134 | info = g_desktop_app_info_new(desktop_id.c_str()); | ||
30 | 135 | |||
31 | 136 | if (info) | ||
32 | 137 | { | ||
33 | 138 | const char* filename = g_desktop_app_info_get_filename(info); | ||
34 | 139 | |||
35 | 140 | if (filename) | ||
36 | 141 | return filename; | ||
37 | 142 | } | ||
38 | 143 | |||
39 | 144 | return ""; | ||
40 | 145 | } | ||
41 | 122 | 146 | ||
42 | 123 | std::string DesktopUtilities::GetBackgroundColor(std::string const& desktop_path) | 147 | std::string DesktopUtilities::GetBackgroundColor(std::string const& desktop_path) |
43 | 124 | { | 148 | { |
45 | 125 | GKeyFile* key_file = g_key_file_new(); | 149 | std::shared_ptr<GKeyFile> key_file(g_key_file_new(), g_key_file_free); |
46 | 126 | 150 | ||
47 | 127 | glib::Error error; | 151 | glib::Error error; |
49 | 128 | g_key_file_load_from_file(key_file, desktop_path.c_str(), static_cast<GKeyFileFlags>(0), &error); | 152 | g_key_file_load_from_file(key_file.get(), desktop_path.c_str(), static_cast<GKeyFileFlags>(0), &error); |
50 | 129 | 153 | ||
51 | 130 | if (error) | 154 | if (error) |
52 | 131 | { | ||
53 | 132 | g_key_file_free(key_file); | ||
54 | 133 | return ""; | 155 | return ""; |
60 | 134 | } | 156 | |
61 | 135 | 157 | glib::String value(g_key_file_get_string(key_file.get(), "Desktop Entry", "X-Unity-IconBackgroundColor", &error)); | |
62 | 136 | glib::String value(g_key_file_get_string(key_file, "Desktop Entry", "X-Unity-IconBackgroundColor", &error)); | 158 | |
58 | 137 | |||
59 | 138 | g_key_file_free(key_file); | ||
63 | 139 | return value.Str(); | 159 | return value.Str(); |
64 | 140 | } | 160 | } |
65 | 141 | 161 | ||
66 | 142 | 162 | ||
67 | === modified file 'UnityCore/DesktopUtilities.h' | |||
68 | --- UnityCore/DesktopUtilities.h 2012-05-25 07:37:21 +0000 | |||
69 | +++ UnityCore/DesktopUtilities.h 2012-09-18 15:52:46 +0000 | |||
70 | @@ -36,6 +36,7 @@ | |||
71 | 36 | static std::string GetDesktopID(std::string const& desktop_path); | 36 | static std::string GetDesktopID(std::string const& desktop_path); |
72 | 37 | static std::string GetDesktopID(std::vector<std::string> const& default_paths, | 37 | static std::string GetDesktopID(std::vector<std::string> const& default_paths, |
73 | 38 | std::string const& desktop_path); | 38 | std::string const& desktop_path); |
74 | 39 | static std::string GetDesktopPathById(std::string const& desktop_id); | ||
75 | 39 | 40 | ||
76 | 40 | static std::string GetBackgroundColor(std::string const& desktop_path); | 41 | static std::string GetBackgroundColor(std::string const& desktop_path); |
77 | 41 | }; | 42 | }; |
78 | 42 | 43 | ||
79 | === modified file 'UnityCore/GLibDBusProxy.cpp' | |||
80 | --- UnityCore/GLibDBusProxy.cpp 2012-07-17 13:42:48 +0000 | |||
81 | +++ UnityCore/GLibDBusProxy.cpp 2012-09-18 15:52:46 +0000 | |||
82 | @@ -90,7 +90,6 @@ | |||
83 | 90 | 90 | ||
84 | 91 | glib::Object<GDBusProxy> proxy_; | 91 | glib::Object<GDBusProxy> proxy_; |
85 | 92 | glib::Object<GCancellable> cancellable_; | 92 | glib::Object<GCancellable> cancellable_; |
86 | 93 | guint watcher_id_; | ||
87 | 94 | bool connected_; | 93 | bool connected_; |
88 | 95 | 94 | ||
89 | 96 | glib::Signal<void, GDBusProxy*, char*, char*, GVariant*> g_signal_connection_; | 95 | glib::Signal<void, GDBusProxy*, char*, char*, GVariant*> g_signal_connection_; |
90 | @@ -113,7 +112,6 @@ | |||
91 | 113 | , bus_type_(bus_type) | 112 | , bus_type_(bus_type) |
92 | 114 | , flags_(flags) | 113 | , flags_(flags) |
93 | 115 | , cancellable_(g_cancellable_new()) | 114 | , cancellable_(g_cancellable_new()) |
94 | 116 | , watcher_id_(0) | ||
95 | 117 | , connected_(false) | 115 | , connected_(false) |
96 | 118 | { | 116 | { |
97 | 119 | StartReconnectionTimeout(); | 117 | StartReconnectionTimeout(); |
98 | @@ -122,8 +120,6 @@ | |||
99 | 122 | DBusProxy::Impl::~Impl() | 120 | DBusProxy::Impl::~Impl() |
100 | 123 | { | 121 | { |
101 | 124 | g_cancellable_cancel(cancellable_); | 122 | g_cancellable_cancel(cancellable_); |
102 | 125 | if (watcher_id_) | ||
103 | 126 | g_bus_unwatch_name(watcher_id_); | ||
104 | 127 | } | 123 | } |
105 | 128 | 124 | ||
106 | 129 | void DBusProxy::Impl::StartReconnectionTimeout() | 125 | void DBusProxy::Impl::StartReconnectionTimeout() |
107 | 130 | 126 | ||
108 | === modified file 'com.canonical.Unity.gschema.xml' | |||
109 | --- com.canonical.Unity.gschema.xml 2012-08-31 09:15:33 +0000 | |||
110 | +++ com.canonical.Unity.gschema.xml 2012-09-18 15:52:46 +0000 | |||
111 | @@ -44,9 +44,9 @@ | |||
112 | 44 | </schema> | 44 | </schema> |
113 | 45 | <schema path="/com/canonical/unity/launcher/" id="com.canonical.Unity.Launcher" gettext-domain="unity"> | 45 | <schema path="/com/canonical/unity/launcher/" id="com.canonical.Unity.Launcher" gettext-domain="unity"> |
114 | 46 | <key type="as" name="favorites"> | 46 | <key type="as" name="favorites"> |
118 | 47 | <default>[ 'ubiquity-gtkui.desktop', 'nautilus-home.desktop', 'firefox.desktop', 'libreoffice-writer.desktop', 'libreoffice-calc.desktop', 'libreoffice-impress.desktop', 'ubuntu-software-center.desktop', 'ubuntuone-installer.desktop', 'gnome-control-center.desktop' ]</default> | 47 | <default>[ 'application://ubiquity-gtkui.desktop', 'application://nautilus-home.desktop', 'application://firefox.desktop', 'application://libreoffice-writer.desktop', 'application://libreoffice-calc.desktop', 'application://libreoffice-impress.desktop', 'application://ubuntu-software-center.desktop', 'application://ubuntuone-installer.desktop', 'application://gnome-control-center.desktop', 'unity://running-apps', 'unity://expo-icon', 'unity://devices' ]</default> |
119 | 48 | <summary>List of desktop file ids for favorites on the launcher.</summary> | 48 | <summary>List of items that should be shown by default in the launcher</summary> |
120 | 49 | <description>These applications are shown in the Launcher by default.</description> | 49 | <description>These items can be application://desktop-id.desktop, device://uiid and unity://special-id (including unity://running-apps that specifies the position of the ran applications, unity://devices the position of the attached devices, unity://expo-icon the position of the workspace switcher and unity://show-desktop-icon the position of the show-desktop icon); the order of this list determines the launcher items position.</description> |
121 | 50 | </key> | 50 | </key> |
122 | 51 | <key type="s" name="favorite-migration"> | 51 | <key type="s" name="favorite-migration"> |
123 | 52 | <default>''</default> | 52 | <default>''</default> |
124 | 53 | 53 | ||
125 | === modified file 'launcher/AbstractLauncherIcon.h' | |||
126 | --- launcher/AbstractLauncherIcon.h 2012-08-15 02:51:33 +0000 | |||
127 | +++ launcher/AbstractLauncherIcon.h 2012-09-18 15:52:46 +0000 | |||
128 | @@ -93,6 +93,7 @@ | |||
129 | 93 | DESKTOP, | 93 | DESKTOP, |
130 | 94 | PLACE, | 94 | PLACE, |
131 | 95 | DEVICE, | 95 | DEVICE, |
132 | 96 | SPACER, | ||
133 | 96 | TRASH, | 97 | TRASH, |
134 | 97 | END | 98 | END |
135 | 98 | }; | 99 | }; |
136 | @@ -117,10 +118,18 @@ | |||
137 | 117 | LAST | 118 | LAST |
138 | 118 | }; | 119 | }; |
139 | 119 | 120 | ||
140 | 121 | enum class Position | ||
141 | 122 | { | ||
142 | 123 | BEGIN, | ||
143 | 124 | FLOATING, | ||
144 | 125 | END | ||
145 | 126 | }; | ||
146 | 127 | |||
147 | 120 | virtual ~AbstractLauncherIcon() {} | 128 | virtual ~AbstractLauncherIcon() {} |
148 | 121 | 129 | ||
149 | 122 | nux::Property<std::string> tooltip_text; | 130 | nux::Property<std::string> tooltip_text; |
150 | 123 | nux::Property<bool> tooltip_enabled; | 131 | nux::Property<bool> tooltip_enabled; |
151 | 132 | nux::Property<Position> position; | ||
152 | 124 | 133 | ||
153 | 125 | virtual void HideTooltip() = 0; | 134 | virtual void HideTooltip() = 0; |
154 | 126 | 135 | ||
155 | @@ -158,8 +167,6 @@ | |||
156 | 158 | 167 | ||
157 | 159 | virtual const bool WindowVisibleOnViewport() = 0; | 168 | virtual const bool WindowVisibleOnViewport() = 0; |
158 | 160 | 169 | ||
159 | 161 | virtual bool IsSpacer() = 0; | ||
160 | 162 | |||
161 | 163 | virtual float PresentUrgency() = 0; | 170 | virtual float PresentUrgency() = 0; |
162 | 164 | 171 | ||
163 | 165 | virtual float GetProgress() = 0; | 172 | virtual float GetProgress() = 0; |
164 | @@ -211,6 +218,11 @@ | |||
165 | 211 | 218 | ||
166 | 212 | virtual void UnStick() = 0; | 219 | virtual void UnStick() = 0; |
167 | 213 | 220 | ||
168 | 221 | static int DefaultPriority(IconType type) | ||
169 | 222 | { | ||
170 | 223 | return static_cast<int>(type) * 1000; | ||
171 | 224 | } | ||
172 | 225 | |||
173 | 214 | sigc::signal<void, int, int, unsigned long> mouse_down; | 226 | sigc::signal<void, int, int, unsigned long> mouse_down; |
174 | 215 | sigc::signal<void, int, int, unsigned long> mouse_up; | 227 | sigc::signal<void, int, int, unsigned long> mouse_up; |
175 | 216 | sigc::signal<void, int, int, unsigned long> mouse_click; | 228 | sigc::signal<void, int, int, unsigned long> mouse_click; |
176 | @@ -221,6 +233,8 @@ | |||
177 | 221 | sigc::signal<void, AbstractLauncherIcon::Ptr> remove; | 233 | sigc::signal<void, AbstractLauncherIcon::Ptr> remove; |
178 | 222 | sigc::signal<void, nux::ObjectPtr<nux::View>> tooltip_visible; | 234 | sigc::signal<void, nux::ObjectPtr<nux::View>> tooltip_visible; |
179 | 223 | sigc::signal<void> visibility_changed; | 235 | sigc::signal<void> visibility_changed; |
180 | 236 | sigc::signal<void> position_saved; | ||
181 | 237 | sigc::signal<void> position_forgot; | ||
182 | 224 | 238 | ||
183 | 225 | sigc::connection needs_redraw_connection; | 239 | sigc::connection needs_redraw_connection; |
184 | 226 | sigc::connection on_icon_added_connection; | 240 | sigc::connection on_icon_added_connection; |
185 | 227 | 241 | ||
186 | === modified file 'launcher/BFBLauncherIcon.cpp' | |||
187 | --- launcher/BFBLauncherIcon.cpp 2012-08-15 02:51:33 +0000 | |||
188 | +++ launcher/BFBLauncherIcon.cpp 2012-09-18 15:52:46 +0000 | |||
189 | @@ -36,6 +36,7 @@ | |||
190 | 36 | { | 36 | { |
191 | 37 | tooltip_text = _("Dash Home"); | 37 | tooltip_text = _("Dash Home"); |
192 | 38 | icon_name = PKGDATADIR"/launcher_bfb.png"; | 38 | icon_name = PKGDATADIR"/launcher_bfb.png"; |
193 | 39 | position = Position::BEGIN; | ||
194 | 39 | SetQuirk(Quirk::VISIBLE, true); | 40 | SetQuirk(Quirk::VISIBLE, true); |
195 | 40 | SetQuirk(Quirk::RUNNING, false); | 41 | SetQuirk(Quirk::RUNNING, false); |
196 | 41 | 42 | ||
197 | 42 | 43 | ||
198 | === modified file 'launcher/BamfLauncherIcon.cpp' | |||
199 | --- launcher/BamfLauncherIcon.cpp 2012-08-21 21:46:54 +0000 | |||
200 | +++ launcher/BamfLauncherIcon.cpp 2012-09-18 15:52:46 +0000 | |||
201 | @@ -74,11 +74,7 @@ | |||
202 | 74 | tooltip_text = BamfName(); | 74 | tooltip_text = BamfName(); |
203 | 75 | icon_name = (icon ? icon.Str() : DEFAULT_ICON); | 75 | icon_name = (icon ? icon.Str() : DEFAULT_ICON); |
204 | 76 | 76 | ||
210 | 77 | if (IsSticky()) | 77 | SetQuirk(Quirk::VISIBLE, bamf_view_user_visible(bamf_view)); |
206 | 78 | SetQuirk(Quirk::VISIBLE, true); | ||
207 | 79 | else | ||
208 | 80 | SetQuirk(Quirk::VISIBLE, bamf_view_user_visible(bamf_view)); | ||
209 | 81 | |||
211 | 82 | SetQuirk(Quirk::ACTIVE, bamf_view_is_active(bamf_view)); | 78 | SetQuirk(Quirk::ACTIVE, bamf_view_is_active(bamf_view)); |
212 | 83 | SetQuirk(Quirk::RUNNING, bamf_view_is_running(bamf_view)); | 79 | SetQuirk(Quirk::RUNNING, bamf_view_is_running(bamf_view)); |
213 | 84 | 80 | ||
214 | @@ -95,7 +91,7 @@ | |||
215 | 95 | sig = new glib::Signal<void, BamfView*, BamfView*>(bamf_view, "child-removed", | 91 | sig = new glib::Signal<void, BamfView*, BamfView*>(bamf_view, "child-removed", |
216 | 96 | [&] (BamfView*, BamfView*) { EnsureWindowState(); }); | 92 | [&] (BamfView*, BamfView*) { EnsureWindowState(); }); |
217 | 97 | _gsignals.Add(sig); | 93 | _gsignals.Add(sig); |
219 | 98 | 94 | ||
220 | 99 | sig = new glib::Signal<void, BamfView*, BamfView*>(bamf_view, "child-moved", | 95 | sig = new glib::Signal<void, BamfView*, BamfView*>(bamf_view, "child-moved", |
221 | 100 | [&] (BamfView *, BamfView *) { | 96 | [&] (BamfView *, BamfView *) { |
222 | 101 | EnsureWindowState(); | 97 | EnsureWindowState(); |
223 | @@ -173,9 +169,12 @@ | |||
224 | 173 | 169 | ||
225 | 174 | BamfLauncherIcon::~BamfLauncherIcon() | 170 | BamfLauncherIcon::~BamfLauncherIcon() |
226 | 175 | { | 171 | { |
228 | 176 | if (_bamf_app) | 172 | if (_bamf_app.IsType(BAMF_TYPE_APPLICATION)) |
229 | 173 | { | ||
230 | 174 | bamf_view_set_sticky(BAMF_VIEW(_bamf_app.RawPtr()), FALSE); | ||
231 | 177 | g_object_set_qdata(G_OBJECT(_bamf_app.RawPtr()), | 175 | g_object_set_qdata(G_OBJECT(_bamf_app.RawPtr()), |
232 | 178 | g_quark_from_static_string("unity-seen"), nullptr); | 176 | g_quark_from_static_string("unity-seen"), nullptr); |
233 | 177 | } | ||
234 | 179 | } | 178 | } |
235 | 180 | 179 | ||
236 | 181 | void BamfLauncherIcon::Remove() | 180 | void BamfLauncherIcon::Remove() |
237 | @@ -201,11 +200,6 @@ | |||
238 | 201 | return bamf_view_is_sticky(BAMF_VIEW(_bamf_app.RawPtr())); | 200 | return bamf_view_is_sticky(BAMF_VIEW(_bamf_app.RawPtr())); |
239 | 202 | } | 201 | } |
240 | 203 | 202 | ||
241 | 204 | bool BamfLauncherIcon::IsVisible() const | ||
242 | 205 | { | ||
243 | 206 | return GetQuirk(Quirk::VISIBLE); | ||
244 | 207 | } | ||
245 | 208 | |||
246 | 209 | bool BamfLauncherIcon::IsActive() const | 203 | bool BamfLauncherIcon::IsActive() const |
247 | 210 | { | 204 | { |
248 | 211 | return GetQuirk(Quirk::ACTIVE); | 205 | return GetQuirk(Quirk::ACTIVE); |
249 | @@ -235,7 +229,6 @@ | |||
250 | 235 | wm->Activate(arg.target); | 229 | wm->Activate(arg.target); |
251 | 236 | return; | 230 | return; |
252 | 237 | } | 231 | } |
253 | 238 | |||
254 | 239 | 232 | ||
255 | 240 | /* We should check each child to see if there is | 233 | /* We should check each child to see if there is |
256 | 241 | * an unmapped (!= minimized) window around and | 234 | * an unmapped (!= minimized) window around and |
257 | @@ -638,22 +631,22 @@ | |||
258 | 638 | GList* children; | 631 | GList* children; |
259 | 639 | 632 | ||
260 | 640 | BamfView *focusable_child = BAMF_VIEW (bamf_application_get_focusable_child (_bamf_app.RawPtr())); | 633 | BamfView *focusable_child = BAMF_VIEW (bamf_application_get_focusable_child (_bamf_app.RawPtr())); |
262 | 641 | 634 | ||
263 | 642 | if (focusable_child != NULL) | 635 | if (focusable_child != NULL) |
264 | 643 | { | 636 | { |
265 | 644 | Window xid; | 637 | Window xid; |
267 | 645 | 638 | ||
268 | 646 | if (BAMF_IS_WINDOW (focusable_child)) | 639 | if (BAMF_IS_WINDOW (focusable_child)) |
269 | 647 | xid = bamf_window_get_xid (BAMF_WINDOW(focusable_child)); | 640 | xid = bamf_window_get_xid (BAMF_WINDOW(focusable_child)); |
270 | 648 | else if (BAMF_IS_TAB (focusable_child)) | 641 | else if (BAMF_IS_TAB (focusable_child)) |
271 | 649 | { | 642 | { |
272 | 650 | BamfTab *focusable_tab = BAMF_TAB (focusable_child); | 643 | BamfTab *focusable_tab = BAMF_TAB (focusable_child); |
274 | 651 | 644 | ||
275 | 652 | xid = bamf_tab_get_xid (focusable_tab); | 645 | xid = bamf_tab_get_xid (focusable_tab); |
277 | 653 | 646 | ||
278 | 654 | bamf_tab_raise (focusable_tab); | 647 | bamf_tab_raise (focusable_tab); |
279 | 655 | } | 648 | } |
281 | 656 | 649 | ||
282 | 657 | windows.push_back(xid); | 650 | windows.push_back(xid); |
283 | 658 | return windows; | 651 | return windows; |
284 | 659 | } | 652 | } |
285 | @@ -662,7 +655,7 @@ | |||
286 | 662 | if (g_strcmp0 (bamf_application_get_application_type (_bamf_app.RawPtr()), "webapp") == 0) | 655 | if (g_strcmp0 (bamf_application_get_application_type (_bamf_app.RawPtr()), "webapp") == 0) |
287 | 663 | { | 656 | { |
288 | 664 | OpenInstanceLauncherIcon(arg); | 657 | OpenInstanceLauncherIcon(arg); |
290 | 665 | 658 | ||
291 | 666 | return windows; | 659 | return windows; |
292 | 667 | } | 660 | } |
293 | 668 | } | 661 | } |
294 | @@ -762,13 +755,13 @@ | |||
295 | 762 | { | 755 | { |
296 | 763 | /* BamfTab does not support the monitor interface...so a bit of a nasty hack here. */ | 756 | /* BamfTab does not support the monitor interface...so a bit of a nasty hack here. */ |
297 | 764 | xid = bamf_tab_get_xid (static_cast<BamfTab*>(l->data)); | 757 | xid = bamf_tab_get_xid (static_cast<BamfTab*>(l->data)); |
299 | 765 | 758 | ||
300 | 766 | if (WindowManager::Default()->IsWindowOnCurrentDesktop(xid) == false) | 759 | if (WindowManager::Default()->IsWindowOnCurrentDesktop(xid) == false) |
301 | 767 | continue; | 760 | continue; |
303 | 768 | 761 | ||
304 | 769 | for (int j = 0; j < max_num_monitors; j++) | 762 | for (int j = 0; j < max_num_monitors; j++) |
305 | 770 | monitors[j] = true; | 763 | monitors[j] = true; |
307 | 771 | 764 | ||
308 | 772 | continue; | 765 | continue; |
309 | 773 | } | 766 | } |
310 | 774 | 767 | ||
311 | @@ -939,30 +932,28 @@ | |||
312 | 939 | 932 | ||
313 | 940 | void BamfLauncherIcon::Stick(bool save) | 933 | void BamfLauncherIcon::Stick(bool save) |
314 | 941 | { | 934 | { |
315 | 935 | SimpleLauncherIcon::Stick(save); | ||
316 | 936 | |||
317 | 942 | if (IsSticky()) | 937 | if (IsSticky()) |
318 | 943 | return; | 938 | return; |
319 | 944 | 939 | ||
320 | 945 | std::string const& desktop_file = DesktopFile(); | ||
321 | 946 | bamf_view_set_sticky(BAMF_VIEW(_bamf_app.RawPtr()), true); | 940 | bamf_view_set_sticky(BAMF_VIEW(_bamf_app.RawPtr()), true); |
322 | 947 | |||
323 | 948 | if (save && !desktop_file.empty()) | ||
324 | 949 | FavoriteStore::Instance().AddFavorite(desktop_file, -1); | ||
325 | 950 | } | 941 | } |
326 | 951 | 942 | ||
327 | 952 | void BamfLauncherIcon::UnStick() | 943 | void BamfLauncherIcon::UnStick() |
328 | 953 | { | 944 | { |
329 | 945 | SimpleLauncherIcon::UnStick(); | ||
330 | 946 | |||
331 | 954 | if (!IsSticky()) | 947 | if (!IsSticky()) |
332 | 955 | return; | 948 | return; |
333 | 956 | 949 | ||
334 | 957 | std::string const& desktop_file = DesktopFile(); | ||
335 | 958 | BamfView* view = BAMF_VIEW(_bamf_app.RawPtr()); | 950 | BamfView* view = BAMF_VIEW(_bamf_app.RawPtr()); |
336 | 959 | bamf_view_set_sticky(view, false); | 951 | bamf_view_set_sticky(view, false); |
337 | 960 | 952 | ||
339 | 961 | if (bamf_view_is_closed(view) || !bamf_view_user_visible(view)) | 953 | SetQuirk(Quirk::VISIBLE, bamf_view_user_visible(view)); |
340 | 954 | |||
341 | 955 | if (bamf_view_is_closed(view)) | ||
342 | 962 | Remove(); | 956 | Remove(); |
343 | 963 | |||
344 | 964 | if (!desktop_file.empty()) | ||
345 | 965 | FavoriteStore::Instance().RemoveFavorite(desktop_file); | ||
346 | 966 | } | 957 | } |
347 | 967 | 958 | ||
348 | 968 | void BamfLauncherIcon::ToggleSticky() | 959 | void BamfLauncherIcon::ToggleSticky() |
349 | @@ -1227,12 +1218,11 @@ | |||
350 | 1227 | { | 1218 | { |
351 | 1228 | if (_remote_uri.empty()) | 1219 | if (_remote_uri.empty()) |
352 | 1229 | { | 1220 | { |
353 | 1230 | const std::string prefix = "application://"; | ||
354 | 1231 | std::string const& desktop_id = GetDesktopID(); | 1221 | std::string const& desktop_id = GetDesktopID(); |
355 | 1232 | 1222 | ||
356 | 1233 | if (!desktop_id.empty()) | 1223 | if (!desktop_id.empty()) |
357 | 1234 | { | 1224 | { |
359 | 1235 | _remote_uri = prefix + desktop_id; | 1225 | _remote_uri = FavoriteStore::URI_PREFIX_APP + desktop_id; |
360 | 1236 | } | 1226 | } |
361 | 1237 | } | 1227 | } |
362 | 1238 | 1228 | ||
363 | @@ -1384,32 +1374,25 @@ | |||
364 | 1384 | if (desktop_file.empty()) | 1374 | if (desktop_file.empty()) |
365 | 1385 | return; | 1375 | return; |
366 | 1386 | 1376 | ||
368 | 1387 | GKeyFile* key_file = g_key_file_new(); | 1377 | std::shared_ptr<GKeyFile> key_file(g_key_file_new(), g_key_file_free); |
369 | 1388 | glib::Error error; | 1378 | glib::Error error; |
370 | 1389 | 1379 | ||
372 | 1390 | g_key_file_load_from_file(key_file, desktop_file.c_str(), (GKeyFileFlags) 0, &error); | 1380 | g_key_file_load_from_file(key_file.get(), desktop_file.c_str(), (GKeyFileFlags) 0, &error); |
373 | 1391 | 1381 | ||
374 | 1392 | if (error) | 1382 | if (error) |
375 | 1393 | { | ||
376 | 1394 | g_key_file_free(key_file); | ||
377 | 1395 | return; | 1383 | return; |
381 | 1396 | } | 1384 | |
382 | 1397 | 1385 | std::shared_ptr<char*> mimes(g_key_file_get_string_list(key_file.get(), "Desktop Entry", "MimeType", nullptr, nullptr), | |
383 | 1398 | char** mimes = g_key_file_get_string_list(key_file, "Desktop Entry", "MimeType", nullptr, nullptr); | 1386 | g_strfreev); |
384 | 1387 | |||
385 | 1399 | if (!mimes) | 1388 | if (!mimes) |
386 | 1400 | { | ||
387 | 1401 | g_key_file_free(key_file); | ||
388 | 1402 | return; | 1389 | return; |
389 | 1403 | } | ||
390 | 1404 | 1390 | ||
392 | 1405 | for (int i = 0; mimes[i]; i++) | 1391 | for (int i = 0; mimes.get()[i]; i++) |
393 | 1406 | { | 1392 | { |
395 | 1407 | unity::glib::String super_type(g_content_type_from_mime_type(mimes[i])); | 1393 | unity::glib::String super_type(g_content_type_from_mime_type(mimes.get()[i])); |
396 | 1408 | _supported_types.insert(super_type.Str()); | 1394 | _supported_types.insert(super_type.Str()); |
397 | 1409 | } | 1395 | } |
398 | 1410 | |||
399 | 1411 | g_key_file_free(key_file); | ||
400 | 1412 | g_strfreev(mimes); | ||
401 | 1413 | } | 1396 | } |
402 | 1414 | } | 1397 | } |
403 | 1415 | 1398 | ||
404 | 1416 | 1399 | ||
405 | === modified file 'launcher/BamfLauncherIcon.h' | |||
406 | --- launcher/BamfLauncherIcon.h 2012-08-20 06:37:21 +0000 | |||
407 | +++ launcher/BamfLauncherIcon.h 2012-09-18 15:52:46 +0000 | |||
408 | @@ -48,7 +48,6 @@ | |||
409 | 48 | std::string DesktopFile(); | 48 | std::string DesktopFile(); |
410 | 49 | 49 | ||
411 | 50 | bool IsSticky() const; | 50 | bool IsSticky() const; |
412 | 51 | bool IsVisible() const; | ||
413 | 52 | bool IsActive() const; | 51 | bool IsActive() const; |
414 | 53 | bool IsRunning() const; | 52 | bool IsRunning() const; |
415 | 54 | bool IsUrgent() const; | 53 | bool IsUrgent() const; |
416 | 55 | 54 | ||
417 | === modified file 'launcher/CMakeLists.txt' | |||
418 | --- launcher/CMakeLists.txt 2012-08-25 15:54:29 +0000 | |||
419 | +++ launcher/CMakeLists.txt 2012-09-18 15:52:46 +0000 | |||
420 | @@ -42,6 +42,7 @@ | |||
421 | 42 | DevicesSettingsImp.cpp | 42 | DevicesSettingsImp.cpp |
422 | 43 | DndData.cpp | 43 | DndData.cpp |
423 | 44 | EdgeBarrierController.cpp | 44 | EdgeBarrierController.cpp |
424 | 45 | ExpoLauncherIcon.cpp | ||
425 | 45 | FavoriteStore.cpp | 46 | FavoriteStore.cpp |
426 | 46 | FavoriteStoreGSettings.cpp | 47 | FavoriteStoreGSettings.cpp |
427 | 47 | FavoriteStorePrivate.cpp | 48 | FavoriteStorePrivate.cpp |
428 | 48 | 49 | ||
429 | === modified file 'launcher/DesktopLauncherIcon.cpp' | |||
430 | --- launcher/DesktopLauncherIcon.cpp 2012-08-02 13:16:06 +0000 | |||
431 | +++ launcher/DesktopLauncherIcon.cpp 2012-09-18 15:52:46 +0000 | |||
432 | @@ -19,6 +19,7 @@ | |||
433 | 19 | 19 | ||
434 | 20 | #include "DesktopLauncherIcon.h" | 20 | #include "DesktopLauncherIcon.h" |
435 | 21 | #include "unity-shared/WindowManager.h" | 21 | #include "unity-shared/WindowManager.h" |
436 | 22 | #include "FavoriteStore.h" | ||
437 | 22 | 23 | ||
438 | 23 | #include <glib/gi18n-lib.h> | 24 | #include <glib/gi18n-lib.h> |
439 | 24 | 25 | ||
440 | @@ -28,17 +29,14 @@ | |||
441 | 28 | { | 29 | { |
442 | 29 | 30 | ||
443 | 30 | DesktopLauncherIcon::DesktopLauncherIcon() | 31 | DesktopLauncherIcon::DesktopLauncherIcon() |
446 | 31 | : SimpleLauncherIcon(IconType::DESKTOP) | 32 | : SimpleLauncherIcon(IconType::DESKTOP) |
447 | 32 | , show_in_switcher_(true) | 33 | , show_in_switcher_(true) |
448 | 33 | { | 34 | { |
449 | 34 | tooltip_text = _("Show Desktop"); | 35 | tooltip_text = _("Show Desktop"); |
450 | 35 | icon_name = "desktop"; | 36 | icon_name = "desktop"; |
451 | 36 | SetQuirk(Quirk::VISIBLE, true); | 37 | SetQuirk(Quirk::VISIBLE, true); |
452 | 37 | SetQuirk(Quirk::RUNNING, false); | 38 | SetQuirk(Quirk::RUNNING, false); |
457 | 38 | } | 39 | SetShortcut('d'); |
454 | 39 | |||
455 | 40 | DesktopLauncherIcon::~DesktopLauncherIcon() | ||
456 | 41 | { | ||
458 | 42 | } | 40 | } |
459 | 43 | 41 | ||
460 | 44 | void | 42 | void |
461 | @@ -53,5 +51,20 @@ | |||
462 | 53 | return "DesktopLauncherIcon"; | 51 | return "DesktopLauncherIcon"; |
463 | 54 | } | 52 | } |
464 | 55 | 53 | ||
465 | 54 | std::string DesktopLauncherIcon::GetRemoteUri() | ||
466 | 55 | { | ||
467 | 56 | return FavoriteStore::URI_PREFIX_UNITY + "desktop-icon"; | ||
468 | 57 | } | ||
469 | 58 | |||
470 | 59 | void DesktopLauncherIcon::SetShowInSwitcher(bool show_in_switcher) | ||
471 | 60 | { | ||
472 | 61 | show_in_switcher_ = show_in_switcher; | ||
473 | 62 | } | ||
474 | 63 | |||
475 | 64 | bool DesktopLauncherIcon::ShowInSwitcher(bool current) | ||
476 | 65 | { | ||
477 | 66 | return show_in_switcher_; | ||
478 | 67 | } | ||
479 | 68 | |||
480 | 56 | } // namespace launcher | 69 | } // namespace launcher |
481 | 57 | } // namespace unity | 70 | } // namespace unity |
482 | 58 | 71 | ||
483 | === modified file 'launcher/DesktopLauncherIcon.h' | |||
484 | --- launcher/DesktopLauncherIcon.h 2012-05-07 19:52:54 +0000 | |||
485 | +++ launcher/DesktopLauncherIcon.h 2012-09-18 15:52:46 +0000 | |||
486 | @@ -29,24 +29,16 @@ | |||
487 | 29 | 29 | ||
488 | 30 | class DesktopLauncherIcon : public SimpleLauncherIcon | 30 | class DesktopLauncherIcon : public SimpleLauncherIcon |
489 | 31 | { | 31 | { |
490 | 32 | |||
491 | 33 | public: | 32 | public: |
492 | 34 | DesktopLauncherIcon(); | 33 | DesktopLauncherIcon(); |
504 | 35 | ~DesktopLauncherIcon(); | 34 | |
505 | 36 | 35 | void SetShowInSwitcher(bool show_in_switcher); | |
506 | 37 | void SetShowInSwitcher(bool show_in_switcher) | 36 | bool ShowInSwitcher(bool current); |
496 | 38 | { | ||
497 | 39 | show_in_switcher_ = show_in_switcher; | ||
498 | 40 | } | ||
499 | 41 | |||
500 | 42 | bool ShowInSwitcher(bool current) | ||
501 | 43 | { | ||
502 | 44 | return show_in_switcher_; | ||
503 | 45 | } | ||
507 | 46 | 37 | ||
508 | 47 | protected: | 38 | protected: |
509 | 48 | void ActivateLauncherIcon(ActionArg arg); | 39 | void ActivateLauncherIcon(ActionArg arg); |
510 | 49 | std::string GetName() const; | 40 | std::string GetName() const; |
511 | 41 | std::string GetRemoteUri(); | ||
512 | 50 | 42 | ||
513 | 51 | private: | 43 | private: |
514 | 52 | bool show_in_switcher_; | 44 | bool show_in_switcher_; |
515 | 53 | 45 | ||
516 | === modified file 'launcher/DeviceLauncherSection.cpp' | |||
517 | --- launcher/DeviceLauncherSection.cpp 2012-08-28 17:28:02 +0000 | |||
518 | +++ launcher/DeviceLauncherSection.cpp 2012-09-18 15:52:46 +0000 | |||
519 | @@ -38,10 +38,7 @@ | |||
520 | 38 | monitor_->volume_added.connect(sigc::mem_fun(this, &DeviceLauncherSection::OnVolumeAdded)); | 38 | monitor_->volume_added.connect(sigc::mem_fun(this, &DeviceLauncherSection::OnVolumeAdded)); |
521 | 39 | monitor_->volume_removed.connect(sigc::mem_fun(this, &DeviceLauncherSection::OnVolumeRemoved)); | 39 | monitor_->volume_removed.connect(sigc::mem_fun(this, &DeviceLauncherSection::OnVolumeRemoved)); |
522 | 40 | 40 | ||
527 | 41 | device_populate_idle_.Run([this] () { | 41 | PopulateEntries(); |
524 | 42 | PopulateEntries(); | ||
525 | 43 | return false; | ||
526 | 44 | }); | ||
528 | 45 | } | 42 | } |
529 | 46 | 43 | ||
530 | 47 | void DeviceLauncherSection::PopulateEntries() | 44 | void DeviceLauncherSection::PopulateEntries() |
531 | @@ -60,11 +57,11 @@ | |||
532 | 60 | if (map_.find(volume) != map_.end()) | 57 | if (map_.find(volume) != map_.end()) |
533 | 61 | return; | 58 | return; |
534 | 62 | 59 | ||
537 | 63 | VolumeLauncherIcon::Ptr icon(new VolumeLauncherIcon(std::make_shared<VolumeImp>(volume, file_manager_opener_, device_notification_display_), | 60 | auto vol = std::make_shared<VolumeImp>(volume, file_manager_opener_, device_notification_display_); |
538 | 64 | devices_settings_)); | 61 | VolumeLauncherIcon::Ptr icon(new VolumeLauncherIcon(vol, devices_settings_)); |
539 | 65 | 62 | ||
540 | 66 | map_[volume] = icon; | 63 | map_[volume] = icon; |
542 | 67 | IconAdded.emit(icon); | 64 | icon_added.emit(icon); |
543 | 68 | } | 65 | } |
544 | 69 | 66 | ||
545 | 70 | void DeviceLauncherSection::OnVolumeRemoved(glib::Object<GVolume> const& volume) | 67 | void DeviceLauncherSection::OnVolumeRemoved(glib::Object<GVolume> const& volume) |
546 | @@ -76,5 +73,15 @@ | |||
547 | 76 | map_.erase(volume_it); | 73 | map_.erase(volume_it); |
548 | 77 | } | 74 | } |
549 | 78 | 75 | ||
550 | 76 | std::vector<VolumeLauncherIcon::Ptr> DeviceLauncherSection::GetIcons() const | ||
551 | 77 | { | ||
552 | 78 | std::vector<VolumeLauncherIcon::Ptr> icons; | ||
553 | 79 | |||
554 | 80 | for (auto const& it : map_) | ||
555 | 81 | icons.push_back(it.second); | ||
556 | 82 | |||
557 | 83 | return icons; | ||
558 | 84 | } | ||
559 | 85 | |||
560 | 79 | } | 86 | } |
561 | 80 | } | 87 | } |
562 | 81 | 88 | ||
563 | === modified file 'launcher/DeviceLauncherSection.h' | |||
564 | --- launcher/DeviceLauncherSection.h 2012-08-22 09:03:25 +0000 | |||
565 | +++ launcher/DeviceLauncherSection.h 2012-09-18 15:52:46 +0000 | |||
566 | @@ -23,8 +23,6 @@ | |||
567 | 23 | #include <map> | 23 | #include <map> |
568 | 24 | #include <memory> | 24 | #include <memory> |
569 | 25 | 25 | ||
570 | 26 | #include <UnityCore/GLibSource.h> | ||
571 | 27 | |||
572 | 28 | #include "AbstractVolumeMonitorWrapper.h" | 26 | #include "AbstractVolumeMonitorWrapper.h" |
573 | 29 | #include "DevicesSettings.h" | 27 | #include "DevicesSettings.h" |
574 | 30 | #include "DeviceNotificationDisplay.h" | 28 | #include "DeviceNotificationDisplay.h" |
575 | @@ -42,7 +40,9 @@ | |||
576 | 42 | DeviceLauncherSection(AbstractVolumeMonitorWrapper::Ptr volume_monitor, | 40 | DeviceLauncherSection(AbstractVolumeMonitorWrapper::Ptr volume_monitor, |
577 | 43 | DevicesSettings::Ptr devices_settings); | 41 | DevicesSettings::Ptr devices_settings); |
578 | 44 | 42 | ||
580 | 45 | sigc::signal<void, AbstractLauncherIcon::Ptr> IconAdded; | 43 | std::vector<VolumeLauncherIcon::Ptr> GetIcons() const; |
581 | 44 | |||
582 | 45 | sigc::signal<void, AbstractLauncherIcon::Ptr> icon_added; | ||
583 | 46 | 46 | ||
584 | 47 | private: | 47 | private: |
585 | 48 | void PopulateEntries(); | 48 | void PopulateEntries(); |
586 | @@ -55,8 +55,6 @@ | |||
587 | 55 | DevicesSettings::Ptr devices_settings_; | 55 | DevicesSettings::Ptr devices_settings_; |
588 | 56 | FileManagerOpener::Ptr file_manager_opener_; | 56 | FileManagerOpener::Ptr file_manager_opener_; |
589 | 57 | DeviceNotificationDisplay::Ptr device_notification_display_; | 57 | DeviceNotificationDisplay::Ptr device_notification_display_; |
590 | 58 | |||
591 | 59 | glib::Idle device_populate_idle_; | ||
592 | 60 | }; | 58 | }; |
593 | 61 | 59 | ||
594 | 62 | } | 60 | } |
595 | 63 | 61 | ||
596 | === modified file 'launcher/DndData.cpp' | |||
597 | --- launcher/DndData.cpp 2012-07-09 14:11:06 +0000 | |||
598 | +++ launcher/DndData.cpp 2012-09-18 15:52:46 +0000 | |||
599 | @@ -27,12 +27,12 @@ | |||
600 | 27 | #include <UnityCore/GLibWrapper.h> | 27 | #include <UnityCore/GLibWrapper.h> |
601 | 28 | 28 | ||
602 | 29 | namespace unity { | 29 | namespace unity { |
606 | 30 | 30 | ||
607 | 31 | void DndData::Fill(char* uris) | 31 | void DndData::Fill(const char* uris) |
608 | 32 | { | 32 | { |
609 | 33 | Reset(); | 33 | Reset(); |
612 | 34 | 34 | ||
613 | 35 | char* pch = strtok (uris, "\r\n"); | 35 | const char* pch = strtok (const_cast<char*>(uris), "\r\n"); |
614 | 36 | while (pch) | 36 | while (pch) |
615 | 37 | { | 37 | { |
616 | 38 | glib::String content_type(g_content_type_guess(pch, | 38 | glib::String content_type(g_content_type_guess(pch, |
617 | 39 | 39 | ||
618 | === modified file 'launcher/DndData.h' | |||
619 | --- launcher/DndData.h 2012-05-07 19:52:54 +0000 | |||
620 | +++ launcher/DndData.h 2012-09-18 15:52:46 +0000 | |||
621 | @@ -32,7 +32,7 @@ | |||
622 | 32 | /** | 32 | /** |
623 | 33 | * Fills the object given a list of uris. | 33 | * Fills the object given a list of uris. |
624 | 34 | **/ | 34 | **/ |
626 | 35 | void Fill(char* uris); | 35 | void Fill(const char* uris); |
627 | 36 | 36 | ||
628 | 37 | /** | 37 | /** |
629 | 38 | * Resets the object. Call this function when no longer need data | 38 | * Resets the object. Call this function when no longer need data |
630 | 39 | 39 | ||
631 | === added file 'launcher/ExpoLauncherIcon.cpp' | |||
632 | --- launcher/ExpoLauncherIcon.cpp 1970-01-01 00:00:00 +0000 | |||
633 | +++ launcher/ExpoLauncherIcon.cpp 2012-09-18 15:52:46 +0000 | |||
634 | @@ -0,0 +1,64 @@ | |||
635 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
636 | 2 | /* | ||
637 | 3 | * Copyright (C) 2012 Canonical Ltd | ||
638 | 4 | * | ||
639 | 5 | * This program is free software: you can redistribute it and/or modify | ||
640 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
641 | 7 | * published by the Free Software Foundation. | ||
642 | 8 | * | ||
643 | 9 | * This program is distributed in the hope that it will be useful, | ||
644 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
645 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
646 | 12 | * GNU General Public License for more details. | ||
647 | 13 | * | ||
648 | 14 | * You should have received a copy of the GNU General Public License | ||
649 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
650 | 16 | * | ||
651 | 17 | * Authored by: Marco Trevisan <marco.trevisan@canonical.com> | ||
652 | 18 | */ | ||
653 | 19 | |||
654 | 20 | #include "ExpoLauncherIcon.h" | ||
655 | 21 | #include "unity-shared/WindowManager.h" | ||
656 | 22 | #include "FavoriteStore.h" | ||
657 | 23 | |||
658 | 24 | #include <glib/gi18n-lib.h> | ||
659 | 25 | |||
660 | 26 | namespace unity | ||
661 | 27 | { | ||
662 | 28 | namespace launcher | ||
663 | 29 | { | ||
664 | 30 | |||
665 | 31 | ExpoLauncherIcon::ExpoLauncherIcon() | ||
666 | 32 | : SimpleLauncherIcon(IconType::EXPO) | ||
667 | 33 | { | ||
668 | 34 | tooltip_text = _("Workspace Switcher"); | ||
669 | 35 | icon_name = "workspace-switcher"; | ||
670 | 36 | SetQuirk(Quirk::VISIBLE, false); | ||
671 | 37 | SetQuirk(Quirk::RUNNING, false); | ||
672 | 38 | SetShortcut('s'); | ||
673 | 39 | } | ||
674 | 40 | |||
675 | 41 | void ExpoLauncherIcon::ActivateLauncherIcon(ActionArg arg) | ||
676 | 42 | { | ||
677 | 43 | SimpleLauncherIcon::ActivateLauncherIcon(arg); | ||
678 | 44 | WindowManager::Default()->InitiateExpo(); | ||
679 | 45 | } | ||
680 | 46 | |||
681 | 47 | void ExpoLauncherIcon::Stick(bool save) | ||
682 | 48 | { | ||
683 | 49 | SimpleLauncherIcon::Stick(save); | ||
684 | 50 | SetQuirk(Quirk::VISIBLE, (WindowManager::Default()->WorkspaceCount() > 1)); | ||
685 | 51 | } | ||
686 | 52 | |||
687 | 53 | std::string ExpoLauncherIcon::GetName() const | ||
688 | 54 | { | ||
689 | 55 | return "ExpoLauncherIcon"; | ||
690 | 56 | } | ||
691 | 57 | |||
692 | 58 | std::string ExpoLauncherIcon::GetRemoteUri() | ||
693 | 59 | { | ||
694 | 60 | return FavoriteStore::URI_PREFIX_UNITY + "expo-icon"; | ||
695 | 61 | } | ||
696 | 62 | |||
697 | 63 | } // namespace launcher | ||
698 | 64 | } // namespace unity | ||
699 | 0 | 65 | ||
700 | === added file 'launcher/ExpoLauncherIcon.h' | |||
701 | --- launcher/ExpoLauncherIcon.h 1970-01-01 00:00:00 +0000 | |||
702 | +++ launcher/ExpoLauncherIcon.h 2012-09-18 15:52:46 +0000 | |||
703 | @@ -0,0 +1,45 @@ | |||
704 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
705 | 2 | /* | ||
706 | 3 | * Copyright (C) 2012 Canonical Ltd | ||
707 | 4 | * | ||
708 | 5 | * This program is free software: you can redistribute it and/or modify | ||
709 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
710 | 7 | * published by the Free Software Foundation. | ||
711 | 8 | * | ||
712 | 9 | * This program is distributed in the hope that it will be useful, | ||
713 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
714 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
715 | 12 | * GNU General Public License for more details. | ||
716 | 13 | * | ||
717 | 14 | * You should have received a copy of the GNU General Public License | ||
718 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
719 | 16 | * | ||
720 | 17 | * Authored by: Marco Trevisan <marco.trevisan@canonical.com> | ||
721 | 18 | */ | ||
722 | 19 | |||
723 | 20 | #ifndef EXPO_LAUNCHER_ICON_H | ||
724 | 21 | #define EXPO_LAUNCHER_ICON_H | ||
725 | 22 | |||
726 | 23 | #include "SimpleLauncherIcon.h" | ||
727 | 24 | |||
728 | 25 | namespace unity | ||
729 | 26 | { | ||
730 | 27 | namespace launcher | ||
731 | 28 | { | ||
732 | 29 | |||
733 | 30 | class ExpoLauncherIcon : public SimpleLauncherIcon | ||
734 | 31 | { | ||
735 | 32 | public: | ||
736 | 33 | ExpoLauncherIcon(); | ||
737 | 34 | void Stick(bool save); | ||
738 | 35 | |||
739 | 36 | protected: | ||
740 | 37 | void ActivateLauncherIcon(ActionArg arg); | ||
741 | 38 | std::string GetName() const; | ||
742 | 39 | std::string GetRemoteUri(); | ||
743 | 40 | }; | ||
744 | 41 | |||
745 | 42 | } | ||
746 | 43 | } | ||
747 | 44 | |||
748 | 45 | #endif // EXPO_LAUNCHER_ICON_H | ||
749 | 0 | 46 | ||
750 | === modified file 'launcher/FavoriteStore.cpp' | |||
751 | --- launcher/FavoriteStore.cpp 2012-05-07 19:52:54 +0000 | |||
752 | +++ launcher/FavoriteStore.cpp 2012-09-18 15:52:46 +0000 | |||
753 | @@ -1,6 +1,6 @@ | |||
754 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
755 | 2 | /* | 2 | /* |
757 | 3 | * Copyright (C) 2010 Canonical Ltd | 3 | * Copyright (C) 2010-2012 Canonical Ltd |
758 | 4 | * | 4 | * |
759 | 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 |
760 | 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 |
761 | @@ -15,19 +15,29 @@ | |||
762 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
763 | 16 | * | 16 | * |
764 | 17 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> | 17 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> |
765 | 18 | * Marco Trevisan <marco.trevisan@canonical.com> | ||
766 | 18 | */ | 19 | */ |
767 | 19 | 20 | ||
768 | 20 | #include <NuxCore/Logger.h> | 21 | #include <NuxCore/Logger.h> |
770 | 21 | #include "FavoriteStoreGSettings.h" | 22 | #include <glib.h> |
771 | 23 | |||
772 | 24 | #include "FavoriteStore.h" | ||
773 | 25 | #include "FavoriteStorePrivate.h" | ||
774 | 22 | 26 | ||
775 | 23 | namespace unity | 27 | namespace unity |
776 | 24 | { | 28 | { |
777 | 25 | namespace | 29 | namespace |
778 | 26 | { | 30 | { |
781 | 27 | nux::logging::Logger logger("unity.favouritestore"); | 31 | nux::logging::Logger logger("unity.favorite.store"); |
782 | 28 | FavoriteStore* favoritestore_instance = nullptr; | 32 | FavoriteStore* favoritestore_instance = nullptr; |
783 | 33 | const std::string PREFIX_SEPARATOR = "://"; | ||
784 | 29 | } | 34 | } |
785 | 30 | 35 | ||
786 | 36 | const std::string FavoriteStore::URI_PREFIX_APP = "application://"; | ||
787 | 37 | const std::string FavoriteStore::URI_PREFIX_FILE = "file://"; | ||
788 | 38 | const std::string FavoriteStore::URI_PREFIX_DEVICE = "device://"; | ||
789 | 39 | const std::string FavoriteStore::URI_PREFIX_UNITY = "unity://"; | ||
790 | 40 | |||
791 | 31 | FavoriteStore::FavoriteStore() | 41 | FavoriteStore::FavoriteStore() |
792 | 32 | { | 42 | { |
793 | 33 | if (favoritestore_instance) | 43 | if (favoritestore_instance) |
794 | @@ -56,4 +66,83 @@ | |||
795 | 56 | return *favoritestore_instance; | 66 | return *favoritestore_instance; |
796 | 57 | } | 67 | } |
797 | 58 | 68 | ||
798 | 69 | bool FavoriteStore::IsValidFavoriteUri(std::string const& uri) | ||
799 | 70 | { | ||
800 | 71 | if (uri.empty()) | ||
801 | 72 | return false; | ||
802 | 73 | |||
803 | 74 | if (uri.find(URI_PREFIX_APP) == 0 || uri.find(URI_PREFIX_FILE) == 0) | ||
804 | 75 | { | ||
805 | 76 | return internal::impl::IsDesktopFilePath(uri); | ||
806 | 77 | } | ||
807 | 78 | else if (uri.find(URI_PREFIX_DEVICE) == 0) | ||
808 | 79 | { | ||
809 | 80 | return uri.length() > URI_PREFIX_DEVICE.length(); | ||
810 | 81 | } | ||
811 | 82 | else if (uri.find(URI_PREFIX_UNITY) == 0) | ||
812 | 83 | { | ||
813 | 84 | return uri.length() > URI_PREFIX_UNITY.length(); | ||
814 | 85 | } | ||
815 | 86 | |||
816 | 87 | return false; | ||
817 | 88 | } | ||
818 | 89 | |||
819 | 90 | std::string FavoriteStore::ParseFavoriteFromUri(std::string const& uri) const | ||
820 | 91 | { | ||
821 | 92 | if (uri.empty()) | ||
822 | 93 | return ""; | ||
823 | 94 | |||
824 | 95 | std::string fav = uri; | ||
825 | 96 | auto prefix_pos = fav.find(PREFIX_SEPARATOR); | ||
826 | 97 | |||
827 | 98 | if (prefix_pos == std::string::npos) | ||
828 | 99 | { | ||
829 | 100 | // We assume that favorites with no prefix, but with a .desktop suffix are applications | ||
830 | 101 | if (internal::impl::IsDesktopFilePath(uri)) | ||
831 | 102 | { | ||
832 | 103 | fav = URI_PREFIX_APP + fav; | ||
833 | 104 | prefix_pos = URI_PREFIX_APP.length(); | ||
834 | 105 | } | ||
835 | 106 | } | ||
836 | 107 | else | ||
837 | 108 | { | ||
838 | 109 | prefix_pos += PREFIX_SEPARATOR.length(); | ||
839 | 110 | } | ||
840 | 111 | |||
841 | 112 | // Matches application://desktop-id.desktop or application:///path/to/file.desktop | ||
842 | 113 | if (fav.find(URI_PREFIX_APP) == 0 || fav.find(URI_PREFIX_FILE) == 0) | ||
843 | 114 | { | ||
844 | 115 | std::string const& fav_value = fav.substr(prefix_pos); | ||
845 | 116 | |||
846 | 117 | if (fav_value.empty()) | ||
847 | 118 | { | ||
848 | 119 | LOG_WARNING(logger) << "Unable to load Favorite for uri '" << fav << "'"; | ||
849 | 120 | return ""; | ||
850 | 121 | } | ||
851 | 122 | |||
852 | 123 | if (fav_value[0] == '/' || fav.find(URI_PREFIX_FILE) == 0) | ||
853 | 124 | { | ||
854 | 125 | if (g_file_test(fav_value.c_str(), G_FILE_TEST_EXISTS)) | ||
855 | 126 | { | ||
856 | 127 | return fav; | ||
857 | 128 | } | ||
858 | 129 | else | ||
859 | 130 | { | ||
860 | 131 | LOG_WARNING(logger) << "Unable to load desktop file: " << fav_value; | ||
861 | 132 | } | ||
862 | 133 | } | ||
863 | 134 | else | ||
864 | 135 | { | ||
865 | 136 | return URI_PREFIX_APP + fav_value; | ||
866 | 137 | } | ||
867 | 138 | } | ||
868 | 139 | else if (IsValidFavoriteUri(fav)) | ||
869 | 140 | { | ||
870 | 141 | return fav; | ||
871 | 142 | } | ||
872 | 143 | |||
873 | 144 | LOG_WARNING(logger) << "Unable to load Favorite for uri '" << fav << "'"; | ||
874 | 145 | return ""; | ||
875 | 146 | } | ||
876 | 147 | |||
877 | 59 | } | 148 | } |
878 | 60 | 149 | ||
879 | === modified file 'launcher/FavoriteStore.h' | |||
880 | --- launcher/FavoriteStore.h 2012-05-07 19:52:54 +0000 | |||
881 | +++ launcher/FavoriteStore.h 2012-09-18 15:52:46 +0000 | |||
882 | @@ -1,6 +1,6 @@ | |||
883 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
884 | 2 | /* | 2 | /* |
886 | 3 | * Copyright (C) 2010 Canonical Ltd | 3 | * Copyright (C) 2010-2012 Canonical Ltd |
887 | 4 | * | 4 | * |
888 | 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 |
889 | 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 |
890 | @@ -15,6 +15,7 @@ | |||
891 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
892 | 16 | * | 16 | * |
893 | 17 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> | 17 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> |
894 | 18 | * Marco Trevisan <marco.trevisan@canonical.com> | ||
895 | 18 | */ | 19 | */ |
896 | 19 | 20 | ||
897 | 20 | #ifndef UNITY_FAVORITE_STORE_H | 21 | #ifndef UNITY_FAVORITE_STORE_H |
898 | @@ -42,26 +43,38 @@ | |||
899 | 42 | 43 | ||
900 | 43 | static FavoriteStore& Instance(); | 44 | static FavoriteStore& Instance(); |
901 | 44 | 45 | ||
903 | 45 | virtual FavoriteList const& GetFavorites() = 0; | 46 | virtual FavoriteList const& GetFavorites() const = 0; |
904 | 46 | 47 | ||
905 | 47 | // These will NOT emit the relevant signals, so bare that in mind | 48 | // These will NOT emit the relevant signals, so bare that in mind |
906 | 48 | // i.e. don't hope that you can add stuff and hook the view up to | 49 | // i.e. don't hope that you can add stuff and hook the view up to |
907 | 49 | // favorite_added events to update the view. The signals only emit if | 50 | // favorite_added events to update the view. The signals only emit if |
908 | 50 | // there has been a change on the GSettings object from an external | 51 | // there has been a change on the GSettings object from an external |
909 | 51 | // source | 52 | // source |
914 | 52 | virtual void AddFavorite(std::string const& desktop_path, int position) = 0; | 53 | virtual void AddFavorite(std::string const& icon_uri, int position) = 0; |
915 | 53 | virtual void RemoveFavorite(std::string const& desktop_path) = 0; | 54 | virtual void RemoveFavorite(std::string const& icon_uri) = 0; |
916 | 54 | virtual void MoveFavorite(std::string const& desktop_path, int position) = 0; | 55 | virtual void MoveFavorite(std::string const& icon_uri, int position) = 0; |
917 | 55 | virtual void SetFavorites(FavoriteList const& desktop_paths) = 0; | 56 | virtual bool IsFavorite(std::string const& icon_uri) const = 0; |
918 | 57 | virtual int FavoritePosition(std::string const& icon_uri) const = 0; | ||
919 | 58 | virtual void SetFavorites(FavoriteList const& icon_uris) = 0; | ||
920 | 56 | 59 | ||
921 | 57 | // Signals | 60 | // Signals |
922 | 58 | // These only emit if something has changed the GSettings object externally | 61 | // These only emit if something has changed the GSettings object externally |
923 | 59 | 62 | ||
925 | 60 | //desktop_path, position, before/after | 63 | //icon_uri, position, before/after |
926 | 61 | sigc::signal<void, std::string const&, std::string const&, bool> favorite_added; | 64 | sigc::signal<void, std::string const&, std::string const&, bool> favorite_added; |
928 | 62 | //desktop_path | 65 | //icon_uri |
929 | 63 | sigc::signal<void, std::string const&> favorite_removed; | 66 | sigc::signal<void, std::string const&> favorite_removed; |
930 | 64 | sigc::signal<void> reordered; | 67 | sigc::signal<void> reordered; |
931 | 68 | |||
932 | 69 | static const std::string URI_PREFIX_APP; | ||
933 | 70 | static const std::string URI_PREFIX_FILE; | ||
934 | 71 | static const std::string URI_PREFIX_DEVICE; | ||
935 | 72 | static const std::string URI_PREFIX_UNITY; | ||
936 | 73 | |||
937 | 74 | static bool IsValidFavoriteUri(std::string const& uri); | ||
938 | 75 | |||
939 | 76 | protected: | ||
940 | 77 | std::string ParseFavoriteFromUri(std::string const& uri) const; | ||
941 | 65 | }; | 78 | }; |
942 | 66 | 79 | ||
943 | 67 | } | 80 | } |
944 | 68 | 81 | ||
945 | === modified file 'launcher/FavoriteStoreGSettings.cpp' | |||
946 | --- launcher/FavoriteStoreGSettings.cpp 2012-08-15 17:22:33 +0000 | |||
947 | +++ launcher/FavoriteStoreGSettings.cpp 2012-09-18 15:52:46 +0000 | |||
948 | @@ -1,6 +1,6 @@ | |||
949 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
950 | 2 | /* | 2 | /* |
952 | 3 | * Copyright (C) 2010 Canonical Ltd | 3 | * Copyright (C) 2010-2012 Canonical Ltd |
953 | 4 | * | 4 | * |
954 | 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 |
955 | 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 |
956 | @@ -15,9 +15,9 @@ | |||
957 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
958 | 16 | * | 16 | * |
959 | 17 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> | 17 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> |
960 | 18 | * Marco Trevisan <marco.trevisan@canonical.com> | ||
961 | 18 | */ | 19 | */ |
962 | 19 | 20 | ||
963 | 20 | #include <gio/gdesktopappinfo.h> | ||
964 | 21 | #include <NuxCore/Logger.h> | 21 | #include <NuxCore/Logger.h> |
965 | 22 | #include <UnityCore/DesktopUtilities.h> | 22 | #include <UnityCore/DesktopUtilities.h> |
966 | 23 | 23 | ||
967 | @@ -40,7 +40,7 @@ | |||
968 | 40 | 40 | ||
969 | 41 | namespace | 41 | namespace |
970 | 42 | { | 42 | { |
972 | 43 | nux::logging::Logger logger("unity.favorites"); | 43 | nux::logging::Logger logger("unity.favorite.store.gsettings"); |
973 | 44 | const std::string SETTINGS_NAME = "com.canonical.Unity.Launcher"; | 44 | const std::string SETTINGS_NAME = "com.canonical.Unity.Launcher"; |
974 | 45 | const std::string SETTINGS_KEY = "favorites"; | 45 | const std::string SETTINGS_KEY = "favorites"; |
975 | 46 | } | 46 | } |
976 | @@ -59,117 +59,89 @@ | |||
977 | 59 | 59 | ||
978 | 60 | void FavoriteStoreGSettings::Refresh() | 60 | void FavoriteStoreGSettings::Refresh() |
979 | 61 | { | 61 | { |
981 | 62 | FillList(favorites_); | 62 | FillList(); |
982 | 63 | } | 63 | } |
983 | 64 | 64 | ||
985 | 65 | void FavoriteStoreGSettings::FillList(FavoriteList& list) | 65 | void FavoriteStoreGSettings::FillList() |
986 | 66 | { | 66 | { |
992 | 67 | list.clear(); | 67 | favorites_.clear(); |
993 | 68 | 68 | std::shared_ptr<gchar*> favs(g_settings_get_strv(settings_, SETTINGS_KEY.c_str())); | |
994 | 69 | gchar** favs = g_settings_get_strv(settings_, SETTINGS_KEY.c_str()); | 69 | |
995 | 70 | 70 | for (int i = 0; favs.get()[i]; ++i) | |
991 | 71 | for (int i = 0; favs[i] != NULL; ++i) | ||
996 | 72 | { | 71 | { |
1016 | 73 | // We will be storing either full /path/to/desktop/files or foo.desktop id's | 72 | std::string const& fav = ParseFavoriteFromUri(favs.get()[i]); |
998 | 74 | if (favs[i][0] == '/') | ||
999 | 75 | { | ||
1000 | 76 | if (g_file_test(favs[i], G_FILE_TEST_EXISTS)) | ||
1001 | 77 | { | ||
1002 | 78 | list.push_back(favs[i]); | ||
1003 | 79 | } | ||
1004 | 80 | else | ||
1005 | 81 | { | ||
1006 | 82 | LOG_WARNING(logger) << "Unable to load desktop file: " | ||
1007 | 83 | << favs[i]; | ||
1008 | 84 | } | ||
1009 | 85 | } | ||
1010 | 86 | else | ||
1011 | 87 | { | ||
1012 | 88 | glib::Object<GDesktopAppInfo> info(g_desktop_app_info_new(favs[i])); | ||
1013 | 89 | const char* filename = 0; | ||
1014 | 90 | if (info) | ||
1015 | 91 | filename = g_desktop_app_info_get_filename(info); | ||
1017 | 92 | 73 | ||
1027 | 93 | if (filename) | 74 | if (!fav.empty()) |
1028 | 94 | { | 75 | favorites_.push_back(fav); |
1020 | 95 | list.push_back(filename); | ||
1021 | 96 | } | ||
1022 | 97 | else | ||
1023 | 98 | { | ||
1024 | 99 | LOG_WARNING(logger) << "Unable to load GDesktopAppInfo for '" << favs[i] << "'"; | ||
1025 | 100 | } | ||
1026 | 101 | } | ||
1029 | 102 | } | 76 | } |
1030 | 103 | |||
1031 | 104 | g_strfreev(favs); | ||
1032 | 105 | } | 77 | } |
1033 | 106 | 78 | ||
1035 | 107 | FavoriteList const& FavoriteStoreGSettings::GetFavorites() | 79 | FavoriteList const& FavoriteStoreGSettings::GetFavorites() const |
1036 | 108 | { | 80 | { |
1037 | 109 | return favorites_; | 81 | return favorites_; |
1038 | 110 | } | 82 | } |
1039 | 111 | 83 | ||
1041 | 112 | void FavoriteStoreGSettings::AddFavorite(std::string const& desktop_path, int position) | 84 | void FavoriteStoreGSettings::AddFavorite(std::string const& icon_uri, int position) |
1042 | 113 | { | 85 | { |
1045 | 114 | int size = favorites_.size(); | 86 | std::string const& fav = ParseFavoriteFromUri(icon_uri); |
1046 | 115 | if (desktop_path.empty() || position > size) | 87 | |
1047 | 88 | if (fav.empty() || position > static_cast<int>(favorites_.size())) | ||
1048 | 116 | return; | 89 | return; |
1049 | 117 | 90 | ||
1050 | 118 | if (position < 0) | 91 | if (position < 0) |
1051 | 119 | { | 92 | { |
1052 | 120 | // It goes on the end. | 93 | // It goes on the end. |
1054 | 121 | favorites_.push_back(desktop_path); | 94 | favorites_.push_back(fav); |
1055 | 122 | } | 95 | } |
1056 | 123 | else | 96 | else |
1057 | 124 | { | 97 | { |
1058 | 125 | FavoriteList::iterator pos = favorites_.begin(); | 98 | FavoriteList::iterator pos = favorites_.begin(); |
1059 | 126 | std::advance(pos, position); | 99 | std::advance(pos, position); |
1061 | 127 | favorites_.insert(pos, desktop_path); | 100 | favorites_.insert(pos, fav); |
1062 | 128 | } | 101 | } |
1063 | 129 | 102 | ||
1064 | 130 | SaveFavorites(favorites_); | 103 | SaveFavorites(favorites_); |
1065 | 131 | Refresh(); | 104 | Refresh(); |
1066 | 132 | } | 105 | } |
1067 | 133 | 106 | ||
1069 | 134 | void FavoriteStoreGSettings::RemoveFavorite(std::string const& desktop_path) | 107 | void FavoriteStoreGSettings::RemoveFavorite(std::string const& icon_uri) |
1070 | 135 | { | 108 | { |
1072 | 136 | if (desktop_path.empty() || desktop_path[0] != '/') | 109 | std::string const& fav = ParseFavoriteFromUri(icon_uri); |
1073 | 110 | |||
1074 | 111 | if (fav.empty()) | ||
1075 | 137 | return; | 112 | return; |
1076 | 138 | 113 | ||
1078 | 139 | FavoriteList::iterator pos = std::find(favorites_.begin(), favorites_.end(), desktop_path); | 114 | FavoriteList::iterator pos = std::find(favorites_.begin(), favorites_.end(), fav); |
1079 | 140 | if (pos == favorites_.end()) | 115 | if (pos == favorites_.end()) |
1080 | 141 | { | ||
1081 | 142 | return; | 116 | return; |
1082 | 143 | } | ||
1083 | 144 | 117 | ||
1084 | 145 | favorites_.erase(pos); | 118 | favorites_.erase(pos); |
1085 | 146 | SaveFavorites(favorites_); | 119 | SaveFavorites(favorites_); |
1086 | 147 | Refresh(); | 120 | Refresh(); |
1087 | 148 | } | 121 | } |
1088 | 149 | 122 | ||
1090 | 150 | void FavoriteStoreGSettings::MoveFavorite(std::string const& desktop_path, int position) | 123 | void FavoriteStoreGSettings::MoveFavorite(std::string const& icon_uri, int position) |
1091 | 151 | { | 124 | { |
1094 | 152 | int size = favorites_.size(); | 125 | std::string const& fav = ParseFavoriteFromUri(icon_uri); |
1095 | 153 | if (desktop_path.empty() || position > size) | 126 | |
1096 | 127 | if (fav.empty() || position > static_cast<int>(favorites_.size())) | ||
1097 | 154 | return; | 128 | return; |
1098 | 155 | 129 | ||
1100 | 156 | FavoriteList::iterator pos = std::find(favorites_.begin(), favorites_.end(), desktop_path); | 130 | FavoriteList::iterator pos = std::find(favorites_.begin(), favorites_.end(), fav); |
1101 | 157 | if (pos == favorites_.end()) | 131 | if (pos == favorites_.end()) |
1102 | 158 | { | ||
1103 | 159 | return; | 132 | return; |
1104 | 160 | } | ||
1105 | 161 | 133 | ||
1106 | 162 | favorites_.erase(pos); | 134 | favorites_.erase(pos); |
1107 | 163 | if (position < 0) | 135 | if (position < 0) |
1108 | 164 | { | 136 | { |
1109 | 165 | // It goes on the end. | 137 | // It goes on the end. |
1111 | 166 | favorites_.push_back(desktop_path); | 138 | favorites_.push_back(fav); |
1112 | 167 | } | 139 | } |
1113 | 168 | else | 140 | else |
1114 | 169 | { | 141 | { |
1115 | 170 | FavoriteList::iterator insert_pos = favorites_.begin(); | 142 | FavoriteList::iterator insert_pos = favorites_.begin(); |
1116 | 171 | std::advance(insert_pos, position); | 143 | std::advance(insert_pos, position); |
1118 | 172 | favorites_.insert(insert_pos, desktop_path); | 144 | favorites_.insert(insert_pos, fav); |
1119 | 173 | } | 145 | } |
1120 | 174 | 146 | ||
1121 | 175 | SaveFavorites(favorites_); | 147 | SaveFavorites(favorites_); |
1122 | @@ -186,26 +158,34 @@ | |||
1123 | 186 | { | 158 | { |
1124 | 187 | const int size = favorites.size(); | 159 | const int size = favorites.size(); |
1125 | 188 | const char* favs[size + 1]; | 160 | const char* favs[size + 1]; |
1126 | 189 | favs[size] = NULL; | ||
1127 | 190 | 161 | ||
1128 | 191 | int index = 0; | ||
1129 | 192 | // Since we don't always save the full path, we store the values we are | 162 | // Since we don't always save the full path, we store the values we are |
1130 | 193 | // actually going to save in a different list. | 163 | // actually going to save in a different list. |
1131 | 194 | auto system_dirs = DesktopUtilities::GetDataDirectories(); | ||
1132 | 195 | FavoriteList values; | 164 | FavoriteList values; |
1135 | 196 | for (FavoriteList::const_iterator i = favorites.begin(), end = favorites.end(); | 165 | int index = 0; |
1136 | 197 | i != end; ++i, ++index) | 166 | |
1137 | 167 | for (auto const& fav_uri : favorites) | ||
1138 | 198 | { | 168 | { |
1139 | 169 | std::string const& fav = ParseFavoriteFromUri(fav_uri); | ||
1140 | 170 | if (fav.empty()) | ||
1141 | 171 | { | ||
1142 | 172 | LOG_WARNING(logger) << "Impossible to add favorite '" << fav_uri << "' to store"; | ||
1143 | 173 | continue; | ||
1144 | 174 | } | ||
1145 | 175 | |||
1146 | 199 | // By using insert we get the iterator to the newly inserted string value. | 176 | // By using insert we get the iterator to the newly inserted string value. |
1147 | 200 | // That way we can use the c_str() method to access the const char* for | 177 | // That way we can use the c_str() method to access the const char* for |
1148 | 201 | // the string that we are going to save. This way we know that the pointer | 178 | // the string that we are going to save. This way we know that the pointer |
1149 | 202 | // is valid for the lifetime of the favs array usage in the method call to | 179 | // is valid for the lifetime of the favs array usage in the method call to |
1150 | 203 | // set the settings, and that we aren't referencing a temporary. | 180 | // set the settings, and that we aren't referencing a temporary. |
1153 | 204 | std::string const& desktop_id = DesktopUtilities::GetDesktopID(system_dirs, *i); | 181 | FavoriteList::iterator iter = values.insert(values.end(), fav); |
1152 | 205 | FavoriteList::iterator iter = values.insert(values.end(), desktop_id); | ||
1154 | 206 | favs[index] = iter->c_str(); | 182 | favs[index] = iter->c_str(); |
1155 | 183 | ++index; | ||
1156 | 207 | } | 184 | } |
1157 | 208 | 185 | ||
1158 | 186 | for (int i = index; i <= size; ++i) | ||
1159 | 187 | favs[i] = nullptr; | ||
1160 | 188 | |||
1161 | 209 | ignore_signals_ = ignore; | 189 | ignore_signals_ = ignore; |
1162 | 210 | if (!g_settings_set_strv(settings_, SETTINGS_KEY.c_str(), favs)) | 190 | if (!g_settings_set_strv(settings_, SETTINGS_KEY.c_str(), favs)) |
1163 | 211 | { | 191 | { |
1164 | @@ -220,7 +200,7 @@ | |||
1165 | 220 | return; | 200 | return; |
1166 | 221 | 201 | ||
1167 | 222 | FavoriteList old(favorites_); | 202 | FavoriteList old(favorites_); |
1169 | 223 | FillList(favorites_); | 203 | FillList(); |
1170 | 224 | 204 | ||
1171 | 225 | auto newbies = impl::GetNewbies(old, favorites_); | 205 | auto newbies = impl::GetNewbies(old, favorites_); |
1172 | 226 | 206 | ||
1173 | @@ -243,7 +223,26 @@ | |||
1174 | 243 | 223 | ||
1175 | 244 | if (impl::NeedToBeReordered(old, favorites_)) | 224 | if (impl::NeedToBeReordered(old, favorites_)) |
1176 | 245 | reordered.emit(); | 225 | reordered.emit(); |
1178 | 246 | 226 | } | |
1179 | 227 | |||
1180 | 228 | bool FavoriteStoreGSettings::IsFavorite(std::string const& icon_uri) const | ||
1181 | 229 | { | ||
1182 | 230 | return std::find(favorites_.begin(), favorites_.end(), icon_uri) != favorites_.end(); | ||
1183 | 231 | } | ||
1184 | 232 | |||
1185 | 233 | int FavoriteStoreGSettings::FavoritePosition(std::string const& icon_uri) const | ||
1186 | 234 | { | ||
1187 | 235 | int index = 0; | ||
1188 | 236 | |||
1189 | 237 | for (auto const& fav : favorites_) | ||
1190 | 238 | { | ||
1191 | 239 | if (fav == icon_uri) | ||
1192 | 240 | return index; | ||
1193 | 241 | |||
1194 | 242 | ++index; | ||
1195 | 243 | } | ||
1196 | 244 | |||
1197 | 245 | return -1; | ||
1198 | 247 | } | 246 | } |
1199 | 248 | 247 | ||
1200 | 249 | } // namespace internal | 248 | } // namespace internal |
1201 | 250 | 249 | ||
1202 | === modified file 'launcher/FavoriteStoreGSettings.h' | |||
1203 | --- launcher/FavoriteStoreGSettings.h 2012-08-01 18:12:10 +0000 | |||
1204 | +++ launcher/FavoriteStoreGSettings.h 2012-09-18 15:52:46 +0000 | |||
1205 | @@ -1,6 +1,6 @@ | |||
1206 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
1207 | 2 | /* | 2 | /* |
1209 | 3 | * Copyright (C) 2010 Canonical Ltd | 3 | * Copyright (C) 2010-2012 Canonical Ltd |
1210 | 4 | * | 4 | * |
1211 | 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 |
1212 | 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 |
1213 | @@ -15,6 +15,7 @@ | |||
1214 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1215 | 16 | * | 16 | * |
1216 | 17 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> | 17 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> |
1217 | 18 | * Marco Trevisan <marco.trevisan@canonical.com> | ||
1218 | 18 | */ | 19 | */ |
1219 | 19 | 20 | ||
1220 | 20 | #ifndef FAVORITE_STORE_GSETTINGS_H | 21 | #ifndef FAVORITE_STORE_GSETTINGS_H |
1221 | @@ -38,17 +39,19 @@ | |||
1222 | 38 | public: | 39 | public: |
1223 | 39 | FavoriteStoreGSettings(); | 40 | FavoriteStoreGSettings(); |
1224 | 40 | 41 | ||
1226 | 41 | virtual FavoriteList const& GetFavorites(); | 42 | virtual FavoriteList const& GetFavorites() const; |
1227 | 42 | virtual void AddFavorite(std::string const& desktop_path, int position); | 43 | virtual void AddFavorite(std::string const& desktop_path, int position); |
1228 | 43 | virtual void RemoveFavorite(std::string const& desktop_path); | 44 | virtual void RemoveFavorite(std::string const& desktop_path); |
1229 | 44 | virtual void MoveFavorite(std::string const& desktop_path, int position); | 45 | virtual void MoveFavorite(std::string const& desktop_path, int position); |
1230 | 46 | virtual bool IsFavorite(std::string const& icon_uri) const; | ||
1231 | 47 | virtual int FavoritePosition(std::string const& icon_uri) const; | ||
1232 | 48 | virtual void SetFavorites(FavoriteList const& desktop_paths); | ||
1233 | 45 | void SaveFavorites(FavoriteList const& favorites, bool ignore = true); | 49 | void SaveFavorites(FavoriteList const& favorites, bool ignore = true); |
1234 | 46 | virtual void SetFavorites(FavoriteList const& desktop_paths); | ||
1235 | 47 | 50 | ||
1236 | 48 | private: | 51 | private: |
1237 | 49 | void Refresh(); | 52 | void Refresh(); |
1238 | 50 | void Changed(); | 53 | void Changed(); |
1240 | 51 | void FillList(FavoriteList& list); | 54 | void FillList(); |
1241 | 52 | 55 | ||
1242 | 53 | FavoriteList favorites_; | 56 | FavoriteList favorites_; |
1243 | 54 | bool ignore_signals_; | 57 | bool ignore_signals_; |
1244 | 55 | 58 | ||
1245 | === modified file 'launcher/FavoriteStorePrivate.cpp' | |||
1246 | --- launcher/FavoriteStorePrivate.cpp 2012-05-07 19:52:54 +0000 | |||
1247 | +++ launcher/FavoriteStorePrivate.cpp 2012-09-18 15:52:46 +0000 | |||
1248 | @@ -124,6 +124,20 @@ | |||
1249 | 124 | return false; | 124 | return false; |
1250 | 125 | } | 125 | } |
1251 | 126 | 126 | ||
1252 | 127 | bool IsDesktopFilePath(std::string const& path) | ||
1253 | 128 | { | ||
1254 | 129 | static const std::string desktop_ext = ".desktop"; | ||
1255 | 130 | auto path_len = path.length(); | ||
1256 | 131 | auto desktop_length = desktop_ext.length(); | ||
1257 | 132 | |||
1258 | 133 | if (path_len > desktop_length) | ||
1259 | 134 | { | ||
1260 | 135 | return path.compare(path_len - desktop_length, desktop_length, desktop_ext) == 0; | ||
1261 | 136 | } | ||
1262 | 137 | |||
1263 | 138 | return false; | ||
1264 | 139 | } | ||
1265 | 140 | |||
1266 | 127 | 141 | ||
1267 | 128 | } // namespace impl | 142 | } // namespace impl |
1268 | 129 | } // namespace internal | 143 | } // namespace internal |
1269 | 130 | 144 | ||
1270 | === modified file 'launcher/FavoriteStorePrivate.h' | |||
1271 | --- launcher/FavoriteStorePrivate.h 2012-05-07 19:52:54 +0000 | |||
1272 | +++ launcher/FavoriteStorePrivate.h 2012-09-18 15:52:46 +0000 | |||
1273 | @@ -32,13 +32,15 @@ | |||
1274 | 32 | 32 | ||
1275 | 33 | std::vector<std::string> GetNewbies(std::list<std::string> const& old, std::list<std::string> const& fresh); | 33 | std::vector<std::string> GetNewbies(std::list<std::string> const& old, std::list<std::string> const& fresh); |
1276 | 34 | 34 | ||
1278 | 35 | void GetSignalAddedInfo(std::list<std::string> const& favs, std::vector<std::string> const& newbies, | 35 | void GetSignalAddedInfo(std::list<std::string> const& favs, std::vector<std::string> const& newbies, |
1279 | 36 | std::string const& path, std::string& position, bool& before); | 36 | std::string const& path, std::string& position, bool& before); |
1280 | 37 | 37 | ||
1281 | 38 | std::vector<std::string> GetRemoved(std::list<std::string> const& old, std::list<std::string> const& fresh); | 38 | std::vector<std::string> GetRemoved(std::list<std::string> const& old, std::list<std::string> const& fresh); |
1282 | 39 | 39 | ||
1283 | 40 | bool NeedToBeReordered(std::list<std::string> const& old, std::list<std::string> const& fresh); | 40 | bool NeedToBeReordered(std::list<std::string> const& old, std::list<std::string> const& fresh); |
1284 | 41 | 41 | ||
1285 | 42 | bool IsDesktopFilePath(std::string const& path); | ||
1286 | 43 | |||
1287 | 42 | 44 | ||
1288 | 43 | } // namespace impl | 45 | } // namespace impl |
1289 | 44 | } // namespace internal | 46 | } // namespace internal |
1290 | 45 | 47 | ||
1291 | === modified file 'launcher/HudLauncherIcon.cpp' | |||
1292 | --- launcher/HudLauncherIcon.cpp 2012-08-22 08:17:33 +0000 | |||
1293 | +++ launcher/HudLauncherIcon.cpp 2012-09-18 15:52:46 +0000 | |||
1294 | @@ -45,6 +45,7 @@ | |||
1295 | 45 | { | 45 | { |
1296 | 46 | tooltip_text = _("HUD"); | 46 | tooltip_text = _("HUD"); |
1297 | 47 | icon_name = PKGDATADIR"/launcher_bfb.png"; | 47 | icon_name = PKGDATADIR"/launcher_bfb.png"; |
1298 | 48 | position = Position::BEGIN; | ||
1299 | 48 | SetQuirk(Quirk::VISIBLE, false); | 49 | SetQuirk(Quirk::VISIBLE, false); |
1300 | 49 | SetQuirk(Quirk::RUNNING, false); | 50 | SetQuirk(Quirk::RUNNING, false); |
1301 | 50 | SetQuirk(Quirk::ACTIVE, true); | 51 | SetQuirk(Quirk::ACTIVE, true); |
1302 | @@ -121,7 +122,7 @@ | |||
1303 | 121 | 122 | ||
1304 | 122 | void HudLauncherIcon::ActivateLauncherIcon(ActionArg arg) | 123 | void HudLauncherIcon::ActivateLauncherIcon(ActionArg arg) |
1305 | 123 | { | 124 | { |
1307 | 124 | if (GetQuirk(Quirk::VISIBLE)) | 125 | if (IsVisible()) |
1308 | 125 | { | 126 | { |
1309 | 126 | ubus_manager_.SendMessage(UBUS_HUD_CLOSE_REQUEST); | 127 | ubus_manager_.SendMessage(UBUS_HUD_CLOSE_REQUEST); |
1310 | 127 | } | 128 | } |
1311 | 128 | 129 | ||
1312 | === modified file 'launcher/Launcher.cpp' | |||
1313 | --- launcher/Launcher.cpp 2012-09-04 15:56:50 +0000 | |||
1314 | +++ launcher/Launcher.cpp 2012-09-18 15:52:46 +0000 | |||
1315 | @@ -54,6 +54,7 @@ | |||
1316 | 54 | #include <UnityCore/GLibWrapper.h> | 54 | #include <UnityCore/GLibWrapper.h> |
1317 | 55 | #include <UnityCore/Variant.h> | 55 | #include <UnityCore/Variant.h> |
1318 | 56 | 56 | ||
1319 | 57 | #include <boost/algorithm/string.hpp> | ||
1320 | 57 | #include <sigc++/sigc++.h> | 58 | #include <sigc++/sigc++.h> |
1321 | 58 | 59 | ||
1322 | 59 | namespace unity | 60 | namespace unity |
1323 | @@ -106,6 +107,7 @@ | |||
1324 | 106 | nux::ObjectPtr<DNDCollectionWindow> const& collection_window, | 107 | nux::ObjectPtr<DNDCollectionWindow> const& collection_window, |
1325 | 107 | NUX_FILE_LINE_DECL) | 108 | NUX_FILE_LINE_DECL) |
1326 | 108 | : View(NUX_FILE_LINE_PARAM) | 109 | : View(NUX_FILE_LINE_PARAM) |
1327 | 110 | , display(nux::GetGraphicsDisplay()->GetX11Display()) | ||
1328 | 109 | , monitor(0) | 111 | , monitor(0) |
1329 | 110 | , _parent(parent) | 112 | , _parent(parent) |
1330 | 111 | , _active_quicklist(nullptr) | 113 | , _active_quicklist(nullptr) |
1331 | @@ -116,6 +118,7 @@ | |||
1332 | 116 | , _data_checked(false) | 118 | , _data_checked(false) |
1333 | 117 | , _steal_drag(false) | 119 | , _steal_drag(false) |
1334 | 118 | , _drag_edge_touching(false) | 120 | , _drag_edge_touching(false) |
1335 | 121 | , _initial_drag_animation(false) | ||
1336 | 119 | , _dash_is_open(false) | 122 | , _dash_is_open(false) |
1337 | 120 | , _hud_is_open(false) | 123 | , _hud_is_open(false) |
1338 | 121 | , _folded_angle(1.0f) | 124 | , _folded_angle(1.0f) |
1339 | @@ -462,9 +465,8 @@ | |||
1340 | 462 | return true; | 465 | return true; |
1341 | 463 | 466 | ||
1342 | 464 | // animations happening on specific icons | 467 | // animations happening on specific icons |
1346 | 465 | LauncherModel::iterator it; | 468 | for (auto const &icon : *_model) |
1347 | 466 | for (it = _model->begin(); it != _model->end(); ++it) | 469 | if (IconNeedsAnimation(icon, current)) |
1345 | 467 | if (IconNeedsAnimation(*it, current)) | ||
1348 | 468 | return true; | 470 | return true; |
1349 | 469 | 471 | ||
1350 | 470 | return false; | 472 | return false; |
1351 | @@ -495,10 +497,10 @@ | |||
1352 | 495 | 497 | ||
1353 | 496 | if (icon->GetIconType() == AbstractLauncherIcon::IconType::HUD) | 498 | if (icon->GetIconType() == AbstractLauncherIcon::IconType::HUD) |
1354 | 497 | { | 499 | { |
1356 | 498 | return (icon->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE)) ? 1.0f : 0.0f; | 500 | return icon->IsVisible() ? 1.0f : 0.0f; |
1357 | 499 | } | 501 | } |
1358 | 500 | 502 | ||
1360 | 501 | if (icon->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE)) | 503 | if (icon->IsVisible()) |
1361 | 502 | { | 504 | { |
1362 | 503 | struct timespec icon_visible_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::VISIBLE); | 505 | struct timespec icon_visible_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::VISIBLE); |
1363 | 504 | int enter_ms = unity::TimeUtil::TimeDelta(¤t, &icon_visible_time); | 506 | int enter_ms = unity::TimeUtil::TimeDelta(¤t, &icon_visible_time); |
1364 | @@ -891,8 +893,11 @@ | |||
1365 | 891 | 893 | ||
1366 | 892 | if (GetActionState() == ACTION_DRAG_ICON || | 894 | if (GetActionState() == ACTION_DRAG_ICON || |
1367 | 893 | (_drag_window && _drag_window->Animating()) || | 895 | (_drag_window && _drag_window->Animating()) || |
1369 | 894 | icon->IsSpacer()) | 896 | icon->GetIconType() == AbstractLauncherIcon::IconType::SPACER) |
1370 | 897 | { | ||
1371 | 895 | arg.skip = true; | 898 | arg.skip = true; |
1372 | 899 | } | ||
1373 | 900 | |||
1374 | 896 | size_modifier *= DragThresholdProgress(current); | 901 | size_modifier *= DragThresholdProgress(current); |
1375 | 897 | } | 902 | } |
1376 | 898 | 903 | ||
1377 | @@ -932,11 +937,12 @@ | |||
1378 | 932 | 937 | ||
1379 | 933 | icon->SetCenter(nux::Point3(roundf(center.x), roundf(center.y), roundf(center.z)), monitor, parent_abs_geo); | 938 | icon->SetCenter(nux::Point3(roundf(center.x), roundf(center.y), roundf(center.z)), monitor, parent_abs_geo); |
1380 | 934 | 939 | ||
1383 | 935 | // FIXME: this is a hack, we should have a look why SetAnimationTarget is necessary in SetAnimationTarget | 940 | // FIXME: this is a hack, to avoid that we set the target to the end of the icon |
1382 | 936 | // we should ideally just need it at start to set the target | ||
1384 | 937 | if (!_initial_drag_animation && icon == _drag_icon && _drag_window && _drag_window->Animating()) | 941 | if (!_initial_drag_animation && icon == _drag_icon && _drag_window && _drag_window->Animating()) |
1387 | 938 | _drag_window->SetAnimationTarget(static_cast<int>(_drag_icon->GetCenter(monitor).x), | 942 | { |
1388 | 939 | static_cast<int>(_drag_icon->GetCenter(monitor).y)); | 943 | auto const& icon_center = _drag_icon->GetCenter(monitor); |
1389 | 944 | _drag_window->SetAnimationTarget(icon_center.x, icon_center.y); | ||
1390 | 945 | } | ||
1391 | 940 | 946 | ||
1392 | 941 | center.y += (half_size * size_modifier) + spacing; // move to end | 947 | center.y += (half_size * size_modifier) + spacing; // move to end |
1393 | 942 | } | 948 | } |
1394 | @@ -953,10 +959,10 @@ | |||
1395 | 953 | nux::Color FullySaturateColor (nux::Color color) | 959 | nux::Color FullySaturateColor (nux::Color color) |
1396 | 954 | { | 960 | { |
1397 | 955 | float max = std::max<float>(color.red, std::max<float>(color.green, color.blue)); | 961 | float max = std::max<float>(color.red, std::max<float>(color.green, color.blue)); |
1398 | 962 | |||
1399 | 956 | if (max > 0.0f) | 963 | if (max > 0.0f) |
1400 | 957 | { | ||
1401 | 958 | color = color * (1.0f / max); | 964 | color = color * (1.0f / max); |
1403 | 959 | } | 965 | |
1404 | 960 | return color; | 966 | return color; |
1405 | 961 | } | 967 | } |
1406 | 962 | 968 | ||
1407 | @@ -1396,8 +1402,8 @@ | |||
1408 | 1396 | 1402 | ||
1409 | 1397 | void Launcher::OnPluginStateChanged() | 1403 | void Launcher::OnPluginStateChanged() |
1410 | 1398 | { | 1404 | { |
1413 | 1399 | _hide_machine.SetQuirk (LauncherHideMachine::EXPO_ACTIVE, WindowManager::Default ()->IsExpoActive ()); | 1405 | _hide_machine.SetQuirk(LauncherHideMachine::EXPO_ACTIVE, WindowManager::Default()->IsExpoActive()); |
1414 | 1400 | _hide_machine.SetQuirk (LauncherHideMachine::SCALE_ACTIVE, WindowManager::Default ()->IsScaleActive ()); | 1406 | _hide_machine.SetQuirk(LauncherHideMachine::SCALE_ACTIVE, WindowManager::Default()->IsScaleActive()); |
1415 | 1401 | } | 1407 | } |
1416 | 1402 | 1408 | ||
1417 | 1403 | LauncherHideMode Launcher::GetHideMode() const | 1409 | LauncherHideMode Launcher::GetHideMode() const |
1418 | @@ -1669,11 +1675,6 @@ | |||
1419 | 1669 | return _model; | 1675 | return _model; |
1420 | 1670 | } | 1676 | } |
1421 | 1671 | 1677 | ||
1422 | 1672 | void Launcher::SetDevicesSettings(DevicesSettings::Ptr devices_settings) | ||
1423 | 1673 | { | ||
1424 | 1674 | devices_settings_ = devices_settings; | ||
1425 | 1675 | } | ||
1426 | 1676 | |||
1427 | 1677 | void Launcher::EnsureIconOnScreen(AbstractLauncherIcon::Ptr selection) | 1678 | void Launcher::EnsureIconOnScreen(AbstractLauncherIcon::Ptr selection) |
1428 | 1678 | { | 1679 | { |
1429 | 1679 | nux::Geometry const& geo = GetGeometry(); | 1680 | nux::Geometry const& geo = GetGeometry(); |
1430 | @@ -1681,7 +1682,7 @@ | |||
1431 | 1681 | int natural_y = 0; | 1682 | int natural_y = 0; |
1432 | 1682 | for (auto icon : *_model) | 1683 | for (auto icon : *_model) |
1433 | 1683 | { | 1684 | { |
1435 | 1684 | if (!icon->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE) || !icon->IsVisibleOnMonitor(monitor)) | 1685 | if (!icon->IsVisible() || !icon->IsVisibleOnMonitor(monitor)) |
1436 | 1685 | continue; | 1686 | continue; |
1437 | 1686 | 1687 | ||
1438 | 1687 | if (icon == selection) | 1688 | if (icon == selection) |
1439 | @@ -1953,7 +1954,7 @@ | |||
1440 | 1953 | EnsureAnimation(); | 1954 | EnsureAnimation(); |
1441 | 1954 | } | 1955 | } |
1442 | 1955 | 1956 | ||
1444 | 1956 | bool Launcher::StartIconDragTimeout() | 1957 | bool Launcher::StartIconDragTimeout(int x, int y) |
1445 | 1957 | { | 1958 | { |
1446 | 1958 | // if we are still waiting… | 1959 | // if we are still waiting… |
1447 | 1959 | if (GetActionState() == ACTION_NONE) | 1960 | if (GetActionState() == ACTION_NONE) |
1448 | @@ -1964,7 +1965,7 @@ | |||
1449 | 1964 | _icon_under_mouse = nullptr; | 1965 | _icon_under_mouse = nullptr; |
1450 | 1965 | } | 1966 | } |
1451 | 1966 | _initial_drag_animation = true; | 1967 | _initial_drag_animation = true; |
1453 | 1967 | StartIconDragRequest(GetMouseX(), GetMouseY()); | 1968 | StartIconDragRequest(x, y); |
1454 | 1968 | } | 1969 | } |
1455 | 1969 | 1970 | ||
1456 | 1970 | return false; | 1971 | return false; |
1457 | @@ -1972,26 +1973,27 @@ | |||
1458 | 1972 | 1973 | ||
1459 | 1973 | void Launcher::StartIconDragRequest(int x, int y) | 1974 | void Launcher::StartIconDragRequest(int x, int y) |
1460 | 1974 | { | 1975 | { |
1467 | 1975 | nux::Geometry geo = GetAbsoluteGeometry(); | 1976 | nux::Geometry const& abs_geo = GetAbsoluteGeometry(); |
1468 | 1976 | AbstractLauncherIcon::Ptr drag_icon = MouseIconIntersection((int)(GetGeometry().width / 2.0f), y); | 1977 | AbstractLauncherIcon::Ptr drag_icon = MouseIconIntersection(abs_geo.width / 2.0f, y); |
1463 | 1977 | |||
1464 | 1978 | x += geo.x; | ||
1465 | 1979 | y += geo.y; | ||
1466 | 1980 | |||
1469 | 1981 | 1978 | ||
1470 | 1982 | // FIXME: nux doesn't give nux::GetEventButton (button_flags) there, relying | 1979 | // FIXME: nux doesn't give nux::GetEventButton (button_flags) there, relying |
1471 | 1983 | // on an internal Launcher property then | 1980 | // on an internal Launcher property then |
1474 | 1984 | bool can_drag = (_model->IconHasSister(drag_icon) || drag_icon->GetIconType() == AbstractLauncherIcon::IconType::DEVICE); | 1981 | if (drag_icon && _last_button_press == 1 && drag_icon->position() == AbstractLauncherIcon::Position::FLOATING) |
1473 | 1985 | if (drag_icon && _last_button_press == 1 && can_drag) | ||
1475 | 1986 | { | 1982 | { |
1476 | 1983 | auto const& icon_center = drag_icon->GetCenter(monitor); | ||
1477 | 1984 | x += abs_geo.x; | ||
1478 | 1985 | y += abs_geo.y; | ||
1479 | 1986 | |||
1480 | 1987 | SetActionState(ACTION_DRAG_ICON); | 1987 | SetActionState(ACTION_DRAG_ICON); |
1481 | 1988 | StartIconDrag(drag_icon); | 1988 | StartIconDrag(drag_icon); |
1483 | 1989 | UpdateDragWindowPosition(drag_icon->GetCenter(monitor).x, drag_icon->GetCenter(monitor).y); | 1989 | UpdateDragWindowPosition(icon_center.x, icon_center.y); |
1484 | 1990 | |||
1485 | 1990 | if (_initial_drag_animation) | 1991 | if (_initial_drag_animation) |
1486 | 1991 | { | 1992 | { |
1487 | 1992 | _drag_window->SetAnimationTarget(x, y); | 1993 | _drag_window->SetAnimationTarget(x, y); |
1488 | 1993 | _drag_window->StartAnimation(); | 1994 | _drag_window->StartAnimation(); |
1489 | 1994 | } | 1995 | } |
1490 | 1996 | |||
1491 | 1995 | EnsureAnimation(); | 1997 | EnsureAnimation(); |
1492 | 1996 | } | 1998 | } |
1493 | 1997 | else | 1999 | else |
1494 | @@ -2008,6 +2010,7 @@ | |||
1495 | 2008 | 2010 | ||
1496 | 2009 | _hide_machine.SetQuirk(LauncherHideMachine::INTERNAL_DND_ACTIVE, true); | 2011 | _hide_machine.SetQuirk(LauncherHideMachine::INTERNAL_DND_ACTIVE, true); |
1497 | 2010 | _drag_icon = icon; | 2012 | _drag_icon = icon; |
1498 | 2013 | _drag_icon_position = _model->IconIndex(icon); | ||
1499 | 2011 | 2014 | ||
1500 | 2012 | HideDragWindow(); | 2015 | HideDragWindow(); |
1501 | 2013 | _offscreen_drag_texture = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(_icon_size, _icon_size, 1, nux::BITFMT_R8G8B8A8); | 2016 | _offscreen_drag_texture = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(_icon_size, _icon_size, 1, nux::BITFMT_R8G8B8A8); |
1502 | @@ -2031,15 +2034,20 @@ | |||
1503 | 2031 | { | 2034 | { |
1504 | 2032 | hovered_icon->SetQuirk(AbstractLauncherIcon::Quirk::PULSE_ONCE, true); | 2035 | hovered_icon->SetQuirk(AbstractLauncherIcon::Quirk::PULSE_ONCE, true); |
1505 | 2033 | 2036 | ||
1507 | 2034 | launcher_removerequest.emit(_drag_icon); | 2037 | remove_request.emit(_drag_icon); |
1508 | 2035 | 2038 | ||
1509 | 2036 | HideDragWindow(); | 2039 | HideDragWindow(); |
1510 | 2037 | EnsureAnimation(); | 2040 | EnsureAnimation(); |
1511 | 2038 | } | 2041 | } |
1512 | 2039 | else | 2042 | else |
1513 | 2040 | { | 2043 | { |
1515 | 2041 | if (!_drag_window->Cancelled()) | 2044 | if (!_drag_window->Cancelled() && _model->IconIndex(_drag_icon) != _drag_icon_position) |
1516 | 2045 | { | ||
1517 | 2046 | if (_drag_icon->GetIconType() == AbstractLauncherIcon::IconType::DEVICE) | ||
1518 | 2047 | _drag_icon->Stick(false); | ||
1519 | 2048 | |||
1520 | 2042 | _model->Save(); | 2049 | _model->Save(); |
1521 | 2050 | } | ||
1522 | 2043 | 2051 | ||
1523 | 2044 | if (_drag_window->on_anim_completed.connected()) | 2052 | if (_drag_window->on_anim_completed.connected()) |
1524 | 2045 | _drag_window->on_anim_completed.disconnect(); | 2053 | _drag_window->on_anim_completed.disconnect(); |
1525 | @@ -2103,15 +2111,11 @@ | |||
1526 | 2103 | return; | 2111 | return; |
1527 | 2104 | 2112 | ||
1528 | 2105 | auto const& launcher_geo = GetGeometry(); | 2113 | auto const& launcher_geo = GetGeometry(); |
1530 | 2106 | auto hovered_icon = MouseIconIntersection((launcher_geo.x + launcher_geo.width) / 2.0, y - GetAbsoluteY()); | 2114 | auto const& hovered_icon = MouseIconIntersection((launcher_geo.x + launcher_geo.width) / 2.0, y - GetAbsoluteY()); |
1531 | 2107 | struct timespec current; | 2115 | struct timespec current; |
1532 | 2108 | clock_gettime(CLOCK_MONOTONIC, ¤t); | 2116 | clock_gettime(CLOCK_MONOTONIC, ¤t); |
1533 | 2109 | float progress = DragThresholdProgress(current); | 2117 | float progress = DragThresholdProgress(current); |
1534 | 2110 | 2118 | ||
1535 | 2111 | // Icons of different types can't be mixed, so let's avoid this. | ||
1536 | 2112 | if (hovered_icon && hovered_icon->GetIconType() != _drag_icon->GetIconType()) | ||
1537 | 2113 | hovered_icon = nullptr; | ||
1538 | 2114 | |||
1539 | 2115 | if (hovered_icon && _drag_icon != hovered_icon) | 2119 | if (hovered_icon && _drag_icon != hovered_icon) |
1540 | 2116 | { | 2120 | { |
1541 | 2117 | if (progress >= 1.0f) | 2121 | if (progress >= 1.0f) |
1542 | @@ -2130,12 +2134,8 @@ | |||
1543 | 2130 | { | 2134 | { |
1544 | 2131 | auto const& icon = *it; | 2135 | auto const& icon = *it; |
1545 | 2132 | 2136 | ||
1550 | 2133 | if (!icon->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE) || | 2137 | if (!icon->IsVisible() || !icon->IsVisibleOnMonitor(monitor)) |
1547 | 2134 | !icon->IsVisibleOnMonitor(monitor) || | ||
1548 | 2135 | icon->GetIconType() != _drag_icon->GetIconType()) | ||
1549 | 2136 | { | ||
1551 | 2137 | continue; | 2138 | continue; |
1552 | 2138 | } | ||
1553 | 2139 | 2139 | ||
1554 | 2140 | if (y >= icon->GetCenter(monitor).y) | 2140 | if (y >= icon->GetCenter(monitor).y) |
1555 | 2141 | { | 2141 | { |
1556 | @@ -2216,7 +2216,9 @@ | |||
1557 | 2216 | } | 2216 | } |
1558 | 2217 | else | 2217 | else |
1559 | 2218 | { | 2218 | { |
1561 | 2219 | StartIconDragRequest(x, y); | 2219 | // We we can safely start the icon drag, from the original mouse-down position |
1562 | 2220 | sources_.Remove(START_DRAGICON_DURATION); | ||
1563 | 2221 | StartIconDragRequest(x - _dnd_delta_x, y - _dnd_delta_y); | ||
1564 | 2220 | } | 2222 | } |
1565 | 2221 | } | 2223 | } |
1566 | 2222 | else if (GetActionState() == ACTION_DRAG_LAUNCHER) | 2224 | else if (GetActionState() == ACTION_DRAG_LAUNCHER) |
1567 | @@ -2226,7 +2228,7 @@ | |||
1568 | 2226 | } | 2228 | } |
1569 | 2227 | else if (GetActionState() == ACTION_DRAG_ICON) | 2229 | else if (GetActionState() == ACTION_DRAG_ICON) |
1570 | 2228 | { | 2230 | { |
1572 | 2229 | nux::Geometry geo = GetAbsoluteGeometry(); | 2231 | nux::Geometry const& geo = GetAbsoluteGeometry(); |
1573 | 2230 | UpdateDragWindowPosition(geo.x + x, geo.y + y); | 2232 | UpdateDragWindowPosition(geo.x + x, geo.y + y); |
1574 | 2231 | } | 2233 | } |
1575 | 2232 | 2234 | ||
1576 | @@ -2405,7 +2407,7 @@ | |||
1577 | 2405 | { | 2407 | { |
1578 | 2406 | _icon_mouse_down = launcher_icon; | 2408 | _icon_mouse_down = launcher_icon; |
1579 | 2407 | // if MouseUp after the time ended -> it's an icon drag, otherwise, it's starting an app | 2409 | // if MouseUp after the time ended -> it's an icon drag, otherwise, it's starting an app |
1581 | 2408 | auto cb_func = sigc::mem_fun(this, &Launcher::StartIconDragTimeout); | 2410 | auto cb_func = sigc::bind(sigc::mem_fun(this, &Launcher::StartIconDragTimeout), x, y); |
1582 | 2409 | sources_.AddTimeout(START_DRAGICON_DURATION, cb_func, START_DRAGICON_TIMEOUT); | 2411 | sources_.AddTimeout(START_DRAGICON_DURATION, cb_func, START_DRAGICON_TIMEOUT); |
1583 | 2410 | 2412 | ||
1584 | 2411 | launcher_icon->mouse_down.emit(nux::GetEventButton(button_flags), monitor, key_flags); | 2413 | launcher_icon->mouse_down.emit(nux::GetEventButton(button_flags), monitor, key_flags); |
1585 | @@ -2452,7 +2454,7 @@ | |||
1586 | 2452 | 2454 | ||
1587 | 2453 | for (it = _model->begin(); it != _model->end(); ++it) | 2455 | for (it = _model->begin(); it != _model->end(); ++it) |
1588 | 2454 | { | 2456 | { |
1590 | 2455 | if (!(*it)->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE) || !(*it)->IsVisibleOnMonitor(monitor)) | 2457 | if (!(*it)->IsVisible() || !(*it)->IsVisibleOnMonitor(monitor)) |
1591 | 2456 | continue; | 2458 | continue; |
1592 | 2457 | 2459 | ||
1593 | 2458 | nux::Point2 screen_coord [4]; | 2460 | nux::Point2 screen_coord [4]; |
1594 | @@ -2537,35 +2539,41 @@ | |||
1595 | 2537 | nux::GetWindowCompositor().RestoreRenderingSurface(); | 2539 | nux::GetWindowCompositor().RestoreRenderingSurface(); |
1596 | 2538 | } | 2540 | } |
1597 | 2539 | 2541 | ||
1598 | 2542 | bool Launcher::DndIsSpecialRequest(std::string const& uri) const | ||
1599 | 2543 | { | ||
1600 | 2544 | return (boost::algorithm::ends_with(uri, ".desktop") || uri.find("device://") == 0); | ||
1601 | 2545 | } | ||
1602 | 2546 | |||
1603 | 2540 | void Launcher::OnDNDDataCollected(const std::list<char*>& mimes) | 2547 | void Launcher::OnDNDDataCollected(const std::list<char*>& mimes) |
1604 | 2541 | { | 2548 | { |
1605 | 2542 | _dnd_data.Reset(); | 2549 | _dnd_data.Reset(); |
1606 | 2543 | 2550 | ||
1608 | 2544 | unity::glib::String uri_list_const(g_strdup("text/uri-list")); | 2551 | const std::string uri_list = "text/uri-list"; |
1609 | 2552 | auto& display = nux::GetWindowThread()->GetGraphicsDisplay(); | ||
1610 | 2545 | 2553 | ||
1612 | 2546 | for (auto it : mimes) | 2554 | for (auto const& mime : mimes) |
1613 | 2547 | { | 2555 | { |
1615 | 2548 | if (!g_str_equal(it, uri_list_const.Value())) | 2556 | if (mime != uri_list) |
1616 | 2549 | continue; | 2557 | continue; |
1617 | 2550 | 2558 | ||
1619 | 2551 | _dnd_data.Fill(nux::GetWindowThread()->GetGraphicsDisplay().GetDndData(uri_list_const.Value())); | 2559 | _dnd_data.Fill(display.GetDndData(const_cast<char*>(uri_list.c_str()))); |
1620 | 2552 | break; | 2560 | break; |
1621 | 2553 | } | 2561 | } |
1622 | 2554 | 2562 | ||
1623 | 2555 | _hide_machine.SetQuirk(LauncherHideMachine::EXTERNAL_DND_ACTIVE, true); | 2563 | _hide_machine.SetQuirk(LauncherHideMachine::EXTERNAL_DND_ACTIVE, true); |
1624 | 2556 | 2564 | ||
1626 | 2557 | for (auto it : _dnd_data.Uris()) | 2565 | auto const& uris = _dnd_data.Uris(); |
1627 | 2566 | if (std::find_if(uris.begin(), uris.end(), [this] (std::string const& uri) | ||
1628 | 2567 | {return DndIsSpecialRequest(uri);}) != uris.end()) | ||
1629 | 2558 | { | 2568 | { |
1635 | 2559 | if (g_str_has_suffix(it.c_str(), ".desktop") || g_str_has_prefix(it.c_str(), "device://")) | 2569 | _steal_drag = true; |
1636 | 2560 | { | 2570 | |
1637 | 2561 | _steal_drag = true; | 2571 | if (IsOverlayOpen()) |
1638 | 2562 | break; | 2572 | SaturateIcons(); |
1634 | 2563 | } | ||
1639 | 2564 | } | 2573 | } |
1642 | 2565 | 2574 | else | |
1641 | 2566 | if (!_steal_drag) | ||
1643 | 2567 | { | 2575 | { |
1645 | 2568 | for (auto it : *_model) | 2576 | for (auto const& it : *_model) |
1646 | 2569 | { | 2577 | { |
1647 | 2570 | if (it->ShouldHighlightOnDrag(_dnd_data)) | 2578 | if (it->ShouldHighlightOnDrag(_dnd_data)) |
1648 | 2571 | { | 2579 | { |
1649 | @@ -2579,11 +2587,6 @@ | |||
1650 | 2579 | } | 2587 | } |
1651 | 2580 | } | 2588 | } |
1652 | 2581 | } | 2589 | } |
1653 | 2582 | else | ||
1654 | 2583 | { | ||
1655 | 2584 | if (IsOverlayOpen()) | ||
1656 | 2585 | SaturateIcons(); | ||
1657 | 2586 | } | ||
1658 | 2587 | } | 2590 | } |
1659 | 2588 | 2591 | ||
1660 | 2589 | void Launcher::ProcessDndEnter() | 2592 | void Launcher::ProcessDndEnter() |
1661 | @@ -2651,32 +2654,29 @@ | |||
1662 | 2651 | 2654 | ||
1663 | 2652 | void Launcher::ProcessDndMove(int x, int y, std::list<char*> mimes) | 2655 | void Launcher::ProcessDndMove(int x, int y, std::list<char*> mimes) |
1664 | 2653 | { | 2656 | { |
1665 | 2654 | nux::Area* parent = GetToplevel(); | ||
1666 | 2655 | unity::glib::String uri_list_const(g_strdup("text/uri-list")); | ||
1667 | 2656 | |||
1668 | 2657 | if (!_data_checked) | 2657 | if (!_data_checked) |
1669 | 2658 | { | 2658 | { |
1670 | 2659 | const std::string uri_list = "text/uri-list"; | ||
1671 | 2659 | _data_checked = true; | 2660 | _data_checked = true; |
1672 | 2660 | _dnd_data.Reset(); | 2661 | _dnd_data.Reset(); |
1673 | 2662 | auto& display = nux::GetWindowThread()->GetGraphicsDisplay(); | ||
1674 | 2661 | 2663 | ||
1675 | 2662 | // get the data | 2664 | // get the data |
1677 | 2663 | for (auto it : mimes) | 2665 | for (auto const& mime : mimes) |
1678 | 2664 | { | 2666 | { |
1680 | 2665 | if (!g_str_equal(it, uri_list_const.Value())) | 2667 | if (mime != uri_list) |
1681 | 2666 | continue; | 2668 | continue; |
1682 | 2667 | 2669 | ||
1684 | 2668 | _dnd_data.Fill(nux::GetWindowThread()->GetGraphicsDisplay().GetDndData(uri_list_const.Value())); | 2670 | _dnd_data.Fill(display.GetDndData(const_cast<char*>(uri_list.c_str()))); |
1685 | 2669 | break; | 2671 | break; |
1686 | 2670 | } | 2672 | } |
1687 | 2671 | 2673 | ||
1688 | 2672 | // see if the launcher wants this one | 2674 | // see if the launcher wants this one |
1690 | 2673 | for (auto it : _dnd_data.Uris()) | 2675 | auto const& uris = _dnd_data.Uris(); |
1691 | 2676 | if (std::find_if(uris.begin(), uris.end(), [this] (std::string const& uri) | ||
1692 | 2677 | {return DndIsSpecialRequest(uri);}) != uris.end()) | ||
1693 | 2674 | { | 2678 | { |
1699 | 2675 | if (g_str_has_suffix(it.c_str(), ".desktop") || g_str_has_prefix(it.c_str(), "device://")) | 2679 | _steal_drag = true; |
1695 | 2676 | { | ||
1696 | 2677 | _steal_drag = true; | ||
1697 | 2678 | break; | ||
1698 | 2679 | } | ||
1700 | 2680 | } | 2680 | } |
1701 | 2681 | 2681 | ||
1702 | 2682 | // only set hover once we know our first x/y | 2682 | // only set hover once we know our first x/y |
1703 | @@ -2685,7 +2685,7 @@ | |||
1704 | 2685 | 2685 | ||
1705 | 2686 | if (!_steal_drag) | 2686 | if (!_steal_drag) |
1706 | 2687 | { | 2687 | { |
1708 | 2688 | for (auto it : *_model) | 2688 | for (auto const& it : *_model) |
1709 | 2689 | { | 2689 | { |
1710 | 2690 | if (it->ShouldHighlightOnDrag(_dnd_data)) | 2690 | if (it->ShouldHighlightOnDrag(_dnd_data)) |
1711 | 2691 | it->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, false); | 2691 | it->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, false); |
1712 | @@ -2695,7 +2695,7 @@ | |||
1713 | 2695 | } | 2695 | } |
1714 | 2696 | } | 2696 | } |
1715 | 2697 | 2697 | ||
1717 | 2698 | SetMousePosition(x - parent->GetGeometry().x, y - parent->GetGeometry().y); | 2698 | SetMousePosition(x - _parent->GetGeometry().x, y - _parent->GetGeometry().y); |
1718 | 2699 | 2699 | ||
1719 | 2700 | if (!IsOverlayOpen() && _mouse_position.x == 0 && _mouse_position.y <= (_parent->GetGeometry().height - _icon_size - 2 * _space_between_icons) && !_drag_edge_touching) | 2700 | if (!IsOverlayOpen() && _mouse_position.x == 0 && _mouse_position.y <= (_parent->GetGeometry().height - _icon_size - 2 * _space_between_icons) && !_drag_edge_touching) |
1720 | 2701 | { | 2701 | { |
1721 | @@ -2722,7 +2722,7 @@ | |||
1722 | 2722 | if (hovered_icon->GetIconType() == AbstractLauncherIcon::IconType::TRASH) | 2722 | if (hovered_icon->GetIconType() == AbstractLauncherIcon::IconType::TRASH) |
1723 | 2723 | _steal_drag = false; | 2723 | _steal_drag = false; |
1724 | 2724 | 2724 | ||
1726 | 2725 | if (hovered_icon->GetIconType() == AbstractLauncherIcon::IconType::APPLICATION || hovered_icon->GetIconType() == AbstractLauncherIcon::IconType::EXPO) | 2725 | if (hovered_icon->position() == AbstractLauncherIcon::Position::FLOATING) |
1727 | 2726 | hovered_icon_is_appropriate = true; | 2726 | hovered_icon_is_appropriate = true; |
1728 | 2727 | } | 2727 | } |
1729 | 2728 | 2728 | ||
1730 | @@ -2732,7 +2732,6 @@ | |||
1731 | 2732 | if (!_dnd_hovered_icon && hovered_icon_is_appropriate) | 2732 | if (!_dnd_hovered_icon && hovered_icon_is_appropriate) |
1732 | 2733 | { | 2733 | { |
1733 | 2734 | _dnd_hovered_icon = new SpacerLauncherIcon(monitor()); | 2734 | _dnd_hovered_icon = new SpacerLauncherIcon(monitor()); |
1734 | 2735 | _dnd_hovered_icon->SetSortPriority(G_MAXINT); | ||
1735 | 2736 | _model->AddIcon(_dnd_hovered_icon); | 2735 | _model->AddIcon(_dnd_hovered_icon); |
1736 | 2737 | _model->ReorderBefore(_dnd_hovered_icon, hovered_icon, true); | 2736 | _model->ReorderBefore(_dnd_hovered_icon, hovered_icon, true); |
1737 | 2738 | } | 2737 | } |
1738 | @@ -2787,34 +2786,10 @@ | |||
1739 | 2787 | { | 2786 | { |
1740 | 2788 | if (_steal_drag) | 2787 | if (_steal_drag) |
1741 | 2789 | { | 2788 | { |
1743 | 2790 | for (auto it : _dnd_data.Uris()) | 2789 | for (auto const& uri : _dnd_data.Uris()) |
1744 | 2791 | { | 2790 | { |
1771 | 2792 | if (g_str_has_suffix(it.c_str(), ".desktop")) | 2791 | if (DndIsSpecialRequest(uri)) |
1772 | 2793 | { | 2792 | add_request.emit(uri, _dnd_hovered_icon); |
1747 | 2794 | char* path = nullptr; | ||
1748 | 2795 | |||
1749 | 2796 | if (g_str_has_prefix(it.c_str(), "application://")) | ||
1750 | 2797 | { | ||
1751 | 2798 | const char* tmp = it.c_str() + strlen("application://"); | ||
1752 | 2799 | unity::glib::String tmp2(g_strdup_printf("file:///usr/share/applications/%s", tmp)); | ||
1753 | 2800 | path = g_filename_from_uri(tmp2.Value(), NULL, NULL); | ||
1754 | 2801 | } | ||
1755 | 2802 | else if (g_str_has_prefix(it.c_str(), "file://")) | ||
1756 | 2803 | { | ||
1757 | 2804 | path = g_filename_from_uri(it.c_str(), NULL, NULL); | ||
1758 | 2805 | } | ||
1759 | 2806 | |||
1760 | 2807 | if (path) | ||
1761 | 2808 | { | ||
1762 | 2809 | launcher_addrequest.emit(path, _dnd_hovered_icon); | ||
1763 | 2810 | g_free(path); | ||
1764 | 2811 | } | ||
1765 | 2812 | } | ||
1766 | 2813 | else if (devices_settings_ && g_str_has_prefix(it.c_str(), "device://")) | ||
1767 | 2814 | { | ||
1768 | 2815 | const gchar* uuid = it.c_str() + 9; | ||
1769 | 2816 | devices_settings_->TryToUnblacklist(uuid); | ||
1770 | 2817 | } | ||
1773 | 2818 | } | 2793 | } |
1774 | 2819 | } | 2794 | } |
1775 | 2820 | else if (_dnd_hovered_icon && _drag_action != nux::DNDACTION_NONE) | 2795 | else if (_dnd_hovered_icon && _drag_action != nux::DNDACTION_NONE) |
1776 | 2821 | 2796 | ||
1777 | === modified file 'launcher/Launcher.h' | |||
1778 | --- launcher/Launcher.h 2012-09-01 14:00:19 +0000 | |||
1779 | +++ launcher/Launcher.h 2012-09-18 15:52:46 +0000 | |||
1780 | @@ -83,8 +83,6 @@ | |||
1781 | 83 | void SetModel(LauncherModel::Ptr model); | 83 | void SetModel(LauncherModel::Ptr model); |
1782 | 84 | LauncherModel::Ptr GetModel() const; | 84 | LauncherModel::Ptr GetModel() const; |
1783 | 85 | 85 | ||
1784 | 86 | void SetDevicesSettings(DevicesSettings::Ptr devices_settings); | ||
1785 | 87 | |||
1786 | 88 | void StartKeyShowLauncher(); | 86 | void StartKeyShowLauncher(); |
1787 | 89 | void EndKeyShowLauncher(); | 87 | void EndKeyShowLauncher(); |
1788 | 90 | 88 | ||
1789 | @@ -121,9 +119,8 @@ | |||
1790 | 121 | int GetDragDelta() const; | 119 | int GetDragDelta() const; |
1791 | 122 | void SetHover(bool hovered); | 120 | void SetHover(bool hovered); |
1792 | 123 | 121 | ||
1796 | 124 | sigc::signal<void, char*, AbstractLauncherIcon::Ptr> launcher_addrequest; | 122 | sigc::signal<void, std::string const&, AbstractLauncherIcon::Ptr> add_request; |
1797 | 125 | sigc::signal<void, AbstractLauncherIcon::Ptr> launcher_removerequest; | 123 | sigc::signal<void, AbstractLauncherIcon::Ptr> remove_request; |
1795 | 126 | sigc::signal<void, AbstractLauncherIcon::Ptr> icon_animation_complete; | ||
1798 | 127 | sigc::signal<void> selection_change; | 124 | sigc::signal<void> selection_change; |
1799 | 128 | sigc::signal<void> hidden_changed; | 125 | sigc::signal<void> hidden_changed; |
1800 | 129 | sigc::signal<void> sc_launcher_icon_animation; | 126 | sigc::signal<void> sc_launcher_icon_animation; |
1801 | @@ -199,7 +196,7 @@ | |||
1802 | 199 | void OnSelectionChanged(AbstractLauncherIcon::Ptr selection); | 196 | void OnSelectionChanged(AbstractLauncherIcon::Ptr selection); |
1803 | 200 | 197 | ||
1804 | 201 | bool StrutHack(); | 198 | bool StrutHack(); |
1806 | 202 | bool StartIconDragTimeout(); | 199 | bool StartIconDragTimeout(int x, int y); |
1807 | 203 | bool OnScrollTimeout(); | 200 | bool OnScrollTimeout(); |
1808 | 204 | bool OnUpdateDragManagerTimeout(); | 201 | bool OnUpdateDragManagerTimeout(); |
1809 | 205 | 202 | ||
1810 | @@ -319,6 +316,7 @@ | |||
1811 | 319 | void DndReset(); | 316 | void DndReset(); |
1812 | 320 | void DndHoveredIconReset(); | 317 | void DndHoveredIconReset(); |
1813 | 321 | void DndTimeoutSetup(); | 318 | void DndTimeoutSetup(); |
1814 | 319 | bool DndIsSpecialRequest(std::string const& uri) const; | ||
1815 | 322 | 320 | ||
1816 | 323 | LauncherModel::Ptr _model; | 321 | LauncherModel::Ptr _model; |
1817 | 324 | nux::BaseWindow* _parent; | 322 | nux::BaseWindow* _parent; |
1818 | @@ -371,6 +369,7 @@ | |||
1819 | 371 | int _launcher_drag_delta_min; | 369 | int _launcher_drag_delta_min; |
1820 | 372 | int _enter_y; | 370 | int _enter_y; |
1821 | 373 | int _last_button_press; | 371 | int _last_button_press; |
1822 | 372 | int _drag_icon_position; | ||
1823 | 374 | float _drag_out_delta_x; | 373 | float _drag_out_delta_x; |
1824 | 375 | bool _drag_gesture_ongoing; | 374 | bool _drag_gesture_ongoing; |
1825 | 376 | float _last_reveal_progress; | 375 | float _last_reveal_progress; |
1826 | @@ -395,8 +394,6 @@ | |||
1827 | 395 | ui::AbstractIconRenderer::Ptr icon_renderer; | 394 | ui::AbstractIconRenderer::Ptr icon_renderer; |
1828 | 396 | BackgroundEffectHelper bg_effect_helper_; | 395 | BackgroundEffectHelper bg_effect_helper_; |
1829 | 397 | 396 | ||
1830 | 398 | DevicesSettings::Ptr devices_settings_; | ||
1831 | 399 | |||
1832 | 400 | UBusManager ubus_; | 397 | UBusManager ubus_; |
1833 | 401 | glib::SourceManager sources_; | 398 | glib::SourceManager sources_; |
1834 | 402 | 399 | ||
1835 | 403 | 400 | ||
1836 | === modified file 'launcher/LauncherController.cpp' | |||
1837 | --- launcher/LauncherController.cpp 2012-09-11 09:59:25 +0000 | |||
1838 | +++ launcher/LauncherController.cpp 2012-09-18 15:52:46 +0000 | |||
1839 | @@ -1,6 +1,6 @@ | |||
1840 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
1841 | 2 | /* | 2 | /* |
1843 | 3 | * Copyright (C) 2010, 2011 Canonical Ltd | 3 | * Copyright (C) 2010-2012 Canonical Ltd |
1844 | 4 | * | 4 | * |
1845 | 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 |
1846 | 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 |
1847 | @@ -16,6 +16,7 @@ | |||
1848 | 16 | * | 16 | * |
1849 | 17 | * Authored by: Jason Smith <jason.smith@canonical.com> | 17 | * Authored by: Jason Smith <jason.smith@canonical.com> |
1850 | 18 | * Tim Penhey <tim.penhey@canonical.com> | 18 | * Tim Penhey <tim.penhey@canonical.com> |
1851 | 19 | * Marco Trevisan <marco.trevisan@canonical.com> | ||
1852 | 19 | */ | 20 | */ |
1853 | 20 | 21 | ||
1854 | 21 | #include <glib/gi18n-lib.h> | 22 | #include <glib/gi18n-lib.h> |
1855 | @@ -25,6 +26,7 @@ | |||
1856 | 25 | #include <Nux/HLayout.h> | 26 | #include <Nux/HLayout.h> |
1857 | 26 | #include <Nux/BaseWindow.h> | 27 | #include <Nux/BaseWindow.h> |
1858 | 27 | #include <NuxCore/Logger.h> | 28 | #include <NuxCore/Logger.h> |
1859 | 29 | #include <UnityCore/DesktopUtilities.h> | ||
1860 | 28 | 30 | ||
1861 | 29 | #include "LauncherOptions.h" | 31 | #include "LauncherOptions.h" |
1862 | 30 | #include "BamfLauncherIcon.h" | 32 | #include "BamfLauncherIcon.h" |
1863 | @@ -35,6 +37,7 @@ | |||
1864 | 35 | #include "LauncherController.h" | 37 | #include "LauncherController.h" |
1865 | 36 | #include "LauncherControllerPrivate.h" | 38 | #include "LauncherControllerPrivate.h" |
1866 | 37 | #include "SoftwareCenterLauncherIcon.h" | 39 | #include "SoftwareCenterLauncherIcon.h" |
1867 | 40 | #include "ExpoLauncherIcon.h" | ||
1868 | 38 | #include "unity-shared/WindowManager.h" | 41 | #include "unity-shared/WindowManager.h" |
1869 | 39 | #include "TrashLauncherIcon.h" | 42 | #include "TrashLauncherIcon.h" |
1870 | 40 | #include "BFBLauncherIcon.h" | 43 | #include "BFBLauncherIcon.h" |
1871 | @@ -82,63 +85,45 @@ | |||
1872 | 82 | const std::string KEYPRESS_TIMEOUT = "keypress-timeout"; | 85 | const std::string KEYPRESS_TIMEOUT = "keypress-timeout"; |
1873 | 83 | const std::string LABELS_TIMEOUT = "label-show-timeout"; | 86 | const std::string LABELS_TIMEOUT = "label-show-timeout"; |
1874 | 84 | const std::string HIDE_TIMEOUT = "hide-timeout"; | 87 | const std::string HIDE_TIMEOUT = "hide-timeout"; |
1879 | 85 | } | 88 | |
1880 | 86 | } | 89 | const std::string SOFTWARE_CENTER_AGENT = "software-center-agent"; |
1881 | 87 | 90 | ||
1882 | 88 | 91 | const std::string RUNNING_APPS_URI = FavoriteStore::URI_PREFIX_UNITY + "running-apps"; | |
1883 | 92 | const std::string DEVICES_URI = FavoriteStore::URI_PREFIX_UNITY + "devices"; | ||
1884 | 93 | } | ||
1885 | 94 | } | ||
1886 | 89 | 95 | ||
1887 | 90 | GDBusInterfaceVTable Controller::Impl::interface_vtable = | 96 | GDBusInterfaceVTable Controller::Impl::interface_vtable = |
1888 | 91 | { Controller::Impl::OnDBusMethodCall, NULL, NULL}; | 97 | { Controller::Impl::OnDBusMethodCall, NULL, NULL}; |
1889 | 92 | 98 | ||
1891 | 93 | Controller::Impl::Impl(Display* display, Controller* parent) | 99 | |
1892 | 100 | Controller::Impl::Impl(Controller* parent) | ||
1893 | 94 | : parent_(parent) | 101 | : parent_(parent) |
1901 | 95 | , model_(new LauncherModel()) | 102 | , model_(std::make_shared<LauncherModel>()) |
1895 | 96 | , sort_priority_(0) | ||
1896 | 97 | , volume_monitor_(new VolumeMonitorWrapper) | ||
1897 | 98 | , devices_settings_(new DevicesSettingsImp) | ||
1898 | 99 | , device_section_(volume_monitor_, devices_settings_) | ||
1899 | 100 | , show_desktop_icon_(false) | ||
1900 | 101 | , display_(display) | ||
1902 | 102 | , matcher_(bamf_matcher_get_default()) | 103 | , matcher_(bamf_matcher_get_default()) |
1903 | 104 | , device_section_(std::make_shared<VolumeMonitorWrapper>(), std::make_shared<DevicesSettingsImp>()) | ||
1904 | 105 | , expo_icon_(new ExpoLauncherIcon()) | ||
1905 | 106 | , desktop_icon_(new DesktopLauncherIcon()) | ||
1906 | 107 | , sort_priority_(AbstractLauncherIcon::DefaultPriority(AbstractLauncherIcon::IconType::APPLICATION)) | ||
1907 | 108 | , launcher_open(false) | ||
1908 | 109 | , launcher_keynav(false) | ||
1909 | 110 | , launcher_grabbed(false) | ||
1910 | 111 | , reactivate_keynav(false) | ||
1911 | 112 | , keynav_restore_window_(true) | ||
1912 | 113 | , launcher_key_press_time_(0) | ||
1913 | 114 | , dbus_owner_(g_bus_own_name(G_BUS_TYPE_SESSION, DBUS_NAME.c_str(), G_BUS_NAME_OWNER_FLAGS_NONE, | ||
1914 | 115 | OnBusAcquired, nullptr, nullptr, this, nullptr)) | ||
1915 | 103 | { | 116 | { |
1916 | 104 | edge_barriers_.options = parent_->options(); | 117 | edge_barriers_.options = parent_->options(); |
1917 | 105 | 118 | ||
1918 | 106 | UScreen* uscreen = UScreen::GetDefault(); | 119 | UScreen* uscreen = UScreen::GetDefault(); |
1946 | 107 | auto monitors = uscreen->GetMonitors(); | 120 | EnsureLaunchers(uscreen->GetPrimaryMonitor(), uscreen->GetMonitors()); |
1947 | 108 | int primary = uscreen->GetPrimaryMonitor(); | 121 | |
1948 | 109 | 122 | SetupIcons(); | |
1922 | 110 | launcher_open = false; | ||
1923 | 111 | launcher_keynav = false; | ||
1924 | 112 | launcher_grabbed = false; | ||
1925 | 113 | reactivate_keynav = false; | ||
1926 | 114 | keynav_restore_window_ = true; | ||
1927 | 115 | |||
1928 | 116 | EnsureLaunchers(primary, monitors); | ||
1929 | 117 | |||
1930 | 118 | launcher_ = launchers[0]; | ||
1931 | 119 | device_section_.IconAdded.connect(sigc::mem_fun(this, &Impl::OnIconAdded)); | ||
1932 | 120 | |||
1933 | 121 | num_workspaces_ = WindowManager::Default()->WorkspaceCount(); | ||
1934 | 122 | if (num_workspaces_ > 1) | ||
1935 | 123 | { | ||
1936 | 124 | InsertExpoAction(); | ||
1937 | 125 | } | ||
1938 | 126 | |||
1939 | 127 | // Insert the "Show Desktop" launcher icon in the launcher... | ||
1940 | 128 | if (show_desktop_icon_) | ||
1941 | 129 | InsertDesktopIcon(); | ||
1942 | 130 | |||
1943 | 131 | InsertTrash(); | ||
1944 | 132 | |||
1945 | 133 | sources_.AddTimeout(500, [&] { SetupBamf(); return false; }); | ||
1949 | 134 | 123 | ||
1950 | 135 | remote_model_.entry_added.connect(sigc::mem_fun(this, &Impl::OnLauncherEntryRemoteAdded)); | 124 | remote_model_.entry_added.connect(sigc::mem_fun(this, &Impl::OnLauncherEntryRemoteAdded)); |
1951 | 136 | remote_model_.entry_removed.connect(sigc::mem_fun(this, &Impl::OnLauncherEntryRemoteRemoved)); | 125 | remote_model_.entry_removed.connect(sigc::mem_fun(this, &Impl::OnLauncherEntryRemoteRemoved)); |
1952 | 137 | 126 | ||
1953 | 138 | FavoriteStore::Instance().favorite_added.connect(sigc::mem_fun(this, &Impl::OnFavoriteStoreFavoriteAdded)); | ||
1954 | 139 | FavoriteStore::Instance().favorite_removed.connect(sigc::mem_fun(this, &Impl::OnFavoriteStoreFavoriteRemoved)); | ||
1955 | 140 | FavoriteStore::Instance().reordered.connect(sigc::mem_fun(this, &Impl::OnFavoriteStoreReordered)); | ||
1956 | 141 | |||
1957 | 142 | LauncherHideMode hide_mode = parent_->options()->hide_mode; | 127 | LauncherHideMode hide_mode = parent_->options()->hide_mode; |
1958 | 143 | BFBLauncherIcon* bfb = new BFBLauncherIcon(hide_mode); | 128 | BFBLauncherIcon* bfb = new BFBLauncherIcon(hide_mode); |
1959 | 144 | RegisterIcon(AbstractLauncherIcon::Ptr(bfb)); | 129 | RegisterIcon(AbstractLauncherIcon::Ptr(bfb)); |
1960 | @@ -146,35 +131,27 @@ | |||
1961 | 146 | HudLauncherIcon* hud = new HudLauncherIcon(hide_mode); | 131 | HudLauncherIcon* hud = new HudLauncherIcon(hide_mode); |
1962 | 147 | RegisterIcon(AbstractLauncherIcon::Ptr(hud)); | 132 | RegisterIcon(AbstractLauncherIcon::Ptr(hud)); |
1963 | 148 | 133 | ||
1965 | 149 | parent_->options()->hide_mode.changed.connect([bfb,hud](LauncherHideMode mode) { | 134 | TrashLauncherIcon* trash = new TrashLauncherIcon(); |
1966 | 135 | RegisterIcon(AbstractLauncherIcon::Ptr(trash)); | ||
1967 | 136 | |||
1968 | 137 | parent_->options()->hide_mode.changed.connect([bfb, hud](LauncherHideMode mode) { | ||
1969 | 150 | bfb->SetHideMode(mode); | 138 | bfb->SetHideMode(mode); |
1970 | 151 | hud->SetHideMode(mode); | 139 | hud->SetHideMode(mode); |
1971 | 152 | }); | 140 | }); |
1972 | 153 | 141 | ||
1973 | 154 | desktop_icon_ = AbstractLauncherIcon::Ptr(new DesktopLauncherIcon()); | ||
1974 | 155 | |||
1975 | 156 | uscreen->changed.connect(sigc::mem_fun(this, &Controller::Impl::OnScreenChanged)); | 142 | uscreen->changed.connect(sigc::mem_fun(this, &Controller::Impl::OnScreenChanged)); |
1976 | 157 | 143 | ||
1977 | 158 | WindowManager& plugin_adapter = *(WindowManager::Default()); | 144 | WindowManager& plugin_adapter = *(WindowManager::Default()); |
1981 | 159 | plugin_adapter.window_focus_changed.connect (sigc::mem_fun (this, &Controller::Impl::OnWindowFocusChanged)); | 145 | plugin_adapter.window_focus_changed.connect(sigc::mem_fun(this, &Controller::Impl::OnWindowFocusChanged)); |
1979 | 160 | |||
1980 | 161 | launcher_key_press_time_ = 0; | ||
1982 | 162 | 146 | ||
1983 | 163 | ubus.RegisterInterest(UBUS_QUICKLIST_END_KEY_NAV, [&](GVariant * args) { | 147 | ubus.RegisterInterest(UBUS_QUICKLIST_END_KEY_NAV, [&](GVariant * args) { |
1984 | 164 | if (reactivate_keynav) | 148 | if (reactivate_keynav) |
1985 | 165 | parent_->KeyNavGrab(); | 149 | parent_->KeyNavGrab(); |
1987 | 166 | model_->SetSelection(reactivate_index); | 150 | |
1988 | 151 | model_->SetSelection(reactivate_index); | ||
1989 | 167 | }); | 152 | }); |
1990 | 168 | 153 | ||
1991 | 169 | parent_->AddChild(model_.get()); | 154 | parent_->AddChild(model_.get()); |
1992 | 170 | |||
1993 | 171 | uscreen->resuming.connect([&]() -> void { | ||
1994 | 172 | for (auto launcher : launchers) | ||
1995 | 173 | launcher->QueueDraw(); | ||
1996 | 174 | }); | ||
1997 | 175 | |||
1998 | 176 | dbus_owner_ = g_bus_own_name(G_BUS_TYPE_SESSION, DBUS_NAME.c_str(), G_BUS_NAME_OWNER_FLAGS_NONE, | ||
1999 | 177 | OnBusAcquired, nullptr, nullptr, this, nullptr); | ||
2000 | 178 | } | 155 | } |
2001 | 179 | 156 | ||
2002 | 180 | Controller::Impl::~Impl() | 157 | Controller::Impl::~Impl() |
2003 | @@ -182,9 +159,9 @@ | |||
2004 | 182 | // Since the launchers are in a window which adds a reference to the | 159 | // Since the launchers are in a window which adds a reference to the |
2005 | 183 | // launcher, we need to make sure the base windows are unreferenced | 160 | // launcher, we need to make sure the base windows are unreferenced |
2006 | 184 | // otherwise the launchers never die. | 161 | // otherwise the launchers never die. |
2008 | 185 | for (auto launcher_ptr : launchers) | 162 | for (auto const& launcher_ptr : launchers) |
2009 | 186 | { | 163 | { |
2011 | 187 | if (launcher_ptr.IsValid()) | 164 | if (launcher_ptr) |
2012 | 188 | launcher_ptr->GetParent()->UnReference(); | 165 | launcher_ptr->GetParent()->UnReference(); |
2013 | 189 | } | 166 | } |
2014 | 190 | 167 | ||
2015 | @@ -198,7 +175,7 @@ | |||
2016 | 198 | unsigned int launchers_size = launchers.size(); | 175 | unsigned int launchers_size = launchers.size(); |
2017 | 199 | unsigned int last_launcher = 0; | 176 | unsigned int last_launcher = 0; |
2018 | 200 | 177 | ||
2020 | 201 | for (unsigned int i = 0; i < num_launchers; i++, last_launcher++) | 178 | for (unsigned int i = 0; i < num_launchers; ++i, ++last_launcher) |
2021 | 202 | { | 179 | { |
2022 | 203 | if (i >= launchers_size) | 180 | if (i >= launchers_size) |
2023 | 204 | { | 181 | { |
2024 | @@ -232,6 +209,7 @@ | |||
2025 | 232 | } | 209 | } |
2026 | 233 | } | 210 | } |
2027 | 234 | 211 | ||
2028 | 212 | launcher_ = launchers[0]; | ||
2029 | 235 | launchers.resize(num_launchers); | 213 | launchers.resize(num_launchers); |
2030 | 236 | } | 214 | } |
2031 | 237 | 215 | ||
2032 | @@ -240,7 +218,7 @@ | |||
2033 | 240 | EnsureLaunchers(primary_monitor, monitors); | 218 | EnsureLaunchers(primary_monitor, monitors); |
2034 | 241 | } | 219 | } |
2035 | 242 | 220 | ||
2037 | 243 | void Controller::Impl::OnWindowFocusChanged (guint32 xid) | 221 | void Controller::Impl::OnWindowFocusChanged(guint32 xid) |
2038 | 244 | { | 222 | { |
2039 | 245 | static bool keynav_first_focus = false; | 223 | static bool keynav_first_focus = false; |
2040 | 246 | 224 | ||
2041 | @@ -264,11 +242,9 @@ | |||
2042 | 264 | nux::BaseWindow* launcher_window = new nux::BaseWindow(TEXT("LauncherWindow")); | 242 | nux::BaseWindow* launcher_window = new nux::BaseWindow(TEXT("LauncherWindow")); |
2043 | 265 | 243 | ||
2044 | 266 | Launcher* launcher = new Launcher(launcher_window, nux::ObjectPtr<DNDCollectionWindow>(new DNDCollectionWindow)); | 244 | Launcher* launcher = new Launcher(launcher_window, nux::ObjectPtr<DNDCollectionWindow>(new DNDCollectionWindow)); |
2045 | 267 | launcher->display = display_; | ||
2046 | 268 | launcher->monitor = monitor; | 245 | launcher->monitor = monitor; |
2047 | 269 | launcher->options = parent_->options(); | 246 | launcher->options = parent_->options(); |
2048 | 270 | launcher->SetModel(model_); | 247 | launcher->SetModel(model_); |
2049 | 271 | launcher->SetDevicesSettings(devices_settings_); | ||
2050 | 272 | 248 | ||
2051 | 273 | nux::HLayout* layout = new nux::HLayout(NUX_TRACKER_LOCATION); | 249 | nux::HLayout* layout = new nux::HLayout(NUX_TRACKER_LOCATION); |
2052 | 274 | layout->AddView(launcher, 1); | 250 | layout->AddView(launcher, 1); |
2053 | @@ -283,58 +259,103 @@ | |||
2054 | 283 | launcher_window->InputWindowEnableStruts(parent_->options()->hide_mode == LAUNCHER_HIDE_NEVER); | 259 | launcher_window->InputWindowEnableStruts(parent_->options()->hide_mode == LAUNCHER_HIDE_NEVER); |
2055 | 284 | launcher_window->SetEnterFocusInputArea(launcher); | 260 | launcher_window->SetEnterFocusInputArea(launcher); |
2056 | 285 | 261 | ||
2061 | 286 | launcher->launcher_addrequest.connect(sigc::mem_fun(this, &Impl::OnLauncherAddRequest)); | 262 | launcher->add_request.connect(sigc::mem_fun(this, &Impl::OnLauncherAddRequest)); |
2062 | 287 | launcher->launcher_removerequest.connect(sigc::mem_fun(this, &Impl::OnLauncherRemoveRequest)); | 263 | launcher->remove_request.connect(sigc::mem_fun(this, &Impl::OnLauncherRemoveRequest)); |
2059 | 288 | |||
2060 | 289 | launcher->icon_animation_complete.connect(sigc::mem_fun(this, &Impl::OnSCIconAnimationComplete)); | ||
2063 | 290 | 264 | ||
2064 | 291 | parent_->AddChild(launcher); | 265 | parent_->AddChild(launcher); |
2065 | 292 | 266 | ||
2066 | 293 | return launcher; | 267 | return launcher; |
2067 | 294 | } | 268 | } |
2068 | 295 | 269 | ||
2100 | 296 | void Controller::Impl::OnLauncherAddRequest(char* path, AbstractLauncherIcon::Ptr before) | 270 | void Controller::Impl::OnLauncherAddRequest(std::string const& icon_uri, AbstractLauncherIcon::Ptr icon_before) |
2101 | 297 | { | 271 | { |
2102 | 298 | for (auto it : model_->GetSublist<BamfLauncherIcon> ()) | 272 | std::string app_uri; |
2103 | 299 | { | 273 | |
2104 | 300 | if (path && path == it->DesktopFile()) | 274 | if (icon_uri.find(FavoriteStore::URI_PREFIX_FILE) == 0) |
2105 | 301 | { | 275 | { |
2106 | 302 | it->Stick(); | 276 | auto const& desktop_path = icon_uri.substr(FavoriteStore::URI_PREFIX_FILE.length()); |
2107 | 303 | model_->ReorderBefore(it, before, false); | 277 | app_uri = FavoriteStore::URI_PREFIX_APP + DesktopUtilities::GetDesktopID(desktop_path); |
2108 | 304 | Save(); | 278 | } |
2109 | 305 | return; | 279 | |
2110 | 306 | } | 280 | auto const& icon = GetIconByUri(app_uri.empty() ? icon_uri : app_uri); |
2111 | 307 | } | 281 | |
2112 | 308 | 282 | if (icon) | |
2113 | 309 | AbstractLauncherIcon::Ptr result = CreateFavorite(path); | 283 | { |
2114 | 310 | if (result) | 284 | icon->Stick(false); |
2115 | 311 | { | 285 | model_->ReorderAfter(icon, icon_before); |
2116 | 312 | RegisterIcon(result); | 286 | } |
2117 | 313 | if (before) | 287 | else |
2118 | 314 | model_->ReorderBefore(result, before, false); | 288 | { |
2119 | 315 | } | 289 | if (icon_before) |
2120 | 316 | 290 | RegisterIcon(CreateFavoriteIcon(icon_uri), icon_before->SortPriority()); | |
2121 | 317 | Save(); | 291 | else |
2122 | 318 | } | 292 | RegisterIcon(CreateFavoriteIcon(icon_uri)); |
2123 | 319 | 293 | } | |
2124 | 320 | void Controller::Impl::Save() | 294 | |
2125 | 321 | { | 295 | SaveIconsOrder(); |
2126 | 322 | unity::FavoriteList desktop_paths; | 296 | } |
2127 | 323 | 297 | ||
2128 | 324 | // Updates gsettings favorites. | 298 | void Controller::Impl::AddFavoriteKeepingOldPosition(FavoriteList& icons, std::string const& icon_uri) const |
2129 | 325 | auto launchers = model_->GetSublist<BamfLauncherIcon> (); | 299 | { |
2130 | 326 | for (auto icon : launchers) | 300 | auto const& favorites = FavoriteStore::Instance().GetFavorites(); |
2131 | 301 | auto it = std::find(favorites.rbegin(), favorites.rend(), icon_uri); | ||
2132 | 302 | |||
2133 | 303 | FavoriteList::reverse_iterator icons_it = icons.rbegin(); | ||
2134 | 304 | |||
2135 | 305 | while (it != favorites.rend()) | ||
2136 | 306 | { | ||
2137 | 307 | icons_it = std::find(icons.rbegin(), icons.rend(), *it); | ||
2138 | 308 | |||
2139 | 309 | if (icons_it != icons.rend()) | ||
2140 | 310 | break; | ||
2141 | 311 | |||
2142 | 312 | ++it; | ||
2143 | 313 | } | ||
2144 | 314 | |||
2145 | 315 | icons.insert(icons_it.base(), icon_uri); | ||
2146 | 316 | } | ||
2147 | 317 | |||
2148 | 318 | void Controller::Impl::SaveIconsOrder() | ||
2149 | 319 | { | ||
2150 | 320 | FavoriteList icons; | ||
2151 | 321 | bool found_first_running_app = false; | ||
2152 | 322 | bool found_first_device = false; | ||
2153 | 323 | |||
2154 | 324 | for (auto const& icon : *model_) | ||
2155 | 327 | { | 325 | { |
2156 | 328 | if (!icon->IsSticky()) | 326 | if (!icon->IsSticky()) |
2157 | 327 | { | ||
2158 | 328 | if (!icon->IsVisible()) | ||
2159 | 329 | continue; | ||
2160 | 330 | |||
2161 | 331 | if (!found_first_running_app && icon->GetIconType() == AbstractLauncherIcon::IconType::APPLICATION) | ||
2162 | 332 | { | ||
2163 | 333 | found_first_running_app = true; | ||
2164 | 334 | icons.push_back(local::RUNNING_APPS_URI); | ||
2165 | 335 | } | ||
2166 | 336 | |||
2167 | 337 | if (!found_first_device && icon->GetIconType() == AbstractLauncherIcon::IconType::DEVICE) | ||
2168 | 338 | { | ||
2169 | 339 | found_first_device = true; | ||
2170 | 340 | icons.push_back(local::DEVICES_URI); | ||
2171 | 341 | } | ||
2172 | 342 | |||
2173 | 329 | continue; | 343 | continue; |
2179 | 330 | 344 | } | |
2180 | 331 | std::string const& desktop_file = icon->DesktopFile(); | 345 | |
2181 | 332 | 346 | std::string const& remote_uri = icon->RemoteUri(); | |
2182 | 333 | if (!desktop_file.empty()) | 347 | |
2183 | 334 | desktop_paths.push_back(desktop_file); | 348 | if (!remote_uri.empty()) |
2184 | 349 | icons.push_back(remote_uri); | ||
2185 | 335 | } | 350 | } |
2186 | 336 | 351 | ||
2188 | 337 | unity::FavoriteStore::Instance().SetFavorites(desktop_paths); | 352 | if (!found_first_running_app) |
2189 | 353 | AddFavoriteKeepingOldPosition(icons, local::RUNNING_APPS_URI); | ||
2190 | 354 | |||
2191 | 355 | if (!found_first_device) | ||
2192 | 356 | AddFavoriteKeepingOldPosition(icons, local::DEVICES_URI); | ||
2193 | 357 | |||
2194 | 358 | FavoriteStore::Instance().SetFavorites(icons); | ||
2195 | 338 | } | 359 | } |
2196 | 339 | 360 | ||
2197 | 340 | void | 361 | void |
2198 | @@ -345,64 +366,53 @@ | |||
2199 | 345 | int icon_y, | 366 | int icon_y, |
2200 | 346 | int icon_size) | 367 | int icon_size) |
2201 | 347 | { | 368 | { |
2202 | 348 | auto bamf_icons = model_->GetSublist<BamfLauncherIcon>(); | ||
2203 | 349 | for (auto icon : bamf_icons) | ||
2204 | 350 | { | ||
2205 | 351 | if (icon->DesktopFile() == path) | ||
2206 | 352 | return; | ||
2207 | 353 | } | ||
2208 | 354 | |||
2209 | 355 | // Check if desktop file was supplied, or if it's set to SC's agent | 369 | // Check if desktop file was supplied, or if it's set to SC's agent |
2210 | 356 | // See https://bugs.launchpad.net/unity/+bug/1002440 | 370 | // See https://bugs.launchpad.net/unity/+bug/1002440 |
2217 | 357 | if (path.empty() || path == "software-center-agent") | 371 | if (path.empty() || path == local::SOFTWARE_CENTER_AGENT) |
2218 | 358 | return; | 372 | return; |
2219 | 359 | 373 | ||
2220 | 360 | SoftwareCenterLauncherIcon::Ptr result = CreateSCLauncherIcon(path, aptdaemon_trans_id, icon_path); | 374 | auto const& icon = std::find_if(model_->begin(), model_->end(), |
2221 | 361 | 375 | [&path](AbstractLauncherIcon::Ptr const& i) { return (i->DesktopFile() == path); }); | |
2222 | 362 | CurrentLauncher()->ForceReveal(true); | 376 | |
2223 | 377 | if (icon != model_->end()) | ||
2224 | 378 | return; | ||
2225 | 379 | |||
2226 | 380 | auto const& result = CreateSCLauncherIcon(path, aptdaemon_trans_id, icon_path); | ||
2227 | 363 | 381 | ||
2228 | 364 | if (result) | 382 | if (result) |
2229 | 365 | { | 383 | { |
2234 | 366 | result->SetQuirk(AbstractLauncherIcon::Quirk::VISIBLE, false); | 384 | // Setting the icon position and adding it to the model, makes the launcher |
2235 | 367 | result->Animate(CurrentLauncher(), icon_x, icon_y, icon_size); | 385 | // to compute its center |
2236 | 368 | RegisterIcon(result); | 386 | RegisterIcon(result, GetLastIconPriority<BamfLauncherIcon>("", true)); |
2237 | 369 | Save(); | 387 | |
2238 | 388 | // This will ensure that the center of the new icon is set, so that | ||
2239 | 389 | // the animation could be done properly. | ||
2240 | 390 | sources_.AddIdle([this, icon_x, icon_y, result] { | ||
2241 | 391 | result->Animate(CurrentLauncher(), icon_x, icon_y); | ||
2242 | 392 | return false; | ||
2243 | 393 | }); | ||
2244 | 370 | } | 394 | } |
2245 | 371 | } | 395 | } |
2246 | 372 | 396 | ||
2247 | 373 | void Controller::Impl::OnSCIconAnimationComplete(AbstractLauncherIcon::Ptr icon) | ||
2248 | 374 | { | ||
2249 | 375 | icon->SetQuirk(AbstractLauncherIcon::Quirk::VISIBLE, true); | ||
2250 | 376 | launcher_->ForceReveal(false); | ||
2251 | 377 | } | ||
2252 | 378 | |||
2253 | 379 | void Controller::Impl::SortAndUpdate() | 397 | void Controller::Impl::SortAndUpdate() |
2254 | 380 | { | 398 | { |
2256 | 381 | gint shortcut = 1; | 399 | unsigned shortcut = 1; |
2257 | 382 | 400 | ||
2260 | 383 | auto launchers = model_->GetSublist<BamfLauncherIcon> (); | 401 | for (auto const& icon : model_->GetSublist<BamfLauncherIcon>()) |
2259 | 384 | for (auto icon : launchers) | ||
2261 | 385 | { | 402 | { |
2262 | 386 | if (shortcut <= 10 && icon->IsVisible()) | 403 | if (shortcut <= 10 && icon->IsVisible()) |
2263 | 387 | { | 404 | { |
2267 | 388 | std::stringstream shortcut_string; | 405 | icon->SetShortcut(std::to_string(shortcut % 10)[0]); |
2265 | 389 | shortcut_string << (shortcut % 10); | ||
2266 | 390 | icon->SetShortcut(shortcut_string.str()[0]); | ||
2268 | 391 | ++shortcut; | 406 | ++shortcut; |
2269 | 392 | } | 407 | } |
2270 | 393 | // reset shortcut | ||
2271 | 394 | else | 408 | else |
2272 | 395 | { | 409 | { |
2273 | 410 | // reset shortcut | ||
2274 | 396 | icon->SetShortcut(0); | 411 | icon->SetShortcut(0); |
2275 | 397 | } | 412 | } |
2276 | 398 | } | 413 | } |
2277 | 399 | } | 414 | } |
2278 | 400 | 415 | ||
2279 | 401 | void Controller::Impl::OnIconAdded(AbstractLauncherIcon::Ptr icon) | ||
2280 | 402 | { | ||
2281 | 403 | this->RegisterIcon(icon); | ||
2282 | 404 | } | ||
2283 | 405 | |||
2284 | 406 | void Controller::Impl::OnIconRemoved(AbstractLauncherIcon::Ptr icon) | 416 | void Controller::Impl::OnIconRemoved(AbstractLauncherIcon::Ptr icon) |
2285 | 407 | { | 417 | { |
2286 | 408 | SortAndUpdate(); | 418 | SortAndUpdate(); |
2287 | @@ -428,10 +438,13 @@ | |||
2288 | 428 | { | 438 | { |
2289 | 429 | auto device_icon = dynamic_cast<VolumeLauncherIcon*>(icon.GetPointer()); | 439 | auto device_icon = dynamic_cast<VolumeLauncherIcon*>(icon.GetPointer()); |
2290 | 430 | 440 | ||
2295 | 431 | if (device_icon && device_icon->CanEject()) | 441 | if (device_icon) |
2296 | 432 | device_icon->EjectAndShowNotification(); | 442 | { |
2297 | 433 | else if (device_icon && device_icon->CanStop()) | 443 | if (device_icon->CanEject()) |
2298 | 434 | device_icon->StopDrive(); | 444 | device_icon->EjectAndShowNotification(); |
2299 | 445 | else if (device_icon->CanStop()) | ||
2300 | 446 | device_icon->StopDrive(); | ||
2301 | 447 | } | ||
2302 | 435 | 448 | ||
2303 | 436 | break; | 449 | break; |
2304 | 437 | } | 450 | } |
2305 | @@ -442,63 +455,63 @@ | |||
2306 | 442 | 455 | ||
2307 | 443 | void Controller::Impl::OnLauncherEntryRemoteAdded(LauncherEntryRemote::Ptr const& entry) | 456 | void Controller::Impl::OnLauncherEntryRemoteAdded(LauncherEntryRemote::Ptr const& entry) |
2308 | 444 | { | 457 | { |
2319 | 445 | for (auto icon : *model_) | 458 | if (entry->AppUri().empty()) |
2320 | 446 | { | 459 | return; |
2321 | 447 | if (!icon || icon->RemoteUri().empty()) | 460 | |
2322 | 448 | continue; | 461 | auto const& apps_icons = model_->GetSublist<BamfLauncherIcon>(); |
2323 | 449 | 462 | auto const& icon = std::find_if(apps_icons.begin(), apps_icons.end(), | |
2324 | 450 | if (entry->AppUri() == icon->RemoteUri()) | 463 | [&entry](AbstractLauncherIcon::Ptr const& i) { return (i->RemoteUri() == entry->AppUri()); }); |
2325 | 451 | { | 464 | |
2326 | 452 | icon->InsertEntryRemote(entry); | 465 | if (icon != apps_icons.end()) |
2327 | 453 | } | 466 | (*icon)->InsertEntryRemote(entry); |
2318 | 454 | } | ||
2328 | 455 | } | 467 | } |
2329 | 456 | 468 | ||
2330 | 457 | void Controller::Impl::OnLauncherEntryRemoteRemoved(LauncherEntryRemote::Ptr const& entry) | 469 | void Controller::Impl::OnLauncherEntryRemoteRemoved(LauncherEntryRemote::Ptr const& entry) |
2331 | 458 | { | 470 | { |
2334 | 459 | for (auto icon : *model_) | 471 | for (auto const& icon : *model_) |
2333 | 460 | { | ||
2335 | 461 | icon->RemoveEntryRemote(entry); | 472 | icon->RemoveEntryRemote(entry); |
2336 | 462 | } | ||
2337 | 463 | } | 473 | } |
2338 | 464 | 474 | ||
2339 | 465 | void Controller::Impl::OnFavoriteStoreFavoriteAdded(std::string const& entry, std::string const& pos, bool before) | 475 | void Controller::Impl::OnFavoriteStoreFavoriteAdded(std::string const& entry, std::string const& pos, bool before) |
2340 | 466 | { | 476 | { |
2345 | 467 | auto bamf_list = model_->GetSublist<BamfLauncherIcon>(); | 477 | if (entry == local::RUNNING_APPS_URI || entry == local::DEVICES_URI) |
2346 | 468 | AbstractLauncherIcon::Ptr other; | 478 | { |
2347 | 469 | if (bamf_list.size() > 0) | 479 | // Since the running apps and the devices are always shown, when added to |
2348 | 470 | other = *(bamf_list.begin()); | 480 | // the model, we only have to re-order them |
2349 | 481 | ResetIconPriorities(); | ||
2350 | 482 | return; | ||
2351 | 483 | } | ||
2352 | 484 | |||
2353 | 485 | AbstractLauncherIcon::Ptr other = *(model_->begin()); | ||
2354 | 471 | 486 | ||
2355 | 472 | if (!pos.empty()) | 487 | if (!pos.empty()) |
2356 | 473 | { | 488 | { |
2358 | 474 | for (auto it : bamf_list) | 489 | for (auto const& it : *model_) |
2359 | 475 | { | 490 | { |
2361 | 476 | if (it->GetQuirk(AbstractLauncherIcon::Quirk::VISIBLE) && pos == it->DesktopFile()) | 491 | if (it->IsVisible() && pos == it->RemoteUri()) |
2362 | 477 | other = it; | 492 | other = it; |
2363 | 478 | } | 493 | } |
2364 | 479 | } | 494 | } |
2365 | 480 | 495 | ||
2367 | 481 | for (auto it : bamf_list) | 496 | AbstractLauncherIcon::Ptr const& fav = GetIconByUri(entry); |
2368 | 497 | if (fav) | ||
2369 | 482 | { | 498 | { |
2379 | 483 | if (entry == it->DesktopFile()) | 499 | fav->Stick(false); |
2380 | 484 | { | 500 | |
2381 | 485 | it->Stick(false); | 501 | if (before) |
2382 | 486 | if (!before) | 502 | model_->ReorderBefore(fav, other, false); |
2383 | 487 | model_->ReorderAfter(it, other); | 503 | else |
2384 | 488 | else | 504 | model_->ReorderAfter(fav, other); |
2376 | 489 | model_->ReorderBefore(it, other, false); | ||
2377 | 490 | return; | ||
2378 | 491 | } | ||
2385 | 492 | } | 505 | } |
2389 | 493 | 506 | else | |
2387 | 494 | AbstractLauncherIcon::Ptr result = CreateFavorite(entry.c_str()); | ||
2388 | 495 | if (result) | ||
2390 | 496 | { | 507 | { |
2391 | 508 | AbstractLauncherIcon::Ptr const& result = CreateFavoriteIcon(entry); | ||
2392 | 497 | RegisterIcon(result); | 509 | RegisterIcon(result); |
2394 | 498 | if (!before) | 510 | |
2395 | 511 | if (before) | ||
2396 | 512 | model_->ReorderBefore(result, other, false); | ||
2397 | 513 | else | ||
2398 | 499 | model_->ReorderAfter(result, other); | 514 | model_->ReorderAfter(result, other); |
2399 | 500 | else | ||
2400 | 501 | model_->ReorderBefore(result, other, false); | ||
2401 | 502 | } | 515 | } |
2402 | 503 | 516 | ||
2403 | 504 | SortAndUpdate(); | 517 | SortAndUpdate(); |
2404 | @@ -506,104 +519,132 @@ | |||
2405 | 506 | 519 | ||
2406 | 507 | void Controller::Impl::OnFavoriteStoreFavoriteRemoved(std::string const& entry) | 520 | void Controller::Impl::OnFavoriteStoreFavoriteRemoved(std::string const& entry) |
2407 | 508 | { | 521 | { |
2415 | 509 | for (auto icon : model_->GetSublist<BamfLauncherIcon> ()) | 522 | if (entry == local::RUNNING_APPS_URI || entry == local::DEVICES_URI) |
2416 | 510 | { | 523 | { |
2417 | 511 | if (icon->DesktopFile() == entry) | 524 | // Since the running apps and the devices are always shown, when added to |
2418 | 512 | { | 525 | // the model, we only have to re-order them |
2419 | 513 | icon->UnStick(); | 526 | ResetIconPriorities(); |
2420 | 514 | break; | 527 | return; |
2421 | 515 | } | 528 | } |
2422 | 529 | |||
2423 | 530 | auto const& icon = GetIconByUri(entry); | ||
2424 | 531 | if (icon) | ||
2425 | 532 | { | ||
2426 | 533 | icon->UnStick(); | ||
2427 | 534 | |||
2428 | 535 | // When devices are removed from favorites, they should be re-ordered (not removed) | ||
2429 | 536 | if (icon->GetIconType() == AbstractLauncherIcon::IconType::DEVICE) | ||
2430 | 537 | ResetIconPriorities(); | ||
2431 | 516 | } | 538 | } |
2432 | 517 | } | 539 | } |
2433 | 518 | 540 | ||
2435 | 519 | void Controller::Impl::OnFavoriteStoreReordered() | 541 | void Controller::Impl::ResetIconPriorities() |
2436 | 520 | { | 542 | { |
2437 | 521 | FavoriteList const& favs = FavoriteStore::Instance().GetFavorites(); | 543 | FavoriteList const& favs = FavoriteStore::Instance().GetFavorites(); |
2456 | 522 | auto bamf_list = model_->GetSublist<BamfLauncherIcon>(); | 544 | auto const& apps_icons = model_->GetSublist<BamfLauncherIcon>(); |
2457 | 523 | 545 | auto const& volumes_icons = model_->GetSublist<VolumeLauncherIcon>(); | |
2458 | 524 | int i = 0; | 546 | bool running_apps_found = false; |
2459 | 525 | for (auto it : favs) | 547 | bool volumes_found = false; |
2460 | 526 | { | 548 | |
2461 | 527 | auto icon = std::find_if(bamf_list.begin(), bamf_list.end(), | 549 | for (auto const& fav : favs) |
2462 | 528 | [&it](AbstractLauncherIcon::Ptr x) { return (x->DesktopFile() == it); }); | 550 | { |
2463 | 529 | 551 | if (fav == local::RUNNING_APPS_URI) | |
2464 | 530 | if (icon != bamf_list.end()) | 552 | { |
2465 | 531 | { | 553 | for (auto const& ico : apps_icons) |
2466 | 532 | (*icon)->SetSortPriority(i++); | 554 | { |
2467 | 533 | } | 555 | if (!ico->IsSticky()) |
2468 | 534 | } | 556 | ico->SetSortPriority(++sort_priority_); |
2469 | 535 | 557 | } | |
2470 | 536 | for (auto it : bamf_list) | 558 | |
2471 | 537 | { | 559 | running_apps_found = true; |
2472 | 538 | if (!it->IsSticky()) | 560 | continue; |
2473 | 539 | it->SetSortPriority(i++); | 561 | } |
2474 | 562 | else if (fav == local::DEVICES_URI) | ||
2475 | 563 | { | ||
2476 | 564 | for (auto const& ico : volumes_icons) | ||
2477 | 565 | { | ||
2478 | 566 | if (!ico->IsSticky()) | ||
2479 | 567 | ico->SetSortPriority(++sort_priority_); | ||
2480 | 568 | } | ||
2481 | 569 | |||
2482 | 570 | volumes_found = true; | ||
2483 | 571 | continue; | ||
2484 | 572 | } | ||
2485 | 573 | |||
2486 | 574 | auto const& icon = GetIconByUri(fav); | ||
2487 | 575 | |||
2488 | 576 | if (icon) | ||
2489 | 577 | icon->SetSortPriority(++sort_priority_); | ||
2490 | 578 | } | ||
2491 | 579 | |||
2492 | 580 | if (!running_apps_found) | ||
2493 | 581 | { | ||
2494 | 582 | for (auto const& ico : apps_icons) | ||
2495 | 583 | { | ||
2496 | 584 | if (!ico->IsSticky()) | ||
2497 | 585 | ico->SetSortPriority(++sort_priority_); | ||
2498 | 586 | } | ||
2499 | 587 | } | ||
2500 | 588 | |||
2501 | 589 | if (!volumes_found) | ||
2502 | 590 | { | ||
2503 | 591 | for (auto const& ico : volumes_icons) | ||
2504 | 592 | { | ||
2505 | 593 | if (!ico->IsSticky()) | ||
2506 | 594 | ico->SetSortPriority(++sort_priority_); | ||
2507 | 595 | } | ||
2508 | 540 | } | 596 | } |
2509 | 541 | 597 | ||
2510 | 542 | model_->Sort(); | 598 | model_->Sort(); |
2511 | 543 | } | 599 | } |
2512 | 544 | 600 | ||
2513 | 545 | void Controller::Impl::OnExpoActivated() | ||
2514 | 546 | { | ||
2515 | 547 | WindowManager::Default()->InitiateExpo(); | ||
2516 | 548 | } | ||
2517 | 549 | |||
2518 | 550 | void Controller::Impl::InsertTrash() | ||
2519 | 551 | { | ||
2520 | 552 | AbstractLauncherIcon::Ptr icon(new TrashLauncherIcon()); | ||
2521 | 553 | RegisterIcon(icon); | ||
2522 | 554 | } | ||
2523 | 555 | |||
2524 | 556 | void Controller::Impl::UpdateNumWorkspaces(int workspaces) | 601 | void Controller::Impl::UpdateNumWorkspaces(int workspaces) |
2525 | 557 | { | 602 | { |
2574 | 558 | if ((num_workspaces_ == 0) && (workspaces > 0)) | 603 | bool visible = expo_icon_->IsVisible(); |
2575 | 559 | { | 604 | bool wp_enabled = (workspaces > 1); |
2576 | 560 | InsertExpoAction(); | 605 | |
2577 | 561 | } | 606 | if (wp_enabled && !visible) |
2578 | 562 | else if ((num_workspaces_ > 0) && (workspaces == 0)) | 607 | { |
2579 | 563 | { | 608 | if (FavoriteStore::Instance().IsFavorite(expo_icon_->RemoteUri())) |
2580 | 564 | RemoveExpoAction(); | 609 | { |
2581 | 565 | } | 610 | expo_icon_->SetQuirk(AbstractLauncherIcon::Quirk::VISIBLE, true); |
2582 | 566 | 611 | } | |
2583 | 567 | num_workspaces_ = workspaces; | 612 | } |
2584 | 568 | } | 613 | else if (!wp_enabled && visible) |
2585 | 569 | 614 | { | |
2586 | 570 | void Controller::Impl::InsertExpoAction() | 615 | expo_icon_->SetQuirk(AbstractLauncherIcon::Quirk::VISIBLE, false); |
2587 | 571 | { | 616 | } |
2588 | 572 | expo_icon_ = AbstractLauncherIcon::Ptr(new SimpleLauncherIcon(AbstractLauncherIcon::IconType::EXPO)); | 617 | } |
2589 | 573 | 618 | ||
2590 | 574 | SimpleLauncherIcon* icon = static_cast<SimpleLauncherIcon*>(expo_icon_.GetPointer()); | 619 | void Controller::Impl::RegisterIcon(AbstractLauncherIcon::Ptr icon, int priority) |
2591 | 575 | icon->tooltip_text = _("Workspace Switcher"); | 620 | { |
2592 | 576 | icon->icon_name = "workspace-switcher"; | 621 | if (!icon || model_->IconIndex(icon) >= 0) |
2593 | 577 | icon->SetQuirk(AbstractLauncherIcon::Quirk::VISIBLE, true); | 622 | return; |
2594 | 578 | icon->SetQuirk(AbstractLauncherIcon::Quirk::RUNNING, false); | 623 | |
2595 | 579 | icon->SetShortcut('s'); | 624 | if (priority != std::numeric_limits<int>::min()) |
2596 | 580 | 625 | icon->SetSortPriority(priority); | |
2597 | 581 | on_expoicon_activate_connection_ = icon->activate.connect(sigc::mem_fun(this, &Impl::OnExpoActivated)); | 626 | |
2598 | 582 | 627 | icon->position_saved.connect([this] { | |
2599 | 583 | 628 | // These calls must be done in order: first we save the new sticky icons | |
2600 | 584 | RegisterIcon(expo_icon_); | 629 | // then we re-order the model so that there won't be two icons with the same |
2601 | 585 | } | 630 | // priority |
2602 | 586 | 631 | SaveIconsOrder(); | |
2603 | 587 | void Controller::Impl::RemoveExpoAction() | 632 | ResetIconPriorities(); |
2604 | 588 | { | 633 | }); |
2605 | 589 | if (on_expoicon_activate_connection_) | 634 | |
2606 | 590 | on_expoicon_activate_connection_.disconnect(); | 635 | std::string const& icon_uri = icon->RemoteUri(); |
2607 | 591 | model_->RemoveIcon(expo_icon_); | 636 | icon->position_forgot.connect([this, icon_uri] { |
2608 | 592 | } | 637 | FavoriteStore::Instance().RemoveFavorite(icon_uri); |
2609 | 593 | 638 | }); | |
2610 | 594 | void Controller::Impl::InsertDesktopIcon() | 639 | |
2611 | 595 | { | 640 | if (icon->GetIconType() == AbstractLauncherIcon::IconType::APPLICATION) |
2612 | 596 | RegisterIcon(desktop_icon_); | 641 | { |
2613 | 597 | } | 642 | icon->visibility_changed.connect(sigc::mem_fun(this, &Impl::SortAndUpdate)); |
2614 | 598 | 643 | SortAndUpdate(); | |
2615 | 599 | void Controller::Impl::RemoveDesktopIcon() | 644 | } |
2616 | 600 | { | 645 | |
2569 | 601 | model_->RemoveIcon(desktop_icon_); | ||
2570 | 602 | } | ||
2571 | 603 | |||
2572 | 604 | void Controller::Impl::RegisterIcon(AbstractLauncherIcon::Ptr icon) | ||
2573 | 605 | { | ||
2617 | 606 | model_->AddIcon(icon); | 646 | model_->AddIcon(icon); |
2618 | 647 | |||
2619 | 607 | std::string const& path = icon->DesktopFile(); | 648 | std::string const& path = icon->DesktopFile(); |
2620 | 608 | 649 | ||
2621 | 609 | if (!path.empty()) | 650 | if (!path.empty()) |
2622 | @@ -615,7 +656,59 @@ | |||
2623 | 615 | } | 656 | } |
2624 | 616 | } | 657 | } |
2625 | 617 | 658 | ||
2627 | 618 | /* static private */ | 659 | template<typename IconType> |
2628 | 660 | int Controller::Impl::GetLastIconPriority(std::string const& favorite_uri, bool sticky) | ||
2629 | 661 | { | ||
2630 | 662 | auto const& icons = model_->GetSublist<IconType>(); | ||
2631 | 663 | int icon_prio = std::numeric_limits<int>::min(); | ||
2632 | 664 | |||
2633 | 665 | AbstractLauncherIcon::Ptr last_icon; | ||
2634 | 666 | |||
2635 | 667 | // Get the last (non)-sticky icon position (if available) | ||
2636 | 668 | for (auto it = icons.rbegin(); it != icons.rend(); ++it) | ||
2637 | 669 | { | ||
2638 | 670 | auto const& icon = *it; | ||
2639 | 671 | bool update_last_icon = ((!last_icon && !sticky) || sticky); | ||
2640 | 672 | |||
2641 | 673 | if (update_last_icon || icon->IsSticky() == sticky) | ||
2642 | 674 | { | ||
2643 | 675 | last_icon = icon; | ||
2644 | 676 | |||
2645 | 677 | if (icon->IsSticky() == sticky) | ||
2646 | 678 | break; | ||
2647 | 679 | } | ||
2648 | 680 | } | ||
2649 | 681 | |||
2650 | 682 | if (last_icon) | ||
2651 | 683 | { | ||
2652 | 684 | icon_prio = last_icon->SortPriority(); | ||
2653 | 685 | |||
2654 | 686 | if (sticky && last_icon->IsSticky() != sticky) | ||
2655 | 687 | icon_prio -= 1; | ||
2656 | 688 | } | ||
2657 | 689 | else if (!favorite_uri.empty()) | ||
2658 | 690 | { | ||
2659 | 691 | // If we have no applications opened, we must guess it position by favorites | ||
2660 | 692 | for (auto const& fav : FavoriteStore::Instance().GetFavorites()) | ||
2661 | 693 | { | ||
2662 | 694 | if (fav == favorite_uri) | ||
2663 | 695 | { | ||
2664 | 696 | if (icon_prio == std::numeric_limits<int>::min()) | ||
2665 | 697 | icon_prio = (*model_->begin())->SortPriority() - 1; | ||
2666 | 698 | |||
2667 | 699 | break; | ||
2668 | 700 | } | ||
2669 | 701 | |||
2670 | 702 | auto const& icon = GetIconByUri(fav); | ||
2671 | 703 | |||
2672 | 704 | if (icon) | ||
2673 | 705 | icon_prio = icon->SortPriority(); | ||
2674 | 706 | } | ||
2675 | 707 | } | ||
2676 | 708 | |||
2677 | 709 | return icon_prio; | ||
2678 | 710 | } | ||
2679 | 711 | |||
2680 | 619 | void Controller::Impl::OnViewOpened(BamfMatcher* matcher, BamfView* view) | 712 | void Controller::Impl::OnViewOpened(BamfMatcher* matcher, BamfView* view) |
2681 | 620 | { | 713 | { |
2682 | 621 | if (!BAMF_IS_APPLICATION(view)) | 714 | if (!BAMF_IS_APPLICATION(view)) |
2683 | @@ -630,35 +723,111 @@ | |||
2684 | 630 | } | 723 | } |
2685 | 631 | 724 | ||
2686 | 632 | AbstractLauncherIcon::Ptr icon(new BamfLauncherIcon(app)); | 725 | AbstractLauncherIcon::Ptr icon(new BamfLauncherIcon(app)); |
2696 | 633 | icon->visibility_changed.connect(sigc::mem_fun(this, &Impl::SortAndUpdate)); | 726 | RegisterIcon(icon, GetLastIconPriority<BamfLauncherIcon>(local::RUNNING_APPS_URI)); |
2697 | 634 | icon->SetSortPriority(sort_priority_++); | 727 | } |
2698 | 635 | RegisterIcon(icon); | 728 | |
2699 | 636 | SortAndUpdate(); | 729 | void Controller::Impl::OnDeviceIconAdded(AbstractLauncherIcon::Ptr icon) |
2700 | 637 | } | 730 | { |
2701 | 638 | 731 | RegisterIcon(icon, GetLastIconPriority<VolumeLauncherIcon>(local::DEVICES_URI)); | |
2702 | 639 | AbstractLauncherIcon::Ptr Controller::Impl::CreateFavorite(const char* file_path) | 732 | } |
2703 | 640 | { | 733 | |
2704 | 641 | BamfApplication* app; | 734 | AbstractLauncherIcon::Ptr Controller::Impl::CreateFavoriteIcon(std::string const& icon_uri) |
2705 | 735 | { | ||
2706 | 642 | AbstractLauncherIcon::Ptr result; | 736 | AbstractLauncherIcon::Ptr result; |
2707 | 643 | 737 | ||
2722 | 644 | app = bamf_matcher_get_application_for_desktop_file(matcher_, file_path, true); | 738 | if (!FavoriteStore::IsValidFavoriteUri(icon_uri)) |
2723 | 645 | if (!app) | 739 | { |
2724 | 646 | return result; | 740 | LOG_WARNING(logger) << "Ignoring favorite '" << icon_uri << "'."; |
2725 | 647 | 741 | return result; | |
2726 | 648 | if (g_object_get_qdata(G_OBJECT(app), g_quark_from_static_string("unity-seen"))) | 742 | } |
2727 | 649 | { | 743 | |
2728 | 650 | bamf_view_set_sticky(BAMF_VIEW(app), true); | 744 | std::string desktop_id; |
2729 | 651 | return result; | 745 | |
2730 | 652 | } | 746 | if (icon_uri.find(FavoriteStore::URI_PREFIX_APP) == 0) |
2731 | 653 | 747 | { | |
2732 | 654 | bamf_view_set_sticky(BAMF_VIEW(app), true); | 748 | desktop_id = icon_uri.substr(FavoriteStore::URI_PREFIX_APP.size()); |
2733 | 655 | AbstractLauncherIcon::Ptr icon (new BamfLauncherIcon(app)); | 749 | } |
2734 | 656 | icon->SetSortPriority(sort_priority_++); | 750 | else if (icon_uri.find(FavoriteStore::URI_PREFIX_FILE) == 0) |
2735 | 657 | result = icon; | 751 | { |
2736 | 752 | desktop_id = icon_uri.substr(FavoriteStore::URI_PREFIX_FILE.size()); | ||
2737 | 753 | } | ||
2738 | 754 | |||
2739 | 755 | if (!desktop_id.empty()) | ||
2740 | 756 | { | ||
2741 | 757 | BamfApplication* app; | ||
2742 | 758 | std::string const& desktop_path = DesktopUtilities::GetDesktopPathById(desktop_id); | ||
2743 | 759 | |||
2744 | 760 | app = bamf_matcher_get_application_for_desktop_file(matcher_, desktop_path.c_str(), true); | ||
2745 | 761 | |||
2746 | 762 | if (!app) | ||
2747 | 763 | return result; | ||
2748 | 764 | |||
2749 | 765 | if (g_object_get_qdata(G_OBJECT(app), g_quark_from_static_string("unity-seen"))) | ||
2750 | 766 | { | ||
2751 | 767 | bamf_view_set_sticky(BAMF_VIEW(app), true); | ||
2752 | 768 | return result; | ||
2753 | 769 | } | ||
2754 | 770 | |||
2755 | 771 | result = AbstractLauncherIcon::Ptr(new BamfLauncherIcon(app)); | ||
2756 | 772 | } | ||
2757 | 773 | else if (icon_uri.find(FavoriteStore::URI_PREFIX_DEVICE) == 0) | ||
2758 | 774 | { | ||
2759 | 775 | auto const& devices = device_section_.GetIcons(); | ||
2760 | 776 | auto const& icon = std::find_if(devices.begin(), devices.end(), | ||
2761 | 777 | [&icon_uri](AbstractLauncherIcon::Ptr const& i) { return (i->RemoteUri() == icon_uri); }); | ||
2762 | 778 | |||
2763 | 779 | if (icon == devices.end()) | ||
2764 | 780 | { | ||
2765 | 781 | // Using an idle to remove the favorite, not to erase while iterating | ||
2766 | 782 | sources_.AddIdle([this, icon_uri] { | ||
2767 | 783 | FavoriteStore::Instance().RemoveFavorite(icon_uri); | ||
2768 | 784 | return false; | ||
2769 | 785 | }); | ||
2770 | 786 | |||
2771 | 787 | return result; | ||
2772 | 788 | } | ||
2773 | 789 | |||
2774 | 790 | result = *icon; | ||
2775 | 791 | } | ||
2776 | 792 | else if (desktop_icon_->RemoteUri() == icon_uri) | ||
2777 | 793 | { | ||
2778 | 794 | result = desktop_icon_; | ||
2779 | 795 | } | ||
2780 | 796 | else if (expo_icon_->RemoteUri() == icon_uri) | ||
2781 | 797 | { | ||
2782 | 798 | result = expo_icon_; | ||
2783 | 799 | } | ||
2784 | 800 | |||
2785 | 801 | if (result) | ||
2786 | 802 | { | ||
2787 | 803 | if (!result->IsSticky()) | ||
2788 | 804 | result->Stick(false); | ||
2789 | 805 | else | ||
2790 | 806 | { | ||
2791 | 807 | LOG_ERROR(logger) << "Ignoring favorite '" << icon_uri << "': it's already on the launcher!"; | ||
2792 | 808 | result = nullptr; | ||
2793 | 809 | } | ||
2794 | 810 | } | ||
2795 | 658 | 811 | ||
2796 | 659 | return result; | 812 | return result; |
2797 | 660 | } | 813 | } |
2798 | 661 | 814 | ||
2799 | 815 | AbstractLauncherIcon::Ptr Controller::Impl::GetIconByUri(std::string const& icon_uri) | ||
2800 | 816 | { | ||
2801 | 817 | if (icon_uri.empty()) | ||
2802 | 818 | return AbstractLauncherIcon::Ptr(); | ||
2803 | 819 | |||
2804 | 820 | auto const& icon = std::find_if(model_->begin(), model_->end(), | ||
2805 | 821 | [&icon_uri](AbstractLauncherIcon::Ptr const& i) { return (i->RemoteUri() == icon_uri); }); | ||
2806 | 822 | |||
2807 | 823 | if (icon != model_->end()) | ||
2808 | 824 | { | ||
2809 | 825 | return *icon; | ||
2810 | 826 | } | ||
2811 | 827 | |||
2812 | 828 | return AbstractLauncherIcon::Ptr(); | ||
2813 | 829 | } | ||
2814 | 830 | |||
2815 | 662 | SoftwareCenterLauncherIcon::Ptr Controller::Impl::CreateSCLauncherIcon(std::string const& file_path, | 831 | SoftwareCenterLauncherIcon::Ptr Controller::Impl::CreateSCLauncherIcon(std::string const& file_path, |
2816 | 663 | std::string const& aptdaemon_trans_id, | 832 | std::string const& aptdaemon_trans_id, |
2817 | 664 | std::string const& icon_path) | 833 | std::string const& icon_path) |
2818 | @@ -678,50 +847,79 @@ | |||
2819 | 678 | 847 | ||
2820 | 679 | bamf_view_set_sticky(BAMF_VIEW(app), true); | 848 | bamf_view_set_sticky(BAMF_VIEW(app), true); |
2821 | 680 | result = new SoftwareCenterLauncherIcon(app, aptdaemon_trans_id, icon_path); | 849 | result = new SoftwareCenterLauncherIcon(app, aptdaemon_trans_id, icon_path); |
2822 | 681 | result->SetSortPriority(sort_priority_++); | ||
2823 | 682 | 850 | ||
2824 | 683 | return result; | 851 | return result; |
2825 | 684 | } | 852 | } |
2826 | 685 | 853 | ||
2847 | 686 | void Controller::Impl::SetupBamf() | 854 | void Controller::Impl::AddRunningApps() |
2848 | 687 | { | 855 | { |
2849 | 688 | GList* apps, *l; | 856 | std::shared_ptr<GList> apps(bamf_matcher_get_applications(matcher_), g_list_free); |
2850 | 689 | BamfApplication* app; | 857 | |
2851 | 690 | 858 | for (GList *l = apps.get(); l; l = l->next) | |
2852 | 691 | FavoriteList const& favs = FavoriteStore::Instance().GetFavorites(); | 859 | { |
2853 | 692 | 860 | if (!BAMF_IS_APPLICATION(l->data)) | |
2854 | 693 | for (FavoriteList::const_iterator i = favs.begin(), end = favs.end(); | 861 | continue; |
2855 | 694 | i != end; ++i) | 862 | |
2856 | 695 | { | 863 | BamfApplication* app = BAMF_APPLICATION(l->data); |
2857 | 696 | AbstractLauncherIcon::Ptr fav = CreateFavorite(i->c_str()); | 864 | |
2858 | 697 | 865 | if (g_object_get_qdata(G_OBJECT(app), g_quark_from_static_string("unity-seen"))) | |
2859 | 698 | if (fav) | 866 | continue; |
2860 | 699 | { | 867 | |
2861 | 700 | fav->SetSortPriority(sort_priority_++); | 868 | AbstractLauncherIcon::Ptr icon(new BamfLauncherIcon(app)); |
2862 | 701 | RegisterIcon(fav); | 869 | RegisterIcon(icon, ++sort_priority_); |
2863 | 702 | } | 870 | } |
2864 | 703 | } | 871 | } |
2865 | 704 | 872 | ||
2866 | 705 | apps = bamf_matcher_get_applications(matcher_); | 873 | void Controller::Impl::AddDevices() |
2867 | 874 | { | ||
2868 | 875 | auto& fav_store = FavoriteStore::Instance(); | ||
2869 | 876 | for (auto const& icon : device_section_.GetIcons()) | ||
2870 | 877 | { | ||
2871 | 878 | if (!icon->IsSticky() && !fav_store.IsFavorite(icon->RemoteUri())) | ||
2872 | 879 | RegisterIcon(icon, ++sort_priority_); | ||
2873 | 880 | } | ||
2874 | 881 | } | ||
2875 | 882 | |||
2876 | 883 | void Controller::Impl::SetupIcons() | ||
2877 | 884 | { | ||
2878 | 885 | auto& favorite_store = FavoriteStore::Instance(); | ||
2879 | 886 | FavoriteList const& favs = favorite_store.GetFavorites(); | ||
2880 | 887 | bool running_apps_added = false; | ||
2881 | 888 | bool devices_added = false; | ||
2882 | 889 | |||
2883 | 890 | for (auto const& fav_uri : favs) | ||
2884 | 891 | { | ||
2885 | 892 | if (fav_uri == local::RUNNING_APPS_URI) | ||
2886 | 893 | { | ||
2887 | 894 | AddRunningApps(); | ||
2888 | 895 | running_apps_added = true; | ||
2889 | 896 | continue; | ||
2890 | 897 | } | ||
2891 | 898 | else if (fav_uri == local::DEVICES_URI) | ||
2892 | 899 | { | ||
2893 | 900 | AddDevices(); | ||
2894 | 901 | devices_added = true; | ||
2895 | 902 | continue; | ||
2896 | 903 | } | ||
2897 | 904 | |||
2898 | 905 | RegisterIcon(CreateFavoriteIcon(fav_uri), ++sort_priority_); | ||
2899 | 906 | } | ||
2900 | 907 | |||
2901 | 908 | if (!running_apps_added) | ||
2902 | 909 | AddRunningApps(); | ||
2903 | 910 | |||
2904 | 911 | if (!devices_added) | ||
2905 | 912 | AddDevices(); | ||
2906 | 913 | |||
2907 | 706 | view_opened_signal_.Connect(matcher_, "view-opened", sigc::mem_fun(this, &Impl::OnViewOpened)); | 914 | view_opened_signal_.Connect(matcher_, "view-opened", sigc::mem_fun(this, &Impl::OnViewOpened)); |
2922 | 707 | 915 | device_section_.icon_added.connect(sigc::mem_fun(this, &Impl::OnDeviceIconAdded)); | |
2923 | 708 | for (l = apps; l; l = l->next) | 916 | favorite_store.favorite_added.connect(sigc::mem_fun(this, &Impl::OnFavoriteStoreFavoriteAdded)); |
2924 | 709 | { | 917 | favorite_store.favorite_removed.connect(sigc::mem_fun(this, &Impl::OnFavoriteStoreFavoriteRemoved)); |
2925 | 710 | app = BAMF_APPLICATION(l->data); | 918 | favorite_store.reordered.connect(sigc::mem_fun(this, &Impl::ResetIconPriorities)); |
2912 | 711 | |||
2913 | 712 | if (g_object_get_qdata(G_OBJECT(app), g_quark_from_static_string("unity-seen"))) | ||
2914 | 713 | continue; | ||
2915 | 714 | |||
2916 | 715 | AbstractLauncherIcon::Ptr icon(new BamfLauncherIcon(app)); | ||
2917 | 716 | icon->SetSortPriority(sort_priority_++); | ||
2918 | 717 | RegisterIcon(icon); | ||
2919 | 718 | } | ||
2920 | 719 | g_list_free(apps); | ||
2921 | 720 | SortAndUpdate(); | ||
2926 | 721 | 919 | ||
2927 | 722 | model_->order_changed.connect(sigc::mem_fun(this, &Impl::SortAndUpdate)); | 920 | model_->order_changed.connect(sigc::mem_fun(this, &Impl::SortAndUpdate)); |
2928 | 723 | model_->icon_removed.connect(sigc::mem_fun(this, &Impl::OnIconRemoved)); | 921 | model_->icon_removed.connect(sigc::mem_fun(this, &Impl::OnIconRemoved)); |
2930 | 724 | model_->saved.connect(sigc::mem_fun(this, &Impl::Save)); | 922 | model_->saved.connect(sigc::mem_fun(this, &Impl::SaveIconsOrder)); |
2931 | 725 | } | 923 | } |
2932 | 726 | 924 | ||
2933 | 727 | void Controller::Impl::SendHomeActivationRequest() | 925 | void Controller::Impl::SendHomeActivationRequest() |
2934 | @@ -729,10 +927,10 @@ | |||
2935 | 729 | ubus.SendMessage(UBUS_PLACE_ENTRY_ACTIVATE_REQUEST, g_variant_new("(sus)", "home.lens", dash::NOT_HANDLED, "")); | 927 | ubus.SendMessage(UBUS_PLACE_ENTRY_ACTIVATE_REQUEST, g_variant_new("(sus)", "home.lens", dash::NOT_HANDLED, "")); |
2936 | 730 | } | 928 | } |
2937 | 731 | 929 | ||
2939 | 732 | Controller::Controller(Display* display) | 930 | Controller::Controller() |
2940 | 733 | : options(Options::Ptr(new Options())) | 931 | : options(Options::Ptr(new Options())) |
2941 | 734 | , multiple_launchers(true) | 932 | , multiple_launchers(true) |
2943 | 735 | , pimpl(new Impl(display, this)) | 933 | , pimpl(new Impl(this)) |
2944 | 736 | { | 934 | { |
2945 | 737 | multiple_launchers.changed.connect([&](bool value) -> void { | 935 | multiple_launchers.changed.connect([&](bool value) -> void { |
2946 | 738 | UScreen* uscreen = UScreen::GetDefault(); | 936 | UScreen* uscreen = UScreen::GetDefault(); |
2947 | @@ -814,19 +1012,6 @@ | |||
2948 | 814 | pimpl->launcher_->GetParent()->PushToFront(); | 1012 | pimpl->launcher_->GetParent()->PushToFront(); |
2949 | 815 | } | 1013 | } |
2950 | 816 | 1014 | ||
2951 | 817 | void Controller::SetShowDesktopIcon(bool show_desktop_icon) | ||
2952 | 818 | { | ||
2953 | 819 | if (pimpl->show_desktop_icon_ == show_desktop_icon) | ||
2954 | 820 | return; | ||
2955 | 821 | |||
2956 | 822 | pimpl->show_desktop_icon_ = show_desktop_icon; | ||
2957 | 823 | |||
2958 | 824 | if (pimpl->show_desktop_icon_) | ||
2959 | 825 | pimpl->InsertDesktopIcon(); | ||
2960 | 826 | else | ||
2961 | 827 | pimpl->RemoveDesktopIcon(); | ||
2962 | 828 | } | ||
2963 | 829 | |||
2964 | 830 | int Controller::Impl::MonitorWithMouse() | 1015 | int Controller::Impl::MonitorWithMouse() |
2965 | 831 | { | 1016 | { |
2966 | 832 | UScreen* uscreen = UScreen::GetDefault(); | 1017 | UScreen* uscreen = UScreen::GetDefault(); |
2967 | @@ -1110,7 +1295,7 @@ | |||
2968 | 1110 | timespec current; | 1295 | timespec current; |
2969 | 1111 | clock_gettime(CLOCK_MONOTONIC, ¤t); | 1296 | clock_gettime(CLOCK_MONOTONIC, ¤t); |
2970 | 1112 | 1297 | ||
2972 | 1113 | unity::variant::BuilderWrapper(builder) | 1298 | variant::BuilderWrapper(builder) |
2973 | 1114 | .add("key_nav_is_active", KeyNavIsActive()) | 1299 | .add("key_nav_is_active", KeyNavIsActive()) |
2974 | 1115 | .add("key_nav_launcher_monitor", pimpl->keyboard_launcher_.IsValid() ? pimpl->keyboard_launcher_->monitor : -1) | 1300 | .add("key_nav_launcher_monitor", pimpl->keyboard_launcher_.IsValid() ? pimpl->keyboard_launcher_->monitor : -1) |
2975 | 1116 | .add("key_nav_selection", pimpl->model_->SelectionIndex()) | 1301 | .add("key_nav_selection", pimpl->model_->SelectionIndex()) |
2976 | 1117 | 1302 | ||
2977 | === modified file 'launcher/LauncherController.h' | |||
2978 | --- launcher/LauncherController.h 2012-08-11 09:16:21 +0000 | |||
2979 | +++ launcher/LauncherController.h 2012-09-18 15:52:46 +0000 | |||
2980 | @@ -47,7 +47,7 @@ | |||
2981 | 47 | nux::Property<Options::Ptr> options; | 47 | nux::Property<Options::Ptr> options; |
2982 | 48 | nux::Property<bool> multiple_launchers; | 48 | nux::Property<bool> multiple_launchers; |
2983 | 49 | 49 | ||
2985 | 50 | Controller(Display* display); | 50 | Controller(); |
2986 | 51 | ~Controller(); | 51 | ~Controller(); |
2987 | 52 | 52 | ||
2988 | 53 | Launcher& launcher() const; | 53 | Launcher& launcher() const; |
2989 | @@ -61,8 +61,6 @@ | |||
2990 | 61 | 61 | ||
2991 | 62 | void PushToFront(); | 62 | void PushToFront(); |
2992 | 63 | 63 | ||
2993 | 64 | void SetShowDesktopIcon(bool show_desktop_icon); | ||
2994 | 65 | |||
2995 | 66 | bool AboutToShowDash(int was_tap, int when) const; | 64 | bool AboutToShowDash(int was_tap, int when) const; |
2996 | 67 | 65 | ||
2997 | 68 | void HandleLauncherKeyPress(int when); | 66 | void HandleLauncherKeyPress(int when); |
2998 | 69 | 67 | ||
2999 | === modified file 'launcher/LauncherControllerPrivate.h' | |||
3000 | --- launcher/LauncherControllerPrivate.h 2012-08-17 13:07:53 +0000 | |||
3001 | +++ launcher/LauncherControllerPrivate.h 2012-09-18 15:52:46 +0000 | |||
3002 | @@ -46,59 +46,53 @@ | |||
3003 | 46 | class Controller::Impl | 46 | class Controller::Impl |
3004 | 47 | { | 47 | { |
3005 | 48 | public: | 48 | public: |
3007 | 49 | Impl(Display* display, Controller* parent); | 49 | Impl(Controller* parent); |
3008 | 50 | ~Impl(); | 50 | ~Impl(); |
3009 | 51 | 51 | ||
3010 | 52 | void UpdateNumWorkspaces(int workspaces); | 52 | void UpdateNumWorkspaces(int workspaces); |
3011 | 53 | 53 | ||
3012 | 54 | Launcher* CreateLauncher(int monitor); | 54 | Launcher* CreateLauncher(int monitor); |
3013 | 55 | 55 | ||
3015 | 56 | void Save(); | 56 | void SaveIconsOrder(); |
3016 | 57 | void SortAndUpdate(); | 57 | void SortAndUpdate(); |
3017 | 58 | 58 | ||
3018 | 59 | nux::ObjectPtr<Launcher> CurrentLauncher(); | 59 | nux::ObjectPtr<Launcher> CurrentLauncher(); |
3019 | 60 | 60 | ||
3021 | 61 | void OnIconAdded(AbstractLauncherIcon::Ptr icon); | 61 | template<typename IconType> |
3022 | 62 | int GetLastIconPriority(std::string const& favorite_uri = "", bool sticky = false); | ||
3023 | 63 | void AddFavoriteKeepingOldPosition(FavoriteList& icons, std::string const& icon_uri) const; | ||
3024 | 64 | |||
3025 | 62 | void OnIconRemoved(AbstractLauncherIcon::Ptr icon); | 65 | void OnIconRemoved(AbstractLauncherIcon::Ptr icon); |
3026 | 66 | void OnDeviceIconAdded(AbstractLauncherIcon::Ptr icon); | ||
3027 | 63 | 67 | ||
3029 | 64 | void OnLauncherAddRequest(char* path, AbstractLauncherIcon::Ptr before); | 68 | void OnLauncherAddRequest(std::string const& icon_uri, AbstractLauncherIcon::Ptr before); |
3030 | 65 | void OnLauncherAddRequestSpecial(std::string const& path, std::string const& aptdaemon_trans_id, | 69 | void OnLauncherAddRequestSpecial(std::string const& path, std::string const& aptdaemon_trans_id, |
3031 | 66 | std::string const& icon_path, int icon_x, int icon_y, int icon_size); | 70 | std::string const& icon_path, int icon_x, int icon_y, int icon_size); |
3032 | 67 | void OnLauncherRemoveRequest(AbstractLauncherIcon::Ptr icon); | 71 | void OnLauncherRemoveRequest(AbstractLauncherIcon::Ptr icon); |
3033 | 68 | void OnSCIconAnimationComplete(AbstractLauncherIcon::Ptr icon); | ||
3034 | 69 | 72 | ||
3035 | 70 | void OnLauncherEntryRemoteAdded(LauncherEntryRemote::Ptr const& entry); | 73 | void OnLauncherEntryRemoteAdded(LauncherEntryRemote::Ptr const& entry); |
3036 | 71 | void OnLauncherEntryRemoteRemoved(LauncherEntryRemote::Ptr const& entry); | 74 | void OnLauncherEntryRemoteRemoved(LauncherEntryRemote::Ptr const& entry); |
3037 | 72 | 75 | ||
3038 | 73 | void OnFavoriteStoreFavoriteAdded(std::string const& entry, std::string const& pos, bool before); | 76 | void OnFavoriteStoreFavoriteAdded(std::string const& entry, std::string const& pos, bool before); |
3039 | 74 | void OnFavoriteStoreFavoriteRemoved(std::string const& entry); | 77 | void OnFavoriteStoreFavoriteRemoved(std::string const& entry); |
3048 | 75 | void OnFavoriteStoreReordered(); | 78 | void ResetIconPriorities(); |
3041 | 76 | |||
3042 | 77 | |||
3043 | 78 | void InsertExpoAction(); | ||
3044 | 79 | void RemoveExpoAction(); | ||
3045 | 80 | |||
3046 | 81 | void InsertDesktopIcon(); | ||
3047 | 82 | void RemoveDesktopIcon(); | ||
3049 | 83 | 79 | ||
3050 | 84 | void SendHomeActivationRequest(); | 80 | void SendHomeActivationRequest(); |
3051 | 85 | 81 | ||
3052 | 86 | int MonitorWithMouse(); | 82 | int MonitorWithMouse(); |
3053 | 87 | 83 | ||
3060 | 88 | void InsertTrash(); | 84 | void RegisterIcon(AbstractLauncherIcon::Ptr icon, int priority = std::numeric_limits<int>::min()); |
3061 | 89 | 85 | ||
3062 | 90 | void RegisterIcon(AbstractLauncherIcon::Ptr icon); | 86 | AbstractLauncherIcon::Ptr CreateFavoriteIcon(std::string const& icon_uri); |
3063 | 91 | 87 | AbstractLauncherIcon::Ptr GetIconByUri(std::string const& icon_uri); | |
3058 | 92 | AbstractLauncherIcon::Ptr CreateFavorite(const char* file_path); | ||
3059 | 93 | |||
3064 | 94 | SoftwareCenterLauncherIcon::Ptr CreateSCLauncherIcon(std::string const& file_path, std::string const& aptdaemon_trans_id, std::string const& icon_path); | 88 | SoftwareCenterLauncherIcon::Ptr CreateSCLauncherIcon(std::string const& file_path, std::string const& aptdaemon_trans_id, std::string const& icon_path); |
3065 | 95 | 89 | ||
3067 | 96 | void SetupBamf(); | 90 | void SetupIcons(); |
3068 | 91 | void AddRunningApps(); | ||
3069 | 92 | void AddDevices(); | ||
3070 | 97 | 93 | ||
3071 | 98 | void EnsureLaunchers(int primary, std::vector<nux::Geometry> const& monitors); | 94 | void EnsureLaunchers(int primary, std::vector<nux::Geometry> const& monitors); |
3072 | 99 | 95 | ||
3073 | 100 | void OnExpoActivated(); | ||
3074 | 101 | |||
3075 | 102 | void OnScreenChanged(int primary_monitor, std::vector<nux::Geometry>& monitors); | 96 | void OnScreenChanged(int primary_monitor, std::vector<nux::Geometry>& monitors); |
3076 | 103 | 97 | ||
3077 | 104 | void OnWindowFocusChanged (guint32 xid); | 98 | void OnWindowFocusChanged (guint32 xid); |
3078 | @@ -123,38 +117,31 @@ | |||
3079 | 123 | 117 | ||
3080 | 124 | Controller* parent_; | 118 | Controller* parent_; |
3081 | 125 | LauncherModel::Ptr model_; | 119 | LauncherModel::Ptr model_; |
3082 | 120 | glib::Object<BamfMatcher> matcher_; | ||
3083 | 126 | nux::ObjectPtr<Launcher> launcher_; | 121 | nux::ObjectPtr<Launcher> launcher_; |
3084 | 127 | nux::ObjectPtr<Launcher> keyboard_launcher_; | 122 | nux::ObjectPtr<Launcher> keyboard_launcher_; |
3085 | 128 | int sort_priority_; | ||
3086 | 129 | AbstractVolumeMonitorWrapper::Ptr volume_monitor_; | ||
3087 | 130 | DevicesSettingsImp::Ptr devices_settings_; | ||
3088 | 131 | DeviceLauncherSection device_section_; | 123 | DeviceLauncherSection device_section_; |
3089 | 132 | LauncherEntryRemoteModel remote_model_; | 124 | LauncherEntryRemoteModel remote_model_; |
3090 | 133 | AbstractLauncherIcon::Ptr expo_icon_; | 125 | AbstractLauncherIcon::Ptr expo_icon_; |
3091 | 134 | AbstractLauncherIcon::Ptr desktop_icon_; | 126 | AbstractLauncherIcon::Ptr desktop_icon_; |
3092 | 135 | int num_workspaces_; | ||
3093 | 136 | bool show_desktop_icon_; | ||
3094 | 137 | Display* display_; | ||
3095 | 138 | |||
3096 | 139 | bool launcher_open; | ||
3097 | 140 | bool launcher_keynav; | ||
3098 | 141 | bool launcher_grabbed; | ||
3099 | 142 | bool reactivate_keynav; | ||
3100 | 143 | int reactivate_index; | ||
3101 | 144 | bool keynav_restore_window_; | ||
3102 | 145 | int launcher_key_press_time_; | ||
3103 | 146 | unsigned int dbus_owner_; | ||
3104 | 147 | |||
3105 | 148 | ui::EdgeBarrierController edge_barriers_; | 127 | ui::EdgeBarrierController edge_barriers_; |
3106 | 149 | |||
3107 | 150 | LauncherList launchers; | 128 | LauncherList launchers; |
3108 | 151 | 129 | ||
3110 | 152 | glib::Object<BamfMatcher> matcher_; | 130 | unsigned sort_priority_; |
3111 | 131 | bool launcher_open; | ||
3112 | 132 | bool launcher_keynav; | ||
3113 | 133 | bool launcher_grabbed; | ||
3114 | 134 | bool reactivate_keynav; | ||
3115 | 135 | int reactivate_index; | ||
3116 | 136 | bool keynav_restore_window_; | ||
3117 | 137 | int launcher_key_press_time_; | ||
3118 | 138 | unsigned dbus_owner_; | ||
3119 | 139 | |||
3120 | 140 | |||
3121 | 153 | glib::Signal<void, BamfMatcher*, BamfView*> view_opened_signal_; | 141 | glib::Signal<void, BamfMatcher*, BamfView*> view_opened_signal_; |
3122 | 154 | glib::SourceManager sources_; | 142 | glib::SourceManager sources_; |
3123 | 155 | UBusManager ubus; | 143 | UBusManager ubus; |
3124 | 156 | 144 | ||
3125 | 157 | sigc::connection on_expoicon_activate_connection_; | ||
3126 | 158 | sigc::connection launcher_key_press_connection_; | 145 | sigc::connection launcher_key_press_connection_; |
3127 | 159 | sigc::connection launcher_event_outside_connection_; | 146 | sigc::connection launcher_event_outside_connection_; |
3128 | 160 | }; | 147 | }; |
3129 | 161 | 148 | ||
3130 | === modified file 'launcher/LauncherIcon.cpp' | |||
3131 | --- launcher/LauncherIcon.cpp 2012-08-15 02:51:33 +0000 | |||
3132 | +++ launcher/LauncherIcon.cpp 2012-09-18 15:52:46 +0000 | |||
3133 | @@ -74,10 +74,11 @@ | |||
3134 | 74 | 74 | ||
3135 | 75 | LauncherIcon::LauncherIcon(IconType type) | 75 | LauncherIcon::LauncherIcon(IconType type) |
3136 | 76 | : _icon_type(type) | 76 | : _icon_type(type) |
3137 | 77 | , _sticky(false) | ||
3138 | 77 | , _remote_urgent(false) | 78 | , _remote_urgent(false) |
3139 | 78 | , _present_urgency(0) | 79 | , _present_urgency(0) |
3140 | 79 | , _progress(0) | 80 | , _progress(0) |
3142 | 80 | , _sort_priority(0) | 81 | , _sort_priority(DefaultPriority(type)) |
3143 | 81 | , _last_monitor(0) | 82 | , _last_monitor(0) |
3144 | 82 | , _background_color(nux::color::White) | 83 | , _background_color(nux::color::White) |
3145 | 83 | , _glow_color(nux::color::White) | 84 | , _glow_color(nux::color::White) |
3146 | @@ -89,7 +90,7 @@ | |||
3147 | 89 | , _saved_center(max_num_monitors) | 90 | , _saved_center(max_num_monitors) |
3148 | 90 | , _allow_quicklist_to_show(true) | 91 | , _allow_quicklist_to_show(true) |
3149 | 91 | { | 92 | { |
3151 | 92 | for (unsigned i = 0; i < unsigned(Quirk::LAST); i++) | 93 | for (unsigned i = 0; i < unsigned(Quirk::LAST); ++i) |
3152 | 93 | { | 94 | { |
3153 | 94 | _quirks[i] = false; | 95 | _quirks[i] = false; |
3154 | 95 | _quirk_times[i].tv_sec = 0; | 96 | _quirk_times[i].tv_sec = 0; |
3155 | @@ -107,10 +108,10 @@ | |||
3156 | 107 | tooltip_text.SetSetterFunction(sigc::mem_fun(this, &LauncherIcon::SetTooltipText)); | 108 | tooltip_text.SetSetterFunction(sigc::mem_fun(this, &LauncherIcon::SetTooltipText)); |
3157 | 108 | tooltip_text = "blank"; | 109 | tooltip_text = "blank"; |
3158 | 109 | 110 | ||
3159 | 111 | position = Position::FLOATING; | ||
3160 | 112 | |||
3161 | 110 | // FIXME: the abstraction is already broken, should be fixed for O | 113 | // FIXME: the abstraction is already broken, should be fixed for O |
3162 | 111 | // right now, hooking the dynamic quicklist the less ugly possible way | 114 | // right now, hooking the dynamic quicklist the less ugly possible way |
3163 | 112 | |||
3164 | 113 | |||
3165 | 114 | mouse_enter.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseEnter)); | 115 | mouse_enter.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseEnter)); |
3166 | 115 | mouse_leave.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseLeave)); | 116 | mouse_leave.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseLeave)); |
3167 | 116 | mouse_down.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseDown)); | 117 | mouse_down.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseDown)); |
3168 | @@ -517,6 +518,7 @@ | |||
3169 | 517 | 518 | ||
3170 | 518 | if (!_tooltip) | 519 | if (!_tooltip) |
3171 | 519 | LoadTooltip(); | 520 | LoadTooltip(); |
3172 | 521 | _tooltip->SetText(tooltip_text()); | ||
3173 | 520 | _tooltip->ShowTooltipWithTipAt(tip_x, tip_y); | 522 | _tooltip->ShowTooltipWithTipAt(tip_x, tip_y); |
3174 | 521 | _tooltip->ShowWindow(!tooltip_text().empty()); | 523 | _tooltip->ShowWindow(!tooltip_text().empty()); |
3175 | 522 | tooltip_visible.emit(_tooltip); | 524 | tooltip_visible.emit(_tooltip); |
3176 | @@ -1179,6 +1181,31 @@ | |||
3177 | 1179 | remove.emit(AbstractLauncherIcon::Ptr(this)); | 1181 | remove.emit(AbstractLauncherIcon::Ptr(this)); |
3178 | 1180 | } | 1182 | } |
3179 | 1181 | 1183 | ||
3180 | 1184 | void LauncherIcon::Stick(bool save) | ||
3181 | 1185 | { | ||
3182 | 1186 | if (_sticky) | ||
3183 | 1187 | return; | ||
3184 | 1188 | |||
3185 | 1189 | _sticky = true; | ||
3186 | 1190 | |||
3187 | 1191 | if (save) | ||
3188 | 1192 | position_saved.emit(); | ||
3189 | 1193 | |||
3190 | 1194 | SetQuirk(Quirk::VISIBLE, true); | ||
3191 | 1195 | } | ||
3192 | 1196 | |||
3193 | 1197 | void LauncherIcon::UnStick() | ||
3194 | 1198 | { | ||
3195 | 1199 | if (!_sticky) | ||
3196 | 1200 | return; | ||
3197 | 1201 | |||
3198 | 1202 | _sticky = false; | ||
3199 | 1203 | |||
3200 | 1204 | position_forgot.emit(); | ||
3201 | 1205 | |||
3202 | 1206 | SetQuirk(Quirk::VISIBLE, false); | ||
3203 | 1207 | } | ||
3204 | 1208 | |||
3205 | 1182 | 1209 | ||
3206 | 1183 | } // namespace launcher | 1210 | } // namespace launcher |
3207 | 1184 | } // namespace unity | 1211 | } // namespace unity |
3208 | 1185 | 1212 | ||
3209 | === modified file 'launcher/LauncherIcon.h' | |||
3210 | --- launcher/LauncherIcon.h 2012-08-15 02:51:33 +0000 | |||
3211 | +++ launcher/LauncherIcon.h 2012-09-18 15:52:46 +0000 | |||
3212 | @@ -108,11 +108,6 @@ | |||
3213 | 108 | 108 | ||
3214 | 109 | const bool WindowVisibleOnViewport(); | 109 | const bool WindowVisibleOnViewport(); |
3215 | 110 | 110 | ||
3216 | 111 | virtual bool IsSpacer() | ||
3217 | 112 | { | ||
3218 | 113 | return false; | ||
3219 | 114 | }; | ||
3220 | 115 | |||
3221 | 116 | float PresentUrgency(); | 111 | float PresentUrgency(); |
3222 | 117 | 112 | ||
3223 | 118 | float GetProgress(); | 113 | float GetProgress(); |
3224 | @@ -188,9 +183,9 @@ | |||
3225 | 188 | 183 | ||
3226 | 189 | virtual std::string DesktopFile() { return std::string(""); } | 184 | virtual std::string DesktopFile() { return std::string(""); } |
3227 | 190 | 185 | ||
3229 | 191 | virtual bool IsSticky() const { return false; } | 186 | virtual bool IsSticky() const { return _sticky; } |
3230 | 192 | 187 | ||
3232 | 193 | virtual bool IsVisible() const { return false; } | 188 | virtual bool IsVisible() const { return GetQuirk(Quirk::VISIBLE); } |
3233 | 194 | 189 | ||
3234 | 195 | virtual bool IsVisibleOnMonitor(int monitor) const; | 190 | virtual bool IsVisibleOnMonitor(int monitor) const; |
3235 | 196 | 191 | ||
3236 | @@ -198,9 +193,9 @@ | |||
3237 | 198 | 193 | ||
3238 | 199 | virtual void AboutToRemove() {} | 194 | virtual void AboutToRemove() {} |
3239 | 200 | 195 | ||
3241 | 201 | virtual void Stick(bool save = true) {} | 196 | virtual void Stick(bool save = true); |
3242 | 202 | 197 | ||
3244 | 203 | virtual void UnStick() {} | 198 | virtual void UnStick(); |
3245 | 204 | 199 | ||
3246 | 205 | protected: | 200 | protected: |
3247 | 206 | std::vector<nux::Point3> GetCenters(); | 201 | std::vector<nux::Point3> GetCenters(); |
3248 | @@ -313,6 +308,7 @@ | |||
3249 | 313 | 308 | ||
3250 | 314 | void OnTooltipEnabledChanged(bool value); | 309 | void OnTooltipEnabledChanged(bool value); |
3251 | 315 | 310 | ||
3252 | 311 | bool _sticky; | ||
3253 | 316 | bool _remote_urgent; | 312 | bool _remote_urgent; |
3254 | 317 | float _present_urgency; | 313 | float _present_urgency; |
3255 | 318 | float _progress; | 314 | float _progress; |
3256 | 319 | 315 | ||
3257 | === modified file 'launcher/LauncherModel.cpp' | |||
3258 | --- launcher/LauncherModel.cpp 2012-09-04 15:51:31 +0000 | |||
3259 | +++ launcher/LauncherModel.cpp 2012-09-18 15:52:46 +0000 | |||
3260 | @@ -56,14 +56,14 @@ | |||
3261 | 56 | 56 | ||
3262 | 57 | bool LauncherModel::IconShouldShelf(AbstractLauncherIcon::Ptr const& icon) const | 57 | bool LauncherModel::IconShouldShelf(AbstractLauncherIcon::Ptr const& icon) const |
3263 | 58 | { | 58 | { |
3265 | 59 | return icon->GetIconType() == AbstractLauncherIcon::IconType::TRASH; | 59 | return icon->position() == AbstractLauncherIcon::Position::END; |
3266 | 60 | } | 60 | } |
3267 | 61 | 61 | ||
3268 | 62 | bool LauncherModel::CompareIcons(AbstractLauncherIcon::Ptr const& first, AbstractLauncherIcon::Ptr const& second) | 62 | bool LauncherModel::CompareIcons(AbstractLauncherIcon::Ptr const& first, AbstractLauncherIcon::Ptr const& second) |
3269 | 63 | { | 63 | { |
3271 | 64 | if (first->GetIconType() < second->GetIconType()) | 64 | if (first->position() < second->position()) |
3272 | 65 | return true; | 65 | return true; |
3274 | 66 | else if (first->GetIconType() > second->GetIconType()) | 66 | else if (first->position() > second->position()) |
3275 | 67 | return false; | 67 | return false; |
3276 | 68 | 68 | ||
3277 | 69 | return first->SortPriority() < second->SortPriority(); | 69 | return first->SortPriority() < second->SortPriority(); |
3278 | @@ -163,25 +163,11 @@ | |||
3279 | 163 | if (!icon) | 163 | if (!icon) |
3280 | 164 | return false; | 164 | return false; |
3281 | 165 | 165 | ||
3301 | 166 | const_iterator it; | 166 | auto const& container = IconShouldShelf(icon) ? _inner_shelf : _inner_main; |
3302 | 167 | const_iterator end; | 167 | |
3303 | 168 | 168 | for (auto const& icon_it : container) | |
3304 | 169 | if (IconShouldShelf(icon)) | 169 | { |
3305 | 170 | { | 170 | if (icon_it != icon && icon_it->GetIconType() == icon->GetIconType()) |
3287 | 171 | it = _inner_shelf.begin(); | ||
3288 | 172 | end = _inner_shelf.end(); | ||
3289 | 173 | } | ||
3290 | 174 | else | ||
3291 | 175 | { | ||
3292 | 176 | it = _inner_main.begin(); | ||
3293 | 177 | end = _inner_main.end(); | ||
3294 | 178 | } | ||
3295 | 179 | |||
3296 | 180 | for (; it != end; ++it) | ||
3297 | 181 | { | ||
3298 | 182 | AbstractLauncherIcon::Ptr const& iter_icon = *it; | ||
3299 | 183 | |||
3300 | 184 | if (iter_icon != icon && iter_icon->GetIconType() == icon->GetIconType()) | ||
3306 | 185 | return true; | 171 | return true; |
3307 | 186 | } | 172 | } |
3308 | 187 | 173 | ||
3309 | @@ -193,16 +179,20 @@ | |||
3310 | 193 | if (icon == other || icon.IsNull() || other.IsNull()) | 179 | if (icon == other || icon.IsNull() || other.IsNull()) |
3311 | 194 | return; | 180 | return; |
3312 | 195 | 181 | ||
3314 | 196 | if (icon->GetIconType() != other->GetIconType()) | 182 | if (icon->position() != other->position()) |
3315 | 197 | return; | 183 | return; |
3316 | 198 | 184 | ||
3317 | 199 | icon->SetSortPriority(other->SortPriority() + 1); | 185 | icon->SetSortPriority(other->SortPriority() + 1); |
3318 | 200 | 186 | ||
3319 | 201 | for (auto it = std::next(std::find(begin(), end(), other)); it != end(); ++it) | 187 | for (auto it = std::next(std::find(begin(), end(), other)); it != end(); ++it) |
3320 | 202 | { | 188 | { |
3321 | 189 | auto const& icon_it = *it; | ||
3322 | 190 | |||
3323 | 191 | if (icon_it == icon) | ||
3324 | 192 | continue; | ||
3325 | 193 | |||
3326 | 203 | // Increasing the priority of the icons next to the other one | 194 | // Increasing the priority of the icons next to the other one |
3329 | 204 | auto const& icon_it = *it; | 195 | int new_priority = icon_it->SortPriority() + 2; |
3328 | 205 | int new_priority = icon_it->SortPriority() + 1; | ||
3330 | 206 | icon_it->SetSortPriority(new_priority); | 196 | icon_it->SetSortPriority(new_priority); |
3331 | 207 | } | 197 | } |
3332 | 208 | 198 | ||
3333 | @@ -214,7 +204,7 @@ | |||
3334 | 214 | if (icon == other || icon.IsNull() || other.IsNull()) | 204 | if (icon == other || icon.IsNull() || other.IsNull()) |
3335 | 215 | return; | 205 | return; |
3336 | 216 | 206 | ||
3338 | 217 | if (icon->GetIconType() != other->GetIconType()) | 207 | if (icon->position() != other->position()) |
3339 | 218 | return; | 208 | return; |
3340 | 219 | 209 | ||
3341 | 220 | bool found_target = false; | 210 | bool found_target = false; |
3342 | @@ -228,7 +218,13 @@ | |||
3343 | 228 | continue; | 218 | continue; |
3344 | 229 | } | 219 | } |
3345 | 230 | 220 | ||
3347 | 231 | int new_priority = icon_it->SortPriority() + (found_target ? 1 : -1); | 221 | int old_priority = icon_it->SortPriority(); |
3348 | 222 | int new_priority = old_priority + (found_target ? 1 : -1); | ||
3349 | 223 | |||
3350 | 224 | // We need to reduce the priority of all the icons previous to 'other' | ||
3351 | 225 | if (icon_it != other && !found_target && other->SortPriority() == old_priority) | ||
3352 | 226 | new_priority -= 1; | ||
3353 | 227 | |||
3354 | 232 | icon_it->SetSortPriority(new_priority); | 228 | icon_it->SetSortPriority(new_priority); |
3355 | 233 | 229 | ||
3356 | 234 | if (icon_it == other) | 230 | if (icon_it == other) |
3357 | @@ -237,7 +233,7 @@ | |||
3358 | 237 | icon_it->SaveCenter(); | 233 | icon_it->SaveCenter(); |
3359 | 238 | 234 | ||
3360 | 239 | center = !center; | 235 | center = !center; |
3362 | 240 | new_priority = new_priority - 1; | 236 | new_priority += -1; |
3363 | 241 | icon->SetSortPriority(new_priority); | 237 | icon->SetSortPriority(new_priority); |
3364 | 242 | 238 | ||
3365 | 243 | if (animate && center) | 239 | if (animate && center) |
3366 | @@ -260,7 +256,7 @@ | |||
3367 | 260 | if (icon == other || icon.IsNull() || other.IsNull()) | 256 | if (icon == other || icon.IsNull() || other.IsNull()) |
3368 | 261 | return; | 257 | return; |
3369 | 262 | 258 | ||
3371 | 263 | if (icon->GetIconType() != other->GetIconType()) | 259 | if (icon->position() != other->position()) |
3372 | 264 | return; | 260 | return; |
3373 | 265 | 261 | ||
3374 | 266 | bool found_icon = false; | 262 | bool found_icon = false; |
3375 | @@ -276,7 +272,13 @@ | |||
3376 | 276 | continue; | 272 | continue; |
3377 | 277 | } | 273 | } |
3378 | 278 | 274 | ||
3380 | 279 | int new_priority = icon_it->SortPriority() + (found_target ? 1 : -1); | 275 | int old_priority = icon_it->SortPriority(); |
3381 | 276 | int new_priority = old_priority + (found_target ? 1 : -1); | ||
3382 | 277 | |||
3383 | 278 | // We need to reduce the priority of all the icons previous to 'other' | ||
3384 | 279 | if (icon_it != other && !found_target && other->SortPriority() == old_priority) | ||
3385 | 280 | new_priority -= 1; | ||
3386 | 281 | |||
3387 | 280 | icon_it->SetSortPriority(new_priority); | 282 | icon_it->SetSortPriority(new_priority); |
3388 | 281 | 283 | ||
3389 | 282 | if (icon_it == other) | 284 | if (icon_it == other) |
3390 | @@ -285,7 +287,7 @@ | |||
3391 | 285 | icon_it->SaveCenter(); | 287 | icon_it->SaveCenter(); |
3392 | 286 | 288 | ||
3393 | 287 | center = !center; | 289 | center = !center; |
3395 | 288 | new_priority = new_priority + (found_icon ? 1 : -1); | 290 | new_priority += found_icon ? 1 : -1; |
3396 | 289 | icon->SetSortPriority(new_priority); | 291 | icon->SetSortPriority(new_priority); |
3397 | 290 | 292 | ||
3398 | 291 | if (animate && center) | 293 | if (animate && center) |
3399 | @@ -377,7 +379,7 @@ | |||
3400 | 377 | 379 | ||
3401 | 378 | for (auto const& current : _inner) | 380 | for (auto const& current : _inner) |
3402 | 379 | { | 381 | { |
3404 | 380 | if (current->GetIconType() != icon->GetIconType()) | 382 | if (current->position() != icon->position()) |
3405 | 381 | continue; | 383 | continue; |
3406 | 382 | 384 | ||
3407 | 383 | if (!found_target) | 385 | if (!found_target) |
3408 | 384 | 386 | ||
3409 | === modified file 'launcher/MockLauncherIcon.h' | |||
3410 | --- launcher/MockLauncherIcon.h 2012-09-04 14:13:16 +0000 | |||
3411 | +++ launcher/MockLauncherIcon.h 2012-09-18 15:52:46 +0000 | |||
3412 | @@ -45,20 +45,20 @@ | |||
3413 | 45 | NUX_DECLARE_OBJECT_TYPE(MockLauncherIcon, AbstractLauncherIcon); | 45 | NUX_DECLARE_OBJECT_TYPE(MockLauncherIcon, AbstractLauncherIcon); |
3414 | 46 | public: | 46 | public: |
3415 | 47 | MockLauncherIcon(IconType type = IconType::APPLICATION) | 47 | MockLauncherIcon(IconType type = IconType::APPLICATION) |
3419 | 48 | : type_(type) | 48 | : icon_(0) |
3420 | 49 | , sort_priority_(0) | 49 | , type_(type) |
3421 | 50 | , icon_(0) | 50 | , sort_priority_(DefaultPriority(type)) |
3422 | 51 | , remote_uri_("fake") | ||
3423 | 51 | { | 52 | { |
3424 | 52 | tooltip_text = "Mock Icon"; | 53 | tooltip_text = "Mock Icon"; |
3425 | 54 | position = Position::FLOATING; | ||
3426 | 53 | 55 | ||
3427 | 54 | for (unsigned i = 0; i < unsigned(Quirk::LAST); ++i) | 56 | for (unsigned i = 0; i < unsigned(Quirk::LAST); ++i) |
3428 | 55 | { | ||
3429 | 56 | quirks_[i] = false; | 57 | quirks_[i] = false; |
3430 | 57 | } | ||
3431 | 58 | } | 58 | } |
3432 | 59 | 59 | ||
3433 | 60 | std::string GetName() const { return "MockLauncherIcon"; } | 60 | std::string GetName() const { return "MockLauncherIcon"; } |
3435 | 61 | 61 | ||
3436 | 62 | void AddProperties(GVariantBuilder* builder) {} | 62 | void AddProperties(GVariantBuilder* builder) {} |
3437 | 63 | 63 | ||
3438 | 64 | void HideTooltip() {} | 64 | void HideTooltip() {} |
3439 | @@ -180,11 +180,6 @@ | |||
3440 | 180 | return true; | 180 | return true; |
3441 | 181 | } | 181 | } |
3442 | 182 | 182 | ||
3443 | 183 | bool IsSpacer() | ||
3444 | 184 | { | ||
3445 | 185 | return false; | ||
3446 | 186 | } | ||
3447 | 187 | |||
3448 | 188 | float PresentUrgency() | 183 | float PresentUrgency() |
3449 | 189 | { | 184 | { |
3450 | 190 | return 0.0f; | 185 | return 0.0f; |
3451 | @@ -244,7 +239,7 @@ | |||
3452 | 244 | 239 | ||
3453 | 245 | std::string RemoteUri() | 240 | std::string RemoteUri() |
3454 | 246 | { | 241 | { |
3456 | 247 | return "fake"; | 242 | return remote_uri_; |
3457 | 248 | } | 243 | } |
3458 | 249 | 244 | ||
3459 | 250 | nux::BaseTexture* TextureForSize(int size) | 245 | nux::BaseTexture* TextureForSize(int size) |
3460 | @@ -293,9 +288,9 @@ | |||
3461 | 293 | bool IsVisible() const { return false; } | 288 | bool IsVisible() const { return false; } |
3462 | 294 | 289 | ||
3463 | 295 | void AboutToRemove() {} | 290 | void AboutToRemove() {} |
3465 | 296 | 291 | ||
3466 | 297 | void Stick(bool save = true) {} | 292 | void Stick(bool save = true) {} |
3468 | 298 | 293 | ||
3469 | 299 | void UnStick() {} | 294 | void UnStick() {} |
3470 | 300 | 295 | ||
3471 | 301 | private: | 296 | private: |
3472 | @@ -346,12 +341,13 @@ | |||
3473 | 346 | return result; | 341 | return result; |
3474 | 347 | } | 342 | } |
3475 | 348 | 343 | ||
3476 | 344 | nux::BaseTexture* icon_; | ||
3477 | 349 | IconType type_; | 345 | IconType type_; |
3478 | 350 | int sort_priority_; | 346 | int sort_priority_; |
3479 | 351 | nux::BaseTexture* icon_; | ||
3480 | 352 | bool quirks_[unsigned(Quirk::LAST)]; | 347 | bool quirks_[unsigned(Quirk::LAST)]; |
3481 | 353 | timespec quirk_times_[unsigned(Quirk::LAST)]; | 348 | timespec quirk_times_[unsigned(Quirk::LAST)]; |
3482 | 354 | std::map<int, nux::Point3> center_; | 349 | std::map<int, nux::Point3> center_; |
3483 | 350 | std::string remote_uri_; | ||
3484 | 355 | }; | 351 | }; |
3485 | 356 | 352 | ||
3486 | 357 | } | 353 | } |
3487 | 358 | 354 | ||
3488 | === modified file 'launcher/SoftwareCenterLauncherIcon.cpp' | |||
3489 | --- launcher/SoftwareCenterLauncherIcon.cpp 2012-08-02 13:16:06 +0000 | |||
3490 | +++ launcher/SoftwareCenterLauncherIcon.cpp 2012-09-18 15:52:46 +0000 | |||
3491 | @@ -45,23 +45,19 @@ | |||
3492 | 45 | , needs_urgent_(false) | 45 | , needs_urgent_(false) |
3493 | 46 | , aptdaemon_trans_id_(aptdaemon_trans_id) | 46 | , aptdaemon_trans_id_(aptdaemon_trans_id) |
3494 | 47 | { | 47 | { |
3496 | 48 | 48 | SetQuirk(Quirk::VISIBLE, false); | |
3497 | 49 | aptdaemon_trans_.Connect("PropertyChanged", sigc::mem_fun(this, &SoftwareCenterLauncherIcon::OnPropertyChanged)); | 49 | aptdaemon_trans_.Connect("PropertyChanged", sigc::mem_fun(this, &SoftwareCenterLauncherIcon::OnPropertyChanged)); |
3498 | 50 | aptdaemon_trans_.Connect("Finished", sigc::mem_fun(this, &SoftwareCenterLauncherIcon::OnFinished)); | 50 | aptdaemon_trans_.Connect("Finished", sigc::mem_fun(this, &SoftwareCenterLauncherIcon::OnFinished)); |
3499 | 51 | 51 | ||
3501 | 52 | icon_name = icon_path; | 52 | if (!icon_path.empty()) |
3502 | 53 | icon_name = icon_path; | ||
3503 | 54 | |||
3504 | 53 | if (!aptdaemon_trans_id_.empty()) // Application is being installed, or hasn't been installed yet | 55 | if (!aptdaemon_trans_id_.empty()) // Application is being installed, or hasn't been installed yet |
3505 | 54 | tooltip_text = _("Waiting to install"); | 56 | tooltip_text = _("Waiting to install"); |
3506 | 55 | } | 57 | } |
3507 | 56 | 58 | ||
3512 | 57 | void SoftwareCenterLauncherIcon::Animate(nux::ObjectPtr<Launcher> launcher, | 59 | void SoftwareCenterLauncherIcon::Animate(nux::ObjectPtr<Launcher> const& launcher, int start_x, int start_y) |
3509 | 58 | int icon_x, | ||
3510 | 59 | int icon_y, | ||
3511 | 60 | int icon_size) | ||
3513 | 61 | { | 60 | { |
3514 | 62 | int target_x = 0; | ||
3515 | 63 | int target_y = 0; | ||
3516 | 64 | |||
3517 | 65 | launcher_ = launcher; | 61 | launcher_ = launcher; |
3518 | 66 | 62 | ||
3519 | 67 | icon_texture_ = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture( | 63 | icon_texture_ = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture( |
3520 | @@ -72,30 +68,15 @@ | |||
3521 | 72 | 68 | ||
3522 | 73 | drag_window_ = new LauncherDragWindow(icon_texture_); | 69 | drag_window_ = new LauncherDragWindow(icon_texture_); |
3523 | 74 | 70 | ||
3524 | 71 | launcher->ForceReveal(true); | ||
3525 | 75 | launcher->RenderIconToTexture(nux::GetWindowThread()->GetGraphicsEngine(), | 72 | launcher->RenderIconToTexture(nux::GetWindowThread()->GetGraphicsEngine(), |
3526 | 76 | AbstractLauncherIcon::Ptr(this), | 73 | AbstractLauncherIcon::Ptr(this), |
3527 | 77 | icon_texture_); | 74 | icon_texture_); |
3528 | 78 | 75 | ||
3530 | 79 | drag_window_->SetBaseXY(icon_x, icon_y); | 76 | auto const& icon_center = GetCenter(launcher->monitor()); |
3531 | 77 | drag_window_->SetBaseXY(start_x, start_y); | ||
3532 | 80 | drag_window_->ShowWindow(true); | 78 | drag_window_->ShowWindow(true); |
3551 | 81 | 79 | drag_window_->SetAnimationTarget(icon_center.x, icon_center.y + (launcher->GetIconSize() / 2)); | |
3534 | 82 | // Find out the center of last BamfLauncherIcon with non-zero co-ordinates | ||
3535 | 83 | auto bamf_icons = launcher->GetModel()->GetSublist<BamfLauncherIcon>(); | ||
3536 | 84 | //TODO: don't iterate through them and pick the last one, just use back() to get the last one. | ||
3537 | 85 | for (auto current_bamf_icon : bamf_icons) | ||
3538 | 86 | { | ||
3539 | 87 | auto icon_center = current_bamf_icon->GetCenter(launcher->monitor); | ||
3540 | 88 | |||
3541 | 89 | if (icon_center.x != 0 && icon_center.y != 0) | ||
3542 | 90 | { | ||
3543 | 91 | target_x = icon_center.x; | ||
3544 | 92 | target_y = icon_center.y; | ||
3545 | 93 | } | ||
3546 | 94 | } | ||
3547 | 95 | |||
3548 | 96 | target_y = target_y + (launcher->GetIconSize() / 2); | ||
3549 | 97 | drag_window_->SetAnimationTarget(target_x, target_y); | ||
3550 | 98 | |||
3552 | 99 | drag_window_->on_anim_completed = drag_window_->anim_completed.connect(sigc::mem_fun(this, &SoftwareCenterLauncherIcon::OnDragAnimationFinished)); | 80 | drag_window_->on_anim_completed = drag_window_->anim_completed.connect(sigc::mem_fun(this, &SoftwareCenterLauncherIcon::OnDragAnimationFinished)); |
3553 | 100 | drag_window_->StartAnimation(); | 81 | drag_window_->StartAnimation(); |
3554 | 101 | } | 82 | } |
3555 | @@ -103,23 +84,29 @@ | |||
3556 | 103 | void SoftwareCenterLauncherIcon::OnDragAnimationFinished() | 84 | void SoftwareCenterLauncherIcon::OnDragAnimationFinished() |
3557 | 104 | { | 85 | { |
3558 | 105 | drag_window_->ShowWindow(false); | 86 | drag_window_->ShowWindow(false); |
3559 | 106 | launcher_->icon_animation_complete.emit(AbstractLauncherIcon::Ptr(this)); | ||
3560 | 107 | drag_window_ = nullptr; | 87 | drag_window_ = nullptr; |
3561 | 88 | launcher_->ForceReveal(false); | ||
3562 | 89 | launcher_ = nullptr; | ||
3563 | 90 | icon_texture_ = nullptr; | ||
3564 | 91 | SetQuirk(Quirk::VISIBLE, true); | ||
3565 | 108 | } | 92 | } |
3566 | 109 | 93 | ||
3567 | 110 | void SoftwareCenterLauncherIcon::ActivateLauncherIcon(ActionArg arg) | 94 | void SoftwareCenterLauncherIcon::ActivateLauncherIcon(ActionArg arg) |
3568 | 111 | { | 95 | { |
3569 | 112 | if (finished_) | 96 | if (finished_) |
3570 | 113 | { | 97 | { |
3577 | 114 | if (needs_urgent_) | 98 | if (needs_urgent_) |
3578 | 115 | { | 99 | { |
3579 | 116 | SetQuirk(Quirk::URGENT, false); | 100 | SetQuirk(Quirk::URGENT, false); |
3580 | 117 | needs_urgent_ = false; | 101 | needs_urgent_ = false; |
3581 | 118 | } | 102 | } |
3582 | 119 | BamfLauncherIcon::ActivateLauncherIcon(arg); | 103 | |
3583 | 104 | BamfLauncherIcon::ActivateLauncherIcon(arg); | ||
3584 | 120 | } | 105 | } |
3585 | 121 | else | 106 | else |
3587 | 122 | SetQuirk(Quirk::STARTING, false); | 107 | { |
3588 | 108 | SetQuirk(Quirk::STARTING, false); | ||
3589 | 109 | } | ||
3590 | 123 | } | 110 | } |
3591 | 124 | 111 | ||
3592 | 125 | void SoftwareCenterLauncherIcon::OnFinished(GVariant *params) | 112 | void SoftwareCenterLauncherIcon::OnFinished(GVariant *params) |
3593 | @@ -135,7 +122,9 @@ | |||
3594 | 135 | SetProgress(0.0f); | 122 | SetProgress(0.0f); |
3595 | 136 | finished_ = true; | 123 | finished_ = true; |
3596 | 137 | needs_urgent_ = true; | 124 | needs_urgent_ = true; |
3598 | 138 | } else { | 125 | } |
3599 | 126 | else | ||
3600 | 127 | { | ||
3601 | 139 | // failure condition, remove icon again | 128 | // failure condition, remove icon again |
3602 | 140 | UnStick(); | 129 | UnStick(); |
3603 | 141 | } | 130 | } |
3604 | @@ -167,7 +156,7 @@ | |||
3605 | 167 | 156 | ||
3606 | 168 | std::string SoftwareCenterLauncherIcon::GetName() const | 157 | std::string SoftwareCenterLauncherIcon::GetName() const |
3607 | 169 | { | 158 | { |
3609 | 170 | return "SoftwareCenterLauncherIcon"; | 159 | return "SoftwareCenterLauncherIcon"; |
3610 | 171 | } | 160 | } |
3611 | 172 | 161 | ||
3612 | 173 | } | 162 | } |
3613 | 174 | 163 | ||
3614 | === modified file 'launcher/SoftwareCenterLauncherIcon.h' | |||
3615 | --- launcher/SoftwareCenterLauncherIcon.h 2012-07-25 03:11:05 +0000 | |||
3616 | +++ launcher/SoftwareCenterLauncherIcon.h 2012-09-18 15:52:46 +0000 | |||
3617 | @@ -42,7 +42,7 @@ | |||
3618 | 42 | std::string const& aptdaemon_trans_id, | 42 | std::string const& aptdaemon_trans_id, |
3619 | 43 | std::string const& icon_path); | 43 | std::string const& icon_path); |
3620 | 44 | 44 | ||
3622 | 45 | void Animate(nux::ObjectPtr<Launcher> launcher, int icon_x, int icon_y, int icon_size); | 45 | void Animate(nux::ObjectPtr<Launcher> const& launcher, int start_x, int start_y); |
3623 | 46 | 46 | ||
3624 | 47 | std::string GetName() const; | 47 | std::string GetName() const; |
3625 | 48 | 48 | ||
3626 | 49 | 49 | ||
3627 | === modified file 'launcher/SpacerLauncherIcon.cpp' | |||
3628 | --- launcher/SpacerLauncherIcon.cpp 2012-08-02 13:16:06 +0000 | |||
3629 | +++ launcher/SpacerLauncherIcon.cpp 2012-09-18 15:52:46 +0000 | |||
3630 | @@ -28,7 +28,7 @@ | |||
3631 | 28 | { | 28 | { |
3632 | 29 | 29 | ||
3633 | 30 | SpacerLauncherIcon::SpacerLauncherIcon(int monitor) | 30 | SpacerLauncherIcon::SpacerLauncherIcon(int monitor) |
3635 | 31 | : SingleMonitorLauncherIcon(IconType::APPLICATION, monitor) | 31 | : SingleMonitorLauncherIcon(IconType::SPACER, monitor) |
3636 | 32 | { | 32 | { |
3637 | 33 | SetQuirk(Quirk::VISIBLE, true); | 33 | SetQuirk(Quirk::VISIBLE, true); |
3638 | 34 | SetQuirk(Quirk::RUNNING, false); | 34 | SetQuirk(Quirk::RUNNING, false); |
3639 | 35 | 35 | ||
3640 | === modified file 'launcher/SpacerLauncherIcon.h' | |||
3641 | --- launcher/SpacerLauncherIcon.h 2012-05-07 19:52:54 +0000 | |||
3642 | +++ launcher/SpacerLauncherIcon.h 2012-09-18 15:52:46 +0000 | |||
3643 | @@ -32,10 +32,6 @@ | |||
3644 | 32 | public: | 32 | public: |
3645 | 33 | SpacerLauncherIcon(int monitor); | 33 | SpacerLauncherIcon(int monitor); |
3646 | 34 | 34 | ||
3647 | 35 | bool IsSpacer() | ||
3648 | 36 | { | ||
3649 | 37 | return true; | ||
3650 | 38 | } | ||
3651 | 39 | protected: | 35 | protected: |
3652 | 40 | std::string GetName() const; | 36 | std::string GetName() const; |
3653 | 41 | }; | 37 | }; |
3654 | 42 | 38 | ||
3655 | === modified file 'launcher/StandaloneLauncher.cpp' | |||
3656 | --- launcher/StandaloneLauncher.cpp 2012-08-15 02:51:33 +0000 | |||
3657 | +++ launcher/StandaloneLauncher.cpp 2012-09-18 15:52:46 +0000 | |||
3658 | @@ -45,7 +45,7 @@ | |||
3659 | 45 | void ThreadWidgetInit(nux::NThread* thread, void* InitData) | 45 | void ThreadWidgetInit(nux::NThread* thread, void* InitData) |
3660 | 46 | { | 46 | { |
3661 | 47 | // launcherWindow->SetGeometry (nux::Geometry(0, 0, 300, 800)); | 47 | // launcherWindow->SetGeometry (nux::Geometry(0, 0, 300, 800)); |
3663 | 48 | controller.reset(new launcher::Controller(0)); | 48 | controller.reset(new launcher::Controller()); |
3664 | 49 | } | 49 | } |
3665 | 50 | 50 | ||
3666 | 51 | int main(int argc, char** argv) | 51 | int main(int argc, char** argv) |
3667 | 52 | 52 | ||
3668 | === modified file 'launcher/TrashLauncherIcon.cpp' | |||
3669 | --- launcher/TrashLauncherIcon.cpp 2012-09-07 09:19:33 +0000 | |||
3670 | +++ launcher/TrashLauncherIcon.cpp 2012-09-18 15:52:46 +0000 | |||
3671 | @@ -48,6 +48,7 @@ | |||
3672 | 48 | { | 48 | { |
3673 | 49 | tooltip_text = _("Trash"); | 49 | tooltip_text = _("Trash"); |
3674 | 50 | icon_name = "user-trash"; | 50 | icon_name = "user-trash"; |
3675 | 51 | position = Position::END; | ||
3676 | 51 | SetQuirk(Quirk::VISIBLE, true); | 52 | SetQuirk(Quirk::VISIBLE, true); |
3677 | 52 | SetQuirk(Quirk::RUNNING, false); | 53 | SetQuirk(Quirk::RUNNING, false); |
3678 | 53 | SetShortcut('t'); | 54 | SetShortcut('t'); |
3679 | 54 | 55 | ||
3680 | === modified file 'launcher/VolumeLauncherIcon.cpp' | |||
3681 | --- launcher/VolumeLauncherIcon.cpp 2012-08-28 17:42:25 +0000 | |||
3682 | +++ launcher/VolumeLauncherIcon.cpp 2012-09-18 15:52:46 +0000 | |||
3683 | @@ -26,6 +26,7 @@ | |||
3684 | 26 | #include "DevicesSettings.h" | 26 | #include "DevicesSettings.h" |
3685 | 27 | #include "Volume.h" | 27 | #include "Volume.h" |
3686 | 28 | #include "VolumeLauncherIcon.h" | 28 | #include "VolumeLauncherIcon.h" |
3687 | 29 | #include "FavoriteStore.h" | ||
3688 | 29 | 30 | ||
3689 | 30 | namespace unity | 31 | namespace unity |
3690 | 31 | { | 32 | { |
3691 | @@ -36,7 +37,7 @@ | |||
3692 | 36 | 37 | ||
3693 | 37 | nux::logging::Logger logger("unity.launcher"); | 38 | nux::logging::Logger logger("unity.launcher"); |
3694 | 38 | 39 | ||
3696 | 39 | const unsigned int volume_changed_timeout = 500; | 40 | const unsigned int volume_changed_timeout = 500; |
3697 | 40 | 41 | ||
3698 | 41 | } | 42 | } |
3699 | 42 | 43 | ||
3700 | @@ -61,7 +62,7 @@ | |||
3701 | 61 | } | 62 | } |
3702 | 62 | 63 | ||
3703 | 63 | ~Impl() | 64 | ~Impl() |
3705 | 64 | { | 65 | { |
3706 | 65 | volume_changed_conn_.disconnect(); | 66 | volume_changed_conn_.disconnect(); |
3707 | 66 | volume_removed_conn_.disconnect(); | 67 | volume_removed_conn_.disconnect(); |
3708 | 67 | settings_changed_conn_.disconnect(); | 68 | settings_changed_conn_.disconnect(); |
3709 | @@ -83,7 +84,7 @@ | |||
3710 | 83 | 84 | ||
3711 | 84 | void UpdateKeepInLauncher() | 85 | void UpdateKeepInLauncher() |
3712 | 85 | { | 86 | { |
3714 | 86 | auto identifier = volume_->GetIdentifier(); | 87 | auto const& identifier = volume_->GetIdentifier(); |
3715 | 87 | keep_in_launcher_ = !devices_settings_->IsABlacklistedDevice(identifier); | 88 | keep_in_launcher_ = !devices_settings_->IsABlacklistedDevice(identifier); |
3716 | 88 | } | 89 | } |
3717 | 89 | 90 | ||
3718 | @@ -104,6 +105,7 @@ | |||
3719 | 104 | if (devices_settings_->IsABlacklistedDevice(volume_->GetIdentifier())) | 105 | if (devices_settings_->IsABlacklistedDevice(volume_->GetIdentifier())) |
3720 | 105 | devices_settings_->TryToUnblacklist(volume_->GetIdentifier()); | 106 | devices_settings_->TryToUnblacklist(volume_->GetIdentifier()); |
3721 | 106 | 107 | ||
3722 | 108 | parent_->UnStick(); | ||
3723 | 107 | parent_->Remove(); | 109 | parent_->Remove(); |
3724 | 108 | } | 110 | } |
3725 | 109 | 111 | ||
3726 | @@ -163,7 +165,8 @@ | |||
3727 | 163 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); | 165 | dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); |
3728 | 164 | 166 | ||
3729 | 165 | gsignals_.Add(new ItemSignal(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, [this] (DbusmenuMenuitem*, int) { | 167 | gsignals_.Add(new ItemSignal(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, [this] (DbusmenuMenuitem*, int) { |
3731 | 166 | auto identifier = volume_->GetIdentifier(); | 168 | auto const& identifier = volume_->GetIdentifier(); |
3732 | 169 | parent_->UnStick(); | ||
3733 | 167 | devices_settings_->TryToBlacklist(identifier); | 170 | devices_settings_->TryToBlacklist(identifier); |
3734 | 168 | })); | 171 | })); |
3735 | 169 | 172 | ||
3736 | @@ -239,6 +242,16 @@ | |||
3737 | 239 | menu.push_back(menu_item); | 242 | menu.push_back(menu_item); |
3738 | 240 | } | 243 | } |
3739 | 241 | 244 | ||
3740 | 245 | std::string GetRemoteUri() | ||
3741 | 246 | { | ||
3742 | 247 | auto const& identifier = volume_->GetIdentifier(); | ||
3743 | 248 | |||
3744 | 249 | if (identifier.empty()) | ||
3745 | 250 | return ""; | ||
3746 | 251 | |||
3747 | 252 | return FavoriteStore::URI_PREFIX_DEVICE + identifier; | ||
3748 | 253 | } | ||
3749 | 254 | |||
3750 | 242 | VolumeLauncherIcon* parent_; | 255 | VolumeLauncherIcon* parent_; |
3751 | 243 | bool keep_in_launcher_; | 256 | bool keep_in_launcher_; |
3752 | 244 | Volume::Ptr volume_; | 257 | Volume::Ptr volume_; |
3753 | @@ -293,6 +306,23 @@ | |||
3754 | 293 | return pimpl_->GetMenus(); | 306 | return pimpl_->GetMenus(); |
3755 | 294 | } | 307 | } |
3756 | 295 | 308 | ||
3757 | 309 | std::string VolumeLauncherIcon::GetRemoteUri() | ||
3758 | 310 | { | ||
3759 | 311 | return pimpl_->GetRemoteUri(); | ||
3760 | 312 | } | ||
3761 | 313 | |||
3762 | 314 | void VolumeLauncherIcon::Stick(bool save) | ||
3763 | 315 | { | ||
3764 | 316 | SimpleLauncherIcon::Stick(save); | ||
3765 | 317 | pimpl_->devices_settings_->TryToUnblacklist(pimpl_->volume_->GetIdentifier()); | ||
3766 | 318 | } | ||
3767 | 319 | |||
3768 | 320 | void VolumeLauncherIcon::UnStick() | ||
3769 | 321 | { | ||
3770 | 322 | SimpleLauncherIcon::UnStick(); | ||
3771 | 323 | SetQuirk(Quirk::VISIBLE, true); | ||
3772 | 324 | } | ||
3773 | 325 | |||
3774 | 296 | // | 326 | // |
3775 | 297 | // Introspection | 327 | // Introspection |
3776 | 298 | // | 328 | // |
3777 | 299 | 329 | ||
3778 | === modified file 'launcher/VolumeLauncherIcon.h' | |||
3779 | --- launcher/VolumeLauncherIcon.h 2012-08-28 17:28:02 +0000 | |||
3780 | +++ launcher/VolumeLauncherIcon.h 2012-09-18 15:52:46 +0000 | |||
3781 | @@ -43,7 +43,10 @@ | |||
3782 | 43 | void EjectAndShowNotification(); // TODO: rename to private virtual void DoDropToTrash(); | 43 | void EjectAndShowNotification(); // TODO: rename to private virtual void DoDropToTrash(); |
3783 | 44 | bool CanStop() const; | 44 | bool CanStop() const; |
3784 | 45 | void StopDrive(); | 45 | void StopDrive(); |
3785 | 46 | void Stick(bool save = true); | ||
3786 | 47 | void UnStick(); | ||
3787 | 46 | MenuItemsVector GetMenus(); | 48 | MenuItemsVector GetMenus(); |
3788 | 49 | std::string GetRemoteUri(); | ||
3789 | 47 | 50 | ||
3790 | 48 | protected: | 51 | protected: |
3791 | 49 | virtual void ActivateLauncherIcon(ActionArg arg); | 52 | virtual void ActivateLauncherIcon(ActionArg arg); |
3792 | 50 | 53 | ||
3793 | === modified file 'manual-tests/Launcher.txt' | |||
3794 | --- manual-tests/Launcher.txt 2012-09-17 12:16:31 +0000 | |||
3795 | +++ manual-tests/Launcher.txt 2012-09-18 15:52:46 +0000 | |||
3796 | @@ -191,6 +191,21 @@ | |||
3797 | 191 | it, and the any pips for running apps show again. | 191 | it, and the any pips for running apps show again. |
3798 | 192 | 192 | ||
3799 | 193 | 193 | ||
3800 | 194 | Dragging fixed icons does not reorder an icon above or below | ||
3801 | 195 | ------------------------------------------------------------ | ||
3802 | 196 | This test is about not reordering when dragging fixed icons. | ||
3803 | 197 | |||
3804 | 198 | #. Move the mouse so it is over the BFB launcher icon | ||
3805 | 199 | #. Press and hold the mouse button | ||
3806 | 200 | #. Try to drag the icon to the right of the launcher. | ||
3807 | 201 | #. Move the mouse down at least to the height of the second launcher icon | ||
3808 | 202 | keeping the mouse pressed. | ||
3809 | 203 | #. Release | ||
3810 | 204 | |||
3811 | 205 | Outcome: | ||
3812 | 206 | * No icon should be dragged. | ||
3813 | 207 | |||
3814 | 208 | |||
3815 | 194 | Dragged launcher icons out of the launcher are properly drawn | 209 | Dragged launcher icons out of the launcher are properly drawn |
3816 | 195 | ------------------------------------------------------------- | 210 | ------------------------------------------------------------- |
3817 | 196 | This test ensures that the launcher icons out of the launcher are properly drawn | 211 | This test ensures that the launcher icons out of the launcher are properly drawn |
3818 | 197 | 212 | ||
3819 | === modified file 'panel/PanelMenuView.h' | |||
3820 | --- panel/PanelMenuView.h 2012-08-22 04:30:28 +0000 | |||
3821 | +++ panel/PanelMenuView.h 2012-09-18 15:52:46 +0000 | |||
3822 | @@ -136,7 +136,6 @@ | |||
3823 | 136 | glib::Object<BamfMatcher> _matcher; | 136 | glib::Object<BamfMatcher> _matcher; |
3824 | 137 | 137 | ||
3825 | 138 | nux::TextureLayer* _title_layer; | 138 | nux::TextureLayer* _title_layer; |
3826 | 139 | nux::HLayout* _menu_layout; | ||
3827 | 140 | nux::ObjectPtr<WindowButtons> _window_buttons; | 139 | nux::ObjectPtr<WindowButtons> _window_buttons; |
3828 | 141 | nux::ObjectPtr<PanelTitlebarGrabArea> _titlebar_grab_area; | 140 | nux::ObjectPtr<PanelTitlebarGrabArea> _titlebar_grab_area; |
3829 | 142 | nux::ObjectPtr<nux::BaseTexture> _title_texture; | 141 | nux::ObjectPtr<nux::BaseTexture> _title_texture; |
3830 | 143 | 142 | ||
3831 | === modified file 'plugins/unityshell/src/unityshell.cpp' | |||
3832 | --- plugins/unityshell/src/unityshell.cpp 2012-09-17 10:20:33 +0000 | |||
3833 | +++ plugins/unityshell/src/unityshell.cpp 2012-09-18 15:52:46 +0000 | |||
3834 | @@ -266,7 +266,6 @@ | |||
3835 | 266 | optionSetAutohideAnimationNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); | 266 | optionSetAutohideAnimationNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); |
3836 | 267 | optionSetDashBlurExperimentalNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); | 267 | optionSetDashBlurExperimentalNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); |
3837 | 268 | optionSetShortcutOverlayNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); | 268 | optionSetShortcutOverlayNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); |
3838 | 269 | optionSetShowDesktopIconNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); | ||
3839 | 270 | optionSetShowLauncherInitiate(boost::bind(&UnityScreen::showLauncherKeyInitiate, this, _1, _2, _3)); | 269 | optionSetShowLauncherInitiate(boost::bind(&UnityScreen::showLauncherKeyInitiate, this, _1, _2, _3)); |
3840 | 271 | optionSetShowLauncherTerminate(boost::bind(&UnityScreen::showLauncherKeyTerminate, this, _1, _2, _3)); | 270 | optionSetShowLauncherTerminate(boost::bind(&UnityScreen::showLauncherKeyTerminate, this, _1, _2, _3)); |
3841 | 272 | optionSetKeyboardFocusInitiate(boost::bind(&UnityScreen::setKeyboardFocusKeyInitiate, this, _1, _2, _3)); | 271 | optionSetKeyboardFocusInitiate(boost::bind(&UnityScreen::setKeyboardFocusKeyInitiate, this, _1, _2, _3)); |
3842 | @@ -2842,9 +2841,6 @@ | |||
3843 | 2842 | enable_shortcut_overlay_ = optionGetShortcutOverlay(); | 2841 | enable_shortcut_overlay_ = optionGetShortcutOverlay(); |
3844 | 2843 | shortcut_controller_->SetEnabled(enable_shortcut_overlay_); | 2842 | shortcut_controller_->SetEnabled(enable_shortcut_overlay_); |
3845 | 2844 | break; | 2843 | break; |
3846 | 2845 | case UnityshellOptions::ShowDesktopIcon: | ||
3847 | 2846 | launcher_controller_->SetShowDesktopIcon(optionGetShowDesktopIcon()); | ||
3848 | 2847 | break; | ||
3849 | 2848 | case UnityshellOptions::DecayRate: | 2844 | case UnityshellOptions::DecayRate: |
3850 | 2849 | launcher_options->edge_decay_rate = optionGetDecayRate() * 100; | 2845 | launcher_options->edge_decay_rate = optionGetDecayRate() * 100; |
3851 | 2850 | break; | 2846 | break; |
3852 | @@ -2917,11 +2913,13 @@ | |||
3853 | 2917 | CompOption::Value& v) | 2913 | CompOption::Value& v) |
3854 | 2918 | { | 2914 | { |
3855 | 2919 | bool status = screen->setOptionForPlugin(plugin, name, v); | 2915 | bool status = screen->setOptionForPlugin(plugin, name, v); |
3856 | 2916 | |||
3857 | 2920 | if (status) | 2917 | if (status) |
3858 | 2921 | { | 2918 | { |
3860 | 2922 | if (strcmp(plugin, "core") == 0 && strcmp(name, "hsize") == 0) | 2919 | if (strcmp(plugin, "core") == 0) |
3861 | 2923 | { | 2920 | { |
3863 | 2924 | launcher_controller_->UpdateNumWorkspaces(screen->vpSize().width() * screen->vpSize().height()); | 2921 | if (strcmp(name, "hsize") == 0 || strcmp(name, "vsize") == 0) |
3864 | 2922 | launcher_controller_->UpdateNumWorkspaces(screen->vpSize().width() * screen->vpSize().height()); | ||
3865 | 2925 | } | 2923 | } |
3866 | 2926 | } | 2924 | } |
3867 | 2927 | return status; | 2925 | return status; |
3868 | @@ -2952,7 +2950,7 @@ | |||
3869 | 2952 | void UnityScreen::initLauncher() | 2950 | void UnityScreen::initLauncher() |
3870 | 2953 | { | 2951 | { |
3871 | 2954 | Timer timer; | 2952 | Timer timer; |
3873 | 2955 | launcher_controller_ = std::make_shared<launcher::Controller>(screen->dpy()); | 2953 | launcher_controller_ = std::make_shared<launcher::Controller>(); |
3874 | 2956 | AddChild(launcher_controller_.get()); | 2954 | AddChild(launcher_controller_.get()); |
3875 | 2957 | 2955 | ||
3876 | 2958 | switcher_controller_ = std::make_shared<switcher::Controller>(); | 2956 | switcher_controller_ = std::make_shared<switcher::Controller>(); |
3877 | 2959 | 2957 | ||
3878 | === modified file 'plugins/unityshell/unityshell.xml.in' | |||
3879 | --- plugins/unityshell/unityshell.xml.in 2012-08-17 14:44:05 +0000 | |||
3880 | +++ plugins/unityshell/unityshell.xml.in 2012-09-18 15:52:46 +0000 | |||
3881 | @@ -400,12 +400,6 @@ | |||
3882 | 400 | <default>true</default> | 400 | <default>true</default> |
3883 | 401 | </option> | 401 | </option> |
3884 | 402 | 402 | ||
3885 | 403 | <option name="show_desktop_icon" type="bool"> | ||
3886 | 404 | <_short>Show "Desktop Icon" in the launcher</_short> | ||
3887 | 405 | <_long>Enable/Disable "Show Desktop Icon" in the launcher.</_long> | ||
3888 | 406 | <default>false</default> | ||
3889 | 407 | </option> | ||
3890 | 408 | |||
3891 | 409 | <option name="menus_fadein" type="int"> | 403 | <option name="menus_fadein" type="int"> |
3892 | 410 | <_short>Menus Fade-in duration</_short> | 404 | <_short>Menus Fade-in duration</_short> |
3893 | 411 | <_long>Duration (in milliseconds) of the menus fade-in animation, used when the mouse goes over the top-panel.</_long> | 405 | <_long>Duration (in milliseconds) of the menus fade-in animation, used when the mouse goes over the top-panel.</_long> |
3894 | 412 | 406 | ||
3895 | === modified file 'tests/CMakeLists.txt' | |||
3896 | --- tests/CMakeLists.txt 2012-09-13 14:41:57 +0000 | |||
3897 | +++ tests/CMakeLists.txt 2012-09-18 15:52:46 +0000 | |||
3898 | @@ -3,16 +3,16 @@ | |||
3899 | 3 | # | 3 | # |
3900 | 4 | # Data | 4 | # Data |
3901 | 5 | # | 5 | # |
3912 | 6 | configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/ubuntuone-installer.desktop | 6 | configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/applications/ubuntuone-installer.desktop |
3913 | 7 | ${CMAKE_BINARY_DIR}/tests/data/ubuntuone-installer.desktop) | 7 | ${CMAKE_BINARY_DIR}/tests/data/applications/ubuntuone-installer.desktop) |
3914 | 8 | configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/ubuntu-software-center.desktop | 8 | configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/applications/ubuntu-software-center.desktop |
3915 | 9 | ${CMAKE_BINARY_DIR}/tests/data/ubuntu-software-center.desktop) | 9 | ${CMAKE_BINARY_DIR}/tests/data/applications/ubuntu-software-center.desktop) |
3916 | 10 | configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/update-manager.desktop | 10 | configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/applications/update-manager.desktop |
3917 | 11 | ${CMAKE_BINARY_DIR}/tests/data/update-manager.desktop) | 11 | ${CMAKE_BINARY_DIR}/tests/data/applications/update-manager.desktop) |
3918 | 12 | configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/bzr-handle-patch.desktop | 12 | configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/applications/bzr-handle-patch.desktop |
3919 | 13 | ${CMAKE_BINARY_DIR}/tests/data/bzr-handle-patch.desktop) | 13 | ${CMAKE_BINARY_DIR}/tests/data/applications/bzr-handle-patch.desktop) |
3920 | 14 | configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/no-icon.desktop | 14 | configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/applications/no-icon.desktop |
3921 | 15 | ${CMAKE_BINARY_DIR}/tests/data/no-icon.desktop) | 15 | ${CMAKE_BINARY_DIR}/tests/data/applications/no-icon.desktop) |
3922 | 16 | # | 16 | # |
3923 | 17 | # Unit tests | 17 | # Unit tests |
3924 | 18 | # | 18 | # |
3925 | @@ -136,6 +136,7 @@ | |||
3926 | 136 | test_indicator_entry.cpp | 136 | test_indicator_entry.cpp |
3927 | 137 | test_indicators.cpp | 137 | test_indicators.cpp |
3928 | 138 | test_introspection.cpp | 138 | test_introspection.cpp |
3929 | 139 | test_favorite_store.cpp | ||
3930 | 139 | test_favorite_store_gsettings.cpp | 140 | test_favorite_store_gsettings.cpp |
3931 | 140 | test_favorite_store_private.cpp | 141 | test_favorite_store_private.cpp |
3932 | 141 | test_home_lens.cpp | 142 | test_home_lens.cpp |
3933 | @@ -200,20 +201,23 @@ | |||
3934 | 200 | # Tests that require X | 201 | # Tests that require X |
3935 | 201 | add_executable(test-gtest | 202 | add_executable(test-gtest |
3936 | 202 | test_main.cpp | 203 | test_main.cpp |
3938 | 203 | test_bamflaunchericon.cpp | 204 | test_bamf_launcher_icon.cpp |
3939 | 204 | test_bfb_launcher_icon.cpp | 205 | test_bfb_launcher_icon.cpp |
3940 | 205 | test_dashview_impl.cpp | 206 | test_dashview_impl.cpp |
3941 | 207 | test_desktop_launcher_icon.cpp | ||
3942 | 206 | test_edge_barrier_controller.cpp | 208 | test_edge_barrier_controller.cpp |
3943 | 207 | test_launcher.cpp | 209 | test_launcher.cpp |
3944 | 208 | test_device_launcher_section.cpp | 210 | test_device_launcher_section.cpp |
3945 | 209 | test_lensview_impl.cpp | 211 | test_lensview_impl.cpp |
3946 | 210 | test_hud_button.cpp | 212 | test_hud_button.cpp |
3947 | 211 | test_hud_controller.cpp | 213 | test_hud_controller.cpp |
3948 | 214 | test_hud_launcher_icon.cpp | ||
3949 | 212 | test_hud_view.cpp | 215 | test_hud_view.cpp |
3950 | 213 | test_icon_loader.cpp | 216 | test_icon_loader.cpp |
3951 | 214 | test_im_text_entry.cpp | 217 | test_im_text_entry.cpp |
3952 | 215 | test_launcher_controller.cpp | 218 | test_launcher_controller.cpp |
3953 | 216 | test_launcher_drag_window.cpp | 219 | test_launcher_drag_window.cpp |
3954 | 220 | test_launcher_icon.cpp | ||
3955 | 217 | test_keyboard_util.cpp | 221 | test_keyboard_util.cpp |
3956 | 218 | test_panel_style.cpp | 222 | test_panel_style.cpp |
3957 | 219 | test_previews_application.cpp | 223 | test_previews_application.cpp |
3958 | @@ -225,10 +229,13 @@ | |||
3959 | 225 | test_quicklist_view.cpp | 229 | test_quicklist_view.cpp |
3960 | 226 | test_resultviewgrid.cpp | 230 | test_resultviewgrid.cpp |
3961 | 227 | test_single_monitor_launcher_icon.cpp | 231 | test_single_monitor_launcher_icon.cpp |
3962 | 232 | test_software_center_launcher_icon.cpp | ||
3963 | 233 | test_expo_launcher_icon.cpp | ||
3964 | 228 | test_switcher_controller.cpp | 234 | test_switcher_controller.cpp |
3965 | 229 | test_switcher_model.cpp | 235 | test_switcher_model.cpp |
3966 | 230 | test_texture_cache.cpp | 236 | test_texture_cache.cpp |
3967 | 231 | test_thumbnail_generator.cpp | 237 | test_thumbnail_generator.cpp |
3968 | 238 | test_trash_launcher_icon.cpp | ||
3969 | 232 | test_launcher_minimize_speed.cpp | 239 | test_launcher_minimize_speed.cpp |
3970 | 233 | test_volume_imp.cpp | 240 | test_volume_imp.cpp |
3971 | 234 | test_volume_launcher_icon.cpp | 241 | test_volume_launcher_icon.cpp |
3972 | @@ -272,6 +279,7 @@ | |||
3973 | 272 | ${CMAKE_SOURCE_DIR}/launcher/DevicesSettingsImp.cpp | 279 | ${CMAKE_SOURCE_DIR}/launcher/DevicesSettingsImp.cpp |
3974 | 273 | ${CMAKE_SOURCE_DIR}/launcher/DndData.cpp | 280 | ${CMAKE_SOURCE_DIR}/launcher/DndData.cpp |
3975 | 274 | ${CMAKE_SOURCE_DIR}/launcher/EdgeBarrierController.cpp | 281 | ${CMAKE_SOURCE_DIR}/launcher/EdgeBarrierController.cpp |
3976 | 282 | ${CMAKE_SOURCE_DIR}/launcher/ExpoLauncherIcon.cpp | ||
3977 | 275 | ${CMAKE_SOURCE_DIR}/launcher/FavoriteStore.cpp | 283 | ${CMAKE_SOURCE_DIR}/launcher/FavoriteStore.cpp |
3978 | 276 | ${CMAKE_SOURCE_DIR}/launcher/FavoriteStoreGSettings.cpp | 284 | ${CMAKE_SOURCE_DIR}/launcher/FavoriteStoreGSettings.cpp |
3979 | 277 | ${CMAKE_SOURCE_DIR}/launcher/FavoriteStorePrivate.cpp | 285 | ${CMAKE_SOURCE_DIR}/launcher/FavoriteStorePrivate.cpp |
3980 | 278 | 286 | ||
3981 | === added directory 'tests/data/applications' | |||
3982 | === renamed file 'tests/data/bzr-handle-patch.desktop' => 'tests/data/applications/bzr-handle-patch.desktop' | |||
3983 | === renamed file 'tests/data/no-icon.desktop' => 'tests/data/applications/no-icon.desktop' | |||
3984 | === renamed file 'tests/data/ubuntu-software-center.desktop' => 'tests/data/applications/ubuntu-software-center.desktop' | |||
3985 | === renamed file 'tests/data/ubuntuone-installer.desktop' => 'tests/data/applications/ubuntuone-installer.desktop' | |||
3986 | === renamed file 'tests/data/update-manager.desktop' => 'tests/data/applications/update-manager.desktop' | |||
3987 | === modified file 'tests/gmockvolume.c' | |||
3988 | --- tests/gmockvolume.c 2012-09-18 11:09:48 +0000 | |||
3989 | +++ tests/gmockvolume.c 2012-09-18 15:52:46 +0000 | |||
3990 | @@ -89,10 +89,11 @@ | |||
3991 | 89 | static void | 89 | static void |
3992 | 90 | g_mock_volume_init (GMockVolume *mock_volume) | 90 | g_mock_volume_init (GMockVolume *mock_volume) |
3993 | 91 | { | 91 | { |
3995 | 92 | mock_volume->name = g_strdup(""); | 92 | guint32 uuid = g_random_int(); |
3996 | 93 | mock_volume->name = g_strdup_printf("MockVolume %u", uuid); | ||
3997 | 93 | mock_volume->icon = g_icon_new_for_string("", NULL); | 94 | mock_volume->icon = g_icon_new_for_string("", NULL); |
4000 | 94 | mock_volume->uuid = g_strdup(""); | 95 | mock_volume->uuid = g_strdup_printf("%u", uuid); |
4001 | 95 | mock_volume->label = g_strdup(""); | 96 | mock_volume->label = g_strdup_printf("MockVolumeLabel"); |
4002 | 96 | mock_volume->mount = NULL; | 97 | mock_volume->mount = NULL; |
4003 | 97 | } | 98 | } |
4004 | 98 | 99 | ||
4005 | 99 | 100 | ||
4006 | === renamed file 'tests/test_bamflaunchericon.cpp' => 'tests/test_bamf_launcher_icon.cpp' | |||
4007 | --- tests/test_bamflaunchericon.cpp 2012-07-16 20:05:59 +0000 | |||
4008 | +++ tests/test_bamf_launcher_icon.cpp 2012-09-18 15:52:46 +0000 | |||
4009 | @@ -23,16 +23,19 @@ | |||
4010 | 23 | #include <gmock/gmock.h> | 23 | #include <gmock/gmock.h> |
4011 | 24 | 24 | ||
4012 | 25 | #include <UnityCore/GLibWrapper.h> | 25 | #include <UnityCore/GLibWrapper.h> |
4013 | 26 | #include <UnityCore/DesktopUtilities.h> | ||
4014 | 26 | 27 | ||
4015 | 27 | #include "BamfLauncherIcon.h" | 28 | #include "BamfLauncherIcon.h" |
4016 | 29 | #include "FavoriteStore.h" | ||
4017 | 28 | 30 | ||
4018 | 29 | using namespace unity; | 31 | using namespace unity; |
4019 | 32 | using namespace unity::launcher; | ||
4020 | 30 | 33 | ||
4021 | 31 | namespace | 34 | namespace |
4022 | 32 | { | 35 | { |
4023 | 33 | 36 | ||
4026 | 34 | const std::string USC_DESKTOP = BUILDDIR"/tests/data/ubuntu-software-center.desktop"; | 37 | const std::string USC_DESKTOP = BUILDDIR"/tests/data/applications/ubuntu-software-center.desktop"; |
4027 | 35 | const std::string NO_ICON_DESKTOP = BUILDDIR"/tests/data/no-icon.desktop"; | 38 | const std::string NO_ICON_DESKTOP = BUILDDIR"/tests/data/applications/no-icon.desktop"; |
4028 | 36 | 39 | ||
4029 | 37 | class TestBamfLauncherIcon : public testing::Test | 40 | class TestBamfLauncherIcon : public testing::Test |
4030 | 38 | { | 41 | { |
4031 | @@ -61,6 +64,11 @@ | |||
4032 | 61 | nux::ObjectPtr<launcher::BamfLauncherIcon> empty_app; | 64 | nux::ObjectPtr<launcher::BamfLauncherIcon> empty_app; |
4033 | 62 | }; | 65 | }; |
4034 | 63 | 66 | ||
4035 | 67 | TEST_F(TestBamfLauncherIcon, Position) | ||
4036 | 68 | { | ||
4037 | 69 | EXPECT_EQ(usc_icon->position(), AbstractLauncherIcon::Position::FLOATING); | ||
4038 | 70 | } | ||
4039 | 71 | |||
4040 | 64 | TEST_F(TestBamfLauncherIcon, TestCustomBackgroundColor) | 72 | TEST_F(TestBamfLauncherIcon, TestCustomBackgroundColor) |
4041 | 65 | { | 73 | { |
4042 | 66 | nux::Color const& color = usc_icon->BackgroundColor(); | 74 | nux::Color const& color = usc_icon->BackgroundColor(); |
4043 | @@ -78,4 +86,64 @@ | |||
4044 | 78 | EXPECT_EQ(empty_app->icon_name.Get(), "application-default-icon"); | 86 | EXPECT_EQ(empty_app->icon_name.Get(), "application-default-icon"); |
4045 | 79 | } | 87 | } |
4046 | 80 | 88 | ||
4047 | 89 | TEST_F(TestBamfLauncherIcon, Stick) | ||
4048 | 90 | { | ||
4049 | 91 | BamfView* bamf_app = BAMF_VIEW(bamf_matcher_get_application_for_desktop_file(bamf_matcher, USC_DESKTOP.c_str(), FALSE)); | ||
4050 | 92 | ASSERT_FALSE(bamf_view_is_sticky(bamf_app)); | ||
4051 | 93 | |||
4052 | 94 | bool saved = false; | ||
4053 | 95 | usc_icon->position_saved.connect([&saved] {saved = true;}); | ||
4054 | 96 | |||
4055 | 97 | usc_icon->Stick(false); | ||
4056 | 98 | EXPECT_TRUE(bamf_view_is_sticky(bamf_app)); | ||
4057 | 99 | EXPECT_TRUE(usc_icon->IsSticky()); | ||
4058 | 100 | EXPECT_TRUE(usc_icon->IsVisible()); | ||
4059 | 101 | EXPECT_FALSE(saved); | ||
4060 | 102 | |||
4061 | 103 | usc_icon->Stick(true); | ||
4062 | 104 | EXPECT_FALSE(saved); | ||
4063 | 105 | bamf_view_set_sticky(bamf_app, FALSE); | ||
4064 | 106 | } | ||
4065 | 107 | |||
4066 | 108 | TEST_F(TestBamfLauncherIcon, StickAndSave) | ||
4067 | 109 | { | ||
4068 | 110 | BamfView* bamf_app = BAMF_VIEW(bamf_matcher_get_application_for_desktop_file(bamf_matcher, USC_DESKTOP.c_str(), FALSE)); | ||
4069 | 111 | ASSERT_FALSE(bamf_view_is_sticky(bamf_app)); | ||
4070 | 112 | |||
4071 | 113 | bool saved = false; | ||
4072 | 114 | usc_icon->position_saved.connect([&saved] {saved = true;}); | ||
4073 | 115 | |||
4074 | 116 | usc_icon->Stick(true); | ||
4075 | 117 | EXPECT_TRUE(bamf_view_is_sticky(bamf_app)); | ||
4076 | 118 | EXPECT_TRUE(usc_icon->IsSticky()); | ||
4077 | 119 | EXPECT_TRUE(usc_icon->IsVisible()); | ||
4078 | 120 | EXPECT_TRUE(saved); | ||
4079 | 121 | bamf_view_set_sticky(bamf_app, FALSE); | ||
4080 | 122 | } | ||
4081 | 123 | |||
4082 | 124 | TEST_F(TestBamfLauncherIcon, Unstick) | ||
4083 | 125 | { | ||
4084 | 126 | BamfView* bamf_app = BAMF_VIEW(bamf_matcher_get_application_for_desktop_file(bamf_matcher, USC_DESKTOP.c_str(), FALSE)); | ||
4085 | 127 | ASSERT_FALSE(bamf_view_is_sticky(bamf_app)); | ||
4086 | 128 | |||
4087 | 129 | bool forgot = false; | ||
4088 | 130 | usc_icon->position_forgot.connect([&forgot] {forgot = true;}); | ||
4089 | 131 | |||
4090 | 132 | usc_icon->Stick(false); | ||
4091 | 133 | ASSERT_TRUE(bamf_view_is_sticky(bamf_app)); | ||
4092 | 134 | ASSERT_TRUE(usc_icon->IsSticky()); | ||
4093 | 135 | |||
4094 | 136 | usc_icon->UnStick(); | ||
4095 | 137 | EXPECT_FALSE(bamf_view_is_sticky(bamf_app)); | ||
4096 | 138 | EXPECT_FALSE(usc_icon->IsSticky()); | ||
4097 | 139 | EXPECT_FALSE(usc_icon->IsVisible()); | ||
4098 | 140 | EXPECT_TRUE(forgot); | ||
4099 | 141 | } | ||
4100 | 142 | |||
4101 | 143 | TEST_F(TestBamfLauncherIcon, RemoteUri) | ||
4102 | 144 | { | ||
4103 | 145 | EXPECT_EQ(usc_icon->RemoteUri(), FavoriteStore::URI_PREFIX_APP + DesktopUtilities::GetDesktopID(USC_DESKTOP)); | ||
4104 | 146 | EXPECT_TRUE(empty_app->RemoteUri().empty()); | ||
4105 | 147 | } | ||
4106 | 148 | |||
4107 | 81 | } | 149 | } |
4108 | 82 | 150 | ||
4109 | === modified file 'tests/test_bfb_launcher_icon.cpp' | |||
4110 | --- tests/test_bfb_launcher_icon.cpp 2012-08-14 15:13:19 +0000 | |||
4111 | +++ tests/test_bfb_launcher_icon.cpp 2012-09-18 15:52:46 +0000 | |||
4112 | @@ -33,18 +33,21 @@ | |||
4113 | 33 | MockBFBLauncherIcon() | 33 | MockBFBLauncherIcon() |
4114 | 34 | : BFBLauncherIcon(LauncherHideMode::LAUNCHER_HIDE_NEVER) | 34 | : BFBLauncherIcon(LauncherHideMode::LAUNCHER_HIDE_NEVER) |
4115 | 35 | {} | 35 | {} |
4116 | 36 | |||
4117 | 37 | AbstractLauncherIcon::MenuItemsVector GetMenus() | ||
4118 | 38 | { | ||
4119 | 39 | return BFBLauncherIcon::GetMenus(); | ||
4120 | 40 | } | ||
4121 | 41 | }; | 36 | }; |
4122 | 42 | 37 | ||
4124 | 43 | TEST(TestBFBLauncherIcon, OverlayMenus) | 38 | struct TestBFBLauncherIcon : testing::Test |
4125 | 44 | { | 39 | { |
4126 | 45 | MockBFBLauncherIcon bfb; | 40 | MockBFBLauncherIcon bfb; |
4129 | 46 | 41 | }; | |
4130 | 47 | for (auto menu_item : bfb.GetMenus()) | 42 | |
4131 | 43 | TEST_F(TestBFBLauncherIcon, Position) | ||
4132 | 44 | { | ||
4133 | 45 | EXPECT_EQ(bfb.position, AbstractLauncherIcon::Position::BEGIN); | ||
4134 | 46 | } | ||
4135 | 47 | |||
4136 | 48 | TEST_F(TestBFBLauncherIcon, OverlayMenus) | ||
4137 | 49 | { | ||
4138 | 50 | for (auto menu_item : bfb.Menus()) | ||
4139 | 48 | { | 51 | { |
4140 | 49 | bool overlay_item = dbusmenu_menuitem_property_get_bool(menu_item, QuicklistMenuItem::OVERLAY_MENU_ITEM_PROPERTY); | 52 | bool overlay_item = dbusmenu_menuitem_property_get_bool(menu_item, QuicklistMenuItem::OVERLAY_MENU_ITEM_PROPERTY); |
4141 | 50 | ASSERT_TRUE(overlay_item); | 53 | ASSERT_TRUE(overlay_item); |
4142 | 51 | 54 | ||
4143 | === added file 'tests/test_desktop_launcher_icon.cpp' | |||
4144 | --- tests/test_desktop_launcher_icon.cpp 1970-01-01 00:00:00 +0000 | |||
4145 | +++ tests/test_desktop_launcher_icon.cpp 2012-09-18 15:52:46 +0000 | |||
4146 | @@ -0,0 +1,80 @@ | |||
4147 | 1 | /* | ||
4148 | 2 | * Copyright 2012 Canonical Ltd. | ||
4149 | 3 | * | ||
4150 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
4151 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
4152 | 6 | * by the Free Software Foundation. | ||
4153 | 7 | * | ||
4154 | 8 | * This program is distributed in the hope that it will be useful, but | ||
4155 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
4156 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
4157 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
4158 | 12 | * | ||
4159 | 13 | * You should have received a copy of the GNU General Public License | ||
4160 | 14 | * version 3 along with this program. If not, see | ||
4161 | 15 | * <http://www.gnu.org/licenses/> | ||
4162 | 16 | * | ||
4163 | 17 | * Authored by: Marco Trevisan (Treviño) <marco.trevisan@canonical.com> | ||
4164 | 18 | */ | ||
4165 | 19 | |||
4166 | 20 | #include <gmock/gmock.h> | ||
4167 | 21 | |||
4168 | 22 | #include "PluginAdapter.h" | ||
4169 | 23 | #include "DesktopLauncherIcon.h" | ||
4170 | 24 | |||
4171 | 25 | using namespace unity; | ||
4172 | 26 | using namespace unity::launcher; | ||
4173 | 27 | |||
4174 | 28 | namespace | ||
4175 | 29 | { | ||
4176 | 30 | |||
4177 | 31 | struct TestDesktopLauncherIcon : testing::Test | ||
4178 | 32 | { | ||
4179 | 33 | DesktopLauncherIcon icon; | ||
4180 | 34 | }; | ||
4181 | 35 | |||
4182 | 36 | TEST_F(TestDesktopLauncherIcon, Type) | ||
4183 | 37 | { | ||
4184 | 38 | EXPECT_EQ(icon.GetIconType(), AbstractLauncherIcon::IconType::DESKTOP); | ||
4185 | 39 | } | ||
4186 | 40 | |||
4187 | 41 | TEST_F(TestDesktopLauncherIcon, Shortcut) | ||
4188 | 42 | { | ||
4189 | 43 | EXPECT_EQ(icon.GetShortcut(), 'd'); | ||
4190 | 44 | } | ||
4191 | 45 | |||
4192 | 46 | TEST_F(TestDesktopLauncherIcon, Position) | ||
4193 | 47 | { | ||
4194 | 48 | EXPECT_EQ(icon.position(), AbstractLauncherIcon::Position::FLOATING); | ||
4195 | 49 | } | ||
4196 | 50 | |||
4197 | 51 | TEST_F(TestDesktopLauncherIcon, ActivateToggleShowDesktop) | ||
4198 | 52 | { | ||
4199 | 53 | auto plugin_adapter = PluginAdapter::Default(); | ||
4200 | 54 | |||
4201 | 55 | ASSERT_FALSE(plugin_adapter->InShowDesktop()); | ||
4202 | 56 | |||
4203 | 57 | icon.Activate(ActionArg()); | ||
4204 | 58 | ASSERT_TRUE(plugin_adapter->InShowDesktop()); | ||
4205 | 59 | |||
4206 | 60 | icon.Activate(ActionArg()); | ||
4207 | 61 | EXPECT_FALSE(plugin_adapter->InShowDesktop()); | ||
4208 | 62 | } | ||
4209 | 63 | |||
4210 | 64 | TEST_F(TestDesktopLauncherIcon, ShowInSwitcher) | ||
4211 | 65 | { | ||
4212 | 66 | EXPECT_TRUE(icon.ShowInSwitcher(false)); | ||
4213 | 67 | EXPECT_TRUE(icon.ShowInSwitcher(true)); | ||
4214 | 68 | |||
4215 | 69 | icon.SetShowInSwitcher(false); | ||
4216 | 70 | |||
4217 | 71 | EXPECT_FALSE(icon.ShowInSwitcher(false)); | ||
4218 | 72 | EXPECT_FALSE(icon.ShowInSwitcher(true)); | ||
4219 | 73 | } | ||
4220 | 74 | |||
4221 | 75 | TEST_F(TestDesktopLauncherIcon, RemoteUri) | ||
4222 | 76 | { | ||
4223 | 77 | EXPECT_EQ(icon.RemoteUri(), "unity://desktop-icon"); | ||
4224 | 78 | } | ||
4225 | 79 | |||
4226 | 80 | } | ||
4227 | 0 | 81 | ||
4228 | === modified file 'tests/test_desktop_utilities.cpp' | |||
4229 | --- tests/test_desktop_utilities.cpp 2012-06-01 09:33:15 +0000 | |||
4230 | +++ tests/test_desktop_utilities.cpp 2012-09-18 15:52:46 +0000 | |||
4231 | @@ -30,7 +30,9 @@ | |||
4232 | 30 | using testing::Eq; | 30 | using testing::Eq; |
4233 | 31 | 31 | ||
4234 | 32 | namespace { | 32 | namespace { |
4236 | 33 | 33 | ||
4237 | 34 | const std::string LOCAL_DATA_DIR = BUILDDIR"/tests/data"; | ||
4238 | 35 | |||
4239 | 34 | TEST(TestDesktopUtilitiesDesktopID, TestEmptyValues) | 36 | TEST(TestDesktopUtilitiesDesktopID, TestEmptyValues) |
4240 | 35 | { | 37 | { |
4241 | 36 | std::vector<std::string> empty_list; | 38 | std::vector<std::string> empty_list; |
4242 | @@ -88,71 +90,99 @@ | |||
4243 | 88 | Eq("subdir-to.desktop")); | 90 | Eq("subdir-to.desktop")); |
4244 | 89 | EXPECT_THAT(DesktopUtilities::GetDesktopID(dirs, "/this/path/applications/subdir1/subdir2/to.desktop"), | 91 | EXPECT_THAT(DesktopUtilities::GetDesktopID(dirs, "/this/path/applications/subdir1/subdir2/to.desktop"), |
4245 | 90 | Eq("subdir1-subdir2-to.desktop")); | 92 | Eq("subdir1-subdir2-to.desktop")); |
4246 | 93 | EXPECT_THAT(DesktopUtilities::GetDesktopID(dirs, "/this/path/applications/subdir1/subdir2-to.desktop"), | ||
4247 | 94 | Eq("subdir1-subdir2-to.desktop")); | ||
4248 | 91 | } | 95 | } |
4249 | 92 | 96 | ||
4250 | 93 | TEST(TestDesktopUtilitiesDataDirectories, TestGetUserDataDirectory) | 97 | TEST(TestDesktopUtilitiesDataDirectories, TestGetUserDataDirectory) |
4251 | 94 | { | 98 | { |
4253 | 95 | const gchar* old_home = g_getenv("XDG_DATA_HOME"); | 99 | const gchar* env = g_getenv("XDG_DATA_HOME"); |
4254 | 100 | std::string old_home = env ? env : ""; | ||
4255 | 101 | |||
4256 | 96 | g_setenv("XDG_DATA_HOME", "UnityUserConfig", TRUE); | 102 | g_setenv("XDG_DATA_HOME", "UnityUserConfig", TRUE); |
4257 | 97 | 103 | ||
4258 | 98 | std::string const& user_data_dir = DesktopUtilities::GetUserDataDirectory(); | 104 | std::string const& user_data_dir = DesktopUtilities::GetUserDataDirectory(); |
4259 | 99 | 105 | ||
4261 | 100 | g_setenv("XDG_DATA_HOME", old_home, TRUE); | 106 | g_setenv("XDG_DATA_HOME", old_home.c_str(), TRUE); |
4262 | 101 | 107 | ||
4263 | 102 | EXPECT_THAT(user_data_dir, Eq("UnityUserConfig")); | 108 | EXPECT_THAT(user_data_dir, Eq("UnityUserConfig")); |
4264 | 103 | } | 109 | } |
4265 | 104 | 110 | ||
4266 | 105 | TEST(TestDesktopUtilitiesDataDirectories, TestGetSystemDataDirectory) | 111 | TEST(TestDesktopUtilitiesDataDirectories, TestGetSystemDataDirectory) |
4267 | 106 | { | 112 | { |
4270 | 107 | const gchar* old_dirs = g_getenv("XDG_DATA_DIRS"); | 113 | const gchar* env = g_getenv("XDG_DATA_DIRS"); |
4271 | 108 | g_setenv("XDG_DATA_DIRS", "dir1:dir2::dir3:dir4", TRUE); | 114 | std::string old_dirs = env ? env : ""; |
4272 | 115 | g_setenv("XDG_DATA_DIRS", ("dir1:dir2::dir3:dir4:"+LOCAL_DATA_DIR).c_str(), TRUE); | ||
4273 | 109 | 116 | ||
4274 | 110 | std::vector<std::string> const& system_dirs = DesktopUtilities::GetSystemDataDirectories(); | 117 | std::vector<std::string> const& system_dirs = DesktopUtilities::GetSystemDataDirectories(); |
4275 | 111 | 118 | ||
4277 | 112 | g_setenv("XDG_DATA_DIRS", old_dirs, TRUE); | 119 | g_setenv("XDG_DATA_DIRS", old_dirs.c_str(), TRUE); |
4278 | 113 | 120 | ||
4280 | 114 | ASSERT_THAT(system_dirs.size(), Eq(4)); | 121 | ASSERT_THAT(system_dirs.size(), Eq(5)); |
4281 | 115 | EXPECT_THAT(system_dirs[0], Eq("dir1")); | 122 | EXPECT_THAT(system_dirs[0], Eq("dir1")); |
4282 | 116 | EXPECT_THAT(system_dirs[1], Eq("dir2")); | 123 | EXPECT_THAT(system_dirs[1], Eq("dir2")); |
4283 | 117 | EXPECT_THAT(system_dirs[2], Eq("dir3")); | 124 | EXPECT_THAT(system_dirs[2], Eq("dir3")); |
4284 | 118 | EXPECT_THAT(system_dirs[3], Eq("dir4")); | 125 | EXPECT_THAT(system_dirs[3], Eq("dir4")); |
4285 | 126 | EXPECT_THAT(system_dirs[4], Eq(LOCAL_DATA_DIR)); | ||
4286 | 119 | } | 127 | } |
4287 | 120 | 128 | ||
4288 | 121 | TEST(TestDesktopUtilitiesDataDirectories, TestGetDataDirectory) | 129 | TEST(TestDesktopUtilitiesDataDirectories, TestGetDataDirectory) |
4289 | 122 | { | 130 | { |
4293 | 123 | const gchar* old_dirs = g_getenv("XDG_DATA_DIRS"); | 131 | const gchar* env = g_getenv("XDG_DATA_DIRS"); |
4294 | 124 | g_setenv("XDG_DATA_DIRS", "dir1:dir2::dir3:dir4", TRUE); | 132 | std::string old_dirs = env ? env : ""; |
4295 | 125 | const gchar* old_home = g_getenv("XDG_DATA_HOME"); | 133 | env = g_getenv("XDG_DATA_HOME"); |
4296 | 134 | std::string old_home = env ? env : ""; | ||
4297 | 135 | |||
4298 | 136 | g_setenv("XDG_DATA_DIRS", ("dir1:dir2::dir3:dir4:"+LOCAL_DATA_DIR).c_str(), TRUE); | ||
4299 | 126 | g_setenv("XDG_DATA_HOME", "UnityUserConfig", TRUE); | 137 | g_setenv("XDG_DATA_HOME", "UnityUserConfig", TRUE); |
4300 | 127 | 138 | ||
4301 | 128 | std::vector<std::string> const& data_dirs = DesktopUtilities::GetDataDirectories(); | 139 | std::vector<std::string> const& data_dirs = DesktopUtilities::GetDataDirectories(); |
4302 | 129 | 140 | ||
4305 | 130 | g_setenv("XDG_DATA_DIRS", old_dirs, TRUE); | 141 | g_setenv("XDG_DATA_DIRS", old_dirs.c_str(), TRUE); |
4306 | 131 | g_setenv("XDG_DATA_HOME", old_home, TRUE); | 142 | g_setenv("XDG_DATA_HOME", old_home.c_str(), TRUE); |
4307 | 132 | 143 | ||
4309 | 133 | ASSERT_THAT(data_dirs.size(), Eq(5)); | 144 | ASSERT_THAT(data_dirs.size(), Eq(6)); |
4310 | 134 | EXPECT_THAT(data_dirs[0], Eq("dir1")); | 145 | EXPECT_THAT(data_dirs[0], Eq("dir1")); |
4311 | 135 | EXPECT_THAT(data_dirs[1], Eq("dir2")); | 146 | EXPECT_THAT(data_dirs[1], Eq("dir2")); |
4312 | 136 | EXPECT_THAT(data_dirs[2], Eq("dir3")); | 147 | EXPECT_THAT(data_dirs[2], Eq("dir3")); |
4313 | 137 | EXPECT_THAT(data_dirs[3], Eq("dir4")); | 148 | EXPECT_THAT(data_dirs[3], Eq("dir4")); |
4320 | 138 | EXPECT_THAT(data_dirs[4], Eq("UnityUserConfig")); | 149 | EXPECT_THAT(data_dirs[4], Eq(LOCAL_DATA_DIR)); |
4321 | 139 | } | 150 | EXPECT_THAT(data_dirs[5], Eq("UnityUserConfig")); |
4322 | 140 | 151 | } | |
4323 | 141 | TEST(TestDesktopUtilitiesDataDirectories, TestGetBackgroundColor) | 152 | |
4324 | 142 | { | 153 | TEST(TestDesktopUtilities, TestGetDesktopPathById) |
4325 | 143 | std::string const& color = DesktopUtilities::GetBackgroundColor(BUILDDIR"/tests/data/ubuntu-software-center.desktop"); | 154 | { |
4326 | 155 | const gchar* env = g_getenv("XDG_DATA_DIRS"); | ||
4327 | 156 | std::string old_dirs = env ? env : ""; | ||
4328 | 157 | env = g_getenv("XDG_DATA_HOME"); | ||
4329 | 158 | std::string old_home = env ? env : ""; | ||
4330 | 159 | |||
4331 | 160 | g_setenv("XDG_DATA_DIRS", LOCAL_DATA_DIR.c_str(), TRUE); | ||
4332 | 161 | g_setenv("XDG_DATA_HOME", "UnityUserConfig", TRUE); | ||
4333 | 162 | |||
4334 | 163 | std::string const& file = DesktopUtilities::GetDesktopPathById("ubuntu-software-center.desktop"); | ||
4335 | 164 | |||
4336 | 165 | g_setenv("XDG_DATA_DIRS", old_dirs.c_str(), TRUE); | ||
4337 | 166 | g_setenv("XDG_DATA_HOME", old_dirs.c_str(), TRUE); | ||
4338 | 167 | |||
4339 | 168 | EXPECT_EQ(file, LOCAL_DATA_DIR + "/applications/ubuntu-software-center.desktop"); | ||
4340 | 169 | } | ||
4341 | 170 | |||
4342 | 171 | TEST(TestDesktopUtilities, TestGetBackgroundColor) | ||
4343 | 172 | { | ||
4344 | 173 | std::string const& color = DesktopUtilities::GetBackgroundColor(LOCAL_DATA_DIR+"/applications/ubuntu-software-center.desktop"); | ||
4345 | 144 | 174 | ||
4346 | 145 | EXPECT_EQ(color, "#aabbcc"); | 175 | EXPECT_EQ(color, "#aabbcc"); |
4347 | 146 | } | 176 | } |
4348 | 147 | 177 | ||
4350 | 148 | TEST(TestDesktopUtilitiesDataDirectories, TestGetBackgroundColorNoKey) | 178 | TEST(TestDesktopUtilities, TestGetBackgroundColorNoKey) |
4351 | 149 | { | 179 | { |
4353 | 150 | std::string const& color = DesktopUtilities::GetBackgroundColor(BUILDDIR"/tests/data/update-manager.desktop"); | 180 | std::string const& color = DesktopUtilities::GetBackgroundColor(LOCAL_DATA_DIR+"/applications/update-manager.desktop"); |
4354 | 151 | 181 | ||
4355 | 152 | EXPECT_TRUE(color.empty()); | 182 | EXPECT_TRUE(color.empty()); |
4356 | 153 | } | 183 | } |
4357 | 154 | 184 | ||
4359 | 155 | TEST(TestDesktopUtilitiesDataDirectories, TestGetBackgroundColorNoFile) | 185 | TEST(TestDesktopUtilities, TestGetBackgroundColorNoFile) |
4360 | 156 | { | 186 | { |
4361 | 157 | std::string const& color = DesktopUtilities::GetBackgroundColor("hello-world.desktop"); | 187 | std::string const& color = DesktopUtilities::GetBackgroundColor("hello-world.desktop"); |
4362 | 158 | 188 | ||
4363 | 159 | 189 | ||
4364 | === modified file 'tests/test_device_launcher_section.cpp' | |||
4365 | --- tests/test_device_launcher_section.cpp 2012-08-17 15:53:06 +0000 | |||
4366 | +++ tests/test_device_launcher_section.cpp 2012-09-18 15:52:46 +0000 | |||
4367 | @@ -21,17 +21,16 @@ | |||
4368 | 21 | */ | 21 | */ |
4369 | 22 | 22 | ||
4370 | 23 | #include <gmock/gmock.h> | 23 | #include <gmock/gmock.h> |
4371 | 24 | |||
4372 | 25 | #include "DevicesSettings.h" | ||
4373 | 26 | #include "test_mock_devices.h" | ||
4374 | 27 | #include "test_utils.h" | ||
4375 | 28 | |||
4376 | 24 | using namespace testing; | 29 | using namespace testing; |
4377 | 25 | |||
4378 | 26 | #include "DeviceLauncherSection.h" | ||
4379 | 27 | #include "DevicesSettings.h" | ||
4380 | 28 | #include "AbstractVolumeMonitorWrapper.h" | ||
4381 | 29 | using namespace unity; | ||
4382 | 30 | using namespace unity::launcher; | 30 | using namespace unity::launcher; |
4383 | 31 | 31 | ||
4387 | 32 | #include "gmockvolume.h" | 32 | namespace unity |
4388 | 33 | #include "test_utils.h" | 33 | { |
4386 | 34 | |||
4389 | 35 | namespace | 34 | namespace |
4390 | 36 | { | 35 | { |
4391 | 37 | 36 | ||
4392 | @@ -50,72 +49,38 @@ | |||
4393 | 50 | bool icon_added; | 49 | bool icon_added; |
4394 | 51 | }; | 50 | }; |
4395 | 52 | 51 | ||
4431 | 53 | class MockVolumeMonitorWrapper : public AbstractVolumeMonitorWrapper | 52 | struct TestDeviceLauncherSection : Test |
4432 | 54 | { | 53 | { |
4398 | 55 | public: | ||
4399 | 56 | typedef std::shared_ptr<MockVolumeMonitorWrapper> Ptr; | ||
4400 | 57 | |||
4401 | 58 | MockVolumeMonitorWrapper() | ||
4402 | 59 | : volume1(G_VOLUME(g_mock_volume_new())) | ||
4403 | 60 | , volume2(G_VOLUME(g_mock_volume_new())) | ||
4404 | 61 | { | ||
4405 | 62 | } | ||
4406 | 63 | |||
4407 | 64 | VolumeList GetVolumes() | ||
4408 | 65 | { | ||
4409 | 66 | VolumeList ret; | ||
4410 | 67 | |||
4411 | 68 | ret.push_back(volume1); | ||
4412 | 69 | ret.push_back(volume2); | ||
4413 | 70 | |||
4414 | 71 | return ret; | ||
4415 | 72 | } | ||
4416 | 73 | |||
4417 | 74 | glib::Object<GVolume> volume1; | ||
4418 | 75 | glib::Object<GVolume> volume2; | ||
4419 | 76 | }; | ||
4420 | 77 | |||
4421 | 78 | class MockDevicesSettings : public DevicesSettings | ||
4422 | 79 | { | ||
4423 | 80 | MOCK_CONST_METHOD1(IsABlacklistedDevice, bool(std::string const& uuid)); | ||
4424 | 81 | MOCK_METHOD1(TryToBlacklist, void(std::string const& uuid)); | ||
4425 | 82 | MOCK_METHOD1(TryToUnblacklist, void(std::string const& uuid)); | ||
4426 | 83 | }; | ||
4427 | 84 | |||
4428 | 85 | class TestDeviceLauncherSection : public Test | ||
4429 | 86 | { | ||
4430 | 87 | public: | ||
4433 | 88 | TestDeviceLauncherSection() | 54 | TestDeviceLauncherSection() |
4434 | 89 | : monitor_(new MockVolumeMonitorWrapper) | 55 | : monitor_(new MockVolumeMonitorWrapper) |
4435 | 90 | , devices_settings_(new MockDevicesSettings) | 56 | , devices_settings_(new MockDevicesSettings) |
4436 | 91 | , section_(monitor_, devices_settings_) | 57 | , section_(monitor_, devices_settings_) |
4437 | 92 | {} | 58 | {} |
4438 | 93 | 59 | ||
4439 | 94 | void SetUp() | ||
4440 | 95 | { | ||
4441 | 96 | // Make sure PopulateEntries is called. | ||
4442 | 97 | Utils::WaitForTimeoutMSec(1500); | ||
4443 | 98 | } | ||
4444 | 99 | |||
4445 | 100 | MockVolumeMonitorWrapper::Ptr monitor_; | 60 | MockVolumeMonitorWrapper::Ptr monitor_; |
4446 | 101 | DevicesSettings::Ptr devices_settings_; | 61 | DevicesSettings::Ptr devices_settings_; |
4447 | 102 | DeviceLauncherSection section_; | 62 | DeviceLauncherSection section_; |
4448 | 103 | }; | 63 | }; |
4449 | 104 | 64 | ||
4452 | 105 | 65 | TEST_F(TestDeviceLauncherSection, NoDuplicates) | |
4451 | 106 | TEST_F(TestDeviceLauncherSection, TestNoDuplicates) | ||
4453 | 107 | { | 66 | { |
4454 | 108 | std::shared_ptr<EventListener> listener(new EventListener); | 67 | std::shared_ptr<EventListener> listener(new EventListener); |
4456 | 109 | section_.IconAdded.connect(sigc::mem_fun(*listener, &EventListener::OnIconAdded)); | 68 | section_.icon_added.connect(sigc::mem_fun(*listener, &EventListener::OnIconAdded)); |
4457 | 110 | 69 | ||
4458 | 111 | // Emit the signal volume_added for each volume. | 70 | // Emit the signal volume_added for each volume. |
4461 | 112 | monitor_->volume_added.emit(monitor_->volume1); | 71 | monitor_->volume_added.emit(*(std::next(monitor_->volumes_.begin(), 0))); |
4462 | 113 | monitor_->volume_added.emit(monitor_->volume2); | 72 | monitor_->volume_added.emit(*(std::next(monitor_->volumes_.begin(), 1))); |
4463 | 114 | 73 | ||
4464 | 115 | Utils::WaitForTimeoutMSec(500); | 74 | Utils::WaitForTimeoutMSec(500); |
4465 | 116 | 75 | ||
4466 | 117 | EXPECT_EQ(listener->icon_added, false); | 76 | EXPECT_EQ(listener->icon_added, false); |
4467 | 118 | } | 77 | } |
4468 | 119 | 78 | ||
4469 | 79 | TEST_F(TestDeviceLauncherSection, GetIcons) | ||
4470 | 80 | { | ||
4471 | 81 | EXPECT_EQ(section_.GetIcons().size(), 2); | ||
4472 | 82 | } | ||
4473 | 83 | |||
4474 | 84 | } | ||
4475 | 120 | } | 85 | } |
4476 | 121 | 86 | ||
4477 | 122 | 87 | ||
4478 | === added file 'tests/test_expo_launcher_icon.cpp' | |||
4479 | --- tests/test_expo_launcher_icon.cpp 1970-01-01 00:00:00 +0000 | |||
4480 | +++ tests/test_expo_launcher_icon.cpp 2012-09-18 15:52:46 +0000 | |||
4481 | @@ -0,0 +1,58 @@ | |||
4482 | 1 | /* | ||
4483 | 2 | * Copyright 2012 Canonical Ltd. | ||
4484 | 3 | * | ||
4485 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
4486 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
4487 | 6 | * by the Free Software Foundation. | ||
4488 | 7 | * | ||
4489 | 8 | * This program is distributed in the hope that it will be useful, but | ||
4490 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
4491 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
4492 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
4493 | 12 | * | ||
4494 | 13 | * You should have received a copy of the GNU General Public License | ||
4495 | 14 | * version 3 along with this program. If not, see | ||
4496 | 15 | * <http://www.gnu.org/licenses/> | ||
4497 | 16 | * | ||
4498 | 17 | * Authored by: Marco Trevisan (Treviño) <marco.trevisan@canonical.com> | ||
4499 | 18 | */ | ||
4500 | 19 | |||
4501 | 20 | #include <gmock/gmock.h> | ||
4502 | 21 | |||
4503 | 22 | #include "ExpoLauncherIcon.h" | ||
4504 | 23 | #include "PluginAdapter.h" | ||
4505 | 24 | |||
4506 | 25 | using namespace unity; | ||
4507 | 26 | using namespace unity::launcher; | ||
4508 | 27 | |||
4509 | 28 | namespace | ||
4510 | 29 | { | ||
4511 | 30 | struct TestExpoLauncherIcon : testing::Test | ||
4512 | 31 | { | ||
4513 | 32 | ExpoLauncherIcon icon; | ||
4514 | 33 | }; | ||
4515 | 34 | |||
4516 | 35 | TEST_F(TestExpoLauncherIcon, ActivateToggleExpo) | ||
4517 | 36 | { | ||
4518 | 37 | auto plugin_adapter = PluginAdapter::Default(); | ||
4519 | 38 | |||
4520 | 39 | ASSERT_FALSE(plugin_adapter->IsExpoActive()); | ||
4521 | 40 | |||
4522 | 41 | icon.Activate(ActionArg()); | ||
4523 | 42 | ASSERT_TRUE(plugin_adapter->IsExpoActive()); | ||
4524 | 43 | |||
4525 | 44 | icon.Activate(ActionArg()); | ||
4526 | 45 | EXPECT_FALSE(plugin_adapter->IsExpoActive()); | ||
4527 | 46 | } | ||
4528 | 47 | |||
4529 | 48 | TEST_F(TestExpoLauncherIcon, Position) | ||
4530 | 49 | { | ||
4531 | 50 | EXPECT_EQ(icon.position(), AbstractLauncherIcon::Position::FLOATING); | ||
4532 | 51 | } | ||
4533 | 52 | |||
4534 | 53 | TEST_F(TestExpoLauncherIcon, RemoteUri) | ||
4535 | 54 | { | ||
4536 | 55 | EXPECT_EQ(icon.RemoteUri(), "unity://expo-icon"); | ||
4537 | 56 | } | ||
4538 | 57 | |||
4539 | 58 | } | ||
4540 | 0 | 59 | ||
4541 | === added file 'tests/test_favorite_store.cpp' | |||
4542 | --- tests/test_favorite_store.cpp 1970-01-01 00:00:00 +0000 | |||
4543 | +++ tests/test_favorite_store.cpp 2012-09-18 15:52:46 +0000 | |||
4544 | @@ -0,0 +1,111 @@ | |||
4545 | 1 | /* | ||
4546 | 2 | * Copyright 2012 Canonical Ltd. | ||
4547 | 3 | * | ||
4548 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
4549 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
4550 | 6 | * by the Free Software Foundation. | ||
4551 | 7 | * | ||
4552 | 8 | * This program is distributed in the hope that it will be useful, but | ||
4553 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
4554 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
4555 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
4556 | 12 | * | ||
4557 | 13 | * You should have received a copy of the GNU General Public License | ||
4558 | 14 | * version 3 along with this program. If not, see | ||
4559 | 15 | * <http://www.gnu.org/licenses/> | ||
4560 | 16 | * | ||
4561 | 17 | * Authored by: Marco Trevisan (Treviño) <marco.trevisan@canonical.com> | ||
4562 | 18 | */ | ||
4563 | 19 | |||
4564 | 20 | #include <gmock/gmock.h> | ||
4565 | 21 | #include <config.h> | ||
4566 | 22 | |||
4567 | 23 | #include "FavoriteStore.h" | ||
4568 | 24 | |||
4569 | 25 | using namespace unity; | ||
4570 | 26 | |||
4571 | 27 | namespace | ||
4572 | 28 | { | ||
4573 | 29 | class MockFavoriteStore : public FavoriteStore | ||
4574 | 30 | { | ||
4575 | 31 | public: | ||
4576 | 32 | FavoriteList const& GetFavorites() const { return fav_list_; } | ||
4577 | 33 | void AddFavorite(std::string const& icon_uri, int position) {} | ||
4578 | 34 | void RemoveFavorite(std::string const& icon_uri) {} | ||
4579 | 35 | void MoveFavorite(std::string const& icon_uri, int position) {} | ||
4580 | 36 | bool IsFavorite(std::string const& icon_uri) const { return false; } | ||
4581 | 37 | int FavoritePosition(std::string const& icon_uri) const { return -1; } | ||
4582 | 38 | void SetFavorites(FavoriteList const& icon_uris) {} | ||
4583 | 39 | |||
4584 | 40 | std::string ParseFavoriteFromUri(std::string const& uri) const | ||
4585 | 41 | { | ||
4586 | 42 | return FavoriteStore::ParseFavoriteFromUri(uri); | ||
4587 | 43 | } | ||
4588 | 44 | |||
4589 | 45 | private: | ||
4590 | 46 | FavoriteList fav_list_; | ||
4591 | 47 | }; | ||
4592 | 48 | |||
4593 | 49 | struct TestFavoriteStore : public testing::Test | ||
4594 | 50 | { | ||
4595 | 51 | MockFavoriteStore favorite_store; | ||
4596 | 52 | }; | ||
4597 | 53 | |||
4598 | 54 | TEST_F(TestFavoriteStore, Construction) | ||
4599 | 55 | { | ||
4600 | 56 | FavoriteStore& instance = FavoriteStore::Instance(); | ||
4601 | 57 | EXPECT_EQ(&instance, &favorite_store); | ||
4602 | 58 | } | ||
4603 | 59 | |||
4604 | 60 | TEST_F(TestFavoriteStore, UriPrefixes) | ||
4605 | 61 | { | ||
4606 | 62 | EXPECT_EQ(FavoriteStore::URI_PREFIX_APP, "application://"); | ||
4607 | 63 | EXPECT_EQ(FavoriteStore::URI_PREFIX_FILE, "file://"); | ||
4608 | 64 | EXPECT_EQ(FavoriteStore::URI_PREFIX_DEVICE, "device://"); | ||
4609 | 65 | EXPECT_EQ(FavoriteStore::URI_PREFIX_UNITY, "unity://"); | ||
4610 | 66 | } | ||
4611 | 67 | |||
4612 | 68 | TEST_F(TestFavoriteStore, IsValidFavoriteUri) | ||
4613 | 69 | { | ||
4614 | 70 | EXPECT_FALSE(FavoriteStore::IsValidFavoriteUri("")); | ||
4615 | 71 | EXPECT_FALSE(FavoriteStore::IsValidFavoriteUri("invalid-favorite")); | ||
4616 | 72 | EXPECT_FALSE(FavoriteStore::IsValidFavoriteUri("/path/to/desktop_file")); | ||
4617 | 73 | EXPECT_FALSE(FavoriteStore::IsValidFavoriteUri("desktop_file")); | ||
4618 | 74 | EXPECT_FALSE(FavoriteStore::IsValidFavoriteUri("file:///path/to/desktop_file")); | ||
4619 | 75 | EXPECT_FALSE(FavoriteStore::IsValidFavoriteUri("application://desktop_file")); | ||
4620 | 76 | EXPECT_FALSE(FavoriteStore::IsValidFavoriteUri("application://")); | ||
4621 | 77 | EXPECT_FALSE(FavoriteStore::IsValidFavoriteUri("device://")); | ||
4622 | 78 | EXPECT_FALSE(FavoriteStore::IsValidFavoriteUri("unity://")); | ||
4623 | 79 | |||
4624 | 80 | EXPECT_TRUE(FavoriteStore::IsValidFavoriteUri("device://uuid")); | ||
4625 | 81 | EXPECT_TRUE(FavoriteStore::IsValidFavoriteUri("file:///path/to/desktop_file.desktop")); | ||
4626 | 82 | EXPECT_TRUE(FavoriteStore::IsValidFavoriteUri("application://desktop_file.desktop")); | ||
4627 | 83 | EXPECT_TRUE(FavoriteStore::IsValidFavoriteUri("device://a")); | ||
4628 | 84 | EXPECT_TRUE(FavoriteStore::IsValidFavoriteUri("unity://b")); | ||
4629 | 85 | EXPECT_TRUE(FavoriteStore::IsValidFavoriteUri("application://c.desktop")); | ||
4630 | 86 | } | ||
4631 | 87 | |||
4632 | 88 | TEST_F(TestFavoriteStore, ParseFavoriteFromUri) | ||
4633 | 89 | { | ||
4634 | 90 | const std::string VALID_DESKTOP_PATH = BUILDDIR"/tests/data/applications/ubuntu-software-center.desktop"; | ||
4635 | 91 | EXPECT_EQ(favorite_store.ParseFavoriteFromUri("file.desktop"), "application://file.desktop"); | ||
4636 | 92 | EXPECT_EQ(favorite_store.ParseFavoriteFromUri(VALID_DESKTOP_PATH), "application://"+VALID_DESKTOP_PATH); | ||
4637 | 93 | |||
4638 | 94 | EXPECT_EQ(favorite_store.ParseFavoriteFromUri("application://file.desktop"), "application://file.desktop"); | ||
4639 | 95 | EXPECT_EQ(favorite_store.ParseFavoriteFromUri("application://"+VALID_DESKTOP_PATH), "application://"+VALID_DESKTOP_PATH); | ||
4640 | 96 | EXPECT_EQ(favorite_store.ParseFavoriteFromUri("file://"+VALID_DESKTOP_PATH), "file://"+VALID_DESKTOP_PATH); | ||
4641 | 97 | |||
4642 | 98 | EXPECT_EQ(favorite_store.ParseFavoriteFromUri("unity://uri"), "unity://uri"); | ||
4643 | 99 | EXPECT_EQ(favorite_store.ParseFavoriteFromUri("device://uuid"), "device://uuid"); | ||
4644 | 100 | |||
4645 | 101 | EXPECT_TRUE(favorite_store.ParseFavoriteFromUri("file").empty()); | ||
4646 | 102 | EXPECT_TRUE(favorite_store.ParseFavoriteFromUri("/path/to/file").empty()); | ||
4647 | 103 | EXPECT_TRUE(favorite_store.ParseFavoriteFromUri("/path/to/file.desktop").empty()); | ||
4648 | 104 | EXPECT_TRUE(favorite_store.ParseFavoriteFromUri("application:///path/to/file.desktop").empty()); | ||
4649 | 105 | EXPECT_TRUE(favorite_store.ParseFavoriteFromUri("file:///path/to/file.desktop").empty()); | ||
4650 | 106 | EXPECT_TRUE(favorite_store.ParseFavoriteFromUri("file://file.desktop").empty()); | ||
4651 | 107 | EXPECT_TRUE(favorite_store.ParseFavoriteFromUri("unity://").empty()); | ||
4652 | 108 | EXPECT_TRUE(favorite_store.ParseFavoriteFromUri("device://").empty()); | ||
4653 | 109 | } | ||
4654 | 110 | |||
4655 | 111 | } | ||
4656 | 0 | 112 | ||
4657 | === modified file 'tests/test_favorite_store_gsettings.cpp' | |||
4658 | --- tests/test_favorite_store_gsettings.cpp 2012-08-02 12:13:38 +0000 | |||
4659 | +++ tests/test_favorite_store_gsettings.cpp 2012-09-18 15:52:46 +0000 | |||
4660 | @@ -21,18 +21,12 @@ | |||
4661 | 21 | 21 | ||
4662 | 22 | #include <config.h> | 22 | #include <config.h> |
4663 | 23 | 23 | ||
4664 | 24 | #include <algorithm> | ||
4665 | 25 | #include <memory> | ||
4666 | 26 | #include <string> | ||
4667 | 27 | |||
4668 | 28 | #define G_SETTINGS_ENABLE_BACKEND | ||
4669 | 29 | #include <gio/gsettingsbackend.h> | ||
4670 | 30 | #include <gmock/gmock.h> | 24 | #include <gmock/gmock.h> |
4671 | 31 | #include <glib.h> | 25 | #include <glib.h> |
4672 | 32 | 26 | ||
4673 | 33 | #include "FavoriteStore.h" | 27 | #include "FavoriteStore.h" |
4674 | 34 | #include "FavoriteStoreGSettings.h" | 28 | #include "FavoriteStoreGSettings.h" |
4676 | 35 | #include "FavoriteStorePrivate.h" | 29 | |
4677 | 36 | #include <UnityCore/GLibWrapper.h> | 30 | #include <UnityCore/GLibWrapper.h> |
4678 | 37 | 31 | ||
4679 | 38 | using namespace unity; | 32 | using namespace unity; |
4680 | @@ -45,14 +39,16 @@ | |||
4681 | 45 | const gchar* SETTINGS_KEY = "favorites"; | 39 | const gchar* SETTINGS_KEY = "favorites"; |
4682 | 46 | const gchar* SCHEMA_DIRECTORY = BUILDDIR"/settings"; | 40 | const gchar* SCHEMA_DIRECTORY = BUILDDIR"/settings"; |
4683 | 47 | 41 | ||
4687 | 48 | const char* base_store_favs[] = { BUILDDIR"/tests/data/ubuntuone-installer.desktop", | 42 | const char* base_store_favs[] = { BUILDDIR"/tests/data/applications/ubuntuone-installer.desktop", |
4688 | 49 | BUILDDIR"/tests/data/ubuntu-software-center.desktop", | 43 | "file://" BUILDDIR "/tests/data/applications/ubuntu-software-center.desktop", |
4689 | 50 | BUILDDIR"/tests/data/update-manager.desktop", | 44 | "application://" BUILDDIR "/tests/data/applications/update-manager.desktop", |
4690 | 45 | "unity://test-icon", | ||
4691 | 46 | "device://uuid", | ||
4692 | 51 | NULL | 47 | NULL |
4693 | 52 | }; | 48 | }; |
4694 | 53 | const int n_base_store_favs = G_N_ELEMENTS(base_store_favs) - 1; /* NULL */ | 49 | const int n_base_store_favs = G_N_ELEMENTS(base_store_favs) - 1; /* NULL */ |
4695 | 54 | 50 | ||
4697 | 55 | const std::string other_desktop = BUILDDIR"/tests/data/bzr-handle-patch.desktop"; | 51 | const std::string other_desktop = "application://" BUILDDIR "/tests/data/applications/bzr-handle-patch.desktop"; |
4698 | 56 | 52 | ||
4699 | 57 | // Utilities | 53 | // Utilities |
4700 | 58 | std::string const& at(FavoriteList const& favs, int index) | 54 | std::string const& at(FavoriteList const& favs, int index) |
4701 | @@ -110,9 +106,9 @@ | |||
4702 | 110 | FavoriteList const& favs = settings.GetFavorites(); | 106 | FavoriteList const& favs = settings.GetFavorites(); |
4703 | 111 | 107 | ||
4704 | 112 | ASSERT_EQ(favs.size(), n_base_store_favs); | 108 | ASSERT_EQ(favs.size(), n_base_store_favs); |
4706 | 113 | EXPECT_TRUE(ends_with(at(favs, 0), base_store_favs[0])); | 109 | EXPECT_TRUE(ends_with(at(favs, 0), FavoriteStore::URI_PREFIX_APP+base_store_favs[0])); |
4707 | 114 | EXPECT_TRUE(ends_with(at(favs, 1), base_store_favs[1])); | 110 | EXPECT_TRUE(ends_with(at(favs, 1), base_store_favs[1])); |
4709 | 115 | EXPECT_TRUE(at(favs, 2) == base_store_favs[2]); | 111 | EXPECT_EQ(at(favs, 2), base_store_favs[2]); |
4710 | 116 | } | 112 | } |
4711 | 117 | 113 | ||
4712 | 118 | TEST_F(TestFavoriteStoreGSettings, TestAddFavorite) | 114 | TEST_F(TestFavoriteStoreGSettings, TestAddFavorite) |
4713 | @@ -122,7 +118,7 @@ | |||
4714 | 122 | settings.AddFavorite(other_desktop, 0); | 118 | settings.AddFavorite(other_desktop, 0); |
4715 | 123 | FavoriteList const& favs = settings.GetFavorites(); | 119 | FavoriteList const& favs = settings.GetFavorites(); |
4716 | 124 | ASSERT_EQ(favs.size(), n_base_store_favs + 1); | 120 | ASSERT_EQ(favs.size(), n_base_store_favs + 1); |
4718 | 125 | EXPECT_TRUE(other_desktop == at(favs, 0)); | 121 | EXPECT_EQ(other_desktop, at(favs, 0)); |
4719 | 126 | } | 122 | } |
4720 | 127 | 123 | ||
4721 | 128 | TEST_F(TestFavoriteStoreGSettings, TestAddFavoritePosition) | 124 | TEST_F(TestFavoriteStoreGSettings, TestAddFavoritePosition) |
4722 | @@ -132,7 +128,7 @@ | |||
4723 | 132 | settings.AddFavorite(other_desktop, 2); | 128 | settings.AddFavorite(other_desktop, 2); |
4724 | 133 | FavoriteList const& favs = settings.GetFavorites(); | 129 | FavoriteList const& favs = settings.GetFavorites(); |
4725 | 134 | ASSERT_EQ(favs.size(), n_base_store_favs + 1); | 130 | ASSERT_EQ(favs.size(), n_base_store_favs + 1); |
4727 | 135 | EXPECT_TRUE(other_desktop == at(favs, 2)); | 131 | EXPECT_EQ(other_desktop, at(favs, 2)); |
4728 | 136 | } | 132 | } |
4729 | 137 | 133 | ||
4730 | 138 | TEST_F(TestFavoriteStoreGSettings,TestAddFavoriteLast) | 134 | TEST_F(TestFavoriteStoreGSettings,TestAddFavoriteLast) |
4731 | @@ -142,7 +138,7 @@ | |||
4732 | 142 | settings.AddFavorite(other_desktop, -1); | 138 | settings.AddFavorite(other_desktop, -1); |
4733 | 143 | FavoriteList const& favs = settings.GetFavorites(); | 139 | FavoriteList const& favs = settings.GetFavorites(); |
4734 | 144 | ASSERT_EQ(favs.size(), n_base_store_favs + 1); | 140 | ASSERT_EQ(favs.size(), n_base_store_favs + 1); |
4736 | 145 | EXPECT_TRUE(other_desktop == favs.back()); | 141 | EXPECT_EQ(other_desktop, favs.back()); |
4737 | 146 | } | 142 | } |
4738 | 147 | 143 | ||
4739 | 148 | TEST_F(TestFavoriteStoreGSettings,TestAddFavoriteOutOfRange) | 144 | TEST_F(TestFavoriteStoreGSettings,TestAddFavoriteOutOfRange) |
4740 | @@ -178,13 +174,13 @@ | |||
4741 | 178 | FavoriteStore &settings = FavoriteStore::Instance(); | 174 | FavoriteStore &settings = FavoriteStore::Instance(); |
4742 | 179 | 175 | ||
4743 | 180 | FavoriteList const& favs = settings.GetFavorites(); | 176 | FavoriteList const& favs = settings.GetFavorites(); |
4751 | 181 | settings.RemoveFavorite(""); | 177 | settings.RemoveFavorite(" "); |
4752 | 182 | EXPECT_EQ(favs.size(), n_base_store_favs); | 178 | EXPECT_EQ(favs.size(), n_base_store_favs); |
4753 | 183 | 179 | ||
4754 | 184 | settings.RemoveFavorite("foo.desktop"); | 180 | settings.RemoveFavorite("application://foo.desktop"); |
4755 | 185 | EXPECT_EQ(favs.size(), n_base_store_favs); | 181 | EXPECT_EQ(favs.size(), n_base_store_favs); |
4756 | 186 | 182 | ||
4757 | 187 | settings.RemoveFavorite("/this/desktop/doesnt/exist/hopefully.desktop"); | 183 | settings.RemoveFavorite("application:///this/desktop/doesnt/exist/hopefully.desktop"); |
4758 | 188 | EXPECT_EQ(favs.size(), n_base_store_favs); | 184 | EXPECT_EQ(favs.size(), n_base_store_favs); |
4759 | 189 | } | 185 | } |
4760 | 190 | 186 | ||
4761 | @@ -198,7 +194,7 @@ | |||
4762 | 198 | 194 | ||
4763 | 199 | ASSERT_EQ(favs.size(), n_base_store_favs); | 195 | ASSERT_EQ(favs.size(), n_base_store_favs); |
4764 | 200 | EXPECT_EQ(at(favs, 0), base_store_favs[2]); | 196 | EXPECT_EQ(at(favs, 0), base_store_favs[2]); |
4766 | 201 | EXPECT_TRUE(ends_with(at(favs, 1), base_store_favs[0])); | 197 | EXPECT_TRUE(ends_with(at(favs, 1), FavoriteStore::URI_PREFIX_APP+base_store_favs[0])); |
4767 | 202 | EXPECT_TRUE(ends_with(at(favs, 2), base_store_favs[1])); | 198 | EXPECT_TRUE(ends_with(at(favs, 2), base_store_favs[1])); |
4768 | 203 | } | 199 | } |
4769 | 204 | 200 | ||
4770 | @@ -212,7 +208,7 @@ | |||
4771 | 212 | settings.MoveFavorite(at(favs, 0), 100); | 208 | settings.MoveFavorite(at(favs, 0), 100); |
4772 | 213 | 209 | ||
4773 | 214 | ASSERT_EQ(favs.size(), n_base_store_favs); | 210 | ASSERT_EQ(favs.size(), n_base_store_favs); |
4775 | 215 | EXPECT_TRUE(ends_with(at(favs, 0), base_store_favs[0])); | 211 | EXPECT_TRUE(ends_with(at(favs, 0), FavoriteStore::URI_PREFIX_APP+base_store_favs[0])); |
4776 | 216 | EXPECT_TRUE(ends_with(at(favs, 1), base_store_favs[1])); | 212 | EXPECT_TRUE(ends_with(at(favs, 1), base_store_favs[1])); |
4777 | 217 | EXPECT_EQ(at(favs, 2), base_store_favs[2]); | 213 | EXPECT_EQ(at(favs, 2), base_store_favs[2]); |
4778 | 218 | } | 214 | } |
4779 | @@ -239,7 +235,7 @@ | |||
4780 | 239 | favorite_store->SaveFavorites(favs, false); | 235 | favorite_store->SaveFavorites(favs, false); |
4781 | 240 | 236 | ||
4782 | 241 | ASSERT_TRUE(signal_received); | 237 | ASSERT_TRUE(signal_received); |
4784 | 242 | EXPECT_EQ(position, base_store_favs[0]); | 238 | EXPECT_EQ(position, FavoriteStore::URI_PREFIX_APP+base_store_favs[0]); |
4785 | 243 | EXPECT_TRUE(before); | 239 | EXPECT_TRUE(before); |
4786 | 244 | } | 240 | } |
4787 | 245 | 241 | ||
4788 | @@ -322,12 +318,12 @@ | |||
4789 | 322 | { | 318 | { |
4790 | 323 | FavoriteStore &settings = FavoriteStore::Instance(); | 319 | FavoriteStore &settings = FavoriteStore::Instance(); |
4791 | 324 | bool signal_received = false; | 320 | bool signal_received = false; |
4793 | 325 | std::string path_removed; | 321 | std::vector<std::string> paths_removed; |
4794 | 326 | 322 | ||
4795 | 327 | settings.favorite_removed.connect([&](std::string const& path) | 323 | settings.favorite_removed.connect([&](std::string const& path) |
4796 | 328 | { | 324 | { |
4797 | 329 | signal_received = true; | 325 | signal_received = true; |
4799 | 330 | path_removed = path; | 326 | paths_removed.push_back(path); |
4800 | 331 | }); | 327 | }); |
4801 | 332 | 328 | ||
4802 | 333 | FavoriteList favs; | 329 | FavoriteList favs; |
4803 | @@ -336,7 +332,10 @@ | |||
4804 | 336 | favorite_store->SaveFavorites(favs, false); | 332 | favorite_store->SaveFavorites(favs, false); |
4805 | 337 | 333 | ||
4806 | 338 | ASSERT_TRUE(signal_received); | 334 | ASSERT_TRUE(signal_received); |
4808 | 339 | EXPECT_EQ(path_removed, base_store_favs[1]); | 335 | ASSERT_EQ(paths_removed.size(), 3); |
4809 | 336 | EXPECT_EQ(paths_removed[0], base_store_favs[4]); | ||
4810 | 337 | EXPECT_EQ(paths_removed[1], base_store_favs[1]); | ||
4811 | 338 | EXPECT_EQ(paths_removed[2], base_store_favs[3]); | ||
4812 | 340 | } | 339 | } |
4813 | 341 | 340 | ||
4814 | 342 | TEST_F(TestFavoriteStoreGSettings, TestFavoriteReordered) | 341 | TEST_F(TestFavoriteStoreGSettings, TestFavoriteReordered) |
4815 | @@ -464,4 +463,28 @@ | |||
4816 | 464 | EXPECT_TRUE(reordered_received); | 463 | EXPECT_TRUE(reordered_received); |
4817 | 465 | } | 464 | } |
4818 | 466 | 465 | ||
4819 | 466 | TEST_F(TestFavoriteStoreGSettings, TestIsFavorite) | ||
4820 | 467 | { | ||
4821 | 468 | EXPECT_TRUE(favorite_store->IsFavorite(FavoriteStore::URI_PREFIX_APP+base_store_favs[0])); | ||
4822 | 469 | |||
4823 | 470 | for (int i = 1; i < n_base_store_favs; i++) | ||
4824 | 471 | { | ||
4825 | 472 | ASSERT_TRUE(favorite_store->IsFavorite(base_store_favs[i])); | ||
4826 | 473 | } | ||
4827 | 474 | |||
4828 | 475 | EXPECT_FALSE(favorite_store->IsFavorite("unity://invalid-favorite")); | ||
4829 | 476 | } | ||
4830 | 477 | |||
4831 | 478 | TEST_F(TestFavoriteStoreGSettings, TestFavoritePosition) | ||
4832 | 479 | { | ||
4833 | 480 | EXPECT_EQ(favorite_store->FavoritePosition(FavoriteStore::URI_PREFIX_APP+base_store_favs[0]), 0); | ||
4834 | 481 | |||
4835 | 482 | for (int i = 1; i < n_base_store_favs; i++) | ||
4836 | 483 | { | ||
4837 | 484 | ASSERT_EQ(favorite_store->FavoritePosition(base_store_favs[i]), i); | ||
4838 | 485 | } | ||
4839 | 486 | |||
4840 | 487 | EXPECT_EQ(favorite_store->FavoritePosition("unity://invalid-favorite"), -1); | ||
4841 | 488 | } | ||
4842 | 489 | |||
4843 | 467 | } // anonymous namespace | 490 | } // anonymous namespace |
4844 | 468 | 491 | ||
4845 | === added file 'tests/test_hud_launcher_icon.cpp' | |||
4846 | --- tests/test_hud_launcher_icon.cpp 1970-01-01 00:00:00 +0000 | |||
4847 | +++ tests/test_hud_launcher_icon.cpp 2012-09-18 15:52:46 +0000 | |||
4848 | @@ -0,0 +1,53 @@ | |||
4849 | 1 | /* | ||
4850 | 2 | * Copyright 2012 Canonical Ltd. | ||
4851 | 3 | * | ||
4852 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
4853 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
4854 | 6 | * by the Free Software Foundation. | ||
4855 | 7 | * | ||
4856 | 8 | * This program is distributed in the hope that it will be useful, but | ||
4857 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
4858 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
4859 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
4860 | 12 | * | ||
4861 | 13 | * You should have received a copy of the GNU General Public License | ||
4862 | 14 | * version 3 along with this program. If not, see | ||
4863 | 15 | * <http://www.gnu.org/licenses/> | ||
4864 | 16 | * | ||
4865 | 17 | * Authored by: Marco Trevisan (Treviño) <marco.trevisan@canonical.com> | ||
4866 | 18 | */ | ||
4867 | 19 | |||
4868 | 20 | #include <gmock/gmock.h> | ||
4869 | 21 | |||
4870 | 22 | #include "HudLauncherIcon.h" | ||
4871 | 23 | |||
4872 | 24 | using namespace unity; | ||
4873 | 25 | using namespace unity::launcher; | ||
4874 | 26 | |||
4875 | 27 | namespace | ||
4876 | 28 | { | ||
4877 | 29 | |||
4878 | 30 | class MockHudLauncherIcon : public HudLauncherIcon | ||
4879 | 31 | { | ||
4880 | 32 | public: | ||
4881 | 33 | MockHudLauncherIcon() | ||
4882 | 34 | : HudLauncherIcon(LauncherHideMode::LAUNCHER_HIDE_NEVER) | ||
4883 | 35 | {} | ||
4884 | 36 | }; | ||
4885 | 37 | |||
4886 | 38 | struct TestHudLauncherIcon : testing::Test | ||
4887 | 39 | { | ||
4888 | 40 | MockHudLauncherIcon hud; | ||
4889 | 41 | }; | ||
4890 | 42 | |||
4891 | 43 | TEST_F(TestHudLauncherIcon, Type) | ||
4892 | 44 | { | ||
4893 | 45 | EXPECT_EQ(hud.GetIconType(), AbstractLauncherIcon::IconType::HUD); | ||
4894 | 46 | } | ||
4895 | 47 | |||
4896 | 48 | TEST_F(TestHudLauncherIcon, Position) | ||
4897 | 49 | { | ||
4898 | 50 | EXPECT_EQ(hud.position(), AbstractLauncherIcon::Position::BEGIN); | ||
4899 | 51 | } | ||
4900 | 52 | |||
4901 | 53 | } | ||
4902 | 0 | 54 | ||
4903 | === modified file 'tests/test_launcher.cpp' | |||
4904 | --- tests/test_launcher.cpp 2012-09-04 14:26:23 +0000 | |||
4905 | +++ tests/test_launcher.cpp 2012-09-18 15:52:46 +0000 | |||
4906 | @@ -48,8 +48,12 @@ | |||
4907 | 48 | { | 48 | { |
4908 | 49 | public: | 49 | public: |
4909 | 50 | typedef nux::ObjectPtr<MockMockLauncherIcon> Ptr; | 50 | typedef nux::ObjectPtr<MockMockLauncherIcon> Ptr; |
4910 | 51 | MockMockLauncherIcon(IconType type = IconType::APPLICATION) | ||
4911 | 52 | : MockLauncherIcon(type) | ||
4912 | 53 | {} | ||
4913 | 51 | 54 | ||
4914 | 52 | MOCK_METHOD1(ShouldHighlightOnDrag, bool(DndData const&)); | 55 | MOCK_METHOD1(ShouldHighlightOnDrag, bool(DndData const&)); |
4915 | 56 | MOCK_METHOD1(Stick, void(bool)); | ||
4916 | 53 | }; | 57 | }; |
4917 | 54 | 58 | ||
4918 | 55 | } | 59 | } |
4919 | @@ -57,7 +61,7 @@ | |||
4920 | 57 | class TestLauncher : public Test | 61 | class TestLauncher : public Test |
4921 | 58 | { | 62 | { |
4922 | 59 | public: | 63 | public: |
4924 | 60 | class MockLauncher : public launcher::Launcher | 64 | class MockLauncher : public Launcher |
4925 | 61 | { | 65 | { |
4926 | 62 | public: | 66 | public: |
4927 | 63 | MockLauncher(nux::BaseWindow* parent, nux::ObjectPtr<DNDCollectionWindow> const& collection_window) | 67 | MockLauncher(nux::BaseWindow* parent, nux::ObjectPtr<DNDCollectionWindow> const& collection_window) |
4928 | @@ -92,6 +96,11 @@ | |||
4929 | 92 | Launcher::ShowDragWindow(); | 96 | Launcher::ShowDragWindow(); |
4930 | 93 | } | 97 | } |
4931 | 94 | 98 | ||
4932 | 99 | void EndIconDrag() | ||
4933 | 100 | { | ||
4934 | 101 | Launcher::EndIconDrag(); | ||
4935 | 102 | } | ||
4936 | 103 | |||
4937 | 95 | void UpdateDragWindowPosition(int x, int y) | 104 | void UpdateDragWindowPosition(int x, int y) |
4938 | 96 | { | 105 | { |
4939 | 97 | Launcher::UpdateDragWindowPosition(x, y); | 106 | Launcher::UpdateDragWindowPosition(x, y); |
4940 | @@ -106,6 +115,55 @@ | |||
4941 | 106 | { | 115 | { |
4942 | 107 | Launcher::ResetMouseDragState(); | 116 | Launcher::ResetMouseDragState(); |
4943 | 108 | } | 117 | } |
4944 | 118 | |||
4945 | 119 | bool DndIsSpecialRequest(std::string const& uri) const | ||
4946 | 120 | { | ||
4947 | 121 | return Launcher::DndIsSpecialRequest(uri); | ||
4948 | 122 | } | ||
4949 | 123 | |||
4950 | 124 | int GetDragIconPosition() const | ||
4951 | 125 | { | ||
4952 | 126 | return _drag_icon_position; | ||
4953 | 127 | } | ||
4954 | 128 | |||
4955 | 129 | void ProcessDndEnter() | ||
4956 | 130 | { | ||
4957 | 131 | Launcher::ProcessDndEnter(); | ||
4958 | 132 | } | ||
4959 | 133 | |||
4960 | 134 | void ProcessDndLeave() | ||
4961 | 135 | { | ||
4962 | 136 | Launcher::ProcessDndLeave(); | ||
4963 | 137 | } | ||
4964 | 138 | |||
4965 | 139 | void ProcessDndMove(int x, int y, std::list<char*> mimes) | ||
4966 | 140 | { | ||
4967 | 141 | Launcher::ProcessDndMove(x, y, mimes); | ||
4968 | 142 | } | ||
4969 | 143 | |||
4970 | 144 | void FakeProcessDndMove(int x, int y, std::list<std::string> uris) | ||
4971 | 145 | { | ||
4972 | 146 | _dnd_data.Reset(); | ||
4973 | 147 | |||
4974 | 148 | std::string data_uri; | ||
4975 | 149 | for (std::string const& uri : uris) | ||
4976 | 150 | data_uri += uri+"\r\n"; | ||
4977 | 151 | |||
4978 | 152 | _dnd_data.Fill(data_uri.c_str()); | ||
4979 | 153 | |||
4980 | 154 | if (std::find_if(_dnd_data.Uris().begin(), _dnd_data.Uris().end(), [this] (std::string const& uri) | ||
4981 | 155 | {return DndIsSpecialRequest(uri);}) != _dnd_data.Uris().end()) | ||
4982 | 156 | { | ||
4983 | 157 | _steal_drag = true; | ||
4984 | 158 | } | ||
4985 | 159 | |||
4986 | 160 | _dnd_hovered_icon = MouseIconIntersection(x, y); | ||
4987 | 161 | } | ||
4988 | 162 | |||
4989 | 163 | void ProcessDndDrop(int x, int y) | ||
4990 | 164 | { | ||
4991 | 165 | Launcher::ProcessDndDrop(x, y); | ||
4992 | 166 | } | ||
4993 | 109 | }; | 167 | }; |
4994 | 110 | 168 | ||
4995 | 111 | TestLauncher() | 169 | TestLauncher() |
4996 | @@ -119,6 +177,29 @@ | |||
4997 | 119 | launcher_->SetModel(model_); | 177 | launcher_->SetModel(model_); |
4998 | 120 | } | 178 | } |
4999 | 121 | 179 | ||
5000 | 180 | std::vector<MockMockLauncherIcon::Ptr> AddMockIcons(unsigned number) |
Looks go to me. +1