Merge lp:~azzar1/unity/gs-integration into lp:unity

Proposed by Andrea Azzarone
Status: Superseded
Proposed branch: lp:~azzar1/unity/gs-integration
Merge into: lp:unity
Diff against target: 1121 lines (+290/-339)
23 files modified
CMakeLists.txt (+1/-0)
com.canonical.Unity.gschema.xml (+1/-1)
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/data/applications/org.gnome.Software.desktop (+3/-4)
tests/test_application_launcher_icon.cpp (+7/-7)
tests/test_desktop_utilities.cpp (+3/-3)
tests/test_favorite_store.cpp (+1/-1)
tests/test_favorite_store_gsettings.cpp (+1/-1)
tests/test_launcher_controller.cpp (+1/-33)
tests/test_software_center_launcher_icon.cpp (+31/-105)
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
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+286653@code.launchpad.net

This proposal has been superseded by a proposal from 2016-02-23.

Commit message

Gnome-software launcher integration.

Description of the change

Gnome-software launcher integration.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Add libappstream-glib-dev as build dependency on debian/control.

Also, please, ensure that this merges with lp:~robert-ancell/unity/gnome-software

See comments, there might be some room for future optimization.

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

Done. We can talk more about the icon stuff later on.

Revision history for this message
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.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2016-02-09 01:57:51 +0000
+++ CMakeLists.txt 2016-02-23 15:49:50 +0000
@@ -228,6 +228,7 @@
228set(UNITY_PROTOCOL_PRIVATE_DEPS unity-protocol-private>=7.1.0)228set(UNITY_PROTOCOL_PRIVATE_DEPS unity-protocol-private>=7.1.0)
229set(UNITY_PLUGIN_SHARED_DEPS229set(UNITY_PLUGIN_SHARED_DEPS
230 ${UNITY_PROTOCOL_PRIVATE_DEPS}230 ${UNITY_PROTOCOL_PRIVATE_DEPS}
231 appstream-glib
231 atk232 atk
232 atk-bridge-2.0233 atk-bridge-2.0
233 cairo>=1.13.1234 cairo>=1.13.1
234235
=== modified file 'com.canonical.Unity.gschema.xml'
--- com.canonical.Unity.gschema.xml 2015-11-23 09:24:10 +0000
+++ com.canonical.Unity.gschema.xml 2016-02-23 15:49:50 +0000
@@ -117,7 +117,7 @@
117 'application://libreoffice-writer.desktop',117 'application://libreoffice-writer.desktop',
118 'application://libreoffice-calc.desktop',118 'application://libreoffice-calc.desktop',
119 'application://libreoffice-impress.desktop',119 'application://libreoffice-impress.desktop',
120 'application://ubuntu-software-center.desktop',120 'application://org.gnome.Software.desktop',
121 'application://ubuntu-amazon-default.desktop',121 'application://ubuntu-amazon-default.desktop',
122 'application://unity-control-center.desktop',122 'application://unity-control-center.desktop',
123 'unity://running-apps',123 'unity://running-apps',
124124
=== modified file 'debian/control'
--- debian/control 2016-02-09 12:20:47 +0000
+++ debian/control 2016-02-23 15:49:50 +0000
@@ -13,6 +13,7 @@
13 gsettings-desktop-schemas-dev,13 gsettings-desktop-schemas-dev,
14 gsettings-ubuntu-schemas (>= 0.0.1+14.04.20140219),14 gsettings-ubuntu-schemas (>= 0.0.1+14.04.20140219),
15 intltool (>= 0.35.0),15 intltool (>= 0.35.0),
16 libappstream-glib-dev,
16 libatk1.0-dev,17 libatk1.0-dev,
17 libbamf3-dev (>= 0.5.2~bzr0),18 libbamf3-dev (>= 0.5.2~bzr0),
18 libboost-dev,19 libboost-dev,
1920
=== modified file 'launcher/LauncherController.cpp'
--- launcher/LauncherController.cpp 2015-12-17 22:32:37 +0000
+++ launcher/LauncherController.cpp 2016-02-23 15:49:50 +0000
@@ -41,6 +41,7 @@
41#include "ExpoLauncherIcon.h"41#include "ExpoLauncherIcon.h"
42#include "TrashLauncherIcon.h"42#include "TrashLauncherIcon.h"
43#include "BFBLauncherIcon.h"43#include "BFBLauncherIcon.h"
44#include "unity-shared/AppStreamApplication.h"
44#include "unity-shared/IconRenderer.h"45#include "unity-shared/IconRenderer.h"
45#include "unity-shared/UScreen.h"46#include "unity-shared/UScreen.h"
46#include "unity-shared/UBusMessages.h"47#include "unity-shared/UBusMessages.h"
@@ -61,13 +62,8 @@
61 "<node>"62 "<node>"
62 " <interface name='com.canonical.Unity.Launcher'>"63 " <interface name='com.canonical.Unity.Launcher'>"
63 ""64 ""
64 " <method name='AddLauncherItemFromPosition'>"65 " <method name='AddLauncherItem'>"
65 " <arg type='s' name='title' direction='in'/>"66 " <arg type='s' name='appstream_app_id' direction='in'/>"
66 " <arg type='s' name='icon' direction='in'/>"
67 " <arg type='i' name='icon_x' direction='in'/>"
68 " <arg type='i' name='icon_y' direction='in'/>"
69 " <arg type='i' name='icon_size' direction='in'/>"
70 " <arg type='s' name='desktop_file' direction='in'/>"
71 " <arg type='s' name='aptdaemon_task' direction='in'/>"67 " <arg type='s' name='aptdaemon_task' direction='in'/>"
72 " </method>"68 " </method>"
73 ""69 ""
@@ -506,44 +502,25 @@
506}502}
507503
508void504void
509Controller::Impl::OnLauncherAddRequestSpecial(std::string const& path,505Controller::Impl::OnLauncherAddRequestSpecial(std::string const& appstream_app_id,
510 std::string const& aptdaemon_trans_id,506 std::string const& aptdaemon_trans_id)
511 std::string const& icon_path,
512 int icon_x,
513 int icon_y,
514 int icon_size)
515{507{
516 // Check if desktop file was supplied, or if it's set to SC's agent508 // Check if desktop file was supplied
517 // See https://bugs.launchpad.net/unity/+bug/1002440509 if (appstream_app_id.empty())
518 if (path.empty() || path == local::SOFTWARE_CENTER_AGENT)
519 return;510 return;
520511
521 auto const& icon = std::find_if(model_->begin(), model_->end(),512 auto const& icon = std::find_if(model_->begin(), model_->end(),
522 [&path](AbstractLauncherIcon::Ptr const& i) { return (i->DesktopFile() == path); });513 [&appstream_app_id](AbstractLauncherIcon::Ptr const& i) { return (i->DesktopFile() == appstream_app_id); });
523514
524 if (icon != model_->end())515 if (icon != model_->end())
525 return;516 return;
526517
527 auto const& result = CreateSCLauncherIcon(path, aptdaemon_trans_id, icon_path);518 auto const& result = CreateSCLauncherIcon(appstream_app_id, aptdaemon_trans_id);
528519
529 if (result)520 if (result)
530 {521 {
531 // Setting the icon position and adding it to the model, makes the launcher
532 // to compute its center
533 RegisterIcon(result, GetLastIconPriority<ApplicationLauncherIcon>("", true));522 RegisterIcon(result, GetLastIconPriority<ApplicationLauncherIcon>("", true));
534523 result->SetQuirk(AbstractLauncherIcon::Quirk::VISIBLE, true);
535 if (icon_x > 0 || icon_y > 0)
536 {
537 // This will ensure that the center of the new icon is set, so that
538 // the animation could be done properly.
539 sources_.AddIdle([this, icon_x, icon_y, result] {
540 return !result->Animate(CurrentLauncher(), icon_x, icon_y);
541 });
542 }
543 else
544 {
545 result->SetQuirk(AbstractLauncherIcon::Quirk::VISIBLE, true);
546 }
547 }524 }
548}525}
549526
@@ -944,22 +921,11 @@
944 return AbstractLauncherIcon::Ptr();921 return AbstractLauncherIcon::Ptr();
945}922}
946923
947SoftwareCenterLauncherIcon::Ptr Controller::Impl::CreateSCLauncherIcon(std::string const& file_path,924SoftwareCenterLauncherIcon::Ptr Controller::Impl::CreateSCLauncherIcon(std::string const& appstream_app_id,
948 std::string const& aptdaemon_trans_id,925 std::string const& aptdaemon_trans_id)
949 std::string const& icon_path)
950{926{
951 SoftwareCenterLauncherIcon::Ptr result;927 ApplicationPtr app = std::make_shared<appstream::Application>(appstream_app_id);
952928 return SoftwareCenterLauncherIcon::Ptr(new SoftwareCenterLauncherIcon(app, aptdaemon_trans_id));
953 ApplicationPtr app = ApplicationManager::Default().GetApplicationForDesktopFile(file_path);
954 if (!app)
955 return result;
956
957 if (app->seen)
958 return result;
959
960 result = new SoftwareCenterLauncherIcon(app, aptdaemon_trans_id, icon_path);
961
962 return result;
963}929}
964930
965void Controller::Impl::AddRunningApps()931void Controller::Impl::AddRunningApps()
@@ -1548,16 +1514,11 @@
15481514
1549GVariant* Controller::Impl::OnDBusMethodCall(std::string const& method, GVariant *parameters)1515GVariant* Controller::Impl::OnDBusMethodCall(std::string const& method, GVariant *parameters)
1550{1516{
1551 if (method == "AddLauncherItemFromPosition")1517 if (method == "AddLauncherItem")
1552 {1518 {
1553 glib::String icon, icon_title, desktop_file, aptdaemon_task;1519 glib::String appstream_app_id, aptdaemon_trans_id;
1554 gint icon_x, icon_y, icon_size;1520 g_variant_get(parameters, "(ss)", &appstream_app_id, &aptdaemon_trans_id);
15551521 OnLauncherAddRequestSpecial(appstream_app_id.Str(), aptdaemon_trans_id.Str());
1556 g_variant_get(parameters, "(ssiiiss)", &icon_title, &icon, &icon_x, &icon_y,
1557 &icon_size, &desktop_file, &aptdaemon_task);
1558
1559 OnLauncherAddRequestSpecial(desktop_file.Str(), aptdaemon_task.Str(),
1560 icon.Str(), icon_x, icon_y, icon_size);
1561 }1522 }
1562 else if (method == "UpdateLauncherIconFavoriteState")1523 else if (method == "UpdateLauncherIconFavoriteState")
1563 {1524 {
15641525
=== modified file 'launcher/LauncherControllerPrivate.h'
--- launcher/LauncherControllerPrivate.h 2015-12-07 18:34:41 +0000
+++ launcher/LauncherControllerPrivate.h 2016-02-23 15:49:50 +0000
@@ -69,8 +69,7 @@
69 void OnDeviceIconAdded(AbstractLauncherIcon::Ptr const& icon);69 void OnDeviceIconAdded(AbstractLauncherIcon::Ptr const& icon);
7070
71 void OnLauncherAddRequest(std::string const& icon_uri, AbstractLauncherIcon::Ptr const& before);71 void OnLauncherAddRequest(std::string const& icon_uri, AbstractLauncherIcon::Ptr const& before);
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);
73 std::string const& icon_path, int icon_x, int icon_y, int icon_size);
74 void OnLauncherUpdateIconStickyState(std::string const& desktop_file, bool sticky);73 void OnLauncherUpdateIconStickyState(std::string const& desktop_file, bool sticky);
75 void OnLauncherRemoveRequest(AbstractLauncherIcon::Ptr const& icon);74 void OnLauncherRemoveRequest(AbstractLauncherIcon::Ptr const& icon);
7675
@@ -90,7 +89,7 @@
90 ApplicationLauncherIcon* CreateAppLauncherIcon(ApplicationPtr const&);89 ApplicationLauncherIcon* CreateAppLauncherIcon(ApplicationPtr const&);
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);
92 AbstractLauncherIcon::Ptr GetIconByUri(std::string const& icon_uri);91 AbstractLauncherIcon::Ptr GetIconByUri(std::string const& icon_uri);
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);
9493
95 void SetupIcons();94 void SetupIcons();
96 void MigrateFavorites();95 void MigrateFavorites();
9796
=== modified file 'launcher/LauncherIcon.cpp'
--- launcher/LauncherIcon.cpp 2015-11-25 23:16:11 +0000
+++ launcher/LauncherIcon.cpp 2016-02-23 15:49:50 +0000
@@ -365,6 +365,20 @@
365 return _unity_theme;365 return _unity_theme;
366}366}
367367
368BaseTexturePtr LauncherIcon::TextureFromPixbuf(GdkPixbuf* pixbuf, int size, bool update_glow_colors)
369{
370 g_return_val_if_fail(GDK_IS_PIXBUF(pixbuf), BaseTexturePtr());
371
372 glib::Object<GdkPixbuf> scaled_pixbuf(gdk_pixbuf_scale_simple(pixbuf, size, size, GDK_INTERP_BILINEAR));
373
374 if (update_glow_colors)
375 ColorForIcon(scaled_pixbuf, _background_color, _glow_color);
376
377 BaseTexturePtr result;
378 result.Adopt(nux::CreateTexture2DFromPixbuf(scaled_pixbuf, true));
379 return result;
380}
381
368BaseTexturePtr LauncherIcon::TextureFromGtkTheme(std::string icon_name, int size, bool update_glow_colors)382BaseTexturePtr LauncherIcon::TextureFromGtkTheme(std::string icon_name, int size, bool update_glow_colors)
369{383{
370 GtkIconTheme* default_theme;384 GtkIconTheme* default_theme;
371385
=== modified file 'launcher/LauncherIcon.h'
--- launcher/LauncherIcon.h 2015-11-25 23:16:11 +0000
+++ launcher/LauncherIcon.h 2016-02-23 15:49:50 +0000
@@ -269,6 +269,8 @@
269269
270 virtual bool HandlesSpread () { return false; }270 virtual bool HandlesSpread () { return false; }
271271
272 BaseTexturePtr TextureFromPixbuf(GdkPixbuf *pixbuf, int size, bool update_glow_colors = true);
273
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);
273275
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);
275277
=== modified file 'launcher/SimpleLauncherIcon.cpp'
--- launcher/SimpleLauncherIcon.cpp 2014-07-30 00:49:35 +0000
+++ launcher/SimpleLauncherIcon.cpp 2016-02-23 15:49:50 +0000
@@ -34,6 +34,7 @@
34SimpleLauncherIcon::SimpleLauncherIcon(IconType type)34SimpleLauncherIcon::SimpleLauncherIcon(IconType type)
35 : LauncherIcon(type)35 : LauncherIcon(type)
36 , icon_name("", sigc::mem_fun(this, &SimpleLauncherIcon::SetIconName))36 , icon_name("", sigc::mem_fun(this, &SimpleLauncherIcon::SetIconName))
37 , icon_pixbuf(glib::Object<GdkPixbuf>(), sigc::mem_fun(this, &SimpleLauncherIcon::SetIconPixbuf))
37{38{
38 auto* theme = gtk_icon_theme_get_default();39 auto* theme = gtk_icon_theme_get_default();
39 theme_changed_signal_.Connect(theme, "changed", [this] (GtkIconTheme *) {40 theme_changed_signal_.Connect(theme, "changed", [this] (GtkIconTheme *) {
@@ -53,17 +54,24 @@
53 if (it != texture_map_.end())54 if (it != texture_map_.end())
54 return it->second.GetPointer();55 return it->second.GetPointer();
5556
56 std::string const& icon_string = icon_name();
57
58 if (icon_string.empty())
59 return nullptr;
60
61 BaseTexturePtr texture;57 BaseTexturePtr texture;
6258
63 if (icon_string[0] == '/')59 if (icon_pixbuf())
64 texture = TextureFromPath(icon_string, size);60 {
61 texture = TextureFromPixbuf(icon_pixbuf(), size);
62 }
65 else63 else
66 texture = TextureFromGtkTheme(icon_string, size);64 {
65 std::string const& icon_string = icon_name();
66
67 if (icon_string.empty())
68 return nullptr;
69
70 if (icon_string[0] == '/')
71 texture = TextureFromPath(icon_string, size);
72 else
73 texture = TextureFromGtkTheme(icon_string, size);
74 }
6775
68 if (!texture)76 if (!texture)
69 return nullptr;77 return nullptr;
@@ -83,6 +91,17 @@
83 return true;91 return true;
84}92}
8593
94bool SimpleLauncherIcon::SetIconPixbuf(glib::Object<GdkPixbuf>& target, glib::Object<GdkPixbuf> const& value)
95{
96 if (target == value)
97 return false;
98
99 target = value;
100 ReloadIcon();
101
102 return true;
103}
104
86void SimpleLauncherIcon::ReloadIcon()105void SimpleLauncherIcon::ReloadIcon()
87{106{
88 texture_map_.clear();107 texture_map_.clear();
89108
=== modified file 'launcher/SimpleLauncherIcon.h'
--- launcher/SimpleLauncherIcon.h 2013-09-19 16:44:03 +0000
+++ launcher/SimpleLauncherIcon.h 2016-02-23 15:49:50 +0000
@@ -38,6 +38,7 @@
3838
39 // Properties39 // Properties
40 nux::Property<std::string> icon_name;40 nux::Property<std::string> icon_name;
41 nux::Property<glib::Object<GdkPixbuf>> icon_pixbuf;
4142
42protected:43protected:
43 std::string GetName() const;44 std::string GetName() const;
@@ -49,6 +50,7 @@
49private:50private:
50 void ReloadIcon();51 void ReloadIcon();
51 bool SetIconName(std::string& target, std::string const& value);52 bool SetIconName(std::string& target, std::string const& value);
53 bool SetIconPixbuf(glib::Object<GdkPixbuf>& target, glib::Object<GdkPixbuf> const& value);
5254
53private:55private:
54 std::unordered_map<int, BaseTexturePtr> texture_map_;56 std::unordered_map<int, BaseTexturePtr> texture_map_;
5557
=== modified file 'launcher/SoftwareCenterLauncherIcon.cpp'
--- launcher/SoftwareCenterLauncherIcon.cpp 2015-12-07 16:13:42 +0000
+++ launcher/SoftwareCenterLauncherIcon.cpp 2016-02-23 15:49:50 +0000
@@ -44,8 +44,7 @@
4444
45NUX_IMPLEMENT_OBJECT_TYPE(SoftwareCenterLauncherIcon);45NUX_IMPLEMENT_OBJECT_TYPE(SoftwareCenterLauncherIcon);
46SoftwareCenterLauncherIcon::SoftwareCenterLauncherIcon(ApplicationPtr const& app,46SoftwareCenterLauncherIcon::SoftwareCenterLauncherIcon(ApplicationPtr const& app,
47 std::string const& aptdaemon_trans_id,47 std::string const& aptdaemon_trans_id)
48 std::string const& icon_path)
49 : WindowedLauncherIcon(IconType::APPLICATION)48 : WindowedLauncherIcon(IconType::APPLICATION)
50 , ApplicationLauncherIcon(app)49 , ApplicationLauncherIcon(app)
51 , aptdaemon_trans_(std::make_shared<glib::DBusProxy>("org.debian.apt",50 , aptdaemon_trans_(std::make_shared<glib::DBusProxy>("org.debian.apt",
@@ -69,61 +68,13 @@
69 SetQuirk(Quirk::PROGRESS, (progress > 0));68 SetQuirk(Quirk::PROGRESS, (progress > 0));
70 });69 });
7170
72 if (!icon_path.empty())71 if (app->icon_pixbuf())
73 icon_name = icon_path;72 icon_pixbuf = app->icon_pixbuf();
7473
75 if (!aptdaemon_trans_id_.empty()) // Application is being installed, or hasn't been installed yet74 if (!aptdaemon_trans_id_.empty()) // Application is being installed, or hasn't been installed yet
76 tooltip_text = _("Waiting to install");75 tooltip_text = _("Waiting to install");
77}76}
7877
79bool SoftwareCenterLauncherIcon::Animate(nux::ObjectPtr<Launcher> const& launcher, int start_x, int start_y)
80{
81 using namespace std::placeholders;
82
83 if (start_x <= 0 && start_y <= 0)
84 {
85 SetQuirk(Quirk::VISIBLE, true);
86 return true;
87 }
88
89 int monitor = launcher->monitor();
90 auto const& icon_center = GetCenter(monitor);
91
92 if (icon_center.x == 0 && icon_center.y == 0)
93 return false;
94
95 auto* floating_icon = new SimpleLauncherIcon(GetIconType());
96 AbstractLauncherIcon::Ptr floating_icon_ptr(floating_icon);
97 floating_icon->icon_name = icon_name();
98
99 // Transform this in a spacer-icon and make it visible only on launcher's monitor
100 icon_name = "";
101 SetQuirk(Quirk::VISIBLE, true, monitor);
102
103 auto rcb = std::bind(&Launcher::RenderIconToTexture, launcher.GetPointer(), _1, _2, floating_icon_ptr);
104 drag_window_ = new LauncherDragWindow(launcher->GetWidth(), rcb);
105 drag_window_->SetBaseXY(start_x, start_y);
106 drag_window_->SetAnimationTarget(icon_center.x, icon_center.y + (launcher->GetIconSize() / 2));
107
108 launcher->ForceReveal(true);
109 drag_window_->ShowWindow(true);
110
111 auto cb = sigc::bind(sigc::mem_fun(this, &SoftwareCenterLauncherIcon::OnDragAnimationFinished), launcher, floating_icon->icon_name());
112 drag_window_->anim_completed.connect(cb);
113 drag_window_->StartSlowAnimation();
114
115 return true;
116}
117
118void SoftwareCenterLauncherIcon::OnDragAnimationFinished(nux::ObjectPtr<Launcher> const& launcher, std::string const& final_icon)
119{
120 icon_name = final_icon;
121 drag_window_->ShowWindow(false);
122 drag_window_.Release();
123 launcher->ForceReveal(false);
124 SetQuirk(Quirk::VISIBLE, true);
125}
126
127void SoftwareCenterLauncherIcon::ActivateLauncherIcon(ActionArg arg)78void SoftwareCenterLauncherIcon::ActivateLauncherIcon(ActionArg arg)
128{79{
129 if (finished_)80 if (finished_)
@@ -144,62 +95,7 @@
14495
145std::string SoftwareCenterLauncherIcon::GetActualDesktopFileAfterInstall()96std::string SoftwareCenterLauncherIcon::GetActualDesktopFileAfterInstall()
146{97{
147 // Fixup the _desktop_file because the one we get from software-center98 return DesktopUtilities::GetDesktopPathById(DesktopFile());
148 // is not the final one, e.g. the s-c-agent does send a temp one and
149 // app-install-data points to the "wrong" one in /usr/share/app-install
150 //
151 // So:
152 // - if there is a desktop file already and it startswith
153 // /usr/share/app-install/desktop, then transform to
154 // /usr/share/application
155 // - if there is a desktop file with prefix /tmp/software-center-agent:
156 // transform to /usr/share/application
157 // (its using "/tmp/software-center-agent:$random:$pkgname.desktop")
158 // maybe:
159 // - and search in /var/lib/apt/lists/$pkgname.list
160 // for a desktop file that roughly matches what we want
161 auto const& desktop_file = DesktopFile();
162
163 // take /usr/share/app-install/desktop/foo:subdir__bar.desktop
164 // and tranform it
165 if (desktop_file.find("/share/app-install/desktop/") != std::string::npos)
166 {
167 auto colon_pos = desktop_file.rfind(":");
168 auto filename = desktop_file.substr(colon_pos + 1, desktop_file.length() - colon_pos);
169 // the app-install-data package encodes subdirs in a funny way, once
170 // that is fixed, this code can be dropped
171 if (filename.find("__") != std::string::npos)
172 {
173 int pos = filename.find("__");
174 filename = filename.replace(pos, 2, "-");
175 }
176 filename = DesktopUtilities::GetDesktopPathById(filename);
177 return filename;
178 }
179 else if (desktop_file.find("/tmp/software-center-agent:") == 0)
180 {
181 // by convention the software-center-agent uses
182 // /usr/share/applications/$pkgname.desktop
183 // or
184 // /usr/share/applications/extras-$pkgname.desktop
185 auto colon_pos = desktop_file.rfind(":");
186 auto desktopf = desktop_file.substr(colon_pos + 1, desktop_file.length() - colon_pos);
187
188 auto filename = DesktopUtilities::GetDesktopPathById(desktopf);
189
190 if (!filename.empty())
191 return filename;
192
193 // now try extras-$pkgname.desktop
194 filename = DesktopUtilities::GetDesktopPathById("extras-" + desktopf);
195 if (!filename.empty())
196 return filename;
197
198 // FIXME: test if there is a file now and if not, search
199 // /var/lib/dpkg/info/$pkgname.list for a desktop file
200 }
201
202 return desktop_file;
203}99}
204100
205void SoftwareCenterLauncherIcon::OnFinished(GVariant *params)101void SoftwareCenterLauncherIcon::OnFinished(GVariant *params)
206102
=== modified file 'launcher/SoftwareCenterLauncherIcon.h'
--- launcher/SoftwareCenterLauncherIcon.h 2013-08-28 16:41:20 +0000
+++ launcher/SoftwareCenterLauncherIcon.h 2016-02-23 15:49:50 +0000
@@ -24,7 +24,6 @@
24#include <string>24#include <string>
25#include <UnityCore/GLibDBusProxy.h>25#include <UnityCore/GLibDBusProxy.h>
26#include "ApplicationLauncherIcon.h"26#include "ApplicationLauncherIcon.h"
27#include "LauncherDragWindow.h"
2827
29namespace unity28namespace unity
30{29{
@@ -39,10 +38,7 @@
39 typedef nux::ObjectPtr<SoftwareCenterLauncherIcon> Ptr;38 typedef nux::ObjectPtr<SoftwareCenterLauncherIcon> Ptr;
4039
41 SoftwareCenterLauncherIcon(ApplicationPtr const& app,40 SoftwareCenterLauncherIcon(ApplicationPtr const& app,
42 std::string const& aptdaemon_trans_id,41 std::string const& aptdaemon_trans_id);
43 std::string const& icon_path);
44
45 bool Animate(nux::ObjectPtr<Launcher> const& launcher, int start_x, int start_y);
4642
47protected:43protected:
48 std::string GetName() const;44 std::string GetName() const;
@@ -52,10 +48,8 @@
52 std::string GetActualDesktopFileAfterInstall();48 std::string GetActualDesktopFileAfterInstall();
53 void OnFinished(GVariant *params);49 void OnFinished(GVariant *params);
54 void OnPropertyChanged(GVariant* params);50 void OnPropertyChanged(GVariant* params);
55 void OnDragAnimationFinished(nux::ObjectPtr<Launcher> const&, std::string const&);
5651
57 glib::DBusProxy::Ptr aptdaemon_trans_;52 glib::DBusProxy::Ptr aptdaemon_trans_;
58 LauncherDragWindow::Ptr drag_window_;
59 bool finished_;53 bool finished_;
60 bool needs_urgent_;54 bool needs_urgent_;
61 std::string aptdaemon_trans_id_;55 std::string aptdaemon_trans_id_;
6256
=== renamed file 'tests/data/applications/ubuntu-software-center.desktop' => 'tests/data/applications/org.gnome.Software.desktop'
--- tests/data/applications/ubuntu-software-center.desktop 2013-06-28 12:52:58 +0000
+++ tests/data/applications/org.gnome.Software.desktop 2016-02-23 15:49:50 +0000
@@ -1,9 +1,8 @@
1[Desktop Entry]1[Desktop Entry]
2Name=Ubuntu Software Center2Name=Software
3GenericName=Software Center3Comment=Add, remove or update software on this computer
4Comment=Lets you choose from thousands of applications available for Ubuntu
5Exec=/bin/true4Exec=/bin/true
6Icon=softwarecenter5Icon=org.gnome.Software
7Terminal=false6Terminal=false
8Type=Application7Type=Application
9Categories=PackageManager;GTK;System;Settings;8Categories=PackageManager;GTK;System;Settings;
109
=== modified file 'tests/test_application_launcher_icon.cpp'
--- tests/test_application_launcher_icon.cpp 2015-12-08 14:34:55 +0000
+++ tests/test_application_launcher_icon.cpp 2016-02-23 15:49:50 +0000
@@ -41,7 +41,7 @@
41namespace41namespace
42{42{
43const std::string DEFAULT_EMPTY_ICON = "application-default-icon";43const std::string DEFAULT_EMPTY_ICON = "application-default-icon";
44const std::string USC_DESKTOP = BUILDDIR"/tests/data/applications/ubuntu-software-center.desktop";44const std::string GS_DESKTOP = BUILDDIR"/tests/data/applications/org.gnome.Software.desktop";
45const std::string UM_DESKTOP = BUILDDIR"/tests/data/applications/update-manager.desktop";45const std::string UM_DESKTOP = BUILDDIR"/tests/data/applications/update-manager.desktop";
46const std::string NO_ICON_DESKTOP = BUILDDIR"/tests/data/applications/no-icon.desktop";46const std::string NO_ICON_DESKTOP = BUILDDIR"/tests/data/applications/no-icon.desktop";
4747
@@ -93,9 +93,9 @@
9393
94 virtual void SetUp() override94 virtual void SetUp() override
95 {95 {
96 usc_app = std::make_shared<MockApplication::Nice>(USC_DESKTOP, "softwarecenter");96 usc_app = std::make_shared<MockApplication::Nice>(GS_DESKTOP, "org.gnome.Software");
97 usc_icon = new MockApplicationLauncherIcon(usc_app);97 usc_icon = new MockApplicationLauncherIcon(usc_app);
98 ASSERT_EQ(usc_icon->DesktopFile(), USC_DESKTOP);98 ASSERT_EQ(usc_icon->DesktopFile(), GS_DESKTOP);
9999
100 empty_app = std::make_shared<MockApplication::Nice>(NO_ICON_DESKTOP);100 empty_app = std::make_shared<MockApplication::Nice>(NO_ICON_DESKTOP);
101 empty_icon = new MockApplicationLauncherIcon(empty_app);101 empty_icon = new MockApplicationLauncherIcon(empty_app);
@@ -175,7 +175,7 @@
175175
176TEST_F(TestApplicationLauncherIcon, ApplicationSignalDisconnection)176TEST_F(TestApplicationLauncherIcon, ApplicationSignalDisconnection)
177{177{
178 std::shared_ptr<MockApplication> app = std::make_shared<MockApplication::Nice>(USC_DESKTOP);178 std::shared_ptr<MockApplication> app = std::make_shared<MockApplication::Nice>(GS_DESKTOP);
179 {179 {
180 MockApplicationLauncherIcon::Ptr icon(new MockApplicationLauncherIcon(app));180 MockApplicationLauncherIcon::Ptr icon(new MockApplicationLauncherIcon(app));
181 EXPECT_FALSE(app->closed.empty());181 EXPECT_FALSE(app->closed.empty());
@@ -201,7 +201,7 @@
201201
202TEST_F(TestApplicationLauncherIcon, TestDefaultIcon)202TEST_F(TestApplicationLauncherIcon, TestDefaultIcon)
203{203{
204 EXPECT_EQ(usc_icon->icon_name(), "softwarecenter");204 EXPECT_EQ(usc_icon->icon_name(), "org.gnome.Software");
205 EXPECT_EQ(empty_icon->icon_name(), DEFAULT_EMPTY_ICON);205 EXPECT_EQ(empty_icon->icon_name(), DEFAULT_EMPTY_ICON);
206 EXPECT_EQ(mock_icon->icon_name(), DEFAULT_EMPTY_ICON);206 EXPECT_EQ(mock_icon->icon_name(), DEFAULT_EMPTY_ICON);
207}207}
@@ -267,7 +267,7 @@
267267
268TEST_F(TestApplicationLauncherIcon, StickStickedDesktopApp)268TEST_F(TestApplicationLauncherIcon, StickStickedDesktopApp)
269{269{
270 auto app = std::make_shared<MockApplication::Nice>(USC_DESKTOP);270 auto app = std::make_shared<MockApplication::Nice>(GS_DESKTOP);
271 app->sticky = true;271 app->sticky = true;
272 app->desktop_file_ = UM_DESKTOP;272 app->desktop_file_ = UM_DESKTOP;
273 MockApplicationLauncherIcon::Ptr icon(new MockApplicationLauncherIcon(app));273 MockApplicationLauncherIcon::Ptr icon(new MockApplicationLauncherIcon(app));
@@ -542,7 +542,7 @@
542542
543TEST_F(TestApplicationLauncherIcon, RemoteUri)543TEST_F(TestApplicationLauncherIcon, RemoteUri)
544{544{
545 EXPECT_EQ(usc_icon->RemoteUri(), FavoriteStore::URI_PREFIX_APP + USC_DESKTOP);545 EXPECT_EQ(usc_icon->RemoteUri(), FavoriteStore::URI_PREFIX_APP + GS_DESKTOP);
546 EXPECT_TRUE(mock_icon->RemoteUri().empty());546 EXPECT_TRUE(mock_icon->RemoteUri().empty());
547}547}
548548
549549
=== modified file 'tests/test_desktop_utilities.cpp'
--- tests/test_desktop_utilities.cpp 2013-03-21 14:01:06 +0000
+++ tests/test_desktop_utilities.cpp 2016-02-23 15:49:50 +0000
@@ -184,17 +184,17 @@
184 g_setenv("XDG_DATA_DIRS", LOCAL_DATA_DIR.c_str(), TRUE);184 g_setenv("XDG_DATA_DIRS", LOCAL_DATA_DIR.c_str(), TRUE);
185 g_setenv("XDG_DATA_HOME", "UnityUserConfig", TRUE);185 g_setenv("XDG_DATA_HOME", "UnityUserConfig", TRUE);
186186
187 std::string const& file = DesktopUtilities::GetDesktopPathById("ubuntu-software-center.desktop");187 std::string const& file = DesktopUtilities::GetDesktopPathById("org.gnome.Software.desktop");
188188
189 g_setenv("XDG_DATA_DIRS", old_dirs.c_str(), TRUE);189 g_setenv("XDG_DATA_DIRS", old_dirs.c_str(), TRUE);
190 g_setenv("XDG_DATA_HOME", old_dirs.c_str(), TRUE);190 g_setenv("XDG_DATA_HOME", old_dirs.c_str(), TRUE);
191191
192 EXPECT_EQ(file, LOCAL_DATA_DIR + "/applications/ubuntu-software-center.desktop");192 EXPECT_EQ(file, LOCAL_DATA_DIR + "/applications/org.gnome.Software.desktop");
193}193}
194194
195TEST(TestDesktopUtilities, TestGetBackgroundColor)195TEST(TestDesktopUtilities, TestGetBackgroundColor)
196{196{
197 std::string const& color = DesktopUtilities::GetBackgroundColor(LOCAL_DATA_DIR+"/applications/ubuntu-software-center.desktop");197 std::string const& color = DesktopUtilities::GetBackgroundColor(LOCAL_DATA_DIR+"/applications/org.gnome.Software.desktop");
198198
199 EXPECT_EQ(color, "#aabbcc");199 EXPECT_EQ(color, "#aabbcc");
200}200}
201201
=== modified file 'tests/test_favorite_store.cpp'
--- tests/test_favorite_store.cpp 2012-09-18 15:47:49 +0000
+++ tests/test_favorite_store.cpp 2016-02-23 15:49:50 +0000
@@ -87,7 +87,7 @@
8787
88TEST_F(TestFavoriteStore, ParseFavoriteFromUri)88TEST_F(TestFavoriteStore, ParseFavoriteFromUri)
89{89{
90 const std::string VALID_DESKTOP_PATH = BUILDDIR"/tests/data/applications/ubuntu-software-center.desktop";90 const std::string VALID_DESKTOP_PATH = BUILDDIR"/tests/data/applications/org.gnome.Software.desktop";
91 EXPECT_EQ(favorite_store.ParseFavoriteFromUri("file.desktop"), "application://file.desktop");91 EXPECT_EQ(favorite_store.ParseFavoriteFromUri("file.desktop"), "application://file.desktop");
92 EXPECT_EQ(favorite_store.ParseFavoriteFromUri(VALID_DESKTOP_PATH), "application://"+VALID_DESKTOP_PATH);92 EXPECT_EQ(favorite_store.ParseFavoriteFromUri(VALID_DESKTOP_PATH), "application://"+VALID_DESKTOP_PATH);
9393
9494
=== modified file 'tests/test_favorite_store_gsettings.cpp'
--- tests/test_favorite_store_gsettings.cpp 2014-03-21 03:42:28 +0000
+++ tests/test_favorite_store_gsettings.cpp 2016-02-23 15:49:50 +0000
@@ -38,7 +38,7 @@
38const gchar* SETTINGS_KEY = "favorites";38const gchar* SETTINGS_KEY = "favorites";
3939
40const char* base_store_favs[] = { BUILDDIR"/tests/data/applications/ubuntuone-installer.desktop",40const char* base_store_favs[] = { BUILDDIR"/tests/data/applications/ubuntuone-installer.desktop",
41 "file://" BUILDDIR "/tests/data/applications/ubuntu-software-center.desktop",41 "file://" BUILDDIR "/tests/data/applications/org.gnome.Software.desktop",
42 "application://" BUILDDIR "/tests/data/applications/update-manager.desktop",42 "application://" BUILDDIR "/tests/data/applications/update-manager.desktop",
43 "unity://test-icon",43 "unity://test-icon",
44 "device://uuid",44 "device://uuid",
4545
=== modified file 'tests/test_launcher_controller.cpp'
--- tests/test_launcher_controller.cpp 2015-12-08 14:34:55 +0000
+++ tests/test_launcher_controller.cpp 2016-02-23 15:49:50 +0000
@@ -61,7 +61,7 @@
61namespace app61namespace app
62{62{
63 const std::string UBUNTU_ONE = BUILDDIR "/tests/data/applications/ubuntuone-installer.desktop";63 const std::string UBUNTU_ONE = BUILDDIR "/tests/data/applications/ubuntuone-installer.desktop";
64 const std::string SW_CENTER = BUILDDIR "/tests/data/applications/ubuntu-software-center.desktop";64 const std::string SW_CENTER = BUILDDIR "/tests/data/applications/org.gnome.Software.desktop";
65 const std::string UPDATE_MANAGER = BUILDDIR "/tests/data/applications/update-manager.desktop";65 const std::string UPDATE_MANAGER = BUILDDIR "/tests/data/applications/update-manager.desktop";
66 const std::string BZR_HANDLE_PATCH = BUILDDIR "/tests/data/applications/bzr-handle-patch.desktop";66 const std::string BZR_HANDLE_PATCH = BUILDDIR "/tests/data/applications/bzr-handle-patch.desktop";
67 const std::string NO_ICON = BUILDDIR "/tests/data/applications/no-icon.desktop";67 const std::string NO_ICON = BUILDDIR "/tests/data/applications/no-icon.desktop";
@@ -1321,38 +1321,6 @@
1321 lc.launcher().remove_request.emit(device_icon);1321 lc.launcher().remove_request.emit(device_icon);
1322}1322}
13231323
1324TEST_F(TestLauncherController, LauncherAddRequestSpecial)
1325{
1326 std::string desktop = app::BZR_HANDLE_PATCH;
1327 std::string icon_uri = FavoriteStore::URI_PREFIX_APP + desktop;
1328 ASSERT_FALSE(lc.Impl()->GetIconByUri(icon_uri).IsValid());
1329 EXPECT_CALL(*unity_app_, LogEvent(_, _)).Times(0);
1330
1331 lc.Impl()->OnLauncherAddRequestSpecial(desktop, "", "", 0, 0, 32);
1332
1333 auto const& sw_center_icon = lc.Impl()->GetIconByUri(icon_uri);
1334 ASSERT_TRUE(sw_center_icon.IsValid());
1335 EXPECT_TRUE(sw_center_icon->IsSticky());
1336 EXPECT_NE(dynamic_cast<SoftwareCenterLauncherIcon*>(sw_center_icon.GetPointer()), nullptr);
1337}
1338
1339TEST_F(TestLauncherController, LauncherAddRequestSpecialIgnored)
1340{
1341 std::string desktop = app::BZR_HANDLE_PATCH;
1342 std::string icon_uri = FavoriteStore::URI_PREFIX_APP + desktop;
1343
1344 MockApplicationLauncherIcon::Ptr bamf_icon(new MockApplicationLauncherIcon::Nice(desktop));
1345 lc.Impl()->RegisterIcon(bamf_icon, std::numeric_limits<int>::max());
1346 ASSERT_TRUE(lc.Impl()->GetIconByUri(icon_uri).IsValid());
1347
1348 EXPECT_CALL(*bamf_icon, Stick(false)).Times(0);
1349
1350 int previous_model_size = lc.Impl()->model_->Size();
1351 lc.Impl()->OnLauncherAddRequestSpecial(desktop, "", "", 0, 0, 32);
1352
1353 EXPECT_EQ(previous_model_size, lc.Impl()->model_->Size());
1354}
1355
1356TEST_F(TestLauncherController, SaveIconsOrder)1324TEST_F(TestLauncherController, SaveIconsOrder)
1357{1325{
1358 favorite_store.ClearFavorites();1326 favorite_store.ClearFavorites();
13591327
=== modified file 'tests/test_software_center_launcher_icon.cpp'
--- tests/test_software_center_launcher_icon.cpp 2015-12-08 14:34:55 +0000
+++ tests/test_software_center_launcher_icon.cpp 2016-02-23 15:49:50 +0000
@@ -42,28 +42,26 @@
42{42{
43namespace43namespace
44{44{
45const std::string PRE_INSTALL_ICON = "sw-center-launcher-icon";45const std::string FINAL_ICON = "org.gnome.Software";
46const std::string FINAL_ICON = "softwarecenter";46const std::string APP_NAME = "Software";
47const std::string APP_NAME = "Ubuntu Software Center";
48const std::string LOCAL_DATA_DIR = BUILDDIR"/tests/data";47const std::string LOCAL_DATA_DIR = BUILDDIR"/tests/data";
49const std::string USC_DESKTOP = LOCAL_DATA_DIR+"/applications/ubuntu-software-center.desktop";48const std::string GS_DESKTOP = LOCAL_DATA_DIR+"/applications/org.gnome.Software.desktop";
50const std::string USC_APP_INSTALL_DESKTOP = "/usr/share/app-install/desktop/software-center:ubuntu-software-center.desktop";49const std::string GS_APP_INSTALL_DESKTOP = "org.gnome.Software.desktop";
51}50}
5251
53struct TestSoftwareCenterLauncherIcon : testmocks::TestUnityAppBase52struct TestSoftwareCenterLauncherIcon : testmocks::TestUnityAppBase
54{53{
55 TestSoftwareCenterLauncherIcon()54 TestSoftwareCenterLauncherIcon()
56 : usc(std::make_shared<MockApplication::Nice>(USC_APP_INSTALL_DESKTOP, FINAL_ICON, APP_NAME))55 : gs(std::make_shared<MockApplication::Nice>(GS_APP_INSTALL_DESKTOP, FINAL_ICON, APP_NAME))
57 , icon(usc, "/com/canonical/unity/test/object/path", PRE_INSTALL_ICON)56 , icon(gs, "/com/canonical/unity/test/object/path")
58 {}57 {}
5958
60 struct MockSoftwareCenterLauncherIcon : SoftwareCenterLauncherIcon59 struct MockSoftwareCenterLauncherIcon : SoftwareCenterLauncherIcon
61 {60 {
62 MockSoftwareCenterLauncherIcon(ApplicationPtr const& app,61 MockSoftwareCenterLauncherIcon(ApplicationPtr const& app,
63 std::string const& aptdaemon_trans_id,62 std::string const& aptdaemon_trans_id)
64 std::string const& icon_path)
65 : WindowedLauncherIcon(IconType::APPLICATION)63 : WindowedLauncherIcon(IconType::APPLICATION)
66 , SoftwareCenterLauncherIcon(app, aptdaemon_trans_id, icon_path)64 , SoftwareCenterLauncherIcon(app, aptdaemon_trans_id)
67 {}65 {}
6866
69 void LauncherIconUnstick() { LauncherIcon::UnStick(); }67 void LauncherIconUnstick() { LauncherIcon::UnStick(); }
@@ -71,7 +69,6 @@
71 using SoftwareCenterLauncherIcon::GetActualDesktopFileAfterInstall;69 using SoftwareCenterLauncherIcon::GetActualDesktopFileAfterInstall;
72 using SoftwareCenterLauncherIcon::OnFinished;70 using SoftwareCenterLauncherIcon::OnFinished;
73 using SoftwareCenterLauncherIcon::OnPropertyChanged;71 using SoftwareCenterLauncherIcon::OnPropertyChanged;
74 using SoftwareCenterLauncherIcon::drag_window_;
75 using LauncherIcon::GetRemoteUri;72 using LauncherIcon::GetRemoteUri;
76 };73 };
7774
@@ -86,7 +83,7 @@
8683
87 panel::Style panel;84 panel::Style panel;
88 nux::ObjectPtr<MockableBaseWindow> launcher_win;85 nux::ObjectPtr<MockableBaseWindow> launcher_win;
89 MockApplication::Ptr usc;86 MockApplication::Ptr gs;
90 MockSoftwareCenterLauncherIcon icon;87 MockSoftwareCenterLauncherIcon icon;
91};88};
9289
@@ -94,75 +91,54 @@
94{91{
95 EXPECT_FALSE(icon.IsVisible());92 EXPECT_FALSE(icon.IsVisible());
96 EXPECT_TRUE(icon.IsSticky());93 EXPECT_TRUE(icon.IsSticky());
97 EXPECT_EQ(AbstractLauncherIcon::Position::FLOATING, icon.position());
98 EXPECT_EQ("Waiting to install", icon.tooltip_text());94 EXPECT_EQ("Waiting to install", icon.tooltip_text());
99 EXPECT_EQ(PRE_INSTALL_ICON, icon.icon_name());
100}95}
10196
102TEST_F(TestSoftwareCenterLauncherIcon, DesktopFileTransformTrivial)97TEST_F(TestSoftwareCenterLauncherIcon, DesktopFileTransformTrivial)
103{98{
104 // no transformation needed99 // no transformation needed
105 usc->desktop_file_ = USC_DESKTOP;100 gs->desktop_file_ = GS_DESKTOP;
106 EXPECT_EQ(icon.GetActualDesktopFileAfterInstall(), USC_DESKTOP);101 EXPECT_EQ(icon.GetActualDesktopFileAfterInstall(), GS_DESKTOP);
107}102}
108103
109TEST_F(TestSoftwareCenterLauncherIcon, DesktopFileTransformAppInstall)
110{
111 // ensure that tranformation from app-install data desktop files works
112 usc->desktop_file_ = "/usr/share/app-install/desktop/pkgname:kde4__afile.desktop";
113 EXPECT_EQ(icon.GetActualDesktopFileAfterInstall(),
114 LOCAL_DATA_DIR+"/applications/kde4/afile.desktop");
115}
116
117TEST_F(TestSoftwareCenterLauncherIcon, DesktopFileTransformSCAgent)
118{
119 // now simualte data coming from the sc-agent
120 usc->desktop_file_ = "/tmp/software-center-agent:VP2W9M:ubuntu-software-center.desktop";
121 EXPECT_EQ(icon.GetActualDesktopFileAfterInstall(), USC_DESKTOP);
122}
123
124// simulate a OnFinished signal from a /usr/share/app-install location
125// and ensure that the remote uri is updated from temp location to
126// the real location
127TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedReplacesDesktopFile)104TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedReplacesDesktopFile)
128{105{
129 icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success")));106 icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success")));
130107 EXPECT_EQ(GS_DESKTOP, icon.DesktopFile());
131 EXPECT_EQ(USC_DESKTOP, icon.DesktopFile());
132}108}
133109
134TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedUpdatesRemoteURI)110TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedUpdatesRemoteURI)
135{111{
136 icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success")));112 icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success")));
137113
138 ASSERT_EQ(USC_DESKTOP, icon.DesktopFile());114 ASSERT_EQ(GS_DESKTOP, icon.DesktopFile());
139 EXPECT_EQ(FavoriteStore::URI_PREFIX_APP + USC_DESKTOP, icon.GetRemoteUri());115 EXPECT_EQ(FavoriteStore::URI_PREFIX_APP + GS_DESKTOP, icon.GetRemoteUri());
140}116}
141117
142TEST_F(TestSoftwareCenterLauncherIcon, DisconnectsOldAppSignals)118TEST_F(TestSoftwareCenterLauncherIcon, DisconnectsOldAppSignals)
143{119{
144 ASSERT_FALSE(usc->closed.empty());120 ASSERT_FALSE(gs->closed.empty());
145121
146 icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success")));122 icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success")));
147123
148 EXPECT_TRUE(usc->closed.empty());124 EXPECT_TRUE(gs->closed.empty());
149 EXPECT_TRUE(usc->window_opened.empty());125 EXPECT_TRUE(gs->window_opened.empty());
150 EXPECT_TRUE(usc->window_moved.empty());126 EXPECT_TRUE(gs->window_moved.empty());
151 EXPECT_TRUE(usc->window_closed.empty());127 EXPECT_TRUE(gs->window_closed.empty());
152 EXPECT_TRUE(usc->visible.changed.empty());128 EXPECT_TRUE(gs->visible.changed.empty());
153 EXPECT_TRUE(usc->active.changed.empty());129 EXPECT_TRUE(gs->active.changed.empty());
154 EXPECT_TRUE(usc->running.changed.empty());130 EXPECT_TRUE(gs->running.changed.empty());
155 EXPECT_TRUE(usc->urgent.changed.empty());131 EXPECT_TRUE(gs->urgent.changed.empty());
156 EXPECT_TRUE(usc->desktop_file.changed.empty());132 EXPECT_TRUE(gs->desktop_file.changed.empty());
157 EXPECT_TRUE(usc->title.changed.empty());133 EXPECT_TRUE(gs->title.changed.empty());
158 EXPECT_TRUE(usc->icon.changed.empty());134 EXPECT_TRUE(gs->icon.changed.empty());
159}135}
160136
161TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedRemoveInvalidNewAppIcon)137TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedRemoveInvalidNewAppIcon)
162{138{
163 // Using an icon ptr, to get the removed signal to be properly emitted139 // Using an icon ptr, to get the removed signal to be properly emitted
164 nux::ObjectPtr<MockSoftwareCenterLauncherIcon> icon_ptr(140 nux::ObjectPtr<MockSoftwareCenterLauncherIcon> icon_ptr(
165 new MockSoftwareCenterLauncherIcon(usc, "/com/canonical/unity/test/object/path", PRE_INSTALL_ICON));141 new MockSoftwareCenterLauncherIcon(gs, "/com/canonical/unity/test/object/path"));
166142
167 bool removed = false;143 bool removed = false;
168 auto& app_manager = unity::ApplicationManager::Default();144 auto& app_manager = unity::ApplicationManager::Default();
@@ -201,7 +177,7 @@
201 icon.LauncherIconUnstick();177 icon.LauncherIconUnstick();
202178
203 bool saved = false;179 bool saved = false;
204 usc->sticky = true;180 gs->sticky = true;
205 icon.position_saved.connect([&saved] {saved = true;});181 icon.position_saved.connect([&saved] {saved = true;});
206 ASSERT_FALSE(icon.IsSticky());182 ASSERT_FALSE(icon.IsSticky());
207183
@@ -214,14 +190,7 @@
214{190{
215 icon.tooltip_text = "FooText";191 icon.tooltip_text = "FooText";
216 icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success")));192 icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success")));
217 EXPECT_EQ(icon.tooltip_text(), usc->title());193 EXPECT_EQ(icon.tooltip_text(), gs->title());
218}
219
220TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedUpdatesIcon)
221{
222 icon.icon_name = "foo-icon";
223 icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success")));
224 EXPECT_EQ(icon.icon_name(), usc->icon());
225}194}
226195
227TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedLogsEvent)196TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedLogsEvent)
@@ -230,52 +199,9 @@
230 icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success")));199 icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success")));
231}200}
232201
233TEST_F(TestSoftwareCenterLauncherIcon, AnimateToInvalidPosition)
234{
235 EXPECT_FALSE(icon.Animate(CreateLauncher(), 1, 2));
236 EXPECT_FALSE(icon.IsVisible());
237 EXPECT_EQ(PRE_INSTALL_ICON, icon.icon_name());
238}
239
240TEST_F(TestSoftwareCenterLauncherIcon, AnimateFromInvalidPosition)
241{
242 EXPECT_TRUE(icon.Animate(CreateLauncher(), 0, 0));
243 EXPECT_TRUE(icon.IsVisible());
244 EXPECT_EQ(PRE_INSTALL_ICON, icon.icon_name());
245}
246
247#pragma GCC diagnostic push202#pragma GCC diagnostic push
248#pragma GCC diagnostic ignored "-Wunused-variable"203#pragma GCC diagnostic ignored "-Wunused-variable"
249204
250struct MultiMonitor : TestSoftwareCenterLauncherIcon, WithParamInterface<unsigned> {};
251INSTANTIATE_TEST_CASE_P(TestSoftwareCenterLauncherIcon, MultiMonitor, Range<unsigned>(0, monitors::MAX, 1));
252
253TEST_P(/*TestSoftwareCenterLauncherIcon*/MultiMonitor, Animate)
254{
255 auto launcher = CreateLauncher();
256 launcher->monitor = GetParam();
257 icon.SetCenter({1, 1, 0}, launcher->monitor());
258 ASSERT_TRUE(icon.Animate(launcher, 2, 2));
259 EXPECT_FALSE(icon.IsVisible());
260 EXPECT_TRUE(icon.icon_name().empty());
261
262 for (unsigned i = 0; i < monitors::MAX; ++i)
263 ASSERT_EQ(static_cast<int>(i) == launcher->monitor(), icon.IsVisibleOnMonitor(i));
264
265 bool animated = false;
266 ASSERT_TRUE(icon.drag_window_);
267 icon.drag_window_->anim_completed.connect([&animated] { animated = true; });
268 Utils::WaitUntilMSec(animated);
269 ASSERT_TRUE(animated);
270
271 EXPECT_EQ(PRE_INSTALL_ICON, icon.icon_name());
272 EXPECT_FALSE(icon.drag_window_);
273
274 for (unsigned i = 0; i < monitors::MAX; ++i)
275 ASSERT_TRUE(icon.IsVisibleOnMonitor(i));
276
277 EXPECT_TRUE(icon.IsVisible());
278}
279205
280struct InstallProgress : TestSoftwareCenterLauncherIcon, WithParamInterface<int> {};206struct InstallProgress : TestSoftwareCenterLauncherIcon, WithParamInterface<int> {};
281INSTANTIATE_TEST_CASE_P(TestSoftwareCenterLauncherIcon, InstallProgress, Range<int>(0, 99, 10));207INSTANTIATE_TEST_CASE_P(TestSoftwareCenterLauncherIcon, InstallProgress, Range<int>(0, 99, 10));
282208
=== added file 'unity-shared/AppStreamApplication.cpp'
--- unity-shared/AppStreamApplication.cpp 1970-01-01 00:00:00 +0000
+++ unity-shared/AppStreamApplication.cpp 2016-02-23 15:49:50 +0000
@@ -0,0 +1,104 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3 * Copyright (C) 2016 Canonical Ltd
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com>
18 */
19
20#include "AppStreamApplication.h"
21
22#include <appstream-glib.h>
23
24#include <iostream>
25
26namespace unity
27{
28namespace appstream
29{
30
31Application::Application(std::string const& appstream_id)
32 : appstream_id_(appstream_id)
33{
34 desktop_file.SetGetterFunction([this](){ return appstream_id_; });
35 title.SetGetterFunction([this](){ return title_; });
36 icon_pixbuf.SetGetterFunction([this](){ return icon_pixbuf_; });
37
38 glib::Object<AsStore> as_store(as_store_new());
39 g_return_if_fail(as_store);
40
41 as_store_load(as_store, AS_STORE_LOAD_FLAG_APP_INFO_SYSTEM, nullptr, nullptr);
42
43 AsApp *as_app = as_store_get_app_by_id(as_store, appstream_id_.c_str());
44 g_return_if_fail(as_app);
45
46 title_ = glib::gchar_to_string(as_app_get_name(as_app, nullptr));
47
48 AsIcon *as_icon = as_app_get_icon_default(as_app);
49 g_return_if_fail(as_icon);
50
51 as_icon_load(as_icon, AS_ICON_LOAD_FLAG_SEARCH_SIZE, nullptr);
52 icon_pixbuf_ = glib::Object<GdkPixbuf>(as_icon_get_pixbuf(as_icon), glib::AddRef());
53}
54
55AppType Application::type() const
56{
57 return AppType::NORMAL;
58}
59
60std::string Application::repr() const
61{
62 std::ostringstream sout;
63 sout << "<AppStream::Application " << appstream_id_ << " >";
64 return sout.str();
65}
66
67WindowList const& Application::GetWindows() const
68{
69 return window_list_;
70}
71
72bool Application::OwnsWindow(Window window_id) const
73{
74 return false;
75}
76
77std::vector<std::string> Application::GetSupportedMimeTypes() const
78{
79 return std::vector<std::string>();
80}
81
82ApplicationWindowPtr Application::GetFocusableWindow() const
83{
84 return nullptr;
85}
86
87void Application::Focus(bool show_on_visible, int monitor) const
88{}
89
90void Application::Quit() const
91{}
92
93bool Application::CreateLocalDesktopFile() const
94{
95 return false;
96}
97
98std::string Application::desktop_id() const
99{
100 return "";
101}
102
103}
104}
0105
=== added file 'unity-shared/AppStreamApplication.h'
--- unity-shared/AppStreamApplication.h 1970-01-01 00:00:00 +0000
+++ unity-shared/AppStreamApplication.h 2016-02-23 15:49:50 +0000
@@ -0,0 +1,61 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3 * Copyright (C) 2016 Canonical Ltd
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com>
18 */
19
20#ifndef UNITYSHARED_APPSTREAM_APPLICATION_H
21#define UNITYSHARED_APPSTREAM_APPLICATION_H
22
23#include "DesktopApplicationManager.h"
24
25namespace unity
26{
27namespace appstream
28{
29
30class Application : public desktop::Application
31{
32public:
33 Application(std::string const& appstream_id);
34
35 AppType type() const override;
36 std::string repr() const override;
37
38 WindowList const& GetWindows() const override;
39 bool OwnsWindow(Window window_id) const override;
40
41 std::vector<std::string> GetSupportedMimeTypes() const override;
42
43 ApplicationWindowPtr GetFocusableWindow() const override;
44 void Focus(bool show_on_visible, int monitor) const override;
45 void Quit() const override;
46
47 bool CreateLocalDesktopFile() const override;
48
49 std::string desktop_id() const override;
50
51private:
52 std::string appstream_id_;
53 std::string title_;
54 glib::Object<_GdkPixbuf> icon_pixbuf_;
55 WindowList window_list_;
56};
57
58}
59}
60
61#endif
062
=== modified file 'unity-shared/ApplicationManager.h'
--- unity-shared/ApplicationManager.h 2015-11-26 00:20:23 +0000
+++ unity-shared/ApplicationManager.h 2016-02-23 15:49:50 +0000
@@ -25,8 +25,10 @@
2525
26#include <sigc++/signal.h>26#include <sigc++/signal.h>
27#include <NuxCore/Property.h>27#include <NuxCore/Property.h>
28#include <UnityCore/GLibWrapper.h>
28#include <unity-shared/WindowManager.h>29#include <unity-shared/WindowManager.h>
2930
31struct _GdkPixbuf;
3032
31namespace unity33namespace unity
32{34{
@@ -153,6 +155,7 @@
153 nux::ROProperty<std::string> desktop_file;155 nux::ROProperty<std::string> desktop_file;
154 nux::ROProperty<std::string> title;156 nux::ROProperty<std::string> title;
155 nux::ROProperty<std::string> icon;157 nux::ROProperty<std::string> icon;
158 nux::ROProperty<glib::Object<_GdkPixbuf>> icon_pixbuf;
156159
157 // Considering using a property for the "unity-seen" quark160 // Considering using a property for the "unity-seen" quark
158 nux::RWProperty<bool> seen;161 nux::RWProperty<bool> seen;
159162
=== modified file 'unity-shared/CMakeLists.txt'
--- unity-shared/CMakeLists.txt 2015-11-06 18:05:38 +0000
+++ unity-shared/CMakeLists.txt 2016-02-23 15:49:50 +0000
@@ -18,6 +18,7 @@
18#18#
19set (UNITY_SHARED_SOURCES19set (UNITY_SHARED_SOURCES
20 ApplicationManager.cpp20 ApplicationManager.cpp
21 AppStreamApplication.cpp
21 BGHash.cpp22 BGHash.cpp
22 CoverArt.cpp23 CoverArt.cpp
23 BackgroundEffectHelper.cpp24 BackgroundEffectHelper.cpp
2425
=== modified file 'unity-shared/DesktopApplicationManager.h'
--- unity-shared/DesktopApplicationManager.h 2014-01-15 14:51:10 +0000
+++ unity-shared/DesktopApplicationManager.h 2016-02-23 15:49:50 +0000
@@ -24,7 +24,7 @@
24#include <UnityCore/GLibWrapper.h>24#include <UnityCore/GLibWrapper.h>
25#include <UnityCore/GLibSignal.h>25#include <UnityCore/GLibSignal.h>
2626
27#include "unity-shared/ApplicationManager.h"27#include "ApplicationManager.h"
2828
29namespace unity29namespace unity
30{30{