Merge lp:~3v1n0/unity/gnome-file-manager-trash into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Brandon Schaefer
Approved revision: no longer in the source branch.
Merged at revision: 3255
Proposed branch: lp:~3v1n0/unity/gnome-file-manager-trash
Merge into: lp:unity
Diff against target: 594 lines (+169/-79)
14 files modified
launcher/CMakeLists.txt (+0/-1)
launcher/DeviceLauncherSection.cpp (+3/-3)
launcher/DeviceLauncherSection.h (+2/-2)
launcher/TrashLauncherIcon.cpp (+7/-12)
launcher/TrashLauncherIcon.h (+3/-4)
launcher/VolumeImp.cpp (+6/-6)
launcher/VolumeImp.h (+2/-2)
tests/test_mock_filemanager.h (+38/-0)
tests/test_trash_launcher_icon.cpp (+23/-8)
tests/test_volume_imp.cpp (+6/-13)
unity-shared/CMakeLists.txt (+1/-0)
unity-shared/FileManager.h (+11/-12)
unity-shared/GnomeFileManager.cpp (+56/-7)
unity-shared/GnomeFileManager.h (+11/-9)
To merge this branch: bzr merge lp:~3v1n0/unity/gnome-file-manager-trash
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Brandon Schaefer (community) Approve
Review via email: mp+154957@code.launchpad.net

Commit message

FileManagerOpener: moved to unity-shared and renamed as FileManager

The implementation is GnomeFileManager. Updated TrashLauncherIcon and VolumeImp.

Description of the change

Moved launcher/FileManagerOpener to unity-shared/FileManager, renamed the implementation to GnomeFileManager, and added another virtual method to empty the trash.
Before requesting the trash file deletion, we call the GtkApplication interface to update the application time-stamp so that the dialog will be always presented.

Using this for TrashLauncherIcon, and VolumeImp.

Added/updated tests.

