Merge lp:~3v1n0/unity/filemanager-operations-timestamp into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 4076
Proposed branch: lp:~3v1n0/unity/filemanager-operations-timestamp
Merge into: lp:unity
Prerequisite: lp:~3v1n0/unity/launcher-filemanager-integration
Diff against target: 94 lines (+4/-39)
2 files modified
unity-shared/GnomeFileManager.cpp (+4/-38)
unity-shared/GnomeFileManager.h (+0/-1)
To merge this branch: bzr merge lp:~3v1n0/unity/filemanager-operations-timestamp
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+280341@code.launchpad.net

Commit message

GnomeFileManager: use *WithTimestamp file operations instead of using Activate workaround

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Andrea Azzarone (azzar1) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'unity-shared/GnomeFileManager.cpp'
--- unity-shared/GnomeFileManager.cpp 2015-12-11 17:59:00 +0000
+++ unity-shared/GnomeFileManager.cpp 2015-12-11 17:59:00 +0000
@@ -169,39 +169,6 @@
169 Open(TRASH_URI, timestamp);169 Open(TRASH_URI, timestamp);
170}170}
171171
172void GnomeFileManager::Activate(uint64_t timestamp)
173{
174 glib::Cancellable cancellable;
175 glib::Object<GFile> file(g_file_new_for_uri(TRASH_URI.c_str()));
176 glib::Object<GAppInfo> app_info(g_file_query_default_handler(file, cancellable, nullptr));
177
178 if (app_info)
179 {
180 GdkDisplay* display = gdk_display_get_default();
181 glib::Object<GdkAppLaunchContext> context(gdk_display_get_app_launch_context(display));
182
183 if (timestamp > 0)
184 gdk_app_launch_context_set_timestamp(context, timestamp);
185
186 auto const& gcontext = glib::object_cast<GAppLaunchContext>(context);
187 auto proxy = std::make_shared<glib::DBusProxy>(NAUTILUS_NAME, NAUTILUS_PATH,
188 "org.freedesktop.Application");
189
190 glib::String context_string(g_app_launch_context_get_startup_notify_id(gcontext, app_info, nullptr));
191
192 if (context_string && g_utf8_validate(context_string, -1, nullptr))
193 {
194 GVariantBuilder builder;
195 g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}"));
196 g_variant_builder_add(&builder, "{sv}", "desktop-startup-id", g_variant_new("s", context_string.Value()));
197 GVariant *param = g_variant_new("(@a{sv})", g_variant_builder_end(&builder));
198
199 // Passing the proxy to the lambda we ensure that it will be destroyed when needed
200 proxy->CallBegin("Activate", param, [proxy] (GVariant*, glib::Error const&) {});
201 }
202 }
203}
204
205bool GnomeFileManager::TrashFile(std::string const& uri)172bool GnomeFileManager::TrashFile(std::string const& uri)
206{173{
207 glib::Cancellable cancellable;174 glib::Cancellable cancellable;
@@ -217,11 +184,10 @@
217184
218void GnomeFileManager::EmptyTrash(uint64_t timestamp)185void GnomeFileManager::EmptyTrash(uint64_t timestamp)
219{186{
220 Activate(timestamp);
221 auto const& proxy = impl_->NautilusOperationsProxy();187 auto const& proxy = impl_->NautilusOperationsProxy();
222188
223 // Passing the proxy to the lambda we ensure that it will be destroyed when needed189 // Passing the proxy to the lambda we ensure that it will be destroyed when needed
224 proxy->CallBegin("EmptyTrash", nullptr, [proxy] (GVariant*, glib::Error const&) {});190 proxy->CallBegin("EmptyTrashWithTimestamp", g_variant_new("(u)", timestamp), [proxy] (GVariant*, glib::Error const&) {});
225}191}
226192
227void GnomeFileManager::CopyFiles(std::set<std::string> const& uris, std::string const& dest, uint64_t timestamp)193void GnomeFileManager::CopyFiles(std::set<std::string> const& uris, std::string const& dest, uint64_t timestamp)
@@ -231,7 +197,7 @@
231197
232 bool found_valid = false;198 bool found_valid = false;
233 GVariantBuilder b;199 GVariantBuilder b;
234 g_variant_builder_init(&b, G_VARIANT_TYPE("(ass)"));200 g_variant_builder_init(&b, G_VARIANT_TYPE("(assu)"));
235 g_variant_builder_open(&b, G_VARIANT_TYPE("as"));201 g_variant_builder_open(&b, G_VARIANT_TYPE("as"));
236202
237 for (auto const& uri : uris)203 for (auto const& uri : uris)
@@ -245,14 +211,14 @@
245211
246 g_variant_builder_close(&b);212 g_variant_builder_close(&b);
247 g_variant_builder_add(&b, "s", dest.c_str());213 g_variant_builder_add(&b, "s", dest.c_str());
214 g_variant_builder_add(&b, "u", timestamp);
248 glib::Variant parameters(g_variant_builder_end(&b));215 glib::Variant parameters(g_variant_builder_end(&b));
249216
250 if (found_valid)217 if (found_valid)
251 {218 {
252 // Passing the proxy to the lambda we ensure that it will be destroyed when needed219 // Passing the proxy to the lambda we ensure that it will be destroyed when needed
253 auto const& proxy = impl_->NautilusOperationsProxy();220 auto const& proxy = impl_->NautilusOperationsProxy();
254 proxy->CallBegin("CopyURIs", parameters, [proxy] (GVariant*, glib::Error const&) {});221 proxy->CallBegin("CopyURIsWithTimestamp", parameters, [proxy] (GVariant*, glib::Error const&) {});
255 Activate(timestamp);
256 }222 }
257}223}
258224
259225
=== modified file 'unity-shared/GnomeFileManager.h'
--- unity-shared/GnomeFileManager.h 2015-12-11 17:59:00 +0000
+++ unity-shared/GnomeFileManager.h 2015-12-11 17:59:00 +0000
@@ -44,7 +44,6 @@
4444
45private:45private:
46 GnomeFileManager();46 GnomeFileManager();
47 void Activate(uint64_t timestamp);
4847
49 struct Impl;48 struct Impl;
50 std::unique_ptr<Impl> impl_;49 std::unique_ptr<Impl> impl_;