[nautilus/wip/muktupavels/delete: 4/4] dbus-manager: implement deleting files
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/muktupavels/delete: 4/4] dbus-manager: implement deleting files
- Date: Fri, 31 Jan 2020 21:33:59 +0000 (UTC)
commit 0e96a23038ea6098de7c1f02047e4cf12645ff57
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Fri Jan 31 00:01:25 2020 +0200
dbus-manager: implement deleting files
https://gitlab.gnome.org/GNOME/nautilus/merge_requests/504
data/dbus-interfaces2.xml | 4 ++++
src/nautilus-dbus-manager.c | 48 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 52 insertions(+)
---
diff --git a/data/dbus-interfaces2.xml b/data/dbus-interfaces2.xml
index 21c204a15..b19ee6d7a 100644
--- a/data/dbus-interfaces2.xml
+++ b/data/dbus-interfaces2.xml
@@ -40,6 +40,10 @@
<arg type='as' name='URIs' direction='in'/>
<arg type='a{sv}' name='PlatformData' direction='in'/>
</method>
+ <method name='DeleteFiles'>
+ <arg type='as' name='URIs' direction='in'/>
+ <arg type='a{sv}' name='PlatformData' direction='in'/>
+ </method>
<method name='CreateFolder'>
<arg type='s' name='URI' direction='in'/>
<arg type='a{sv}' name='PlatformData' direction='in'/>
diff --git a/src/nautilus-dbus-manager.c b/src/nautilus-dbus-manager.c
index e4ae2023f..2b40c538f 100644
--- a/src/nautilus-dbus-manager.c
+++ b/src/nautilus-dbus-manager.c
@@ -411,6 +411,50 @@ handle_trash_files2 (NautilusDBusFileOperations2 *object,
return TRUE; /* invocation was handled */
}
+static void
+delete_on_finished (GHashTable *debutting_uris,
+ gboolean user_cancel,
+ gpointer callback_data)
+{
+ g_application_release (g_application_get_default ());
+}
+
+static void
+handle_delete_files_internal (const char **sources,
+ NautilusFileOperationsDBusData *dbus_data)
+{
+ g_autolist (GFile) source_files = NULL;
+ gint idx;
+
+ for (idx = 0; sources[idx] != NULL; idx++)
+ {
+ source_files = g_list_prepend (source_files,
+ g_file_new_for_uri (sources[idx]));
+ }
+
+ g_application_hold (g_application_get_default ());
+ nautilus_file_operations_delete_async (source_files, NULL,
+ dbus_data,
+ delete_on_finished, NULL);
+}
+
+static gboolean
+handle_delete_files2 (NautilusDBusFileOperations2 *object,
+ GDBusMethodInvocation *invocation,
+ const gchar **sources,
+ GVariant *platform_data)
+{
+ NautilusFileOperationsDBusData *dbus_data;
+
+ dbus_data = nautilus_file_operations_dbus_data_new (platform_data);
+
+ handle_delete_files_internal (sources, dbus_data);
+ nautilus_file_operations_dbus_data_unref (dbus_data);
+
+ nautilus_dbus_file_operations2_complete_delete_files (object, invocation);
+ return TRUE; /* invocation was handled */
+}
+
static void
rename_file_on_finished (NautilusFile *file,
GFile *result_location,
@@ -516,6 +560,10 @@ nautilus_dbus_manager_init (NautilusDBusManager *self)
"handle-trash-files",
G_CALLBACK (handle_trash_files2),
self);
+ g_signal_connect (self->file_operations2,
+ "handle-delete-files",
+ G_CALLBACK (handle_delete_files2),
+ self);
g_signal_connect (self->file_operations,
"handle-create-folder",
G_CALLBACK (handle_create_folder),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]