Merge lp:~azzar1/unity/gs-integration into lp:unity
- gs-integration
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Marco Trevisan (Treviño) |
Approved revision: | no longer in the source branch. |
Merged at revision: | 4079 |
Proposed branch: | lp:~azzar1/unity/gs-integration |
Merge into: | lp:unity |
Prerequisite: | lp:~robert-ancell/unity/gnome-software |
Diff against target: |
897 lines (+247/-295) 17 files modified
CMakeLists.txt (+1/-0) debian/control (+1/-0) launcher/LauncherController.cpp (+18/-57) launcher/LauncherControllerPrivate.h (+2/-3) launcher/LauncherIcon.cpp (+14/-0) launcher/LauncherIcon.h (+2/-0) launcher/SimpleLauncherIcon.cpp (+27/-8) launcher/SimpleLauncherIcon.h (+2/-0) launcher/SoftwareCenterLauncherIcon.cpp (+4/-108) launcher/SoftwareCenterLauncherIcon.h (+1/-7) tests/test_launcher_controller.cpp (+0/-32) tests/test_software_center_launcher_icon.cpp (+5/-79) unity-shared/AppStreamApplication.cpp (+104/-0) unity-shared/AppStreamApplication.h (+61/-0) unity-shared/ApplicationManager.h (+3/-0) unity-shared/CMakeLists.txt (+1/-0) unity-shared/DesktopApplicationManager.h (+1/-1) |
To merge this branch: | bzr merge lp:~azzar1/unity/gs-integration |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Marco Trevisan (Treviño) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
Review via email: mp+286915@code.launchpad.net |
This proposal supersedes a proposal from 2016-02-19.
Commit message
Gnome-software launcher integration.
Description of the change
Gnome-software launcher integration.
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
Marco Trevisan (Treviño) (3v1n0) wrote : Posted in a previous version of this proposal | # |
Add libappstream-
Also, please, ensure that this merges with lp:~robert-ancell/unity/gnome-software
See comments, there might be some room for future optimization.
Andrea Azzarone (azzar1) wrote : Posted in a previous version of this proposal | # |
Done. We can talk more about the icon stuff later on.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:4076
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Marco Trevisan (Treviño) (3v1n0) wrote : Posted in a previous version of this proposal | # |
Ok, looks good...
It would be nice if we might also get the application icon path instead of the pixbuf, so please keep looking at this for next improvements.
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
Ok, looks good...
It would be nice if we might also get the application icon path instead of the pixbuf, so please keep looking at this for next improvements.
Preview Diff
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2016-02-09 01:57:51 +0000 | |||
3 | +++ CMakeLists.txt 2016-02-23 15:50:24 +0000 | |||
4 | @@ -228,6 +228,7 @@ | |||
5 | 228 | set(UNITY_PROTOCOL_PRIVATE_DEPS unity-protocol-private>=7.1.0) | 228 | set(UNITY_PROTOCOL_PRIVATE_DEPS unity-protocol-private>=7.1.0) |
6 | 229 | set(UNITY_PLUGIN_SHARED_DEPS | 229 | set(UNITY_PLUGIN_SHARED_DEPS |
7 | 230 | ${UNITY_PROTOCOL_PRIVATE_DEPS} | 230 | ${UNITY_PROTOCOL_PRIVATE_DEPS} |
8 | 231 | appstream-glib | ||
9 | 231 | atk | 232 | atk |
10 | 232 | atk-bridge-2.0 | 233 | atk-bridge-2.0 |
11 | 233 | cairo>=1.13.1 | 234 | cairo>=1.13.1 |
12 | 234 | 235 | ||
13 | === modified file 'debian/control' | |||
14 | --- debian/control 2016-02-09 12:20:47 +0000 | |||
15 | +++ debian/control 2016-02-23 15:50:24 +0000 | |||
16 | @@ -13,6 +13,7 @@ | |||
17 | 13 | gsettings-desktop-schemas-dev, | 13 | gsettings-desktop-schemas-dev, |
18 | 14 | gsettings-ubuntu-schemas (>= 0.0.1+14.04.20140219), | 14 | gsettings-ubuntu-schemas (>= 0.0.1+14.04.20140219), |
19 | 15 | intltool (>= 0.35.0), | 15 | intltool (>= 0.35.0), |
20 | 16 | libappstream-glib-dev, | ||
21 | 16 | libatk1.0-dev, | 17 | libatk1.0-dev, |
22 | 17 | libbamf3-dev (>= 0.5.2~bzr0), | 18 | libbamf3-dev (>= 0.5.2~bzr0), |
23 | 18 | libboost-dev, | 19 | libboost-dev, |
24 | 19 | 20 | ||
25 | === modified file 'launcher/LauncherController.cpp' | |||
26 | --- launcher/LauncherController.cpp 2015-12-17 22:32:37 +0000 | |||
27 | +++ launcher/LauncherController.cpp 2016-02-23 15:50:24 +0000 | |||
28 | @@ -41,6 +41,7 @@ | |||
29 | 41 | #include "ExpoLauncherIcon.h" | 41 | #include "ExpoLauncherIcon.h" |
30 | 42 | #include "TrashLauncherIcon.h" | 42 | #include "TrashLauncherIcon.h" |
31 | 43 | #include "BFBLauncherIcon.h" | 43 | #include "BFBLauncherIcon.h" |
32 | 44 | #include "unity-shared/AppStreamApplication.h" | ||
33 | 44 | #include "unity-shared/IconRenderer.h" | 45 | #include "unity-shared/IconRenderer.h" |
34 | 45 | #include "unity-shared/UScreen.h" | 46 | #include "unity-shared/UScreen.h" |
35 | 46 | #include "unity-shared/UBusMessages.h" | 47 | #include "unity-shared/UBusMessages.h" |
36 | @@ -61,13 +62,8 @@ | |||
37 | 61 | "<node>" | 62 | "<node>" |
38 | 62 | " <interface name='com.canonical.Unity.Launcher'>" | 63 | " <interface name='com.canonical.Unity.Launcher'>" |
39 | 63 | "" | 64 | "" |
47 | 64 | " <method name='AddLauncherItemFromPosition'>" | 65 | " <method name='AddLauncherItem'>" |
48 | 65 | " <arg type='s' name='title' direction='in'/>" | 66 | " <arg type='s' name='appstream_app_id' direction='in'/>" |
42 | 66 | " <arg type='s' name='icon' direction='in'/>" | ||
43 | 67 | " <arg type='i' name='icon_x' direction='in'/>" | ||
44 | 68 | " <arg type='i' name='icon_y' direction='in'/>" | ||
45 | 69 | " <arg type='i' name='icon_size' direction='in'/>" | ||
46 | 70 | " <arg type='s' name='desktop_file' direction='in'/>" | ||
49 | 71 | " <arg type='s' name='aptdaemon_task' direction='in'/>" | 67 | " <arg type='s' name='aptdaemon_task' direction='in'/>" |
50 | 72 | " </method>" | 68 | " </method>" |
51 | 73 | "" | 69 | "" |
52 | @@ -506,44 +502,25 @@ | |||
53 | 506 | } | 502 | } |
54 | 507 | 503 | ||
55 | 508 | void | 504 | void |
62 | 509 | Controller::Impl::OnLauncherAddRequestSpecial(std::string const& path, | 505 | Controller::Impl::OnLauncherAddRequestSpecial(std::string const& appstream_app_id, |
63 | 510 | std::string const& aptdaemon_trans_id, | 506 | std::string const& aptdaemon_trans_id) |
58 | 511 | std::string const& icon_path, | ||
59 | 512 | int icon_x, | ||
60 | 513 | int icon_y, | ||
61 | 514 | int icon_size) | ||
64 | 515 | { | 507 | { |
68 | 516 | // Check if desktop file was supplied, or if it's set to SC's agent | 508 | // Check if desktop file was supplied |
69 | 517 | // See https://bugs.launchpad.net/unity/+bug/1002440 | 509 | if (appstream_app_id.empty()) |
67 | 518 | if (path.empty() || path == local::SOFTWARE_CENTER_AGENT) | ||
70 | 519 | return; | 510 | return; |
71 | 520 | 511 | ||
72 | 521 | auto const& icon = std::find_if(model_->begin(), model_->end(), | 512 | auto const& icon = std::find_if(model_->begin(), model_->end(), |
74 | 522 | [&path](AbstractLauncherIcon::Ptr const& i) { return (i->DesktopFile() == path); }); | 513 | [&appstream_app_id](AbstractLauncherIcon::Ptr const& i) { return (i->DesktopFile() == appstream_app_id); }); |
75 | 523 | 514 | ||
76 | 524 | if (icon != model_->end()) | 515 | if (icon != model_->end()) |
77 | 525 | return; | 516 | return; |
78 | 526 | 517 | ||
80 | 527 | auto const& result = CreateSCLauncherIcon(path, aptdaemon_trans_id, icon_path); | 518 | auto const& result = CreateSCLauncherIcon(appstream_app_id, aptdaemon_trans_id); |
81 | 528 | 519 | ||
82 | 529 | if (result) | 520 | if (result) |
83 | 530 | { | 521 | { |
84 | 531 | // Setting the icon position and adding it to the model, makes the launcher | ||
85 | 532 | // to compute its center | ||
86 | 533 | RegisterIcon(result, GetLastIconPriority<ApplicationLauncherIcon>("", true)); | 522 | RegisterIcon(result, GetLastIconPriority<ApplicationLauncherIcon>("", true)); |
100 | 534 | 523 | result->SetQuirk(AbstractLauncherIcon::Quirk::VISIBLE, true); | |
88 | 535 | if (icon_x > 0 || icon_y > 0) | ||
89 | 536 | { | ||
90 | 537 | // This will ensure that the center of the new icon is set, so that | ||
91 | 538 | // the animation could be done properly. | ||
92 | 539 | sources_.AddIdle([this, icon_x, icon_y, result] { | ||
93 | 540 | return !result->Animate(CurrentLauncher(), icon_x, icon_y); | ||
94 | 541 | }); | ||
95 | 542 | } | ||
96 | 543 | else | ||
97 | 544 | { | ||
98 | 545 | result->SetQuirk(AbstractLauncherIcon::Quirk::VISIBLE, true); | ||
99 | 546 | } | ||
101 | 547 | } | 524 | } |
102 | 548 | } | 525 | } |
103 | 549 | 526 | ||
104 | @@ -944,22 +921,11 @@ | |||
105 | 944 | return AbstractLauncherIcon::Ptr(); | 921 | return AbstractLauncherIcon::Ptr(); |
106 | 945 | } | 922 | } |
107 | 946 | 923 | ||
111 | 947 | SoftwareCenterLauncherIcon::Ptr Controller::Impl::CreateSCLauncherIcon(std::string const& file_path, | 924 | SoftwareCenterLauncherIcon::Ptr Controller::Impl::CreateSCLauncherIcon(std::string const& appstream_app_id, |
112 | 948 | std::string const& aptdaemon_trans_id, | 925 | std::string const& aptdaemon_trans_id) |
110 | 949 | std::string const& icon_path) | ||
113 | 950 | { | 926 | { |
126 | 951 | SoftwareCenterLauncherIcon::Ptr result; | 927 | ApplicationPtr app = std::make_shared<appstream::Application>(appstream_app_id); |
127 | 952 | 928 | return SoftwareCenterLauncherIcon::Ptr(new SoftwareCenterLauncherIcon(app, aptdaemon_trans_id)); | |
116 | 953 | ApplicationPtr app = ApplicationManager::Default().GetApplicationForDesktopFile(file_path); | ||
117 | 954 | if (!app) | ||
118 | 955 | return result; | ||
119 | 956 | |||
120 | 957 | if (app->seen) | ||
121 | 958 | return result; | ||
122 | 959 | |||
123 | 960 | result = new SoftwareCenterLauncherIcon(app, aptdaemon_trans_id, icon_path); | ||
124 | 961 | |||
125 | 962 | return result; | ||
128 | 963 | } | 929 | } |
129 | 964 | 930 | ||
130 | 965 | void Controller::Impl::AddRunningApps() | 931 | void Controller::Impl::AddRunningApps() |
131 | @@ -1548,16 +1514,11 @@ | |||
132 | 1548 | 1514 | ||
133 | 1549 | GVariant* Controller::Impl::OnDBusMethodCall(std::string const& method, GVariant *parameters) | 1515 | GVariant* Controller::Impl::OnDBusMethodCall(std::string const& method, GVariant *parameters) |
134 | 1550 | { | 1516 | { |
136 | 1551 | if (method == "AddLauncherItemFromPosition") | 1517 | if (method == "AddLauncherItem") |
137 | 1552 | { | 1518 | { |
146 | 1553 | glib::String icon, icon_title, desktop_file, aptdaemon_task; | 1519 | glib::String appstream_app_id, aptdaemon_trans_id; |
147 | 1554 | gint icon_x, icon_y, icon_size; | 1520 | g_variant_get(parameters, "(ss)", &appstream_app_id, &aptdaemon_trans_id); |
148 | 1555 | 1521 | OnLauncherAddRequestSpecial(appstream_app_id.Str(), aptdaemon_trans_id.Str()); | |
141 | 1556 | g_variant_get(parameters, "(ssiiiss)", &icon_title, &icon, &icon_x, &icon_y, | ||
142 | 1557 | &icon_size, &desktop_file, &aptdaemon_task); | ||
143 | 1558 | |||
144 | 1559 | OnLauncherAddRequestSpecial(desktop_file.Str(), aptdaemon_task.Str(), | ||
145 | 1560 | icon.Str(), icon_x, icon_y, icon_size); | ||
149 | 1561 | } | 1522 | } |
150 | 1562 | else if (method == "UpdateLauncherIconFavoriteState") | 1523 | else if (method == "UpdateLauncherIconFavoriteState") |
151 | 1563 | { | 1524 | { |
152 | 1564 | 1525 | ||
153 | === modified file 'launcher/LauncherControllerPrivate.h' | |||
154 | --- launcher/LauncherControllerPrivate.h 2015-12-07 18:34:41 +0000 | |||
155 | +++ launcher/LauncherControllerPrivate.h 2016-02-23 15:50:24 +0000 | |||
156 | @@ -69,8 +69,7 @@ | |||
157 | 69 | void OnDeviceIconAdded(AbstractLauncherIcon::Ptr const& icon); | 69 | void OnDeviceIconAdded(AbstractLauncherIcon::Ptr const& icon); |
158 | 70 | 70 | ||
159 | 71 | void OnLauncherAddRequest(std::string const& icon_uri, AbstractLauncherIcon::Ptr const& before); | 71 | void OnLauncherAddRequest(std::string const& icon_uri, AbstractLauncherIcon::Ptr const& before); |
162 | 72 | void OnLauncherAddRequestSpecial(std::string const& path, std::string const& aptdaemon_trans_id, | 72 | void OnLauncherAddRequestSpecial(std::string const& appstream_app_id, std::string const& aptdaemon_trans_id); |
161 | 73 | std::string const& icon_path, int icon_x, int icon_y, int icon_size); | ||
163 | 74 | void OnLauncherUpdateIconStickyState(std::string const& desktop_file, bool sticky); | 73 | void OnLauncherUpdateIconStickyState(std::string const& desktop_file, bool sticky); |
164 | 75 | void OnLauncherRemoveRequest(AbstractLauncherIcon::Ptr const& icon); | 74 | void OnLauncherRemoveRequest(AbstractLauncherIcon::Ptr const& icon); |
165 | 76 | 75 | ||
166 | @@ -90,7 +89,7 @@ | |||
167 | 90 | ApplicationLauncherIcon* CreateAppLauncherIcon(ApplicationPtr const&); | 89 | ApplicationLauncherIcon* CreateAppLauncherIcon(ApplicationPtr const&); |
168 | 91 | AbstractLauncherIcon::Ptr CreateFavoriteIcon(std::string const& icon_uri, bool emit_signal = false); | 90 | AbstractLauncherIcon::Ptr CreateFavoriteIcon(std::string const& icon_uri, bool emit_signal = false); |
169 | 92 | AbstractLauncherIcon::Ptr GetIconByUri(std::string const& icon_uri); | 91 | AbstractLauncherIcon::Ptr GetIconByUri(std::string const& icon_uri); |
171 | 93 | SoftwareCenterLauncherIcon::Ptr CreateSCLauncherIcon(std::string const& file_path, std::string const& aptdaemon_trans_id, std::string const& icon_path); | 92 | SoftwareCenterLauncherIcon::Ptr CreateSCLauncherIcon(std::string const& appstream_app_id, std::string const& aptdaemon_trans_id); |
172 | 94 | 93 | ||
173 | 95 | void SetupIcons(); | 94 | void SetupIcons(); |
174 | 96 | void MigrateFavorites(); | 95 | void MigrateFavorites(); |
175 | 97 | 96 | ||
176 | === modified file 'launcher/LauncherIcon.cpp' | |||
177 | --- launcher/LauncherIcon.cpp 2015-11-25 23:16:11 +0000 | |||
178 | +++ launcher/LauncherIcon.cpp 2016-02-23 15:50:24 +0000 | |||
179 | @@ -365,6 +365,20 @@ | |||
180 | 365 | return _unity_theme; | 365 | return _unity_theme; |
181 | 366 | } | 366 | } |
182 | 367 | 367 | ||
183 | 368 | BaseTexturePtr LauncherIcon::TextureFromPixbuf(GdkPixbuf* pixbuf, int size, bool update_glow_colors) | ||
184 | 369 | { | ||
185 | 370 | g_return_val_if_fail(GDK_IS_PIXBUF(pixbuf), BaseTexturePtr()); | ||
186 | 371 | |||
187 | 372 | glib::Object<GdkPixbuf> scaled_pixbuf(gdk_pixbuf_scale_simple(pixbuf, size, size, GDK_INTERP_BILINEAR)); | ||
188 | 373 | |||
189 | 374 | if (update_glow_colors) | ||
190 | 375 | ColorForIcon(scaled_pixbuf, _background_color, _glow_color); | ||
191 | 376 | |||
192 | 377 | BaseTexturePtr result; | ||
193 | 378 | result.Adopt(nux::CreateTexture2DFromPixbuf(scaled_pixbuf, true)); | ||
194 | 379 | return result; | ||
195 | 380 | } | ||
196 | 381 | |||
197 | 368 | BaseTexturePtr LauncherIcon::TextureFromGtkTheme(std::string icon_name, int size, bool update_glow_colors) | 382 | BaseTexturePtr LauncherIcon::TextureFromGtkTheme(std::string icon_name, int size, bool update_glow_colors) |
198 | 369 | { | 383 | { |
199 | 370 | GtkIconTheme* default_theme; | 384 | GtkIconTheme* default_theme; |
200 | 371 | 385 | ||
201 | === modified file 'launcher/LauncherIcon.h' | |||
202 | --- launcher/LauncherIcon.h 2015-11-25 23:16:11 +0000 | |||
203 | +++ launcher/LauncherIcon.h 2016-02-23 15:50:24 +0000 | |||
204 | @@ -269,6 +269,8 @@ | |||
205 | 269 | 269 | ||
206 | 270 | virtual bool HandlesSpread () { return false; } | 270 | virtual bool HandlesSpread () { return false; } |
207 | 271 | 271 | ||
208 | 272 | BaseTexturePtr TextureFromPixbuf(GdkPixbuf *pixbuf, int size, bool update_glow_colors = true); | ||
209 | 273 | |||
210 | 272 | BaseTexturePtr TextureFromGtkTheme(std::string name, int size, bool update_glow_colors = true); | 274 | BaseTexturePtr TextureFromGtkTheme(std::string name, int size, bool update_glow_colors = true); |
211 | 273 | 275 | ||
212 | 274 | BaseTexturePtr TextureFromSpecificGtkTheme(GtkIconTheme* theme, std::string const& name, int size, bool update_glow_colors = true, bool is_default_theme = false); | 276 | BaseTexturePtr TextureFromSpecificGtkTheme(GtkIconTheme* theme, std::string const& name, int size, bool update_glow_colors = true, bool is_default_theme = false); |
213 | 275 | 277 | ||
214 | === modified file 'launcher/SimpleLauncherIcon.cpp' | |||
215 | --- launcher/SimpleLauncherIcon.cpp 2014-07-30 00:49:35 +0000 | |||
216 | +++ launcher/SimpleLauncherIcon.cpp 2016-02-23 15:50:24 +0000 | |||
217 | @@ -34,6 +34,7 @@ | |||
218 | 34 | SimpleLauncherIcon::SimpleLauncherIcon(IconType type) | 34 | SimpleLauncherIcon::SimpleLauncherIcon(IconType type) |
219 | 35 | : LauncherIcon(type) | 35 | : LauncherIcon(type) |
220 | 36 | , icon_name("", sigc::mem_fun(this, &SimpleLauncherIcon::SetIconName)) | 36 | , icon_name("", sigc::mem_fun(this, &SimpleLauncherIcon::SetIconName)) |
221 | 37 | , icon_pixbuf(glib::Object<GdkPixbuf>(), sigc::mem_fun(this, &SimpleLauncherIcon::SetIconPixbuf)) | ||
222 | 37 | { | 38 | { |
223 | 38 | auto* theme = gtk_icon_theme_get_default(); | 39 | auto* theme = gtk_icon_theme_get_default(); |
224 | 39 | theme_changed_signal_.Connect(theme, "changed", [this] (GtkIconTheme *) { | 40 | theme_changed_signal_.Connect(theme, "changed", [this] (GtkIconTheme *) { |
225 | @@ -53,17 +54,24 @@ | |||
226 | 53 | if (it != texture_map_.end()) | 54 | if (it != texture_map_.end()) |
227 | 54 | return it->second.GetPointer(); | 55 | return it->second.GetPointer(); |
228 | 55 | 56 | ||
229 | 56 | std::string const& icon_string = icon_name(); | ||
230 | 57 | |||
231 | 58 | if (icon_string.empty()) | ||
232 | 59 | return nullptr; | ||
233 | 60 | |||
234 | 61 | BaseTexturePtr texture; | 57 | BaseTexturePtr texture; |
235 | 62 | 58 | ||
238 | 63 | if (icon_string[0] == '/') | 59 | if (icon_pixbuf()) |
239 | 64 | texture = TextureFromPath(icon_string, size); | 60 | { |
240 | 61 | texture = TextureFromPixbuf(icon_pixbuf(), size); | ||
241 | 62 | } | ||
242 | 65 | else | 63 | else |
244 | 66 | texture = TextureFromGtkTheme(icon_string, size); | 64 | { |
245 | 65 | std::string const& icon_string = icon_name(); | ||
246 | 66 | |||
247 | 67 | if (icon_string.empty()) | ||
248 | 68 | return nullptr; | ||
249 | 69 | |||
250 | 70 | if (icon_string[0] == '/') | ||
251 | 71 | texture = TextureFromPath(icon_string, size); | ||
252 | 72 | else | ||
253 | 73 | texture = TextureFromGtkTheme(icon_string, size); | ||
254 | 74 | } | ||
255 | 67 | 75 | ||
256 | 68 | if (!texture) | 76 | if (!texture) |
257 | 69 | return nullptr; | 77 | return nullptr; |
258 | @@ -83,6 +91,17 @@ | |||
259 | 83 | return true; | 91 | return true; |
260 | 84 | } | 92 | } |
261 | 85 | 93 | ||
262 | 94 | bool SimpleLauncherIcon::SetIconPixbuf(glib::Object<GdkPixbuf>& target, glib::Object<GdkPixbuf> const& value) | ||
263 | 95 | { | ||
264 | 96 | if (target == value) | ||
265 | 97 | return false; | ||
266 | 98 | |||
267 | 99 | target = value; | ||
268 | 100 | ReloadIcon(); | ||
269 | 101 | |||
270 | 102 | return true; | ||
271 | 103 | } | ||
272 | 104 | |||
273 | 86 | void SimpleLauncherIcon::ReloadIcon() | 105 | void SimpleLauncherIcon::ReloadIcon() |
274 | 87 | { | 106 | { |
275 | 88 | texture_map_.clear(); | 107 | texture_map_.clear(); |
276 | 89 | 108 | ||
277 | === modified file 'launcher/SimpleLauncherIcon.h' | |||
278 | --- launcher/SimpleLauncherIcon.h 2013-09-19 16:44:03 +0000 | |||
279 | +++ launcher/SimpleLauncherIcon.h 2016-02-23 15:50:24 +0000 | |||
280 | @@ -38,6 +38,7 @@ | |||
281 | 38 | 38 | ||
282 | 39 | // Properties | 39 | // Properties |
283 | 40 | nux::Property<std::string> icon_name; | 40 | nux::Property<std::string> icon_name; |
284 | 41 | nux::Property<glib::Object<GdkPixbuf>> icon_pixbuf; | ||
285 | 41 | 42 | ||
286 | 42 | protected: | 43 | protected: |
287 | 43 | std::string GetName() const; | 44 | std::string GetName() const; |
288 | @@ -49,6 +50,7 @@ | |||
289 | 49 | private: | 50 | private: |
290 | 50 | void ReloadIcon(); | 51 | void ReloadIcon(); |
291 | 51 | bool SetIconName(std::string& target, std::string const& value); | 52 | bool SetIconName(std::string& target, std::string const& value); |
292 | 53 | bool SetIconPixbuf(glib::Object<GdkPixbuf>& target, glib::Object<GdkPixbuf> const& value); | ||
293 | 52 | 54 | ||
294 | 53 | private: | 55 | private: |
295 | 54 | std::unordered_map<int, BaseTexturePtr> texture_map_; | 56 | std::unordered_map<int, BaseTexturePtr> texture_map_; |
296 | 55 | 57 | ||
297 | === modified file 'launcher/SoftwareCenterLauncherIcon.cpp' | |||
298 | --- launcher/SoftwareCenterLauncherIcon.cpp 2015-12-07 16:13:42 +0000 | |||
299 | +++ launcher/SoftwareCenterLauncherIcon.cpp 2016-02-23 15:50:24 +0000 | |||
300 | @@ -44,8 +44,7 @@ | |||
301 | 44 | 44 | ||
302 | 45 | NUX_IMPLEMENT_OBJECT_TYPE(SoftwareCenterLauncherIcon); | 45 | NUX_IMPLEMENT_OBJECT_TYPE(SoftwareCenterLauncherIcon); |
303 | 46 | SoftwareCenterLauncherIcon::SoftwareCenterLauncherIcon(ApplicationPtr const& app, | 46 | SoftwareCenterLauncherIcon::SoftwareCenterLauncherIcon(ApplicationPtr const& app, |
306 | 47 | std::string const& aptdaemon_trans_id, | 47 | std::string const& aptdaemon_trans_id) |
305 | 48 | std::string const& icon_path) | ||
307 | 49 | : WindowedLauncherIcon(IconType::APPLICATION) | 48 | : WindowedLauncherIcon(IconType::APPLICATION) |
308 | 50 | , ApplicationLauncherIcon(app) | 49 | , ApplicationLauncherIcon(app) |
309 | 51 | , aptdaemon_trans_(std::make_shared<glib::DBusProxy>("org.debian.apt", | 50 | , aptdaemon_trans_(std::make_shared<glib::DBusProxy>("org.debian.apt", |
310 | @@ -69,61 +68,13 @@ | |||
311 | 69 | SetQuirk(Quirk::PROGRESS, (progress > 0)); | 68 | SetQuirk(Quirk::PROGRESS, (progress > 0)); |
312 | 70 | }); | 69 | }); |
313 | 71 | 70 | ||
316 | 72 | if (!icon_path.empty()) | 71 | if (app->icon_pixbuf()) |
317 | 73 | icon_name = icon_path; | 72 | icon_pixbuf = app->icon_pixbuf(); |
318 | 74 | 73 | ||
319 | 75 | if (!aptdaemon_trans_id_.empty()) // Application is being installed, or hasn't been installed yet | 74 | if (!aptdaemon_trans_id_.empty()) // Application is being installed, or hasn't been installed yet |
320 | 76 | tooltip_text = _("Waiting to install"); | 75 | tooltip_text = _("Waiting to install"); |
321 | 77 | } | 76 | } |
322 | 78 | 77 | ||
323 | 79 | bool SoftwareCenterLauncherIcon::Animate(nux::ObjectPtr<Launcher> const& launcher, int start_x, int start_y) | ||
324 | 80 | { | ||
325 | 81 | using namespace std::placeholders; | ||
326 | 82 | |||
327 | 83 | if (start_x <= 0 && start_y <= 0) | ||
328 | 84 | { | ||
329 | 85 | SetQuirk(Quirk::VISIBLE, true); | ||
330 | 86 | return true; | ||
331 | 87 | } | ||
332 | 88 | |||
333 | 89 | int monitor = launcher->monitor(); | ||
334 | 90 | auto const& icon_center = GetCenter(monitor); | ||
335 | 91 | |||
336 | 92 | if (icon_center.x == 0 && icon_center.y == 0) | ||
337 | 93 | return false; | ||
338 | 94 | |||
339 | 95 | auto* floating_icon = new SimpleLauncherIcon(GetIconType()); | ||
340 | 96 | AbstractLauncherIcon::Ptr floating_icon_ptr(floating_icon); | ||
341 | 97 | floating_icon->icon_name = icon_name(); | ||
342 | 98 | |||
343 | 99 | // Transform this in a spacer-icon and make it visible only on launcher's monitor | ||
344 | 100 | icon_name = ""; | ||
345 | 101 | SetQuirk(Quirk::VISIBLE, true, monitor); | ||
346 | 102 | |||
347 | 103 | auto rcb = std::bind(&Launcher::RenderIconToTexture, launcher.GetPointer(), _1, _2, floating_icon_ptr); | ||
348 | 104 | drag_window_ = new LauncherDragWindow(launcher->GetWidth(), rcb); | ||
349 | 105 | drag_window_->SetBaseXY(start_x, start_y); | ||
350 | 106 | drag_window_->SetAnimationTarget(icon_center.x, icon_center.y + (launcher->GetIconSize() / 2)); | ||
351 | 107 | |||
352 | 108 | launcher->ForceReveal(true); | ||
353 | 109 | drag_window_->ShowWindow(true); | ||
354 | 110 | |||
355 | 111 | auto cb = sigc::bind(sigc::mem_fun(this, &SoftwareCenterLauncherIcon::OnDragAnimationFinished), launcher, floating_icon->icon_name()); | ||
356 | 112 | drag_window_->anim_completed.connect(cb); | ||
357 | 113 | drag_window_->StartSlowAnimation(); | ||
358 | 114 | |||
359 | 115 | return true; | ||
360 | 116 | } | ||
361 | 117 | |||
362 | 118 | void SoftwareCenterLauncherIcon::OnDragAnimationFinished(nux::ObjectPtr<Launcher> const& launcher, std::string const& final_icon) | ||
363 | 119 | { | ||
364 | 120 | icon_name = final_icon; | ||
365 | 121 | drag_window_->ShowWindow(false); | ||
366 | 122 | drag_window_.Release(); | ||
367 | 123 | launcher->ForceReveal(false); | ||
368 | 124 | SetQuirk(Quirk::VISIBLE, true); | ||
369 | 125 | } | ||
370 | 126 | |||
371 | 127 | void SoftwareCenterLauncherIcon::ActivateLauncherIcon(ActionArg arg) | 78 | void SoftwareCenterLauncherIcon::ActivateLauncherIcon(ActionArg arg) |
372 | 128 | { | 79 | { |
373 | 129 | if (finished_) | 80 | if (finished_) |
374 | @@ -144,62 +95,7 @@ | |||
375 | 144 | 95 | ||
376 | 145 | std::string SoftwareCenterLauncherIcon::GetActualDesktopFileAfterInstall() | 96 | std::string SoftwareCenterLauncherIcon::GetActualDesktopFileAfterInstall() |
377 | 146 | { | 97 | { |
434 | 147 | // Fixup the _desktop_file because the one we get from software-center | 98 | return DesktopUtilities::GetDesktopPathById(DesktopFile()); |
379 | 148 | // is not the final one, e.g. the s-c-agent does send a temp one and | ||
380 | 149 | // app-install-data points to the "wrong" one in /usr/share/app-install | ||
381 | 150 | // | ||
382 | 151 | // So: | ||
383 | 152 | // - if there is a desktop file already and it startswith | ||
384 | 153 | // /usr/share/app-install/desktop, then transform to | ||
385 | 154 | // /usr/share/application | ||
386 | 155 | // - if there is a desktop file with prefix /tmp/software-center-agent: | ||
387 | 156 | // transform to /usr/share/application | ||
388 | 157 | // (its using "/tmp/software-center-agent:$random:$pkgname.desktop") | ||
389 | 158 | // maybe: | ||
390 | 159 | // - and search in /var/lib/apt/lists/$pkgname.list | ||
391 | 160 | // for a desktop file that roughly matches what we want | ||
392 | 161 | auto const& desktop_file = DesktopFile(); | ||
393 | 162 | |||
394 | 163 | // take /usr/share/app-install/desktop/foo:subdir__bar.desktop | ||
395 | 164 | // and tranform it | ||
396 | 165 | if (desktop_file.find("/share/app-install/desktop/") != std::string::npos) | ||
397 | 166 | { | ||
398 | 167 | auto colon_pos = desktop_file.rfind(":"); | ||
399 | 168 | auto filename = desktop_file.substr(colon_pos + 1, desktop_file.length() - colon_pos); | ||
400 | 169 | // the app-install-data package encodes subdirs in a funny way, once | ||
401 | 170 | // that is fixed, this code can be dropped | ||
402 | 171 | if (filename.find("__") != std::string::npos) | ||
403 | 172 | { | ||
404 | 173 | int pos = filename.find("__"); | ||
405 | 174 | filename = filename.replace(pos, 2, "-"); | ||
406 | 175 | } | ||
407 | 176 | filename = DesktopUtilities::GetDesktopPathById(filename); | ||
408 | 177 | return filename; | ||
409 | 178 | } | ||
410 | 179 | else if (desktop_file.find("/tmp/software-center-agent:") == 0) | ||
411 | 180 | { | ||
412 | 181 | // by convention the software-center-agent uses | ||
413 | 182 | // /usr/share/applications/$pkgname.desktop | ||
414 | 183 | // or | ||
415 | 184 | // /usr/share/applications/extras-$pkgname.desktop | ||
416 | 185 | auto colon_pos = desktop_file.rfind(":"); | ||
417 | 186 | auto desktopf = desktop_file.substr(colon_pos + 1, desktop_file.length() - colon_pos); | ||
418 | 187 | |||
419 | 188 | auto filename = DesktopUtilities::GetDesktopPathById(desktopf); | ||
420 | 189 | |||
421 | 190 | if (!filename.empty()) | ||
422 | 191 | return filename; | ||
423 | 192 | |||
424 | 193 | // now try extras-$pkgname.desktop | ||
425 | 194 | filename = DesktopUtilities::GetDesktopPathById("extras-" + desktopf); | ||
426 | 195 | if (!filename.empty()) | ||
427 | 196 | return filename; | ||
428 | 197 | |||
429 | 198 | // FIXME: test if there is a file now and if not, search | ||
430 | 199 | // /var/lib/dpkg/info/$pkgname.list for a desktop file | ||
431 | 200 | } | ||
432 | 201 | |||
433 | 202 | return desktop_file; | ||
435 | 203 | } | 99 | } |
436 | 204 | 100 | ||
437 | 205 | void SoftwareCenterLauncherIcon::OnFinished(GVariant *params) | 101 | void SoftwareCenterLauncherIcon::OnFinished(GVariant *params) |
438 | 206 | 102 | ||
439 | === modified file 'launcher/SoftwareCenterLauncherIcon.h' | |||
440 | --- launcher/SoftwareCenterLauncherIcon.h 2013-08-28 16:41:20 +0000 | |||
441 | +++ launcher/SoftwareCenterLauncherIcon.h 2016-02-23 15:50:24 +0000 | |||
442 | @@ -24,7 +24,6 @@ | |||
443 | 24 | #include <string> | 24 | #include <string> |
444 | 25 | #include <UnityCore/GLibDBusProxy.h> | 25 | #include <UnityCore/GLibDBusProxy.h> |
445 | 26 | #include "ApplicationLauncherIcon.h" | 26 | #include "ApplicationLauncherIcon.h" |
446 | 27 | #include "LauncherDragWindow.h" | ||
447 | 28 | 27 | ||
448 | 29 | namespace unity | 28 | namespace unity |
449 | 30 | { | 29 | { |
450 | @@ -39,10 +38,7 @@ | |||
451 | 39 | typedef nux::ObjectPtr<SoftwareCenterLauncherIcon> Ptr; | 38 | typedef nux::ObjectPtr<SoftwareCenterLauncherIcon> Ptr; |
452 | 40 | 39 | ||
453 | 41 | SoftwareCenterLauncherIcon(ApplicationPtr const& app, | 40 | SoftwareCenterLauncherIcon(ApplicationPtr const& app, |
458 | 42 | std::string const& aptdaemon_trans_id, | 41 | std::string const& aptdaemon_trans_id); |
455 | 43 | std::string const& icon_path); | ||
456 | 44 | |||
457 | 45 | bool Animate(nux::ObjectPtr<Launcher> const& launcher, int start_x, int start_y); | ||
459 | 46 | 42 | ||
460 | 47 | protected: | 43 | protected: |
461 | 48 | std::string GetName() const; | 44 | std::string GetName() const; |
462 | @@ -52,10 +48,8 @@ | |||
463 | 52 | std::string GetActualDesktopFileAfterInstall(); | 48 | std::string GetActualDesktopFileAfterInstall(); |
464 | 53 | void OnFinished(GVariant *params); | 49 | void OnFinished(GVariant *params); |
465 | 54 | void OnPropertyChanged(GVariant* params); | 50 | void OnPropertyChanged(GVariant* params); |
466 | 55 | void OnDragAnimationFinished(nux::ObjectPtr<Launcher> const&, std::string const&); | ||
467 | 56 | 51 | ||
468 | 57 | glib::DBusProxy::Ptr aptdaemon_trans_; | 52 | glib::DBusProxy::Ptr aptdaemon_trans_; |
469 | 58 | LauncherDragWindow::Ptr drag_window_; | ||
470 | 59 | bool finished_; | 53 | bool finished_; |
471 | 60 | bool needs_urgent_; | 54 | bool needs_urgent_; |
472 | 61 | std::string aptdaemon_trans_id_; | 55 | std::string aptdaemon_trans_id_; |
473 | 62 | 56 | ||
474 | === modified file 'tests/test_launcher_controller.cpp' | |||
475 | --- tests/test_launcher_controller.cpp 2016-02-23 15:50:24 +0000 | |||
476 | +++ tests/test_launcher_controller.cpp 2016-02-23 15:50:24 +0000 | |||
477 | @@ -1321,38 +1321,6 @@ | |||
478 | 1321 | lc.launcher().remove_request.emit(device_icon); | 1321 | lc.launcher().remove_request.emit(device_icon); |
479 | 1322 | } | 1322 | } |
480 | 1323 | 1323 | ||
481 | 1324 | TEST_F(TestLauncherController, LauncherAddRequestSpecial) | ||
482 | 1325 | { | ||
483 | 1326 | std::string desktop = app::BZR_HANDLE_PATCH; | ||
484 | 1327 | std::string icon_uri = FavoriteStore::URI_PREFIX_APP + desktop; | ||
485 | 1328 | ASSERT_FALSE(lc.Impl()->GetIconByUri(icon_uri).IsValid()); | ||
486 | 1329 | EXPECT_CALL(*unity_app_, LogEvent(_, _)).Times(0); | ||
487 | 1330 | |||
488 | 1331 | lc.Impl()->OnLauncherAddRequestSpecial(desktop, "", "", 0, 0, 32); | ||
489 | 1332 | |||
490 | 1333 | auto const& sw_center_icon = lc.Impl()->GetIconByUri(icon_uri); | ||
491 | 1334 | ASSERT_TRUE(sw_center_icon.IsValid()); | ||
492 | 1335 | EXPECT_TRUE(sw_center_icon->IsSticky()); | ||
493 | 1336 | EXPECT_NE(dynamic_cast<SoftwareCenterLauncherIcon*>(sw_center_icon.GetPointer()), nullptr); | ||
494 | 1337 | } | ||
495 | 1338 | |||
496 | 1339 | TEST_F(TestLauncherController, LauncherAddRequestSpecialIgnored) | ||
497 | 1340 | { | ||
498 | 1341 | std::string desktop = app::BZR_HANDLE_PATCH; | ||
499 | 1342 | std::string icon_uri = FavoriteStore::URI_PREFIX_APP + desktop; | ||
500 | 1343 | |||
501 | 1344 | MockApplicationLauncherIcon::Ptr bamf_icon(new MockApplicationLauncherIcon::Nice(desktop)); | ||
502 | 1345 | lc.Impl()->RegisterIcon(bamf_icon, std::numeric_limits<int>::max()); | ||
503 | 1346 | ASSERT_TRUE(lc.Impl()->GetIconByUri(icon_uri).IsValid()); | ||
504 | 1347 | |||
505 | 1348 | EXPECT_CALL(*bamf_icon, Stick(false)).Times(0); | ||
506 | 1349 | |||
507 | 1350 | int previous_model_size = lc.Impl()->model_->Size(); | ||
508 | 1351 | lc.Impl()->OnLauncherAddRequestSpecial(desktop, "", "", 0, 0, 32); | ||
509 | 1352 | |||
510 | 1353 | EXPECT_EQ(previous_model_size, lc.Impl()->model_->Size()); | ||
511 | 1354 | } | ||
512 | 1355 | |||
513 | 1356 | TEST_F(TestLauncherController, SaveIconsOrder) | 1324 | TEST_F(TestLauncherController, SaveIconsOrder) |
514 | 1357 | { | 1325 | { |
515 | 1358 | favorite_store.ClearFavorites(); | 1326 | favorite_store.ClearFavorites(); |
516 | 1359 | 1327 | ||
517 | === modified file 'tests/test_software_center_launcher_icon.cpp' | |||
518 | --- tests/test_software_center_launcher_icon.cpp 2016-02-23 15:50:24 +0000 | |||
519 | +++ tests/test_software_center_launcher_icon.cpp 2016-02-23 15:50:24 +0000 | |||
520 | @@ -42,28 +42,26 @@ | |||
521 | 42 | { | 42 | { |
522 | 43 | namespace | 43 | namespace |
523 | 44 | { | 44 | { |
524 | 45 | const std::string PRE_INSTALL_ICON = "software-launcher-icon"; | ||
525 | 46 | const std::string FINAL_ICON = "org.gnome.Software"; | 45 | const std::string FINAL_ICON = "org.gnome.Software"; |
526 | 47 | const std::string APP_NAME = "Software"; | 46 | const std::string APP_NAME = "Software"; |
527 | 48 | const std::string LOCAL_DATA_DIR = BUILDDIR"/tests/data"; | 47 | const std::string LOCAL_DATA_DIR = BUILDDIR"/tests/data"; |
528 | 49 | const std::string GS_DESKTOP = LOCAL_DATA_DIR+"/applications/org.gnome.Software.desktop"; | 48 | const std::string GS_DESKTOP = LOCAL_DATA_DIR+"/applications/org.gnome.Software.desktop"; |
530 | 50 | const std::string GS_APP_INSTALL_DESKTOP = "/usr/share/app-install/desktop/software-center:org.gnome.Software.desktop"; | 49 | const std::string GS_APP_INSTALL_DESKTOP = "org.gnome.Software.desktop"; |
531 | 51 | } | 50 | } |
532 | 52 | 51 | ||
533 | 53 | struct TestSoftwareCenterLauncherIcon : testmocks::TestUnityAppBase | 52 | struct TestSoftwareCenterLauncherIcon : testmocks::TestUnityAppBase |
534 | 54 | { | 53 | { |
535 | 55 | TestSoftwareCenterLauncherIcon() | 54 | TestSoftwareCenterLauncherIcon() |
536 | 56 | : gs(std::make_shared<MockApplication::Nice>(GS_APP_INSTALL_DESKTOP, FINAL_ICON, APP_NAME)) | 55 | : gs(std::make_shared<MockApplication::Nice>(GS_APP_INSTALL_DESKTOP, FINAL_ICON, APP_NAME)) |
538 | 57 | , icon(gs, "/com/canonical/unity/test/object/path", PRE_INSTALL_ICON) | 56 | , icon(gs, "/com/canonical/unity/test/object/path") |
539 | 58 | {} | 57 | {} |
540 | 59 | 58 | ||
541 | 60 | struct MockSoftwareCenterLauncherIcon : SoftwareCenterLauncherIcon | 59 | struct MockSoftwareCenterLauncherIcon : SoftwareCenterLauncherIcon |
542 | 61 | { | 60 | { |
543 | 62 | MockSoftwareCenterLauncherIcon(ApplicationPtr const& app, | 61 | MockSoftwareCenterLauncherIcon(ApplicationPtr const& app, |
546 | 63 | std::string const& aptdaemon_trans_id, | 62 | std::string const& aptdaemon_trans_id) |
545 | 64 | std::string const& icon_path) | ||
547 | 65 | : WindowedLauncherIcon(IconType::APPLICATION) | 63 | : WindowedLauncherIcon(IconType::APPLICATION) |
549 | 66 | , SoftwareCenterLauncherIcon(app, aptdaemon_trans_id, icon_path) | 64 | , SoftwareCenterLauncherIcon(app, aptdaemon_trans_id) |
550 | 67 | {} | 65 | {} |
551 | 68 | 66 | ||
552 | 69 | void LauncherIconUnstick() { LauncherIcon::UnStick(); } | 67 | void LauncherIconUnstick() { LauncherIcon::UnStick(); } |
553 | @@ -71,7 +69,6 @@ | |||
554 | 71 | using SoftwareCenterLauncherIcon::GetActualDesktopFileAfterInstall; | 69 | using SoftwareCenterLauncherIcon::GetActualDesktopFileAfterInstall; |
555 | 72 | using SoftwareCenterLauncherIcon::OnFinished; | 70 | using SoftwareCenterLauncherIcon::OnFinished; |
556 | 73 | using SoftwareCenterLauncherIcon::OnPropertyChanged; | 71 | using SoftwareCenterLauncherIcon::OnPropertyChanged; |
557 | 74 | using SoftwareCenterLauncherIcon::drag_window_; | ||
558 | 75 | using LauncherIcon::GetRemoteUri; | 72 | using LauncherIcon::GetRemoteUri; |
559 | 76 | }; | 73 | }; |
560 | 77 | 74 | ||
561 | @@ -94,9 +91,7 @@ | |||
562 | 94 | { | 91 | { |
563 | 95 | EXPECT_FALSE(icon.IsVisible()); | 92 | EXPECT_FALSE(icon.IsVisible()); |
564 | 96 | EXPECT_TRUE(icon.IsSticky()); | 93 | EXPECT_TRUE(icon.IsSticky()); |
565 | 97 | EXPECT_EQ(AbstractLauncherIcon::Position::FLOATING, icon.position()); | ||
566 | 98 | EXPECT_EQ("Waiting to install", icon.tooltip_text()); | 94 | EXPECT_EQ("Waiting to install", icon.tooltip_text()); |
567 | 99 | EXPECT_EQ(PRE_INSTALL_ICON, icon.icon_name()); | ||
568 | 100 | } | 95 | } |
569 | 101 | 96 | ||
570 | 102 | TEST_F(TestSoftwareCenterLauncherIcon, DesktopFileTransformTrivial) | 97 | TEST_F(TestSoftwareCenterLauncherIcon, DesktopFileTransformTrivial) |
571 | @@ -106,28 +101,9 @@ | |||
572 | 106 | EXPECT_EQ(icon.GetActualDesktopFileAfterInstall(), GS_DESKTOP); | 101 | EXPECT_EQ(icon.GetActualDesktopFileAfterInstall(), GS_DESKTOP); |
573 | 107 | } | 102 | } |
574 | 108 | 103 | ||
575 | 109 | TEST_F(TestSoftwareCenterLauncherIcon, DesktopFileTransformAppInstall) | ||
576 | 110 | { | ||
577 | 111 | // ensure that tranformation from app-install data desktop files works | ||
578 | 112 | gs->desktop_file_ = "/usr/share/app-install/desktop/pkgname:kde4__afile.desktop"; | ||
579 | 113 | EXPECT_EQ(icon.GetActualDesktopFileAfterInstall(), | ||
580 | 114 | LOCAL_DATA_DIR+"/applications/kde4/afile.desktop"); | ||
581 | 115 | } | ||
582 | 116 | |||
583 | 117 | TEST_F(TestSoftwareCenterLauncherIcon, DesktopFileTransformSCAgent) | ||
584 | 118 | { | ||
585 | 119 | // now simualte data coming from the software-center-agent | ||
586 | 120 | gs->desktop_file_ = "/tmp/software-center-agent:VP2W9M:org.gnome.Software.desktop"; | ||
587 | 121 | EXPECT_EQ(icon.GetActualDesktopFileAfterInstall(), GS_DESKTOP); | ||
588 | 122 | } | ||
589 | 123 | |||
590 | 124 | // simulate a OnFinished signal from a /usr/share/app-install location | ||
591 | 125 | // and ensure that the remote uri is updated from temp location to | ||
592 | 126 | // the real location | ||
593 | 127 | TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedReplacesDesktopFile) | 104 | TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedReplacesDesktopFile) |
594 | 128 | { | 105 | { |
595 | 129 | icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success"))); | 106 | icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success"))); |
596 | 130 | |||
597 | 131 | EXPECT_EQ(GS_DESKTOP, icon.DesktopFile()); | 107 | EXPECT_EQ(GS_DESKTOP, icon.DesktopFile()); |
598 | 132 | } | 108 | } |
599 | 133 | 109 | ||
600 | @@ -162,7 +138,7 @@ | |||
601 | 162 | { | 138 | { |
602 | 163 | // Using an icon ptr, to get the removed signal to be properly emitted | 139 | // Using an icon ptr, to get the removed signal to be properly emitted |
603 | 164 | nux::ObjectPtr<MockSoftwareCenterLauncherIcon> icon_ptr( | 140 | nux::ObjectPtr<MockSoftwareCenterLauncherIcon> icon_ptr( |
605 | 165 | new MockSoftwareCenterLauncherIcon(gs, "/com/canonical/unity/test/object/path", PRE_INSTALL_ICON)); | 141 | new MockSoftwareCenterLauncherIcon(gs, "/com/canonical/unity/test/object/path")); |
606 | 166 | 142 | ||
607 | 167 | bool removed = false; | 143 | bool removed = false; |
608 | 168 | auto& app_manager = unity::ApplicationManager::Default(); | 144 | auto& app_manager = unity::ApplicationManager::Default(); |
609 | @@ -217,65 +193,15 @@ | |||
610 | 217 | EXPECT_EQ(icon.tooltip_text(), gs->title()); | 193 | EXPECT_EQ(icon.tooltip_text(), gs->title()); |
611 | 218 | } | 194 | } |
612 | 219 | 195 | ||
613 | 220 | TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedUpdatesIcon) | ||
614 | 221 | { | ||
615 | 222 | icon.icon_name = "foo-icon"; | ||
616 | 223 | icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success"))); | ||
617 | 224 | EXPECT_EQ(icon.icon_name(), gs->icon()); | ||
618 | 225 | } | ||
619 | 226 | |||
620 | 227 | TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedLogsEvent) | 196 | TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedLogsEvent) |
621 | 228 | { | 197 | { |
622 | 229 | EXPECT_CALL(*unity_app_, LogEvent(ApplicationEventType::ACCESS, _)); | 198 | EXPECT_CALL(*unity_app_, LogEvent(ApplicationEventType::ACCESS, _)); |
623 | 230 | icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success"))); | 199 | icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success"))); |
624 | 231 | } | 200 | } |
625 | 232 | 201 | ||
626 | 233 | TEST_F(TestSoftwareCenterLauncherIcon, AnimateToInvalidPosition) | ||
627 | 234 | { | ||
628 | 235 | EXPECT_FALSE(icon.Animate(CreateLauncher(), 1, 2)); | ||
629 | 236 | EXPECT_FALSE(icon.IsVisible()); | ||
630 | 237 | EXPECT_EQ(PRE_INSTALL_ICON, icon.icon_name()); | ||
631 | 238 | } | ||
632 | 239 | |||
633 | 240 | TEST_F(TestSoftwareCenterLauncherIcon, AnimateFromInvalidPosition) | ||
634 | 241 | { | ||
635 | 242 | EXPECT_TRUE(icon.Animate(CreateLauncher(), 0, 0)); | ||
636 | 243 | EXPECT_TRUE(icon.IsVisible()); | ||
637 | 244 | EXPECT_EQ(PRE_INSTALL_ICON, icon.icon_name()); | ||
638 | 245 | } | ||
639 | 246 | |||
640 | 247 | #pragma GCC diagnostic push | 202 | #pragma GCC diagnostic push |
641 | 248 | #pragma GCC diagnostic ignored "-Wunused-variable" | 203 | #pragma GCC diagnostic ignored "-Wunused-variable" |
642 | 249 | 204 | ||
643 | 250 | struct MultiMonitor : TestSoftwareCenterLauncherIcon, WithParamInterface<unsigned> {}; | ||
644 | 251 | INSTANTIATE_TEST_CASE_P(TestSoftwareCenterLauncherIcon, MultiMonitor, Range<unsigned>(0, monitors::MAX, 1)); | ||
645 | 252 | |||
646 | 253 | TEST_P(/*TestSoftwareCenterLauncherIcon*/MultiMonitor, Animate) | ||
647 | 254 | { | ||
648 | 255 | auto launcher = CreateLauncher(); | ||
649 | 256 | launcher->monitor = GetParam(); | ||
650 | 257 | icon.SetCenter({1, 1, 0}, launcher->monitor()); | ||
651 | 258 | ASSERT_TRUE(icon.Animate(launcher, 2, 2)); | ||
652 | 259 | EXPECT_FALSE(icon.IsVisible()); | ||
653 | 260 | EXPECT_TRUE(icon.icon_name().empty()); | ||
654 | 261 | |||
655 | 262 | for (unsigned i = 0; i < monitors::MAX; ++i) | ||
656 | 263 | ASSERT_EQ(static_cast<int>(i) == launcher->monitor(), icon.IsVisibleOnMonitor(i)); | ||
657 | 264 | |||
658 | 265 | bool animated = false; | ||
659 | 266 | ASSERT_TRUE(icon.drag_window_); | ||
660 | 267 | icon.drag_window_->anim_completed.connect([&animated] { animated = true; }); | ||
661 | 268 | Utils::WaitUntilMSec(animated); | ||
662 | 269 | ASSERT_TRUE(animated); | ||
663 | 270 | |||
664 | 271 | EXPECT_EQ(PRE_INSTALL_ICON, icon.icon_name()); | ||
665 | 272 | EXPECT_FALSE(icon.drag_window_); | ||
666 | 273 | |||
667 | 274 | for (unsigned i = 0; i < monitors::MAX; ++i) | ||
668 | 275 | ASSERT_TRUE(icon.IsVisibleOnMonitor(i)); | ||
669 | 276 | |||
670 | 277 | EXPECT_TRUE(icon.IsVisible()); | ||
671 | 278 | } | ||
672 | 279 | 205 | ||
673 | 280 | struct InstallProgress : TestSoftwareCenterLauncherIcon, WithParamInterface<int> {}; | 206 | struct InstallProgress : TestSoftwareCenterLauncherIcon, WithParamInterface<int> {}; |
674 | 281 | INSTANTIATE_TEST_CASE_P(TestSoftwareCenterLauncherIcon, InstallProgress, Range<int>(0, 99, 10)); | 207 | INSTANTIATE_TEST_CASE_P(TestSoftwareCenterLauncherIcon, InstallProgress, Range<int>(0, 99, 10)); |
675 | 282 | 208 | ||
676 | === added file 'unity-shared/AppStreamApplication.cpp' | |||
677 | --- unity-shared/AppStreamApplication.cpp 1970-01-01 00:00:00 +0000 | |||
678 | +++ unity-shared/AppStreamApplication.cpp 2016-02-23 15:50:24 +0000 | |||
679 | @@ -0,0 +1,104 @@ | |||
680 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
681 | 2 | /* | ||
682 | 3 | * Copyright (C) 2016 Canonical Ltd | ||
683 | 4 | * | ||
684 | 5 | * This program is free software: you can redistribute it and/or modify | ||
685 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
686 | 7 | * published by the Free Software Foundation. | ||
687 | 8 | * | ||
688 | 9 | * This program is distributed in the hope that it will be useful, | ||
689 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
690 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
691 | 12 | * GNU General Public License for more details. | ||
692 | 13 | * | ||
693 | 14 | * You should have received a copy of the GNU General Public License | ||
694 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
695 | 16 | * | ||
696 | 17 | * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com> | ||
697 | 18 | */ | ||
698 | 19 | |||
699 | 20 | #include "AppStreamApplication.h" | ||
700 | 21 | |||
701 | 22 | #include <appstream-glib.h> | ||
702 | 23 | |||
703 | 24 | #include <iostream> | ||
704 | 25 | |||
705 | 26 | namespace unity | ||
706 | 27 | { | ||
707 | 28 | namespace appstream | ||
708 | 29 | { | ||
709 | 30 | |||
710 | 31 | Application::Application(std::string const& appstream_id) | ||
711 | 32 | : appstream_id_(appstream_id) | ||
712 | 33 | { | ||
713 | 34 | desktop_file.SetGetterFunction([this](){ return appstream_id_; }); | ||
714 | 35 | title.SetGetterFunction([this](){ return title_; }); | ||
715 | 36 | icon_pixbuf.SetGetterFunction([this](){ return icon_pixbuf_; }); | ||
716 | 37 | |||
717 | 38 | glib::Object<AsStore> as_store(as_store_new()); | ||
718 | 39 | g_return_if_fail(as_store); | ||
719 | 40 | |||
720 | 41 | as_store_load(as_store, AS_STORE_LOAD_FLAG_APP_INFO_SYSTEM, nullptr, nullptr); | ||
721 | 42 | |||
722 | 43 | AsApp *as_app = as_store_get_app_by_id(as_store, appstream_id_.c_str()); | ||
723 | 44 | g_return_if_fail(as_app); | ||
724 | 45 | |||
725 | 46 | title_ = glib::gchar_to_string(as_app_get_name(as_app, nullptr)); | ||
726 | 47 | |||
727 | 48 | AsIcon *as_icon = as_app_get_icon_default(as_app); | ||
728 | 49 | g_return_if_fail(as_icon); | ||
729 | 50 | |||
730 | 51 | as_icon_load(as_icon, AS_ICON_LOAD_FLAG_SEARCH_SIZE, nullptr); | ||
731 | 52 | icon_pixbuf_ = glib::Object<GdkPixbuf>(as_icon_get_pixbuf(as_icon), glib::AddRef()); | ||
732 | 53 | } | ||
733 | 54 | |||
734 | 55 | AppType Application::type() const | ||
735 | 56 | { | ||
736 | 57 | return AppType::NORMAL; | ||
737 | 58 | } | ||
738 | 59 | |||
739 | 60 | std::string Application::repr() const | ||
740 | 61 | { | ||
741 | 62 | std::ostringstream sout; | ||
742 | 63 | sout << "<AppStream::Application " << appstream_id_ << " >"; | ||
743 | 64 | return sout.str(); | ||
744 | 65 | } | ||
745 | 66 | |||
746 | 67 | WindowList const& Application::GetWindows() const | ||
747 | 68 | { | ||
748 | 69 | return window_list_; | ||
749 | 70 | } | ||
750 | 71 | |||
751 | 72 | bool Application::OwnsWindow(Window window_id) const | ||
752 | 73 | { | ||
753 | 74 | return false; | ||
754 | 75 | } | ||
755 | 76 | |||
756 | 77 | std::vector<std::string> Application::GetSupportedMimeTypes() const | ||
757 | 78 | { | ||
758 | 79 | return std::vector<std::string>(); | ||
759 | 80 | } | ||
760 | 81 | |||
761 | 82 | ApplicationWindowPtr Application::GetFocusableWindow() const | ||
762 | 83 | { | ||
763 | 84 | return nullptr; | ||
764 | 85 | } | ||
765 | 86 | |||
766 | 87 | void Application::Focus(bool show_on_visible, int monitor) const | ||
767 | 88 | {} | ||
768 | 89 | |||
769 | 90 | void Application::Quit() const | ||
770 | 91 | {} | ||
771 | 92 | |||
772 | 93 | bool Application::CreateLocalDesktopFile() const | ||
773 | 94 | { | ||
774 | 95 | return false; | ||
775 | 96 | } | ||
776 | 97 | |||
777 | 98 | std::string Application::desktop_id() const | ||
778 | 99 | { | ||
779 | 100 | return ""; | ||
780 | 101 | } | ||
781 | 102 | |||
782 | 103 | } | ||
783 | 104 | } | ||
784 | 0 | 105 | ||
785 | === added file 'unity-shared/AppStreamApplication.h' | |||
786 | --- unity-shared/AppStreamApplication.h 1970-01-01 00:00:00 +0000 | |||
787 | +++ unity-shared/AppStreamApplication.h 2016-02-23 15:50:24 +0000 | |||
788 | @@ -0,0 +1,61 @@ | |||
789 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
790 | 2 | /* | ||
791 | 3 | * Copyright (C) 2016 Canonical Ltd | ||
792 | 4 | * | ||
793 | 5 | * This program is free software: you can redistribute it and/or modify | ||
794 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
795 | 7 | * published by the Free Software Foundation. | ||
796 | 8 | * | ||
797 | 9 | * This program is distributed in the hope that it will be useful, | ||
798 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
799 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
800 | 12 | * GNU General Public License for more details. | ||
801 | 13 | * | ||
802 | 14 | * You should have received a copy of the GNU General Public License | ||
803 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
804 | 16 | * | ||
805 | 17 | * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com> | ||
806 | 18 | */ | ||
807 | 19 | |||
808 | 20 | #ifndef UNITYSHARED_APPSTREAM_APPLICATION_H | ||
809 | 21 | #define UNITYSHARED_APPSTREAM_APPLICATION_H | ||
810 | 22 | |||
811 | 23 | #include "DesktopApplicationManager.h" | ||
812 | 24 | |||
813 | 25 | namespace unity | ||
814 | 26 | { | ||
815 | 27 | namespace appstream | ||
816 | 28 | { | ||
817 | 29 | |||
818 | 30 | class Application : public desktop::Application | ||
819 | 31 | { | ||
820 | 32 | public: | ||
821 | 33 | Application(std::string const& appstream_id); | ||
822 | 34 | |||
823 | 35 | AppType type() const override; | ||
824 | 36 | std::string repr() const override; | ||
825 | 37 | |||
826 | 38 | WindowList const& GetWindows() const override; | ||
827 | 39 | bool OwnsWindow(Window window_id) const override; | ||
828 | 40 | |||
829 | 41 | std::vector<std::string> GetSupportedMimeTypes() const override; | ||
830 | 42 | |||
831 | 43 | ApplicationWindowPtr GetFocusableWindow() const override; | ||
832 | 44 | void Focus(bool show_on_visible, int monitor) const override; | ||
833 | 45 | void Quit() const override; | ||
834 | 46 | |||
835 | 47 | bool CreateLocalDesktopFile() const override; | ||
836 | 48 | |||
837 | 49 | std::string desktop_id() const override; | ||
838 | 50 | |||
839 | 51 | private: | ||
840 | 52 | std::string appstream_id_; | ||
841 | 53 | std::string title_; | ||
842 | 54 | glib::Object<_GdkPixbuf> icon_pixbuf_; | ||
843 | 55 | WindowList window_list_; | ||
844 | 56 | }; | ||
845 | 57 | |||
846 | 58 | } | ||
847 | 59 | } | ||
848 | 60 | |||
849 | 61 | #endif | ||
850 | 0 | 62 | ||
851 | === modified file 'unity-shared/ApplicationManager.h' | |||
852 | --- unity-shared/ApplicationManager.h 2015-11-26 00:20:23 +0000 | |||
853 | +++ unity-shared/ApplicationManager.h 2016-02-23 15:50:24 +0000 | |||
854 | @@ -25,8 +25,10 @@ | |||
855 | 25 | 25 | ||
856 | 26 | #include <sigc++/signal.h> | 26 | #include <sigc++/signal.h> |
857 | 27 | #include <NuxCore/Property.h> | 27 | #include <NuxCore/Property.h> |
858 | 28 | #include <UnityCore/GLibWrapper.h> | ||
859 | 28 | #include <unity-shared/WindowManager.h> | 29 | #include <unity-shared/WindowManager.h> |
860 | 29 | 30 | ||
861 | 31 | struct _GdkPixbuf; | ||
862 | 30 | 32 | ||
863 | 31 | namespace unity | 33 | namespace unity |
864 | 32 | { | 34 | { |
865 | @@ -153,6 +155,7 @@ | |||
866 | 153 | nux::ROProperty<std::string> desktop_file; | 155 | nux::ROProperty<std::string> desktop_file; |
867 | 154 | nux::ROProperty<std::string> title; | 156 | nux::ROProperty<std::string> title; |
868 | 155 | nux::ROProperty<std::string> icon; | 157 | nux::ROProperty<std::string> icon; |
869 | 158 | nux::ROProperty<glib::Object<_GdkPixbuf>> icon_pixbuf; | ||
870 | 156 | 159 | ||
871 | 157 | // Considering using a property for the "unity-seen" quark | 160 | // Considering using a property for the "unity-seen" quark |
872 | 158 | nux::RWProperty<bool> seen; | 161 | nux::RWProperty<bool> seen; |
873 | 159 | 162 | ||
874 | === modified file 'unity-shared/CMakeLists.txt' | |||
875 | --- unity-shared/CMakeLists.txt 2015-11-06 18:05:38 +0000 | |||
876 | +++ unity-shared/CMakeLists.txt 2016-02-23 15:50:24 +0000 | |||
877 | @@ -18,6 +18,7 @@ | |||
878 | 18 | # | 18 | # |
879 | 19 | set (UNITY_SHARED_SOURCES | 19 | set (UNITY_SHARED_SOURCES |
880 | 20 | ApplicationManager.cpp | 20 | ApplicationManager.cpp |
881 | 21 | AppStreamApplication.cpp | ||
882 | 21 | BGHash.cpp | 22 | BGHash.cpp |
883 | 22 | CoverArt.cpp | 23 | CoverArt.cpp |
884 | 23 | BackgroundEffectHelper.cpp | 24 | BackgroundEffectHelper.cpp |
885 | 24 | 25 | ||
886 | === modified file 'unity-shared/DesktopApplicationManager.h' | |||
887 | --- unity-shared/DesktopApplicationManager.h 2014-01-15 14:51:10 +0000 | |||
888 | +++ unity-shared/DesktopApplicationManager.h 2016-02-23 15:50:24 +0000 | |||
889 | @@ -24,7 +24,7 @@ | |||
890 | 24 | #include <UnityCore/GLibWrapper.h> | 24 | #include <UnityCore/GLibWrapper.h> |
891 | 25 | #include <UnityCore/GLibSignal.h> | 25 | #include <UnityCore/GLibSignal.h> |
892 | 26 | 26 | ||
894 | 27 | #include "unity-shared/ApplicationManager.h" | 27 | #include "ApplicationManager.h" |
895 | 28 | 28 | ||
896 | 29 | namespace unity | 29 | namespace unity |
897 | 30 | { | 30 | { |
FAILED: Continuous integration, rev:4070 jenkins. qa.ubuntu. com/job/ unity-ci/ 1409/ jenkins. qa.ubuntu. com/job/ unity-xenial- amd64-ci/ 59/console jenkins. qa.ubuntu. com/job/ unity-xenial- armhf-ci/ 59/console jenkins. qa.ubuntu. com/job/ unity-xenial- i386-ci/ 59/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/unity- ci/1409/ rebuild
http://