Blame SOURCES/add-desktop-icons-rename.patch

af40a0
From bac4bd595c518983571b0fb41fcf5586f27544eb Mon Sep 17 00:00:00 2001
af40a0
From: Carlos Soriano <csoriano@redhat.com>
af40a0
Date: Mon, 19 Nov 2018 08:55:22 +0000
af40a0
Subject: [PATCH] dbus: Implement rename file
af40a0
af40a0
So desktop icons extensions can use it.
af40a0
af40a0
af40a0
(cherry picked from commit 42c5ce657e2b24ddf19932e9e3284a045d60ff51)
af40a0
---
af40a0
 data/dbus-interfaces.xml    |  4 ++++
af40a0
 src/nautilus-dbus-manager.c | 33 +++++++++++++++++++++++++++++++++
af40a0
 2 files changed, 37 insertions(+)
af40a0
af40a0
diff --git a/data/dbus-interfaces.xml b/data/dbus-interfaces.xml
af40a0
index 298871bc4..1827f92ab 100644
af40a0
--- a/data/dbus-interfaces.xml
af40a0
+++ b/data/dbus-interfaces.xml
af40a0
@@ -39,6 +39,10 @@
af40a0
     <method name='CreateFolder'>
af40a0
       <arg type='s' name='URI' direction='in'/>
af40a0
     </method>
af40a0
+    <method name='RenameFile'>
af40a0
+      <arg type='s' name='URI' direction='in'/>
af40a0
+      <arg type='s' name='NewName' direction='in'/>
af40a0
+    </method>
af40a0
     <method name='Undo'>
af40a0
     </method>
af40a0
     <method name='Redo'>
af40a0
diff --git a/src/nautilus-dbus-manager.c b/src/nautilus-dbus-manager.c
af40a0
index 3257c4bd4..43f27e10a 100644
af40a0
--- a/src/nautilus-dbus-manager.c
af40a0
+++ b/src/nautilus-dbus-manager.c
af40a0
@@ -27,6 +27,7 @@
af40a0
 
af40a0
 #include "nautilus-file-operations.h"
af40a0
 #include "nautilus-file-undo-manager.h"
af40a0
+#include "nautilus-file.h"
af40a0
 
af40a0
 #define DEBUG_FLAG NAUTILUS_DEBUG_DBUS
af40a0
 #include "nautilus-debug.h"
af40a0
@@ -230,6 +231,34 @@ handle_trash_files (NautilusDBusFileOperations  *object,
af40a0
     return TRUE; /* invocation was handled */
af40a0
 }
af40a0
 
af40a0
+static void
af40a0
+rename_file_on_finished (NautilusFile *file,
af40a0
+                         GFile        *result_location,
af40a0
+                         GError       *error,
af40a0
+                         gpointer      callback_data)
af40a0
+{
af40a0
+    g_application_release (g_application_get_default ());
af40a0
+}
af40a0
+
af40a0
+static gboolean
af40a0
+handle_rename_file (NautilusDBusFileOperations *object,
af40a0
+                    GDBusMethodInvocation      *invocation,
af40a0
+                    const gchar                *uri,
af40a0
+                    const gchar                *new_name)
af40a0
+{
af40a0
+    NautilusFile *file = NULL;
af40a0
+
af40a0
+    file = nautilus_file_get_by_uri (uri);
af40a0
+
af40a0
+    g_application_hold (g_application_get_default ());
af40a0
+    nautilus_file_rename (file, new_name,
af40a0
+                          rename_file_on_finished, NULL);
af40a0
+
af40a0
+    nautilus_dbus_file_operations_complete_rename_file (object, invocation);
af40a0
+
af40a0
+    return TRUE; /* invocation was handled */
af40a0
+}
af40a0
+
af40a0
 
af40a0
 static void
af40a0
 undo_manager_changed (NautilusDBusManager *self)
af40a0
@@ -266,6 +295,10 @@ nautilus_dbus_manager_init (NautilusDBusManager *self)
af40a0
                       "handle-create-folder",
af40a0
                       G_CALLBACK (handle_create_folder),
af40a0
                       self);
af40a0
+    g_signal_connect (self->file_operations,
af40a0
+                      "handle-rename-file",
af40a0
+                      G_CALLBACK (handle_rename_file),
af40a0
+                      self);
af40a0
     g_signal_connect (self->file_operations,
af40a0
                       "handle-undo",
af40a0
                       G_CALLBACK (handle_undo),
af40a0
-- 
af40a0
2.18.1
af40a0