18
18
* Marco Trevisan <marco.trevisan@canonical.com>
21
#include "FileManagerOpenerImp.h"
21
#include "GnomeFileManager.h"
22
22
#include <NuxCore/Logger.h>
23
23
#include <UnityCore/GLibWrapper.h>
24
#include <UnityCore/GLibDBusProxy.h>
24
25
#include <gdk/gdk.h>
31
DECLARE_LOGGER(logger, "unity.launcher.filemanager.opener.imp");
33
void FileManagerOpenerImp::Open(std::string const& uri, unsigned long long timestamp)
33
DECLARE_LOGGER(logger, "unity.filemanager.gnome");
35
const std::string TRASH_URI = "trash:";
38
void GnomeFileManager::Open(std::string const& uri, unsigned long long timestamp)
62
void GnomeFileManager::Activate(unsigned long long timestamp)
64
glib::Cancellable cancellable;
65
glib::Object<GFile> file(g_file_new_for_uri(TRASH_URI.c_str()));
66
glib::Object<GAppInfo> app_info(g_file_query_default_handler(file, cancellable, nullptr));
70
GdkDisplay* display = gdk_display_get_default();
71
glib::Object<GdkAppLaunchContext> context(gdk_display_get_app_launch_context(display));
74
gdk_app_launch_context_set_timestamp(context, timestamp);
76
auto const& gcontext = glib::object_cast<GAppLaunchContext>(context);
77
auto proxy = std::make_shared<glib::DBusProxy>("org.gnome.NautilusApplication",
78
"/org/gnome/NautilusApplication",
79
"org.gtk.Application");
81
glib::String context_string(g_app_launch_context_get_startup_notify_id(gcontext, app_info, nullptr));
83
if (context_string && g_utf8_validate(context_string, -1, nullptr))
85
GVariantBuilder builder;
86
g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}"));
87
g_variant_builder_add(&builder, "{sv}", "desktop-startup-id", g_variant_new("s", context_string.Value()));
88
GVariant *param = g_variant_new("(@a{sv})", g_variant_builder_end(&builder));
90
// Passing the proxy to the lambda we ensure that it will be destroyed when needed
91
proxy->CallBegin("Activate", param, [proxy] (GVariant*, glib::Error const&) {});
96
void GnomeFileManager::EmptyTrash(unsigned long long timestamp)
100
auto proxy = std::make_shared<glib::DBusProxy>("org.gnome.Nautilus", "/org/gnome/Nautilus",
101
"org.gnome.Nautilus.FileOperations");
103
// Passing the proxy to the lambda we ensure that it will be destroyed when needed
104
proxy->CallBegin("EmptyTrash", nullptr, [proxy] (GVariant*, glib::Error const&) {});