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 /unity-shared | |
| parent | 55c4d0b695a240559d7b544274f99ea39747729e (diff) | |
| parent | 6a53f55de17e56e3ae2ccabf8fcc716a7db28462 (diff) | |
Merging with trunk
(bzr r4068.4.35)
Diffstat (limited to 'unity-shared')
| -rw-r--r-- | unity-shared/AppStreamApplication.cpp | 104 | ||||
| -rw-r--r-- | unity-shared/AppStreamApplication.h | 61 | ||||
| -rw-r--r-- | unity-shared/ApplicationManager.h | 3 | ||||
| -rw-r--r-- | unity-shared/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | unity-shared/DesktopApplicationManager.h | 2 | ||||
| -rw-r--r-- | unity-shared/GnomeFileManager.cpp | 42 | ||||
| -rw-r--r-- | unity-shared/GnomeFileManager.h | 1 |
7 files changed, 174 insertions, 40 deletions
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_; |
