[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:45:04 +0000 (UTC)
commit 55ac5ff924caa6efc19769fbfe45c8b1b7cc529d
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 | 47 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 51 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 1623745bd..7df6665d3 100644
--- a/src/nautilus-dbus-manager.c
+++ b/src/nautilus-dbus-manager.c
@@ -404,6 +404,49 @@ 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)
+{
+ g_autoptr (NautilusFileOperationsDBusData) dbus_data = NULL;
+
+ dbus_data = nautilus_file_operations_dbus_data_new (platform_data);
+
+ handle_delete_files_internal (sources, 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,
@@ -508,6 +551,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]