diff options
| author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2016-02-25 16:59:41 +0100 |
|---|---|---|
| committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2016-02-25 16:59:41 +0100 |
| commit | e53bea2480a7baa70bf41ff2f5e21c60749f875a (patch) | |
| tree | c60ca121fd733033a29e5ad0cb5f7e6ee9d5fbaa | |
| parent | 55c4d0b695a240559d7b544274f99ea39747729e (diff) | |
| parent | 6a53f55de17e56e3ae2ccabf8fcc716a7db28462 (diff) | |
Merging with trunk
(bzr r4068.4.35)
30 files changed, 350 insertions, 381 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c74a35f24..23a89c469 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -228,6 +228,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MAINTAINER_CXXFLAGS}") set(UNITY_PROTOCOL_PRIVATE_DEPS unity-protocol-private>=7.1.0) set(UNITY_PLUGIN_SHARED_DEPS ${UNITY_PROTOCOL_PRIVATE_DEPS} + appstream-glib atk atk-bridge-2.0 cairo>=1.13.1 @@ -28,7 +28,7 @@ libglib2.0-dev libgdk-pixbuf2.0-dev libcairo2-dev libpng12-dev libglew1.5-dev libglewmx1.5-dev libxxf86vm-dev libgl1-mesa-dev libsigc++-2.0-dev - libpango1.0-dev doxygen cmake pkg-config intltool libgee-dev + libpango1.0-dev doxygen cmake pkg-config intltool libbamf-dev gsettings-desktop-schemas-dev libgconf2-dev libglib2.0-dev libdbusmenu-glib-dev libgtk2.0-dev libdee-dev libindicator-dev libboost-dev libboost-serialization-dev libmetacity-dev python-dev cython diff --git a/com.canonical.Unity.gschema.xml b/com.canonical.Unity.gschema.xml index e733673c4..62061a117 100644 --- a/com.canonical.Unity.gschema.xml +++ b/com.canonical.Unity.gschema.xml @@ -117,7 +117,7 @@ 'application://libreoffice-writer.desktop', 'application://libreoffice-calc.desktop', 'application://libreoffice-impress.desktop', - 'application://ubuntu-software-center.desktop', + 'application://org.gnome.Software.desktop', 'application://ubuntu-amazon-default.desktop', 'application://unity-control-center.desktop', 'unity://running-apps', diff --git a/debian/changelog b/debian/changelog index f3ab7fd8b..fc1f89f69 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,19 @@ +unity (7.4.0+16.04.20160223.1-0ubuntu1) xenial; urgency=medium + + [ Andrea Azzarone, Didier Roche ] + * Gnome-software launcher integration. + + [ Marco Trevisan (Treviño) ] + * GnomeFileManager: use *WithTimestamp file operations instead of + using Activate workaround (LP: #1445595) + * unity.migrations: add 04_unity_update_software_center_desktop_file + + [ Robert Ancell ] + * Drop unused build-dependency on libgee-dev. + * Switch from Ubuntu Software Center to GNOME Software. (LP: #1547129) + + -- Marco Trevisan (Treviño) <mail@3v1n0.net> Tue, 23 Feb 2016 22:39:18 +0000 + unity (7.4.0+16.04.20160209.3-0ubuntu1) xenial; urgency=medium [ Didier Roche ] diff --git a/debian/control b/debian/control index 7c30e36b2..a29300f85 100644 --- a/debian/control +++ b/debian/control @@ -13,6 +13,7 @@ Build-Depends: cmake, gsettings-desktop-schemas-dev, gsettings-ubuntu-schemas (>= 0.0.1+14.04.20140219), intltool (>= 0.35.0), + libappstream-glib-dev, libatk1.0-dev, libbamf3-dev (>= 0.5.2~bzr0), libboost-dev, @@ -20,7 +21,6 @@ Build-Depends: cmake, libdbus-1-dev, libdbusmenu-glib-dev (>= 0.3.91), libdee-dev (>= 1.2.6), - libgee-dev (>= 0.5.0), libgeis-dev (>= 2.0.10), libgl1-mesa-dri, libglib2.0-dev (>= 2.39.1), diff --git a/debian/unity.migrations b/debian/unity.migrations index 1d94ec01b..58bd12d59 100644 --- a/debian/unity.migrations +++ b/debian/unity.migrations @@ -1,3 +1,4 @@ tools/migration-scripts/01_unity_change_dconf_path tools/migration-scripts/02_unity_setup_text_scale_factor tools/migration-scripts/03_unity_first_run_stamp_move +tools/migration-scripts/04_unity_update_software_center_desktop_file diff --git a/launcher/LauncherController.cpp b/launcher/LauncherController.cpp index be9516fa9..4cd56b745 100644 --- a/launcher/LauncherController.cpp +++ b/launcher/LauncherController.cpp @@ -41,6 +41,7 @@ #include "ExpoLauncherIcon.h" #include "TrashLauncherIcon.h" #include "BFBLauncherIcon.h" +#include "unity-shared/AppStreamApplication.h" #include "unity-shared/IconRenderer.h" #include "unity-shared/UScreen.h" #include "unity-shared/UBusMessages.h" @@ -61,13 +62,8 @@ const std::string DBUS_INTROSPECTION = "<node>" " <interface name='com.canonical.Unity.Launcher'>" "" - " <method name='AddLauncherItemFromPosition'>" - " <arg type='s' name='title' direction='in'/>" - " <arg type='s' name='icon' direction='in'/>" - " <arg type='i' name='icon_x' direction='in'/>" - " <arg type='i' name='icon_y' direction='in'/>" - " <arg type='i' name='icon_size' direction='in'/>" - " <arg type='s' name='desktop_file' direction='in'/>" + " <method name='AddLauncherItem'>" + " <arg type='s' name='appstream_app_id' direction='in'/>" " <arg type='s' name='aptdaemon_task' direction='in'/>" " </method>" "" @@ -506,44 +502,25 @@ Controller::Impl::OnLauncherUpdateIconStickyState(std::string const& icon_uri, b } void -Controller::Impl::OnLauncherAddRequestSpecial(std::string const& path, - std::string const& aptdaemon_trans_id, - std::string const& icon_path, - int icon_x, - int icon_y, - int icon_size) -{ - // Check if desktop file was supplied, or if it's set to SC's agent - // See https://bugs.launchpad.net/unity/+bug/1002440 - if (path.empty() || path == local::SOFTWARE_CENTER_AGENT) +Controller::Impl::OnLauncherAddRequestSpecial(std::string const& appstream_app_id, + std::string const& aptdaemon_trans_id) +{ + // Check if desktop file was supplied + if (appstream_app_id.empty()) return; auto const& icon = std::find_if(model_->begin(), model_->end(), - [&path](AbstractLauncherIcon::Ptr const& i) { return (i->DesktopFile() == path); }); + [&appstream_app_id](AbstractLauncherIcon::Ptr const& i) { return (i->DesktopFile() == appstream_app_id); }); if (icon != model_->end()) return; - auto const& result = CreateSCLauncherIcon(path, aptdaemon_trans_id, icon_path); + auto const& result = CreateSCLauncherIcon(appstream_app_id, aptdaemon_trans_id); if (result) { - // Setting the icon position and adding it to the model, makes the launcher - // to compute its center RegisterIcon(result, GetLastIconPriority<ApplicationLauncherIcon>("", true)); - - if (icon_x > 0 || icon_y > 0) - { - // This will ensure that the center of the new icon is set, so that - // the animation could be done properly. - sources_.AddIdle([this, icon_x, icon_y, result] { - return !result->Animate(CurrentLauncher(), icon_x, icon_y); - }); - } - else - { - result->SetQuirk(AbstractLauncherIcon::Quirk::VISIBLE, true); - } + result->SetQuirk(AbstractLauncherIcon::Quirk::VISIBLE, true); } } @@ -944,22 +921,11 @@ AbstractLauncherIcon::Ptr Controller::Impl::GetIconByUri(std::string const& icon return AbstractLauncherIcon::Ptr(); } -SoftwareCenterLauncherIcon::Ptr Controller::Impl::CreateSCLauncherIcon(std::string const& file_path, - std::string const& aptdaemon_trans_id, - std::string const& icon_path) +SoftwareCenterLauncherIcon::Ptr Controller::Impl::CreateSCLauncherIcon(std::string const& appstream_app_id, + std::string const& aptdaemon_trans_id) { - SoftwareCenterLauncherIcon::Ptr result; - - ApplicationPtr app = ApplicationManager::Default().GetApplicationForDesktopFile(file_path); - if (!app) - return result; - - if (app->seen) - return result; - - result = new SoftwareCenterLauncherIcon(app, aptdaemon_trans_id, icon_path); - - return result; + ApplicationPtr app = std::make_shared<appstream::Application>(appstream_app_id); + return SoftwareCenterLauncherIcon::Ptr(new SoftwareCenterLauncherIcon(app, aptdaemon_trans_id)); } void Controller::Impl::AddRunningApps() @@ -1548,16 +1514,11 @@ void Controller::Impl::OpenQuicklist() GVariant* Controller::Impl::OnDBusMethodCall(std::string const& method, GVariant *parameters) { - if (method == "AddLauncherItemFromPosition") + if (method == "AddLauncherItem") { - glib::String icon, icon_title, desktop_file, aptdaemon_task; - gint icon_x, icon_y, icon_size; - - g_variant_get(parameters, "(ssiiiss)", &icon_title, &icon, &icon_x, &icon_y, - &icon_size, &desktop_file, &aptdaemon_task); - - OnLauncherAddRequestSpecial(desktop_file.Str(), aptdaemon_task.Str(), - icon.Str(), icon_x, icon_y, icon_size); + glib::String appstream_app_id, aptdaemon_trans_id; + g_variant_get(parameters, "(ss)", &appstream_app_id, &aptdaemon_trans_id); + OnLauncherAddRequestSpecial(appstream_app_id.Str(), aptdaemon_trans_id.Str()); } else if (method == "UpdateLauncherIconFavoriteState") { diff --git a/launcher/LauncherControllerPrivate.h b/launcher/LauncherControllerPrivate.h index 914e6877b..268c1fb58 100644 --- a/launcher/LauncherControllerPrivate.h +++ b/launcher/LauncherControllerPrivate.h @@ -69,8 +69,7 @@ public: void OnDeviceIconAdded(AbstractLauncherIcon::Ptr const& icon); void OnLauncherAddRequest(std::string const& icon_uri, AbstractLauncherIcon::Ptr const& before); - void OnLauncherAddRequestSpecial(std::string const& path, std::string const& aptdaemon_trans_id, - std::string const& icon_path, int icon_x, int icon_y, int icon_size); + void OnLauncherAddRequestSpecial(std::string const& appstream_app_id, std::string const& aptdaemon_trans_id); void OnLauncherUpdateIconStickyState(std::string const& desktop_file, bool sticky); void OnLauncherRemoveRequest(AbstractLauncherIcon::Ptr const& icon); @@ -90,7 +89,7 @@ public: ApplicationLauncherIcon* CreateAppLauncherIcon(ApplicationPtr const&); AbstractLauncherIcon::Ptr CreateFavoriteIcon(std::string const& icon_uri, bool emit_signal = false); AbstractLauncherIcon::Ptr GetIconByUri(std::string const& icon_uri); - SoftwareCenterLauncherIcon::Ptr CreateSCLauncherIcon(std::string const& file_path, std::string const& aptdaemon_trans_id, std::string const& icon_path); + SoftwareCenterLauncherIcon::Ptr CreateSCLauncherIcon(std::string const& appstream_app_id, std::string const& aptdaemon_trans_id); void SetupIcons(); void MigrateFavorites(); diff --git a/launcher/LauncherIcon.cpp b/launcher/LauncherIcon.cpp index 4726f2d35..4f9575251 100644 --- a/launcher/LauncherIcon.cpp +++ b/launcher/LauncherIcon.cpp @@ -321,6 +321,20 @@ void LauncherIcon::ColorForIcon(GdkPixbuf* pixbuf, nux::Color& background, nux:: glow = nux::Color(nux::color::RedGreenBlue(hsv)); } +BaseTexturePtr LauncherIcon::TextureFromPixbuf(GdkPixbuf* pixbuf, int size, bool update_glow_colors) +{ + g_return_val_if_fail(GDK_IS_PIXBUF(pixbuf), BaseTexturePtr()); + + glib::Object<GdkPixbuf> scaled_pixbuf(gdk_pixbuf_scale_simple(pixbuf, size, size, GDK_INTERP_BILINEAR)); + + if (update_glow_colors) + ColorForIcon(scaled_pixbuf, _background_color, _glow_color); + + BaseTexturePtr result; + result.Adopt(nux::CreateTexture2DFromPixbuf(scaled_pixbuf, true)); + return result; +} + BaseTexturePtr LauncherIcon::TextureFromGtkTheme(std::string icon_name, int size, bool update_glow_colors) { GtkIconTheme* default_theme; diff --git a/launcher/LauncherIcon.h b/launcher/LauncherIcon.h index 85aee677a..1391b7d7a 100644 --- a/launcher/LauncherIcon.h +++ b/launcher/LauncherIcon.h @@ -269,6 +269,8 @@ protected: virtual bool HandlesSpread () { return false; } + BaseTexturePtr TextureFromPixbuf(GdkPixbuf *pixbuf, int size, bool update_glow_colors = true); + BaseTexturePtr TextureFromGtkTheme(std::string name, int size, bool update_glow_colors = true); BaseTexturePtr TextureFromSpecificGtkTheme(GtkIconTheme* theme, std::string const& name, int size, bool update_glow_colors = true, bool is_default_theme = false); diff --git a/launcher/SimpleLauncherIcon.cpp b/launcher/SimpleLauncherIcon.cpp index b1fbcc08c..49898b344 100644 --- a/launcher/SimpleLauncherIcon.cpp +++ b/launcher/SimpleLauncherIcon.cpp @@ -35,6 +35,7 @@ NUX_IMPLEMENT_OBJECT_TYPE(SimpleLauncherIcon); SimpleLauncherIcon::SimpleLauncherIcon(IconType type) : LauncherIcon(type) , icon_name("", sigc::mem_fun(this, &SimpleLauncherIcon::SetIconName)) + , icon_pixbuf(glib::Object<GdkPixbuf>(), sigc::mem_fun(this, &SimpleLauncherIcon::SetIconPixbuf)) { theme::Settings::Get()->icons_changed.connect(sigc::mem_fun(this, &SimpleLauncherIcon::ReloadIcon)); } @@ -50,17 +51,24 @@ nux::BaseTexture* SimpleLauncherIcon::GetTextureForSize(int size) if (it != texture_map_.end()) return it->second.GetPointer(); - std::string const& icon_string = icon_name(); - - if (icon_string.empty()) - return nullptr; - BaseTexturePtr texture; - if (icon_string[0] == '/') - texture = TextureFromPath(icon_string, size); + if (icon_pixbuf()) + { + texture = TextureFromPixbuf(icon_pixbuf(), size); + } else - texture = TextureFromGtkTheme(icon_string, size); + { + std::string const& icon_string = icon_name(); + + if (icon_string.empty()) + return nullptr; + + if (icon_string[0] == '/') + texture = TextureFromPath(icon_string, size); + else + texture = TextureFromGtkTheme(icon_string, size); + } if (!texture) return nullptr; @@ -80,6 +88,17 @@ bool SimpleLauncherIcon::SetIconName(std::string& target, std::string const& val return true; } +bool SimpleLauncherIcon::SetIconPixbuf(glib::Object<GdkPixbuf>& target, glib::Object<GdkPixbuf> const& value) +{ + if (target == value) + return false; + + target = value; + ReloadIcon(); + + return true; +} + void SimpleLauncherIcon::ReloadIcon() { texture_map_.clear(); diff --git a/launcher/SimpleLauncherIcon.h b/launcher/SimpleLauncherIcon.h index 5b7247974..9f46dc4ae 100644 --- a/launcher/SimpleLauncherIcon.h +++ b/launcher/SimpleLauncherIcon.h @@ -37,6 +37,7 @@ public: // Properties nux::Property<std::string> icon_name; + nux::Property<glib::Object<GdkPixbuf>> icon_pixbuf; protected: std::string GetName() const; @@ -48,6 +49,7 @@ protected: private: void ReloadIcon(); bool SetIconName(std::string& target, std::string const& value); + bool SetIconPixbuf(glib::Object<GdkPixbuf>& target, glib::Object<GdkPixbuf> const& value); private: std::unordered_map<int, BaseTexturePtr> texture_map_; diff --git a/launcher/SoftwareCenterLauncherIcon.cpp b/launcher/SoftwareCenterLauncherIcon.cpp index fc842e9cb..ef345a670 100644 --- a/launcher/SoftwareCenterLauncherIcon.cpp +++ b/launcher/SoftwareCenterLauncherIcon.cpp @@ -44,8 +44,7 @@ const int INSTALL_TIP_DURATION = 1500; NUX_IMPLEMENT_OBJECT_TYPE(SoftwareCenterLauncherIcon); SoftwareCenterLauncherIcon::SoftwareCenterLauncherIcon(ApplicationPtr const& app, - std::string const& aptdaemon_trans_id, - std::string const& icon_path) + std::string const& aptdaemon_trans_id) : WindowedLauncherIcon(IconType::APPLICATION) , ApplicationLauncherIcon(app) , aptdaemon_trans_(std::make_shared<glib::DBusProxy>("org.debian.apt", @@ -69,61 +68,13 @@ SoftwareCenterLauncherIcon::SoftwareCenterLauncherIcon(ApplicationPtr const& app SetQuirk(Quirk::PROGRESS, (progress > 0)); }); - if (!icon_path.empty()) - icon_name = icon_path; + if (app->icon_pixbuf()) + icon_pixbuf = app->icon_pixbuf(); if (!aptdaemon_trans_id_.empty()) // Application is being installed, or hasn't been installed yet tooltip_text = _("Waiting to install"); } -bool SoftwareCenterLauncherIcon::Animate(nux::ObjectPtr<Launcher> const& launcher, int start_x, int start_y) -{ - using namespace std::placeholders; - - if (start_x <= 0 && start_y <= 0) - { - SetQuirk(Quirk::VISIBLE, true); - return true; - } - - int monitor = launcher->monitor(); - auto const& icon_center = GetCenter(monitor); - - if (icon_center.x == 0 && icon_center.y == 0) - return false; - - auto* floating_icon = new SimpleLauncherIcon(GetIconType()); - AbstractLauncherIcon::Ptr floating_icon_ptr(floating_icon); - floating_icon->icon_name = icon_name(); - - // Transform this in a spacer-icon and make it visible only on launcher's monitor - icon_name = ""; - SetQuirk(Quirk::VISIBLE, true, monitor); - - auto rcb = std::bind(&Launcher::RenderIconToTexture, launcher.GetPointer(), _1, _2, floating_icon_ptr); - drag_window_ = new LauncherDragWindow(launcher->GetWidth(), rcb); - drag_window_->SetBaseXY(start_x, start_y); - drag_window_->SetAnimationTarget(icon_center.x, icon_center.y + (launcher->GetIconSize() / 2)); - - launcher->ForceReveal(true); - drag_window_->ShowWindow(true); - - auto cb = sigc::bind(sigc::mem_fun(this, &SoftwareCenterLauncherIcon::OnDragAnimationFinished), launcher, floating_icon->icon_name()); - drag_window_->anim_completed.connect(cb); - drag_window_->StartSlowAnimation(); - - return true; -} - -void SoftwareCenterLauncherIcon::OnDragAnimationFinished(nux::ObjectPtr<Launcher> const& launcher, std::string const& final_icon) -{ - icon_name = final_icon; - drag_window_->ShowWindow(false); - drag_window_.Release(); - launcher->ForceReveal(false); - SetQuirk(Quirk::VISIBLE, true); -} - void SoftwareCenterLauncherIcon::ActivateLauncherIcon(ActionArg arg) { if (finished_) @@ -144,62 +95,7 @@ void SoftwareCenterLauncherIcon::ActivateLauncherIcon(ActionArg arg) std::string SoftwareCenterLauncherIcon::GetActualDesktopFileAfterInstall() { - // Fixup the _desktop_file because the one we get from software-center - // is not the final one, e.g. the s-c-agent does send a temp one and - // app-install-data points to the "wrong" one in /usr/share/app-install - // - // So: - // - if there is a desktop file already and it startswith - // /usr/share/app-install/desktop, then transform to - // /usr/share/application - // - if there is a desktop file with prefix /tmp/software-center-agent: - // transform to /usr/share/application - // (its using "/tmp/software-center-agent:$random:$pkgname.desktop") - // maybe: - // - and search in /var/lib/apt/lists/$pkgname.list - // for a desktop file that roughly matches what we want - auto const& desktop_file = DesktopFile(); - - // take /usr/share/app-install/desktop/foo:subdir__bar.desktop - // and tranform it - if (desktop_file.find("/share/app-install/desktop/") != std::string::npos) - { - auto colon_pos = desktop_file.rfind(":"); - auto filename = desktop_file.substr(colon_pos + 1, desktop_file.length() - colon_pos); - // the app-install-data package encodes subdirs in a funny way, once - // that is fixed, this code can be dropped - if (filename.find("__") != std::string::npos) - { - int pos = filename.find("__"); - filename = filename.replace(pos, 2, "-"); - } - filename = DesktopUtilities::GetDesktopPathById(filename); - return filename; - } - else if (desktop_file.find("/tmp/software-center-agent:") == 0) - { - // by convention the software-center-agent uses - // /usr/share/applications/$pkgname.desktop - // or - // /usr/share/applications/extras-$pkgname.desktop - auto colon_pos = desktop_file.rfind(":"); - auto desktopf = desktop_file.substr(colon_pos + 1, desktop_file.length() - colon_pos); - - auto filename = DesktopUtilities::GetDesktopPathById(desktopf); - - if (!filename.empty()) - return filename; - - // now try extras-$pkgname.desktop - filename = DesktopUtilities::GetDesktopPathById("extras-" + desktopf); - if (!filename.empty()) - return filename; - - // FIXME: test if there is a file now and if not, search - // /var/lib/dpkg/info/$pkgname.list for a desktop file - } - - return desktop_file; + return DesktopUtilities::GetDesktopPathById(DesktopFile()); } void SoftwareCenterLauncherIcon::OnFinished(GVariant *params) diff --git a/launcher/SoftwareCenterLauncherIcon.h b/launcher/SoftwareCenterLauncherIcon.h index 0c3e1cd2f..525b937e7 100644 --- a/launcher/SoftwareCenterLauncherIcon.h +++ b/launcher/SoftwareCenterLauncherIcon.h @@ -24,7 +24,6 @@ #include <string> #include <UnityCore/GLibDBusProxy.h> #include "ApplicationLauncherIcon.h" -#include "LauncherDragWindow.h" namespace unity { @@ -39,10 +38,7 @@ public: typedef nux::ObjectPtr<SoftwareCenterLauncherIcon> Ptr; SoftwareCenterLauncherIcon(ApplicationPtr const& app, - std::string const& aptdaemon_trans_id, - std::string const& icon_path); - - bool Animate(nux::ObjectPtr<Launcher> const& launcher, int start_x, int start_y); + std::string const& aptdaemon_trans_id); protected: std::string GetName() const; @@ -52,10 +48,8 @@ private: std::string GetActualDesktopFileAfterInstall(); void OnFinished(GVariant *params); void OnPropertyChanged(GVariant* params); - void OnDragAnimationFinished(nux::ObjectPtr<Launcher> const&, std::string const&); glib::DBusProxy::Ptr aptdaemon_trans_; - LauncherDragWindow::Ptr drag_window_; bool finished_; bool needs_urgent_; std::string aptdaemon_trans_id_; diff --git a/tests/data/applications/ubuntu-software-center.desktop b/tests/data/applications/org.gnome.Software.desktop index d633a43ac..7481fd62d 100644 --- a/tests/data/applications/ubuntu-software-center.desktop +++ b/tests/data/applications/org.gnome.Software.desktop @@ -1,9 +1,8 @@ [Desktop Entry] -Name=Ubuntu Software Center -GenericName=Software Center -Comment=Lets you choose from thousands of applications available for Ubuntu +Name=Software +Comment=Add, remove or update software on this computer Exec=/bin/true -Icon=softwarecenter +Icon=org.gnome.Software Terminal=false Type=Application Categories=PackageManager;GTK;System;Settings; diff --git a/tests/test_application_launcher_icon.cpp b/tests/test_application_launcher_icon.cpp index c34c39b6c..610417c91 100644 --- a/tests/test_application_launcher_icon.cpp +++ b/tests/test_application_launcher_icon.cpp @@ -41,7 +41,7 @@ using namespace unity::launcher; namespace { const std::string DEFAULT_EMPTY_ICON = "application-default-icon"; -const std::string USC_DESKTOP = BUILDDIR"/tests/data/applications/ubuntu-software-center.desktop"; +const std::string GS_DESKTOP = BUILDDIR"/tests/data/applications/org.gnome.Software.desktop"; const std::string UM_DESKTOP = BUILDDIR"/tests/data/applications/update-manager.desktop"; const std::string NO_ICON_DESKTOP = BUILDDIR"/tests/data/applications/no-icon.desktop"; @@ -93,9 +93,9 @@ struct TestApplicationLauncherIcon : testmocks::TestUnityAppBase virtual void SetUp() override { - usc_app = std::make_shared<MockApplication::Nice>(USC_DESKTOP, "softwarecenter"); + usc_app = std::make_shared<MockApplication::Nice>(GS_DESKTOP, "org.gnome.Software"); usc_icon = new MockApplicationLauncherIcon(usc_app); - ASSERT_EQ(usc_icon->DesktopFile(), USC_DESKTOP); + ASSERT_EQ(usc_icon->DesktopFile(), GS_DESKTOP); empty_app = std::make_shared<MockApplication::Nice>(NO_ICON_DESKTOP); empty_icon = new MockApplicationLauncherIcon(empty_app); @@ -175,7 +175,7 @@ struct TestApplicationLauncherIcon : testmocks::TestUnityAppBase TEST_F(TestApplicationLauncherIcon, ApplicationSignalDisconnection) { - std::shared_ptr<MockApplication> app = std::make_shared<MockApplication::Nice>(USC_DESKTOP); + std::shared_ptr<MockApplication> app = std::make_shared<MockApplication::Nice>(GS_DESKTOP); { MockApplicationLauncherIcon::Ptr icon(new MockApplicationLauncherIcon(app)); EXPECT_FALSE(app->closed.empty()); @@ -201,7 +201,7 @@ TEST_F(TestApplicationLauncherIcon, TestCustomBackgroundColor) TEST_F(TestApplicationLauncherIcon, TestDefaultIcon) { - EXPECT_EQ(usc_icon->icon_name(), "softwarecenter"); + EXPECT_EQ(usc_icon->icon_name(), "org.gnome.Software"); EXPECT_EQ(empty_icon->icon_name(), DEFAULT_EMPTY_ICON); EXPECT_EQ(mock_icon->icon_name(), DEFAULT_EMPTY_ICON); } @@ -267,7 +267,7 @@ TEST_F(TestApplicationLauncherIcon, StickAndSaveDesktopLessApp) TEST_F(TestApplicationLauncherIcon, StickStickedDesktopApp) { - auto app = std::make_shared<MockApplication::Nice>(USC_DESKTOP); + auto app = std::make_shared<MockApplication::Nice>(GS_DESKTOP); app->sticky = true; app->desktop_file_ = UM_DESKTOP; MockApplicationLauncherIcon::Ptr icon(new MockApplicationLauncherIcon(app)); @@ -542,7 +542,7 @@ TEST_F(TestApplicationLauncherIcon, UpdateDesktopForgetsOldPositionUpdatesUriAnd TEST_F(TestApplicationLauncherIcon, RemoteUri) { - EXPECT_EQ(usc_icon->RemoteUri(), FavoriteStore::URI_PREFIX_APP + USC_DESKTOP); + EXPECT_EQ(usc_icon->RemoteUri(), FavoriteStore::URI_PREFIX_APP + GS_DESKTOP); EXPECT_TRUE(mock_icon->RemoteUri().empty()); } diff --git a/tests/test_desktop_utilities.cpp b/tests/test_desktop_utilities.cpp index b8726b943..f77b9ac3e 100644 --- a/tests/test_desktop_utilities.cpp +++ b/tests/test_desktop_utilities.cpp @@ -184,17 +184,17 @@ TEST(TestDesktopUtilities, TestGetDesktopPathById) g_setenv("XDG_DATA_DIRS", LOCAL_DATA_DIR.c_str(), TRUE); g_setenv("XDG_DATA_HOME", "UnityUserConfig", TRUE); - std::string const& file = DesktopUtilities::GetDesktopPathById("ubuntu-software-center.desktop"); + std::string const& file = DesktopUtilities::GetDesktopPathById("org.gnome.Software.desktop"); g_setenv("XDG_DATA_DIRS", old_dirs.c_str(), TRUE); g_setenv("XDG_DATA_HOME", old_dirs.c_str(), TRUE); - EXPECT_EQ(file, LOCAL_DATA_DIR + "/applications/ubuntu-software-center.desktop"); + EXPECT_EQ(file, LOCAL_DATA_DIR + "/applications/org.gnome.Software.desktop"); } TEST(TestDesktopUtilities, TestGetBackgroundColor) { - std::string const& color = DesktopUtilities::GetBackgroundColor(LOCAL_DATA_DIR+"/applications/ubuntu-software-center.desktop"); + std::string const& color = DesktopUtilities::GetBackgroundColor(LOCAL_DATA_DIR+"/applications/org.gnome.Software.desktop"); EXPECT_EQ(color, "#aabbcc"); } diff --git a/tests/test_favorite_store.cpp b/tests/test_favorite_store.cpp index 3fd0d1bd3..da9089189 100644 --- a/tests/test_favorite_store.cpp +++ b/tests/test_favorite_store.cpp @@ -87,7 +87,7 @@ TEST_F(TestFavoriteStore, IsValidFavoriteUri) TEST_F(TestFavoriteStore, ParseFavoriteFromUri) { - const std::string VALID_DESKTOP_PATH = BUILDDIR"/tests/data/applications/ubuntu-software-center.desktop"; + const std::string VALID_DESKTOP_PATH = BUILDDIR"/tests/data/applications/org.gnome.Software.desktop"; EXPECT_EQ(favorite_store.ParseFavoriteFromUri("file.desktop"), "application://file.desktop"); EXPECT_EQ(favorite_store.ParseFavoriteFromUri(VALID_DESKTOP_PATH), "application://"+VALID_DESKTOP_PATH); diff --git a/tests/test_favorite_store_gsettings.cpp b/tests/test_favorite_store_gsettings.cpp index 9f9c1b4b0..a1b584238 100644 --- a/tests/test_favorite_store_gsettings.cpp +++ b/tests/test_favorite_store_gsettings.cpp @@ -38,7 +38,7 @@ const gchar* SETTINGS_NAME = "com.canonical.Unity.Launcher"; const gchar* SETTINGS_KEY = "favorites"; const char* base_store_favs[] = { BUILDDIR"/tests/data/applications/ubuntuone-installer.desktop", - "file://" BUILDDIR "/tests/data/applications/ubuntu-software-center.desktop", + "file://" BUILDDIR "/tests/data/applications/org.gnome.Software.desktop", "application://" BUILDDIR "/tests/data/applications/update-manager.desktop", "unity://test-icon", "device://uuid", diff --git a/tests/test_launcher_controller.cpp b/tests/test_launcher_controller.cpp index 7758b1830..eee05c0bf 100644 --- a/tests/test_launcher_controller.cpp +++ b/tests/test_launcher_controller.cpp @@ -61,7 +61,7 @@ const std::string DEVICES_URI = "unity://devices"; namespace app { const std::string UBUNTU_ONE = BUILDDIR "/tests/data/applications/ubuntuone-installer.desktop"; - const std::string SW_CENTER = BUILDDIR "/tests/data/applications/ubuntu-software-center.desktop"; + const std::string SW_CENTER = BUILDDIR "/tests/data/applications/org.gnome.Software.desktop"; const std::string UPDATE_MANAGER = BUILDDIR "/tests/data/applications/update-manager.desktop"; const std::string BZR_HANDLE_PATCH = BUILDDIR "/tests/data/applications/bzr-handle-patch.desktop"; const std::string NO_ICON = BUILDDIR "/tests/data/applications/no-icon.desktop"; @@ -1321,38 +1321,6 @@ TEST_F(TestLauncherController, LauncherRemoveRequestDeviceStops) lc.launcher().remove_request.emit(device_icon); } -TEST_F(TestLauncherController, LauncherAddRequestSpecial) -{ - std::string desktop = app::BZR_HANDLE_PATCH; - std::string icon_uri = FavoriteStore::URI_PREFIX_APP + desktop; - ASSERT_FALSE(lc.Impl()->GetIconByUri(icon_uri).IsValid()); - EXPECT_CALL(*unity_app_, LogEvent(_, _)).Times(0); - - lc.Impl()->OnLauncherAddRequestSpecial(desktop, "", "", 0, 0, 32); - - auto const& sw_center_icon = lc.Impl()->GetIconByUri(icon_uri); - ASSERT_TRUE(sw_center_icon.IsValid()); - EXPECT_TRUE(sw_center_icon->IsSticky()); - EXPECT_NE(dynamic_cast<SoftwareCenterLauncherIcon*>(sw_center_icon.GetPointer()), nullptr); -} - -TEST_F(TestLauncherController, LauncherAddRequestSpecialIgnored) -{ - std::string desktop = app::BZR_HANDLE_PATCH; - std::string icon_uri = FavoriteStore::URI_PREFIX_APP + desktop; - - MockApplicationLauncherIcon::Ptr bamf_icon(new MockApplicationLauncherIcon::Nice(desktop)); - lc.Impl()->RegisterIcon(bamf_icon, std::numeric_limits<int>::max()); - ASSERT_TRUE(lc.Impl()->GetIconByUri(icon_uri).IsValid()); - - EXPECT_CALL(*bamf_icon, Stick(false)).Times(0); - - int previous_model_size = lc.Impl()->model_->Size(); - lc.Impl()->OnLauncherAddRequestSpecial(desktop, "", "", 0, 0, 32); - - EXPECT_EQ(previous_model_size, lc.Impl()->model_->Size()); -} - TEST_F(TestLauncherController, SaveIconsOrder) { favorite_store.ClearFavorites(); diff --git a/tests/test_software_center_launcher_icon.cpp b/tests/test_software_center_launcher_icon.cpp index 6ee4d8d12..98ef81d4d 100644 --- a/tests/test_software_center_launcher_icon.cpp +++ b/tests/test_software_center_launcher_icon.cpp @@ -42,28 +42,26 @@ namespace launcher { namespace { -const std::string PRE_INSTALL_ICON = "sw-center-launcher-icon"; -const std::string FINAL_ICON = "softwarecenter"; -const std::string APP_NAME = "Ubuntu Software Center"; +const std::string FINAL_ICON = "org.gnome.Software"; +const std::string APP_NAME = "Software"; const std::string LOCAL_DATA_DIR = BUILDDIR"/tests/data"; -const std::string USC_DESKTOP = LOCAL_DATA_DIR+"/applications/ubuntu-software-center.desktop"; -const std::string USC_APP_INSTALL_DESKTOP = "/usr/share/app-install/desktop/software-center:ubuntu-software-center.desktop"; +const std::string GS_DESKTOP = LOCAL_DATA_DIR+"/applications/org.gnome.Software.desktop"; +const std::string GS_APP_INSTALL_DESKTOP = "org.gnome.Software.desktop"; } struct TestSoftwareCenterLauncherIcon : testmocks::TestUnityAppBase { TestSoftwareCenterLauncherIcon() - : usc(std::make_shared<MockApplication::Nice>(USC_APP_INSTALL_DESKTOP, FINAL_ICON, APP_NAME)) - , icon(usc, "/com/canonical/unity/test/object/path", PRE_INSTALL_ICON) + : gs(std::make_shared<MockApplication::Nice>(GS_APP_INSTALL_DESKTOP, FINAL_ICON, APP_NAME)) + , icon(gs, "/com/canonical/unity/test/object/path") {} struct MockSoftwareCenterLauncherIcon : SoftwareCenterLauncherIcon { MockSoftwareCenterLauncherIcon(ApplicationPtr const& app, - std::string const& aptdaemon_trans_id, - std::string const& icon_path) + std::string const& aptdaemon_trans_id) : WindowedLauncherIcon(IconType::APPLICATION) - , SoftwareCenterLauncherIcon(app, aptdaemon_trans_id, icon_path) + , SoftwareCenterLauncherIcon(app, aptdaemon_trans_id) {} void LauncherIconUnstick() { LauncherIcon::UnStick(); } @@ -71,7 +69,6 @@ struct TestSoftwareCenterLauncherIcon : testmocks::TestUnityAppBase using SoftwareCenterLauncherIcon::GetActualDesktopFileAfterInstall; using SoftwareCenterLauncherIcon::OnFinished; using SoftwareCenterLauncherIcon::OnPropertyChanged; - using SoftwareCenterLauncherIcon::drag_window_; using LauncherIcon::GetRemoteUri; }; @@ -86,7 +83,7 @@ struct TestSoftwareCenterLauncherIcon : testmocks::TestUnityAppBase panel::Style panel; nux::ObjectPtr<MockableBaseWindow> launcher_win; - MockApplication::Ptr usc; + MockApplication::Ptr gs; MockSoftwareCenterLauncherIcon icon; }; @@ -94,75 +91,54 @@ TEST_F(TestSoftwareCenterLauncherIcon, Construction) { EXPECT_FALSE(icon.IsVisible()); EXPECT_TRUE(icon.IsSticky()); - EXPECT_EQ(AbstractLauncherIcon::Position::FLOATING, icon.position()); EXPECT_EQ("Waiting to install", icon.tooltip_text()); - EXPECT_EQ(PRE_INSTALL_ICON, icon.icon_name()); } TEST_F(TestSoftwareCenterLauncherIcon, DesktopFileTransformTrivial) { // no transformation needed - usc->desktop_file_ = USC_DESKTOP; - EXPECT_EQ(icon.GetActualDesktopFileAfterInstall(), USC_DESKTOP); + gs->desktop_file_ = GS_DESKTOP; + EXPECT_EQ(icon.GetActualDesktopFileAfterInstall(), GS_DESKTOP); } -TEST_F(TestSoftwareCenterLauncherIcon, DesktopFileTransformAppInstall) -{ - // ensure that tranformation from app-install data desktop files works - usc->desktop_file_ = "/usr/share/app-install/desktop/pkgname:kde4__afile.desktop"; - EXPECT_EQ(icon.GetActualDesktopFileAfterInstall(), - LOCAL_DATA_DIR+"/applications/kde4/afile.desktop"); -} - -TEST_F(TestSoftwareCenterLauncherIcon, DesktopFileTransformSCAgent) -{ - // now simualte data coming from the sc-agent - usc->desktop_file_ = "/tmp/software-center-agent:VP2W9M:ubuntu-software-center.desktop"; - EXPECT_EQ(icon.GetActualDesktopFileAfterInstall(), USC_DESKTOP); -} - -// simulate a OnFinished signal from a /usr/share/app-install location -// and ensure that the remote uri is updated from temp location to -// the real location TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedReplacesDesktopFile) { icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success"))); - - EXPECT_EQ(USC_DESKTOP, icon.DesktopFile()); + EXPECT_EQ(GS_DESKTOP, icon.DesktopFile()); } TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedUpdatesRemoteURI) { icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success"))); - ASSERT_EQ(USC_DESKTOP, icon.DesktopFile()); - EXPECT_EQ(FavoriteStore::URI_PREFIX_APP + USC_DESKTOP, icon.GetRemoteUri()); + ASSERT_EQ(GS_DESKTOP, icon.DesktopFile()); + EXPECT_EQ(FavoriteStore::URI_PREFIX_APP + GS_DESKTOP, icon.GetRemoteUri()); } TEST_F(TestSoftwareCenterLauncherIcon, DisconnectsOldAppSignals) { - ASSERT_FALSE(usc->closed.empty()); + ASSERT_FALSE(gs->closed.empty()); icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success"))); - EXPECT_TRUE(usc->closed.empty()); - EXPECT_TRUE(usc->window_opened.empty()); - EXPECT_TRUE(usc->window_moved.empty()); - EXPECT_TRUE(usc->window_closed.empty()); - EXPECT_TRUE(usc->visible.changed.empty()); - EXPECT_TRUE(usc->active.changed.empty()); - EXPECT_TRUE(usc->running.changed.empty()); - EXPECT_TRUE(usc->urgent.changed.empty()); - EXPECT_TRUE(usc->desktop_file.changed.empty()); - EXPECT_TRUE(usc->title.changed.empty()); - EXPECT_TRUE(usc->icon.changed.empty()); + EXPECT_TRUE(gs->closed.empty()); + EXPECT_TRUE(gs->window_opened.empty()); + EXPECT_TRUE(gs->window_moved.empty()); + EXPECT_TRUE(gs->window_closed.empty()); + EXPECT_TRUE(gs->visible.changed.empty()); + EXPECT_TRUE(gs->active.changed.empty()); + EXPECT_TRUE(gs->running.changed.empty()); + EXPECT_TRUE(gs->urgent.changed.empty()); + EXPECT_TRUE(gs->desktop_file.changed.empty()); + EXPECT_TRUE(gs->title.changed.empty()); + EXPECT_TRUE(gs->icon.changed.empty()); } TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedRemoveInvalidNewAppIcon) { // Using an icon ptr, to get the removed signal to be properly emitted nux::ObjectPtr<MockSoftwareCenterLauncherIcon> icon_ptr( - new MockSoftwareCenterLauncherIcon(usc, "/com/canonical/unity/test/object/path", PRE_INSTALL_ICON)); + new MockSoftwareCenterLauncherIcon(gs, "/com/canonical/unity/test/object/path")); bool removed = false; auto& app_manager = unity::ApplicationManager::Default(); @@ -201,7 +177,7 @@ TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedKeepsStickyStatus) icon.LauncherIconUnstick(); bool saved = false; - usc->sticky = true; + gs->sticky = true; icon.position_saved.connect([&saved] {saved = true;}); ASSERT_FALSE(icon.IsSticky()); @@ -214,14 +190,7 @@ TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedUpdatesTooltip) { icon.tooltip_text = "FooText"; icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success"))); - EXPECT_EQ(icon.tooltip_text(), usc->title()); -} - -TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedUpdatesIcon) -{ - icon.icon_name = "foo-icon"; - icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success"))); - EXPECT_EQ(icon.icon_name(), usc->icon()); + EXPECT_EQ(icon.tooltip_text(), gs->title()); } TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedLogsEvent) @@ -230,52 +199,9 @@ TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedLogsEvent) icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success"))); } -TEST_F(TestSoftwareCenterLauncherIcon, AnimateToInvalidPosition) -{ - EXPECT_FALSE(icon.Animate(CreateLauncher(), 1, 2)); - EXPECT_FALSE(icon.IsVisible()); - EXPECT_EQ(PRE_INSTALL_ICON, icon.icon_name()); -} - -TEST_F(TestSoftwareCenterLauncherIcon, AnimateFromInvalidPosition) -{ - EXPECT_TRUE(icon.Animate(CreateLauncher(), 0, 0)); - EXPECT_TRUE(icon.IsVisible()); - EXPECT_EQ(PRE_INSTALL_ICON, icon.icon_name()); -} - #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-variable" -struct MultiMonitor : TestSoftwareCenterLauncherIcon, WithParamInterface<unsigned> {}; -INSTANTIATE_TEST_CASE_P(TestSoftwareCenterLauncherIcon, MultiMonitor, Range<unsigned>(0, monitors::MAX, 1)); - -TEST_P(/*TestSoftwareCenterLauncherIcon*/MultiMonitor, Animate) -{ - auto launcher = CreateLauncher(); - launcher->monitor = GetParam(); - icon.SetCenter({1, 1, 0}, launcher->monitor()); - ASSERT_TRUE(icon.Animate(launcher, 2, 2)); - EXPECT_FALSE(icon.IsVisible()); - EXPECT_TRUE(icon.icon_name().empty()); - - for (unsigned i = 0; i < monitors::MAX; ++i) - ASSERT_EQ(static_cast<int>(i) == launcher->monitor(), icon.IsVisibleOnMonitor(i)); - - bool animated = false; - ASSERT_TRUE(icon.drag_window_); - icon.drag_window_->anim_completed.connect([&animated] { animated = true; }); - Utils::WaitUntilMSec(animated); - ASSERT_TRUE(animated); - - EXPECT_EQ(PRE_INSTALL_ICON, icon.icon_name()); - EXPECT_FALSE(icon.drag_window_); - - for (unsigned i = 0; i < monitors::MAX; ++i) - ASSERT_TRUE(icon.IsVisibleOnMonitor(i)); - - EXPECT_TRUE(icon.IsVisible()); -} struct InstallProgress : TestSoftwareCenterLauncherIcon, WithParamInterface<int> {}; INSTANTIATE_TEST_CASE_P(TestSoftwareCenterLauncherIcon, InstallProgress, Range<int>(0, 99, 10)); diff --git a/tools/migration-scripts/02_unity_setup_text_scale_factor b/tools/migration-scripts/02_unity_setup_text_scale_factor index 4b6fec3db..b4d42557d 100755 --- a/tools/migration-scripts/02_unity_setup_text_scale_factor +++ b/tools/migration-scripts/02_unity_setup_text_scale_factor @@ -28,11 +28,12 @@ UNITY_UI_SETTINGS = "com.canonical.Unity.Interface"; UNITY_UI_SETTINGS_PATH = "/com/canonical/unity/interface/" UNITY_TEXT_SCALE_FACTOR = "text-scale-factor"; -if GNOME_UI_SETTINGS not in Gio.Settings.list_schemas(): +gnome_ui_schema = Gio.SettingsSchemaSource.get_default().lookup(GNOME_UI_SETTINGS, recursive=False) +if not gnome_ui_schema: print("No gnome desktop interface schemas found, no migration needed") sys.exit(0) -text_scale_factor = Gio.Settings(schema=GNOME_UI_SETTINGS).get_double(GNOME_TEXT_SCALE_FACTOR) +text_scale_factor = Gio.Settings(settings_schema=gnome_ui_schema).get_double(GNOME_TEXT_SCALE_FACTOR) # gsettings doesn't work directly, the key is somewhat reverted. Work one level under then: dconf! # Gio.Settings(schema=UNITY_UI_SETTINGS).set_int(UNITY_TEXT_SCALE_FACTOR, text_scale_factor) diff --git a/tools/migration-scripts/04_unity_update_software_center_desktop_file b/tools/migration-scripts/04_unity_update_software_center_desktop_file new file mode 100644 index 000000000..3521b68be --- /dev/null +++ b/tools/migration-scripts/04_unity_update_software_center_desktop_file @@ -0,0 +1,36 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- +# Copyright (C) 2016 Canonical +# +# Authors: +# Marco Trevisan <marco.trevisan@canonical.com> +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; version 3. +# +# This program is distributed in the hope that it will be useful, but WITHOUTa +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +from gi.repository import Gio + +UNITY_LAUNCHER_SETTINGS = "com.canonical.Unity.Launcher"; +UNITY_LAUNCHER_SETTINGS_PATH = "/com/canonical/unity/launcher/" +UNITY_LAUNCER_FAVORITES = "favorites"; + +favorites = Gio.Settings(schema=UNITY_LAUNCHER_SETTINGS).get_strv(UNITY_LAUNCER_FAVORITES) + +for i in range(len(favorites)): + if 'ubuntu-software-center.desktop' in favorites[i]: + favorites[i] = favorites[i].replace('ubuntu-software-center', 'org.gnome.Software') + +# gsettings doesn't work directly, the key is somewhat reverted. Work one level under then: dconf! +from subprocess import Popen, PIPE, STDOUT +p = Popen(("dconf load "+UNITY_LAUNCHER_SETTINGS_PATH).split(), stdout=PIPE, stdin=PIPE, stderr=STDOUT) +p.communicate(input=bytes("[/]\n"+UNITY_LAUNCER_FAVORITES+"={}".format(favorites), 'utf-8')) diff --git a/unity-shared/AppStreamApplication.cpp b/unity-shared/AppStreamApplication.cpp new file mode 100644 index 000000000..12c575bd1 --- /dev/null +++ b/unity-shared/AppStreamApplication.cpp @@ -0,0 +1,104 @@ +// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- +/* + * Copyright (C) 2016 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com> + */ + +#include "AppStreamApplication.h" + +#include <appstream-glib.h> + +#include <iostream> + +namespace unity +{ +namespace appstream +{ + +Application::Application(std::string const& appstream_id) + : appstream_id_(appstream_id) +{ + desktop_file.SetGetterFunction([this](){ return appstream_id_; }); + title.SetGetterFunction([this](){ return title_; }); + icon_pixbuf.SetGetterFunction([this](){ return icon_pixbuf_; }); + + glib::Object<AsStore> as_store(as_store_new()); + g_return_if_fail(as_store); + + as_store_load(as_store, AS_STORE_LOAD_FLAG_APP_INFO_SYSTEM, nullptr, nullptr); + + AsApp *as_app = as_store_get_app_by_id(as_store, appstream_id_.c_str()); + g_return_if_fail(as_app); + + title_ = glib::gchar_to_string(as_app_get_name(as_app, nullptr)); + + AsIcon *as_icon = as_app_get_icon_default(as_app); + g_return_if_fail(as_icon); + + as_icon_load(as_icon, AS_ICON_LOAD_FLAG_SEARCH_SIZE, nullptr); + icon_pixbuf_ = glib::Object<GdkPixbuf>(as_icon_get_pixbuf(as_icon), glib::AddRef()); +} + +AppType Application::type() const +{ + return AppType::NORMAL; +} + +std::string Application::repr() const +{ + std::ostringstream sout; + sout << "<AppStream::Application " << appstream_id_ << " >"; + return sout.str(); +} + +WindowList const& Application::GetWindows() const +{ + return window_list_; +} + +bool Application::OwnsWindow(Window window_id) const +{ + return false; +} + +std::vector<std::string> Application::GetSupportedMimeTypes() const +{ + return std::vector<std::string>(); +} + +ApplicationWindowPtr Application::GetFocusableWindow() const +{ + return nullptr; +} + +void Application::Focus(bool show_on_visible, int monitor) const +{} + +void Application::Quit() const +{} + +bool Application::CreateLocalDesktopFile() const +{ + return false; +} + +std::string Application::desktop_id() const +{ + return ""; +} + +} +} diff --git a/unity-shared/AppStreamApplication.h b/unity-shared/AppStreamApplication.h new file mode 100644 index 000000000..e07a90d79 --- /dev/null +++ b/unity-shared/AppStreamApplication.h @@ -0,0 +1,61 @@ +// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- +/* + * Copyright (C) 2016 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com> + */ + +#ifndef UNITYSHARED_APPSTREAM_APPLICATION_H +#define UNITYSHARED_APPSTREAM_APPLICATION_H + +#include "DesktopApplicationManager.h" + +namespace unity +{ +namespace appstream +{ + +class Application : public desktop::Application +{ +public: + Application(std::string const& appstream_id); + + AppType type() const override; + std::string repr() const override; + + WindowList const& GetWindows() const override; + bool OwnsWindow(Window window_id) const override; + + std::vector<std::string> GetSupportedMimeTypes() const override; + + ApplicationWindowPtr GetFocusableWindow() const override; + void Focus(bool show_on_visible, int monitor) const override; + void Quit() const override; + + bool CreateLocalDesktopFile() const override; + + std::string desktop_id() const override; + +private: + std::string appstream_id_; + std::string title_; + glib::Object<_GdkPixbuf> icon_pixbuf_; + WindowList window_list_; +}; + +} +} + +#endif diff --git a/unity-shared/ApplicationManager.h b/unity-shared/ApplicationManager.h index 8a5e6270d..942dfa8b2 100644 --- a/unity-shared/ApplicationManager.h +++ b/unity-shared/ApplicationManager.h @@ -25,8 +25,10 @@ #include <sigc++/signal.h> #include <NuxCore/Property.h> +#include <UnityCore/GLibWrapper.h> #include <unity-shared/WindowManager.h> +struct _GdkPixbuf; namespace unity { @@ -153,6 +155,7 @@ public: nux::ROProperty<std::string> desktop_file; nux::ROProperty<std::string> title; nux::ROProperty<std::string> icon; + nux::ROProperty<glib::Object<_GdkPixbuf>> icon_pixbuf; // Considering using a property for the "unity-seen" quark nux::RWProperty<bool> seen; diff --git a/unity-shared/CMakeLists.txt b/unity-shared/CMakeLists.txt index 19a5e3f65..7ad243f57 100644 --- a/unity-shared/CMakeLists.txt +++ b/unity-shared/CMakeLists.txt @@ -18,6 +18,7 @@ include_directories (.. ../services ../UnityCore ${UNITY_SRC} ${CMAKE_BINARY_DIR # set (UNITY_SHARED_SOURCES ApplicationManager.cpp + AppStreamApplication.cpp BGHash.cpp CoverArt.cpp BackgroundEffectHelper.cpp diff --git a/unity-shared/DesktopApplicationManager.h b/unity-shared/DesktopApplicationManager.h index 8bd7f1105..6ab2ede47 100644 --- a/unity-shared/DesktopApplicationManager.h +++ b/unity-shared/DesktopApplicationManager.h @@ -24,7 +24,7 @@ #include <UnityCore/GLibWrapper.h> #include <UnityCore/GLibSignal.h> -#include "unity-shared/ApplicationManager.h" +#include "ApplicationManager.h" namespace unity { diff --git a/unity-shared/GnomeFileManager.cpp b/unity-shared/GnomeFileManager.cpp index e273ffd70..4ec6e51f2 100644 --- a/unity-shared/GnomeFileManager.cpp +++ b/unity-shared/GnomeFileManager.cpp @@ -169,39 +169,6 @@ void GnomeFileManager::OpenTrash(uint64_t timestamp) Open(TRASH_URI, timestamp); } -void GnomeFileManager::Activate(uint64_t timestamp) -{ - glib::Cancellable cancellable; - glib::Object<GFile> file(g_file_new_for_uri(TRASH_URI.c_str())); - glib::Object<GAppInfo> app_info(g_file_query_default_handler(file, cancellable, nullptr)); - - if (app_info) - { - GdkDisplay* display = gdk_display_get_default(); - glib::Object<GdkAppLaunchContext> context(gdk_display_get_app_launch_context(display)); - - if (timestamp > 0) - gdk_app_launch_context_set_timestamp(context, timestamp); - - auto const& gcontext = glib::object_cast<GAppLaunchContext>(context); - auto proxy = std::make_shared<glib::DBusProxy>(NAUTILUS_NAME, NAUTILUS_PATH, - "org.freedesktop.Application"); - - glib::String context_string(g_app_launch_context_get_startup_notify_id(gcontext, app_info, nullptr)); - - if (context_string && g_utf8_validate(context_string, -1, nullptr)) - { - GVariantBuilder builder; - g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}")); - g_variant_builder_add(&builder, "{sv}", "desktop-startup-id", g_variant_new("s", context_string.Value())); - GVariant *param = g_variant_new("(@a{sv})", g_variant_builder_end(&builder)); - - // Passing the proxy to the lambda we ensure that it will be destroyed when needed - proxy->CallBegin("Activate", param, [proxy] (GVariant*, glib::Error const&) {}); - } - } -} - bool GnomeFileManager::TrashFile(std::string const& uri) { glib::Cancellable cancellable; @@ -217,11 +184,10 @@ bool GnomeFileManager::TrashFile(std::string const& uri) void GnomeFileManager::EmptyTrash(uint64_t timestamp) { - Activate(timestamp); auto const& proxy = impl_->NautilusOperationsProxy(); // Passing the proxy to the lambda we ensure that it will be destroyed when needed - proxy->CallBegin("EmptyTrash", nullptr, [proxy] (GVariant*, glib::Error const&) {}); + proxy->CallBegin("EmptyTrashWithTimestamp", g_variant_new("(u)", timestamp), [proxy] (GVariant*, glib::Error const&) {}); } void GnomeFileManager::CopyFiles(std::set<std::string> const& uris, std::string const& dest, uint64_t timestamp) @@ -231,7 +197,7 @@ void GnomeFileManager::CopyFiles(std::set<std::string> const& uris, std::string bool found_valid = false; GVariantBuilder b; - g_variant_builder_init(&b, G_VARIANT_TYPE("(ass)")); + g_variant_builder_init(&b, G_VARIANT_TYPE("(assu)")); g_variant_builder_open(&b, G_VARIANT_TYPE("as")); for (auto const& uri : uris) @@ -245,14 +211,14 @@ void GnomeFileManager::CopyFiles(std::set<std::string> const& uris, std::string g_variant_builder_close(&b); g_variant_builder_add(&b, "s", dest.c_str()); + g_variant_builder_add(&b, "u", timestamp); glib::Variant parameters(g_variant_builder_end(&b)); if (found_valid) { // Passing the proxy to the lambda we ensure that it will be destroyed when needed auto const& proxy = impl_->NautilusOperationsProxy(); - proxy->CallBegin("CopyURIs", parameters, [proxy] (GVariant*, glib::Error const&) {}); - Activate(timestamp); + proxy->CallBegin("CopyURIsWithTimestamp", parameters, [proxy] (GVariant*, glib::Error const&) {}); } } diff --git a/unity-shared/GnomeFileManager.h b/unity-shared/GnomeFileManager.h index b017ce0ea..8f3b3c3b5 100644 --- a/unity-shared/GnomeFileManager.h +++ b/unity-shared/GnomeFileManager.h @@ -44,7 +44,6 @@ public: private: GnomeFileManager(); - void Activate(uint64_t timestamp); struct Impl; std::unique_ptr<Impl> impl_; |
