[nautilus/wip/muktupavels/delete: 2/2] dbus-manager: add DeleteFiles method
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/muktupavels/delete: 2/2] dbus-manager: add DeleteFiles method
- Date: Mon, 3 Feb 2020 11:31:53 +0000 (UTC)
commit 24292d1be7fba020773b684c8c60f98d47c28f0e
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Fri Jan 31 00:01:25 2020 +0200
dbus-manager: add DeleteFiles method
Add DeleteFiles method to make it possible to permanently delete
files avoiding trash.
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 0e62e5725..88d6f6e56 100644
--- a/data/dbus-interfaces2.xml
+++ b/data/dbus-interfaces2.xml
@@ -50,6 +50,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 199dc10ca..03e8faa55 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]