To post a comment you must log in.
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Yay for working test now. LGTM.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/CMakeLists.txt'
2--- launcher/CMakeLists.txt 2013-02-27 01:16:31 +0000
3+++ launcher/CMakeLists.txt 2013-03-25 15:57:22 +0000
4@@ -32,7 +32,6 @@
5 FavoriteStore.cpp
6 FavoriteStoreGSettings.cpp
7 FavoriteStorePrivate.cpp
8- FileManagerOpenerImp.cpp
9 HudLauncherIcon.cpp
10 Launcher.cpp
11 LauncherController.cpp
12
13=== modified file 'launcher/DeviceLauncherSection.cpp'
14--- launcher/DeviceLauncherSection.cpp 2013-03-13 20:54:45 +0000
15+++ launcher/DeviceLauncherSection.cpp 2013-03-25 15:57:22 +0000
16@@ -20,8 +20,8 @@
17 #include "DeviceLauncherSection.h"
18 #include "DeviceNotificationDisplayImp.h"
19 #include "DevicesSettings.h"
20-#include "FileManagerOpenerImp.h"
21 #include "VolumeImp.h"
22+#include "unity-shared/GnomeFileManager.h"
23
24 namespace unity
25 {
26@@ -32,7 +32,7 @@
27 DevicesSettings::Ptr devices_settings)
28 : monitor_(volume_monitor)
29 , devices_settings_(devices_settings)
30- , file_manager_opener_(std::make_shared<FileManagerOpenerImp>())
31+ , file_manager_(std::make_shared<GnomeFileManager>())
32 , device_notification_display_(std::make_shared<DeviceNotificationDisplayImp>())
33 {
34 monitor_->volume_added.connect(sigc::mem_fun(this, &DeviceLauncherSection::OnVolumeAdded));
35@@ -57,7 +57,7 @@
36 if (map_.find(volume) != map_.end())
37 return;
38
39- auto vol = std::make_shared<VolumeImp>(volume, file_manager_opener_, device_notification_display_);
40+ auto vol = std::make_shared<VolumeImp>(volume, file_manager_, device_notification_display_);
41 VolumeLauncherIcon::Ptr icon(new VolumeLauncherIcon(vol, devices_settings_));
42
43 map_[volume] = icon;
44
45=== modified file 'launcher/DeviceLauncherSection.h'
46--- launcher/DeviceLauncherSection.h 2012-10-11 01:44:15 +0000
47+++ launcher/DeviceLauncherSection.h 2013-03-25 15:57:22 +0000
48@@ -26,8 +26,8 @@
49 #include "AbstractVolumeMonitorWrapper.h"
50 #include "DevicesSettings.h"
51 #include "DeviceNotificationDisplay.h"
52-#include "FileManagerOpener.h"
53 #include "VolumeLauncherIcon.h"
54+#include "unity-shared/FileManager.h"
55
56 namespace unity
57 {
58@@ -53,7 +53,7 @@
59 std::map<GVolume*, VolumeLauncherIcon::Ptr> map_;
60 AbstractVolumeMonitorWrapper::Ptr monitor_;
61 DevicesSettings::Ptr devices_settings_;
62- FileManagerOpener::Ptr file_manager_opener_;
63+ FileManager::Ptr file_manager_;
64 DeviceNotificationDisplay::Ptr device_notification_display_;
65 };
66
67
68=== modified file 'launcher/TrashLauncherIcon.cpp'
69--- launcher/TrashLauncherIcon.cpp 2013-03-21 19:50:20 +0000
70+++ launcher/TrashLauncherIcon.cpp 2013-03-25 15:57:22 +0000
71@@ -25,28 +25,27 @@
72 #include <glib/gi18n-lib.h>
73 #include <Nux/WindowCompositor.h>
74 #include <NuxCore/Logger.h>
75-#include <UnityCore/GLibDBusProxy.h>
76 #include <zeitgeist.h>
77
78 #include "Launcher.h"
79 #include "QuicklistManager.h"
80 #include "QuicklistMenuItemLabel.h"
81-#include "FileManagerOpenerImp.h"
82+#include "unity-shared/GnomeFileManager.h"
83
84 namespace unity
85 {
86 namespace launcher
87 {
88-DECLARE_LOGGER(logger, "unity.launcher.icon");
89+DECLARE_LOGGER(logger, "unity.launcher.icon.trash");
90 namespace
91 {
92 const std::string ZEITGEIST_UNITY_ACTOR = "application://compiz.desktop";
93- const std::string TRASH_URI = "trash:///";
94+ const std::string TRASH_URI = "trash:";
95 }
96
97-TrashLauncherIcon::TrashLauncherIcon(FileManagerOpener::Ptr const& fmo)
98+TrashLauncherIcon::TrashLauncherIcon(FileManager::Ptr const& fmo)
99 : SimpleLauncherIcon(IconType::TRASH)
100- , file_manager_(fmo ? fmo : std::make_shared<FileManagerOpenerImp>())
101+ , file_manager_(fmo ? fmo : std::make_shared<GnomeFileManager>())
102 {
103 tooltip_text = _("Trash");
104 icon_name = "user-trash";
105@@ -86,12 +85,8 @@
106 dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, !empty_);
107 dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true);
108 empty_activated_signal_.Connect(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
109- [this] (DbusmenuMenuitem*, unsigned) {
110- auto proxy = std::make_shared<glib::DBusProxy>("org.gnome.Nautilus", "/org/gnome/Nautilus",
111- "org.gnome.Nautilus.FileOperations");
112-
113- // Passing the proxy to the lambda we ensure that it will be destroyed when needed
114- proxy->CallBegin("EmptyTrash", nullptr, [proxy] (GVariant*, glib::Error const&) {});
115+ [this] (DbusmenuMenuitem*, unsigned timestamp) {
116+ file_manager_->EmptyTrash(timestamp);
117 });
118
119 result.push_back(menu_item);
120
121=== modified file 'launcher/TrashLauncherIcon.h'
122--- launcher/TrashLauncherIcon.h 2013-03-21 19:50:20 +0000
123+++ launcher/TrashLauncherIcon.h 2013-03-25 15:57:22 +0000
124@@ -26,7 +26,7 @@
125
126 #include "DndData.h"
127 #include "SimpleLauncherIcon.h"
128-#include "FileManagerOpener.h"
129+#include "unity-shared/FileManager.h"
130
131 namespace unity
132 {
133@@ -35,9 +35,8 @@
134
135 class TrashLauncherIcon : public SimpleLauncherIcon
136 {
137-
138 public:
139- TrashLauncherIcon(FileManagerOpener::Ptr const& = nullptr);
140+ TrashLauncherIcon(FileManager::Ptr const& = nullptr);
141
142 protected:
143 void UpdateTrashIcon();
144@@ -55,7 +54,7 @@
145 static void UpdateTrashIconCb(GObject* source, GAsyncResult* res, gpointer data);
146
147 bool empty_;
148- FileManagerOpener::Ptr file_manager_;
149+ FileManager::Ptr file_manager_;
150 glib::Cancellable cancellable_;
151 glib::Object<GFileMonitor> trash_monitor_;
152 glib::Signal<void, GFileMonitor*, GFile*, GFile*, GFileMonitorEvent> trash_changed_signal_;
153
154=== modified file 'launcher/VolumeImp.cpp'
155--- launcher/VolumeImp.cpp 2013-03-21 19:52:02 +0000
156+++ launcher/VolumeImp.cpp 2013-03-25 15:57:22 +0000
157@@ -36,13 +36,13 @@
158 {
159 public:
160 Impl(glib::Object<GVolume> const& volume,
161- FileManagerOpener::Ptr const& file_manager_opener,
162+ FileManager::Ptr const& file_manager,
163 DeviceNotificationDisplay::Ptr const& device_notification_display,
164 VolumeImp* parent)
165 : parent_(parent)
166 , open_timestamp_(0)
167 , volume_(volume)
168- , file_manager_opener_(file_manager_opener)
169+ , file_manager_(file_manager)
170 , device_notification_display_(device_notification_display)
171 {
172 signal_volume_changed_.Connect(volume_, "changed", [this] (GVolume*) {
173@@ -167,7 +167,7 @@
174
175 void OpenInFileManager()
176 {
177- file_manager_opener_->Open(GetUri(), open_timestamp_);
178+ file_manager_->Open(GetUri(), open_timestamp_);
179 }
180
181 std::string GetUri()
182@@ -216,7 +216,7 @@
183 unsigned long long open_timestamp_;
184 glib::Cancellable cancellable_;
185 glib::Object<GVolume> volume_;
186- FileManagerOpener::Ptr file_manager_opener_;
187+ FileManager::Ptr file_manager_;
188 DeviceNotificationDisplay::Ptr device_notification_display_;
189
190 glib::Signal<void, GVolume*> signal_volume_changed_;
191@@ -228,9 +228,9 @@
192 //
193
194 VolumeImp::VolumeImp(glib::Object<GVolume> const& volume,
195- FileManagerOpener::Ptr const& file_manager_opener,
196+ FileManager::Ptr const& file_manager,
197 DeviceNotificationDisplay::Ptr const& device_notification_display)
198- : pimpl(new Impl(volume, file_manager_opener, device_notification_display, this))
199+ : pimpl(new Impl(volume, file_manager, device_notification_display, this))
200 {}
201
202 VolumeImp::~VolumeImp()
203
204=== modified file 'launcher/VolumeImp.h'
205--- launcher/VolumeImp.h 2013-03-13 20:54:45 +0000
206+++ launcher/VolumeImp.h 2013-03-25 15:57:22 +0000
207@@ -25,8 +25,8 @@
208 #include <UnityCore/GLibWrapper.h>
209
210 #include "DeviceNotificationDisplay.h"
211-#include "FileManagerOpener.h"
212 #include "Volume.h"
213+#include "unity-shared/FileManager.h"
214
215 namespace unity
216 {
217@@ -39,7 +39,7 @@
218 typedef std::shared_ptr<VolumeImp> Ptr;
219
220 VolumeImp(glib::Object<GVolume> const& volume,
221- FileManagerOpener::Ptr const& file_manager_opener,
222+ FileManager::Ptr const& file_manager,
223 DeviceNotificationDisplay::Ptr const& device_notification_display);
224 virtual ~VolumeImp();
225
226
227=== added file 'tests/test_mock_filemanager.h'
228--- tests/test_mock_filemanager.h 1970-01-01 00:00:00 +0000
229+++ tests/test_mock_filemanager.h 2013-03-25 15:57:22 +0000
230@@ -0,0 +1,38 @@
231+/*
232+ * Copyright 2013 Canonical Ltd.
233+ *
234+ * This program is free software: you can redistribute it and/or modify it
235+ * under the terms of the GNU General Public License version 3, as published
236+ * by the Free Software Foundation.
237+ *
238+ * This program is distributed in the hope that it will be useful, but
239+ * WITHOUT ANY WARRANTY; without even the implied warranties of
240+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
241+ * PURPOSE. See the GNU General Public License for more details.
242+ *
243+ * You should have received a copy of the GNU General Public License
244+ * version 3 along with this program. If not, see
245+ * <http://www.gnu.org/licenses/>
246+ *
247+ * Authored by: Marco Trevisan (Treviño) <marco.trevisan@canonical.com>
248+ */
249+
250+#ifndef TEST_MOCK_FILEMANAGER_H
251+#define TEST_MOCK_FILEMANAGER_H
252+
253+#include "FileManager.h"
254+
255+namespace unity
256+{
257+
258+struct MockFileManager : FileManager
259+{
260+ typedef std::shared_ptr<MockFileManager> Ptr;
261+
262+ MOCK_METHOD2(Open, void(std::string const& uri, unsigned long long time));
263+ MOCK_METHOD1(EmptyTrash, void(unsigned long long time));
264+};
265+
266+}
267+
268+#endif
269\ No newline at end of file
270
271=== modified file 'tests/test_trash_launcher_icon.cpp'
272--- tests/test_trash_launcher_icon.cpp 2013-03-14 00:17:36 +0000
273+++ tests/test_trash_launcher_icon.cpp 2013-03-25 15:57:22 +0000
274@@ -20,25 +20,22 @@
275 #include <gmock/gmock.h>
276
277 #include "TrashLauncherIcon.h"
278+#include "test_mock_filemanager.h"
279
280 using namespace unity;
281 using namespace unity::launcher;
282
283 namespace
284 {
285-struct MockFileManagerOpener : launcher::FileManagerOpener
286-{
287- MOCK_METHOD2(Open, void(std::string const& uri, unsigned long long time));
288-};
289
290 struct TestTrashLauncherIcon : testing::Test
291 {
292 TestTrashLauncherIcon()
293- : fmo_(std::make_shared<MockFileManagerOpener>())
294- , icon(fmo_)
295+ : fm_(std::make_shared<MockFileManager>())
296+ , icon(fm_)
297 {}
298
299- std::shared_ptr<MockFileManagerOpener> fmo_;
300+ MockFileManager::Ptr fm_;
301 TrashLauncherIcon icon;
302 };
303
304@@ -50,8 +47,26 @@
305 TEST_F(TestTrashLauncherIcon, Activate)
306 {
307 unsigned long long time = g_random_int();
308- EXPECT_CALL(*fmo_, Open("trash:///", time));
309+ EXPECT_CALL(*fm_, Open("trash:", time));
310 icon.Activate(ActionArg(ActionArg::Source::LAUNCHER, 0, time));
311 }
312
313+TEST_F(TestTrashLauncherIcon, Quicklist)
314+{
315+ auto const& menus = icon.Menus();
316+ EXPECT_EQ(menus.size(), 1);
317+}
318+
319+TEST_F(TestTrashLauncherIcon, QuicklistEmptyTrash)
320+{
321+ auto const& menus = icon.Menus();
322+ ASSERT_EQ(menus.size(), 1);
323+
324+ auto const& empty_trash_menu = menus.front();
325+
326+ unsigned time = g_random_int();
327+ EXPECT_CALL(*fm_, EmptyTrash(time));
328+ dbusmenu_menuitem_handle_event(empty_trash_menu, DBUSMENU_MENUITEM_EVENT_ACTIVATED, nullptr, time);
329+}
330+
331 }
332
333=== modified file 'tests/test_volume_imp.cpp'
334--- tests/test_volume_imp.cpp 2013-03-13 20:54:45 +0000
335+++ tests/test_volume_imp.cpp 2013-03-25 15:57:22 +0000
336@@ -26,19 +26,12 @@
337 #include "gmockvolume.h"
338 #include "launcher/VolumeImp.h"
339 #include "test_utils.h"
340+#include "test_mock_filemanager.h"
341 using namespace unity;
342
343 namespace
344 {
345
346-class MockFileManagerOpener : public launcher::FileManagerOpener
347-{
348-public:
349- typedef std::shared_ptr<MockFileManagerOpener> Ptr;
350-
351- MOCK_METHOD2(Open, void(std::string const& uri, unsigned long long time));
352-};
353-
354 class MockDeviceNotificationDisplay : public launcher::DeviceNotificationDisplay
355 {
356 public:
357@@ -53,14 +46,14 @@
358 void SetUp()
359 {
360 gvolume_ = g_mock_volume_new();
361- file_manager_opener_.reset(new MockFileManagerOpener);
362+ file_manager_.reset(new MockFileManager);
363 device_notification_display_.reset(new MockDeviceNotificationDisplay);
364 volume_.reset(new launcher::VolumeImp(glib::Object<GVolume>(G_VOLUME(gvolume_.RawPtr()), glib::AddRef()),
365- file_manager_opener_, device_notification_display_));
366+ file_manager_, device_notification_display_));
367 }
368
369 glib::Object<GMockVolume> gvolume_;
370- MockFileManagerOpener::Ptr file_manager_opener_;
371+ MockFileManager::Ptr file_manager_;
372 MockDeviceNotificationDisplay::Ptr device_notification_display_;
373 launcher::VolumeImp::Ptr volume_;
374 };
375@@ -129,14 +122,14 @@
376 TEST_F(TestVolumeImp, TestMountAndOpenInFileManager)
377 {
378 unsigned long long time = g_random_int();
379- EXPECT_CALL(*file_manager_opener_, Open(ROOT_FILE_URI, time));
380+ EXPECT_CALL(*file_manager_, Open(ROOT_FILE_URI, time));
381
382 volume_->MountAndOpenInFileManager(time);
383 EXPECT_EQ(g_mock_volume_last_mount_had_mount_operation(gvolume_), TRUE);
384 EXPECT_TRUE(volume_->IsMounted());
385
386 time = g_random_int();
387- EXPECT_CALL(*file_manager_opener_, Open(ROOT_FILE_URI, time));
388+ EXPECT_CALL(*file_manager_, Open(ROOT_FILE_URI, time));
389
390 volume_->MountAndOpenInFileManager(time);
391 EXPECT_EQ(g_mock_volume_last_mount_had_mount_operation(gvolume_), TRUE);
392
393=== modified file 'unity-shared/CMakeLists.txt'
394--- unity-shared/CMakeLists.txt 2013-02-01 20:30:27 +0000
395+++ unity-shared/CMakeLists.txt 2013-03-25 15:57:22 +0000
396@@ -26,6 +26,7 @@
397 DebugDBusInterface.cpp
398 DefaultThumbnailProvider.cpp
399 DeltaRestrainment.cpp
400+ GnomeFileManager.cpp
401 FontSettings.cpp
402 GraphicsUtils.cpp
403 IMTextEntry.cpp
404
405=== renamed file 'launcher/FileManagerOpener.h' => 'unity-shared/FileManager.h'
406--- launcher/FileManagerOpener.h 2013-03-13 20:54:45 +0000
407+++ unity-shared/FileManager.h 2013-03-25 15:57:22 +0000
408@@ -1,6 +1,6 @@
409 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
410 /*
411- * Copyright (C) 2012 Canonical Ltd
412+ * Copyright (C) 2012-2013 Canonical Ltd
413 *
414 * This program is free software: you can redistribute it and/or modify
415 * it under the terms of the GNU General Public License version 3 as
416@@ -15,34 +15,33 @@
417 * along with this program. If not, see <http://www.gnu.org/licenses/>.
418 *
419 * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com>
420+ * Marco Trevisan <marco.trevisan@canonical.com>
421 */
422
423-#ifndef UNITYSHELL_FILEMANAGER_OPENER_H
424-#define UNITYSHELL_FILEMANAGER_OPENER_H
425+#ifndef UNITYSHELL_FILEMANAGER_H
426+#define UNITYSHELL_FILEMANAGER_H
427
428 #include <memory>
429 #include <string>
430
431 namespace unity
432 {
433-namespace launcher
434-{
435
436-class FileManagerOpener
437+class FileManager
438 {
439 public:
440- typedef std::shared_ptr<FileManagerOpener> Ptr;
441+ typedef std::shared_ptr<FileManager> Ptr;
442
443- FileManagerOpener() = default;
444- virtual ~FileManagerOpener() {}
445+ FileManager() = default;
446+ virtual ~FileManager() {}
447 virtual void Open(std::string const& uri, unsigned long long timestamp = 0) = 0;
448+ virtual void EmptyTrash(unsigned long long timestamp = 0) = 0;
449
450 private:
451- FileManagerOpener(FileManagerOpener const&) = delete;
452- FileManagerOpener& operator=(FileManagerOpener const&) = delete;
453+ FileManager(FileManager const&) = delete;
454+ FileManager& operator=(FileManager const&) = delete;
455 };
456
457 }
458-}
459
460 #endif
461
462=== renamed file 'launcher/FileManagerOpenerImp.cpp' => 'unity-shared/GnomeFileManager.cpp'
463--- launcher/FileManagerOpenerImp.cpp 2013-03-13 20:54:45 +0000
464+++ unity-shared/GnomeFileManager.cpp 2013-03-25 15:57:22 +0000
465@@ -18,19 +18,24 @@
466 * Marco Trevisan <marco.trevisan@canonical.com>
467 */
468
469-#include "FileManagerOpenerImp.h"
470+#include "GnomeFileManager.h"
471 #include <NuxCore/Logger.h>
472 #include <UnityCore/GLibWrapper.h>
473+#include <UnityCore/GLibDBusProxy.h>
474 #include <gdk/gdk.h>
475+#include <gio/gio.h>
476
477 namespace unity
478 {
479-namespace launcher
480+
481+namespace
482 {
483-
484-DECLARE_LOGGER(logger, "unity.launcher.filemanager.opener.imp");
485-
486-void FileManagerOpenerImp::Open(std::string const& uri, unsigned long long timestamp)
487+DECLARE_LOGGER(logger, "unity.filemanager.gnome");
488+
489+const std::string TRASH_URI = "trash:";
490+}
491+
492+void GnomeFileManager::Open(std::string const& uri, unsigned long long timestamp)
493 {
494 if (uri.empty())
495 {
496@@ -54,5 +59,49 @@
497 }
498 }
499
500-}
501+void GnomeFileManager::Activate(unsigned long long timestamp)
502+{
503+ glib::Cancellable cancellable;
504+ glib::Object<GFile> file(g_file_new_for_uri(TRASH_URI.c_str()));
505+ glib::Object<GAppInfo> app_info(g_file_query_default_handler(file, cancellable, nullptr));
506+
507+ if (app_info)
508+ {
509+ GdkDisplay* display = gdk_display_get_default();
510+ glib::Object<GdkAppLaunchContext> context(gdk_display_get_app_launch_context(display));
511+
512+ if (timestamp > 0)
513+ gdk_app_launch_context_set_timestamp(context, timestamp);
514+
515+ auto const& gcontext = glib::object_cast<GAppLaunchContext>(context);
516+ auto proxy = std::make_shared<glib::DBusProxy>("org.gnome.NautilusApplication",
517+ "/org/gnome/NautilusApplication",
518+ "org.gtk.Application");
519+
520+ glib::String context_string(g_app_launch_context_get_startup_notify_id(gcontext, app_info, nullptr));
521+
522+ if (context_string && g_utf8_validate(context_string, -1, nullptr))
523+ {
524+ GVariantBuilder builder;
525+ g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}"));
526+ g_variant_builder_add(&builder, "{sv}", "desktop-startup-id", g_variant_new("s", context_string.Value()));
527+ GVariant *param = g_variant_new("(@a{sv})", g_variant_builder_end(&builder));
528+
529+ // Passing the proxy to the lambda we ensure that it will be destroyed when needed
530+ proxy->CallBegin("Activate", param, [proxy] (GVariant*, glib::Error const&) {});
531+ }
532+ }
533+}
534+
535+void GnomeFileManager::EmptyTrash(unsigned long long timestamp)
536+{
537+ Activate(timestamp);
538+
539+ auto proxy = std::make_shared<glib::DBusProxy>("org.gnome.Nautilus", "/org/gnome/Nautilus",
540+ "org.gnome.Nautilus.FileOperations");
541+
542+ // Passing the proxy to the lambda we ensure that it will be destroyed when needed
543+ proxy->CallBegin("EmptyTrash", nullptr, [proxy] (GVariant*, glib::Error const&) {});
544+}
545+
546 }
547
548=== renamed file 'launcher/FileManagerOpenerImp.h' => 'unity-shared/GnomeFileManager.h'
549--- launcher/FileManagerOpenerImp.h 2013-03-13 20:54:45 +0000
550+++ unity-shared/GnomeFileManager.h 2013-03-25 15:57:22 +0000
551@@ -1,6 +1,6 @@
552 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
553 /*
554- * Copyright (C) 2012 Canonical Ltd
555+ * Copyright (C) 2012-2013 Canonical Ltd
556 *
557 * This program is free software: you can redistribute it and/or modify
558 * it under the terms of the GNU General Public License version 3 as
559@@ -15,25 +15,27 @@
560 * along with this program. If not, see <http://www.gnu.org/licenses/>.
561 *
562 * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com>
563+ * Marco Trevisan <marco.trevisan@canonical.com>
564 */
565
566-#ifndef UNITYSHELL_FILEMANAGER_OPENER_IMP_H
567-#define UNITYSHELL_FILEMANAGER_OPENER_IMP_H
568+#ifndef UNITYSHELL_GNOME_FILEMANAGER_H
569+#define UNITYSHELL_GNOME_FILEMANAGER_H
570
571-#include "FileManagerOpener.h"
572+#include "FileManager.h"
573
574 namespace unity
575 {
576-namespace launcher
577-{
578
579-class FileManagerOpenerImp : public FileManagerOpener
580+class GnomeFileManager : public FileManager
581 {
582 public:
583- virtual void Open(std::string const& uri, unsigned long long timestamp);
584+ void Open(std::string const& uri, unsigned long long timestamp);
585+ void EmptyTrash(unsigned long long timestamp);
586+
587+private:
588+ void Activate(unsigned long long timestamp);
589 };
590
591 }
592-}
593
594 #endif