Blame SOURCES/0013-dbus-manager-Provide-undo-status.patch

af40a0
From 90229bd32fde57feb4dd37bc018d47c7a29e7e93 Mon Sep 17 00:00:00 2001
af40a0
From: Carlos Soriano <csoriano@redhat.com>
af40a0
Date: Sat, 18 Aug 2018 20:31:36 +0200
af40a0
Subject: [PATCH] dbus-manager: Provide undo status
af40a0
af40a0
This is interesting for the desktop icons integration, so it can hide
af40a0
the undo/redo menu items appropriately.
af40a0
---
af40a0
 data/dbus-interfaces.xml    |  1 +
af40a0
 src/nautilus-dbus-manager.c | 31 +++++++++++++++++++++++++++++--
af40a0
 2 files changed, 30 insertions(+), 2 deletions(-)
af40a0
af40a0
diff --git a/data/dbus-interfaces.xml b/data/dbus-interfaces.xml
af40a0
index 64176225c..078cf24a2 100644
af40a0
--- a/data/dbus-interfaces.xml
af40a0
+++ b/data/dbus-interfaces.xml
af40a0
@@ -43,5 +43,6 @@
af40a0
     </method>
af40a0
     <method name='Redo'>
af40a0
     </method>
af40a0
+    <property name="UndoStatus" type="i" access="read"/>
af40a0
   </interface>
af40a0
 </node>
af40a0
diff --git a/src/nautilus-dbus-manager.c b/src/nautilus-dbus-manager.c
af40a0
index f11ede0ad..64f004d88 100644
af40a0
--- a/src/nautilus-dbus-manager.c
af40a0
+++ b/src/nautilus-dbus-manager.c
af40a0
@@ -237,6 +237,17 @@ handle_trash_files (NautilusDBusFileOperations  *object,
af40a0
     return TRUE; /* invocation was handled */
af40a0
 }
af40a0
af40a0
+
af40a0
+static void
af40a0
+undo_manager_changed (NautilusDBusManager *self)
af40a0
+{
af40a0
+    NautilusFileUndoManagerState undo_state;
af40a0
+
af40a0
+    undo_state = nautilus_file_undo_manager_get_state ();
af40a0
+    nautilus_dbus_file_operations_set_undo_status (self->file_operations,
af40a0
+                                                   undo_state);
af40a0
+}
af40a0
+
af40a0
 static void
af40a0
 nautilus_dbus_manager_init (NautilusDBusManager *self)
af40a0
 {
af40a0
@@ -292,12 +303,28 @@ nautilus_dbus_manager_register (NautilusDBusManager  *self,
af40a0
                                 GDBusConnection      *connection,
af40a0
                                 GError              **error)
af40a0
 {
af40a0
-    return g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self->file_operations),
af40a0
-                                             connection, "/org/gnome/Nautilus" PROFILE, error);
af40a0
+    gboolean succes;
af40a0
+
af40a0
+    succes = g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self->file_operations),
af40a0
+                                               connection, "/org/gnome/Nautilus" PROFILE, error);
af40a0
+    if (succes)
af40a0
+    {
af40a0
+        g_signal_connect_object (nautilus_file_undo_manager_get (),
af40a0
+                                 "undo-changed",
af40a0
+                                 G_CALLBACK (undo_manager_changed),
af40a0
+                                 self,
af40a0
+                                 G_CONNECT_SWAPPED);
af40a0
+
af40a0
+        undo_manager_changed (self);
af40a0
+    }
af40a0
+
af40a0
+    return succes;
af40a0
 }
af40a0
af40a0
 void
af40a0
 nautilus_dbus_manager_unregister (NautilusDBusManager *self)
af40a0
 {
af40a0
     g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (self->file_operations));
af40a0
+
af40a0
+    g_signal_handlers_disconnect_by_data (nautilus_file_undo_manager_get (), self);
af40a0
 }
af40a0
--
af40a0
2.17.1