import nautilus-3.28.1-5.el8

This commit is contained in:
CentOS Sources 2019-05-07 05:41:01 -04:00 committed by Andrew Lukoshko
commit 7583314264
17 changed files with 3885 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
SOURCES/nautilus-3.28.1.tar.xz

1
.nautilus.metadata Normal file
View File

@ -0,0 +1 @@
f5fb5185ad922f906a22bc0aeae4cc76a243200d SOURCES/nautilus-3.28.1.tar.xz

View File

@ -0,0 +1,69 @@
From db2b7aea67c994ba8a6e5a9ffec245b1daebcdfb Mon Sep 17 00:00:00 2001
From: Carlos Soriano <csoriano@redhat.com>
Date: Mon, 6 Aug 2018 17:32:00 +0200
Subject: [PATCH 01/11] dbus-manager: Implement trashing files
So desktop icons extension can use it.
---
data/dbus-interfaces.xml | 3 +++
src/nautilus-dbus-manager.c | 24 ++++++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/data/dbus-interfaces.xml b/data/dbus-interfaces.xml
index 35fb9945b..4588762a9 100644
--- a/data/dbus-interfaces.xml
+++ b/data/dbus-interfaces.xml
@@ -35,5 +35,8 @@
<arg type='s' name='DestinationDirectoryURI' direction='in'/>
<arg type='s' name='DestinationDisplayName' direction='in'/>
</method>
+ <method name='TrashFiles'>
+ <arg type='as' name='URIs' direction='in'/>
+ </method>
</interface>
</node>
diff --git a/src/nautilus-dbus-manager.c b/src/nautilus-dbus-manager.c
index 3611a2358..4da1c727b 100644
--- a/src/nautilus-dbus-manager.c
+++ b/src/nautilus-dbus-manager.c
@@ -131,6 +131,26 @@ handle_empty_trash (NautilusDBusFileOperations *object,
return TRUE; /* invocation was handled */
}
+static gboolean
+handle_trash_files (NautilusDBusFileOperations *object,
+ GDBusMethodInvocation *invocation,
+ const gchar **sources)
+{
+ 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]));
+ }
+
+ nautilus_file_operations_trash_or_delete (source_files, NULL, NULL, NULL);
+
+ nautilus_dbus_file_operations_complete_trash_files (object, invocation);
+ return TRUE; /* invocation was handled */
+}
+
static void
nautilus_dbus_manager_init (NautilusDBusManager *self)
{
@@ -148,6 +168,10 @@ nautilus_dbus_manager_init (NautilusDBusManager *self)
"handle-empty-trash",
G_CALLBACK (handle_empty_trash),
self);
+ g_signal_connect (self->file_operations,
+ "handle-trash-files",
+ G_CALLBACK (handle_trash_files),
+ self);
}
static void
--
2.17.1

View File

@ -0,0 +1,71 @@
From d2be99e4528759d28985246a55c9d4513e78f918 Mon Sep 17 00:00:00 2001
From: Carlos Soriano <csoriano@redhat.com>
Date: Mon, 6 Aug 2018 20:11:31 +0200
Subject: [PATCH 02/11] dbus-manager: Implement creation of new folders
For the integration with the desktop icons extension.
---
data/dbus-interfaces.xml | 3 +++
src/nautilus-dbus-manager.c | 26 ++++++++++++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/data/dbus-interfaces.xml b/data/dbus-interfaces.xml
index 4588762a9..4e67f1393 100644
--- a/data/dbus-interfaces.xml
+++ b/data/dbus-interfaces.xml
@@ -38,5 +38,8 @@
<method name='TrashFiles'>
<arg type='as' name='URIs' direction='in'/>
</method>
+ <method name='CreateFolder'>
+ <arg type='s' name='URI' direction='in'/>
+ </method>
</interface>
</node>
diff --git a/src/nautilus-dbus-manager.c b/src/nautilus-dbus-manager.c
index 4da1c727b..337a73262 100644
--- a/src/nautilus-dbus-manager.c
+++ b/src/nautilus-dbus-manager.c
@@ -94,6 +94,28 @@ handle_copy_file (NautilusDBusFileOperations *object,
return TRUE; /* invocation was handled */
}
+static gboolean
+handle_create_folder (NautilusDBusFileOperations *object,
+ GDBusMethodInvocation *invocation,
+ const gchar *uri)
+{
+ g_autoptr (GFile) file = NULL;
+ g_autoptr (GFile) parent_file = NULL;
+ g_autofree gchar *basename = NULL;
+ g_autofree gchar *parent_file_uri = NULL;
+
+ file = g_file_new_for_uri (uri);
+ basename = g_file_get_basename (file);
+ parent_file = g_file_get_parent (file);
+ parent_file_uri = g_file_get_uri (parent_file);
+
+ nautilus_file_operations_new_folder (NULL, parent_file_uri, basename,
+ NULL, NULL);
+
+ nautilus_dbus_file_operations_complete_create_folder (object, invocation);
+ return TRUE; /* invocation was handled */
+}
+
static gboolean
handle_copy_uris (NautilusDBusFileOperations *object,
GDBusMethodInvocation *invocation,
@@ -172,6 +194,10 @@ nautilus_dbus_manager_init (NautilusDBusManager *self)
"handle-trash-files",
G_CALLBACK (handle_trash_files),
self);
+ g_signal_connect (self->file_operations,
+ "handle-create-folder",
+ G_CALLBACK (handle_create_folder),
+ self);
}
static void
--
2.17.1

View File

@ -0,0 +1,88 @@
From 42ea37f93c134d55cd622e3e346726babaf56139 Mon Sep 17 00:00:00 2001
From: Carlos Soriano <csoriano@redhat.com>
Date: Mon, 6 Aug 2018 20:12:00 +0200
Subject: [PATCH 03/11] dbus-manager: Implement undo/redo
For the integration with the desktop icons extension.
---
data/dbus-interfaces.xml | 4 ++++
src/nautilus-dbus-manager.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+)
diff --git a/data/dbus-interfaces.xml b/data/dbus-interfaces.xml
index 4e67f1393..2133bb99c 100644
--- a/data/dbus-interfaces.xml
+++ b/data/dbus-interfaces.xml
@@ -41,5 +41,9 @@
<method name='CreateFolder'>
<arg type='s' name='URI' direction='in'/>
</method>
+ <method name='Undo'>
+ </method>
+ <method name='Redo'>
+ </method>
</interface>
</node>
diff --git a/src/nautilus-dbus-manager.c b/src/nautilus-dbus-manager.c
index 337a73262..bce6b5c4d 100644
--- a/src/nautilus-dbus-manager.c
+++ b/src/nautilus-dbus-manager.c
@@ -26,6 +26,7 @@
#include "nautilus-generated.h"
#include "nautilus-file-operations.h"
+#include "nautilus-file-undo-manager.h"
#define DEBUG_FLAG NAUTILUS_DEBUG_DBUS
#include "nautilus-debug.h"
@@ -94,6 +95,32 @@ handle_copy_file (NautilusDBusFileOperations *object,
return TRUE; /* invocation was handled */
}
+static gboolean
+handle_redo (NautilusDBusFileOperations *object,
+ GDBusMethodInvocation *invocation)
+{
+ g_autoptr (NautilusFileUndoManager) undo_manager = NULL;
+
+ undo_manager = nautilus_file_undo_manager_get ();
+ nautilus_file_undo_manager_redo (NULL);
+
+ nautilus_dbus_file_operations_complete_redo (object, invocation);
+ return TRUE; /* invocation was handled */
+}
+
+static gboolean
+handle_undo (NautilusDBusFileOperations *object,
+ GDBusMethodInvocation *invocation)
+{
+ g_autoptr (NautilusFileUndoManager) undo_manager = NULL;
+
+ undo_manager = nautilus_file_undo_manager_get ();
+ nautilus_file_undo_manager_undo (NULL);
+
+ nautilus_dbus_file_operations_complete_undo (object, invocation);
+ return TRUE; /* invocation was handled */
+}
+
static gboolean
handle_create_folder (NautilusDBusFileOperations *object,
GDBusMethodInvocation *invocation,
@@ -198,6 +225,14 @@ nautilus_dbus_manager_init (NautilusDBusManager *self)
"handle-create-folder",
G_CALLBACK (handle_create_folder),
self);
+ g_signal_connect (self->file_operations,
+ "handle-undo",
+ G_CALLBACK (handle_undo),
+ self);
+ g_signal_connect (self->file_operations,
+ "handle-redo",
+ G_CALLBACK (handle_redo),
+ self);
}
static void
--
2.17.1

View File

@ -0,0 +1,46 @@
From ef022816e3fe321d9ee9b5a2deab96ca718f7215 Mon Sep 17 00:00:00 2001
From: Carlos Soriano <csoriano@redhat.com>
Date: Tue, 7 Aug 2018 10:47:28 +0200
Subject: [PATCH 04/11] dbus-manager: Use a more robust copy operation
We were using the copy_file operation which seems to be quite buggy,
Nautilus should probably drop that one soon, specially since no other
part of Nautilus uses it.
---
src/nautilus-dbus-manager.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/src/nautilus-dbus-manager.c b/src/nautilus-dbus-manager.c
index bce6b5c4d..8135c9650 100644
--- a/src/nautilus-dbus-manager.c
+++ b/src/nautilus-dbus-manager.c
@@ -150,22 +150,17 @@ handle_copy_uris (NautilusDBusFileOperations *object,
const gchar *destination)
{
GList *source_files = NULL;
- GFile *dest_dir;
gint idx;
- dest_dir = g_file_new_for_uri (destination);
-
for (idx = 0; sources[idx] != NULL; idx++)
{
- source_files = g_list_prepend (source_files,
- g_file_new_for_uri (sources[idx]));
+ source_files = g_list_prepend (source_files, g_strdup (sources[idx]));
}
- nautilus_file_operations_copy (source_files, dest_dir, NULL, NULL, NULL);
-
- g_list_free_full (source_files, g_object_unref);
- g_object_unref (dest_dir);
+ nautilus_file_operations_copy_move (source_files, destination,
+ GDK_ACTION_COPY, NULL, NULL, NULL);
+ g_list_free_full (source_files, g_free);
nautilus_dbus_file_operations_complete_copy_uris (object, invocation);
return TRUE; /* invocation was handled */
}
--
2.17.1

View File

@ -0,0 +1,88 @@
From 32f347bd83495edf2bda746d17e613c868a7c379 Mon Sep 17 00:00:00 2001
From: Carlos Soriano <csoriano@redhat.com>
Date: Tue, 7 Aug 2018 11:51:54 +0200
Subject: [PATCH 05/11] file-operations: Don't crash if source file not present
on creation
When creating a file it was checking if the file already exists, and if
so it tried to give a new name based on the original file that was being
duplicated from which is the case for the regular copy/paste and the
template creation.
However, creating a file is not only about duplicating from another one,
it also can come from creating a folder, that although in the UI it
prevents doing so, it can still be done through the dbus operation.
Fix that by checking whether there is an actual source file, and if not,
use the name provided as base name.
---
src/nautilus-file-operations.c | 36 ++++++++++++++++------------------
1 file changed, 17 insertions(+), 19 deletions(-)
diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c
index 4d84b98be..cf5e7f46b 100644
--- a/src/nautilus-file-operations.c
+++ b/src/nautilus-file-operations.c
@@ -7324,20 +7324,18 @@ retry:
{
g_autofree char *filename2 = NULL;
g_autofree char *suffix = NULL;
- NautilusFile *file;
- file = nautilus_file_get (job->src);
- if (nautilus_file_is_directory (file))
- {
- filename_base = filename;
- }
- else
+ filename_base = filename;
+ if (job->src != NULL)
{
- filename_base = eel_filename_strip_extension (filename);
+ g_autoptr (NautilusFile) file = NULL;
+ file = nautilus_file_get (job->src);
+ if (!nautilus_file_is_directory (file))
+ {
+ filename_base = eel_filename_strip_extension (filename);
+ }
}
- nautilus_file_unref (file);
-
offset = strlen (filename_base);
suffix = g_strdup (filename + offset);
@@ -7377,21 +7375,21 @@ retry:
{
g_autofree char *suffix = NULL;
g_autofree gchar *filename2 = NULL;
- NautilusFile *file;
g_clear_object (&dest);
- file = nautilus_file_get (job->src);
- if (nautilus_file_is_directory (file))
- {
- filename_base = filename;
- }
- else
+ filename_base = filename;
+ if (job->src != NULL)
{
- filename_base = eel_filename_strip_extension (filename);
+ g_autoptr (NautilusFile) file = NULL;
+
+ file = nautilus_file_get (job->src);
+ if (!nautilus_file_is_directory (file))
+ {
+ filename_base = eel_filename_strip_extension (filename);
+ }
}
- nautilus_file_unref (file);
offset = strlen (filename_base);
suffix = g_strdup (filename + offset);
--
2.17.1

View File

@ -0,0 +1,359 @@
From 965a1fb9dcd468b9fc0b87279f3a4a33b6bd635c Mon Sep 17 00:00:00 2001
From: Carlos Soriano <csoriano@redhat.com>
Date: Tue, 7 Aug 2018 12:40:42 +0200
Subject: [PATCH 06/11] properties-window: Keep alive properties window if
called through DBus
The properties window can be used from within Nautilus, and therefore a
dialog window makes sense, or from outside Nautilus, such as the
FileManager dbus free desktop standard.
In the later, used for integration with things like desktop icons
extensions, we need to keep the application alive since GApplication
would close the application if no application window is alive after a
timeout.
To fix this, this work makes the window hint a regular window if used
from those cases.
---
src/nautilus-files-view.c | 6 +-
src/nautilus-freedesktop-dbus.c | 10 ++-
src/nautilus-pathbar.c | 3 +-
src/nautilus-properties-window.c | 106 ++++++++++++++++++++++---------
src/nautilus-properties-window.h | 10 ++-
src/nautilus-window.c | 3 +-
6 files changed, 101 insertions(+), 37 deletions(-)
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 8aff33e25..5395390e7 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -2435,14 +2435,16 @@ action_properties (GSimpleAction *action,
{
files = g_list_append (NULL, nautilus_file_ref (priv->directory_as_file));
- nautilus_properties_window_present (files, GTK_WIDGET (view), NULL);
+ nautilus_properties_window_present (files, GTK_WIDGET (view), NULL,
+ NULL, NULL);
nautilus_file_list_free (files);
}
}
else
{
- nautilus_properties_window_present (selection, GTK_WIDGET (view), NULL);
+ nautilus_properties_window_present (selection, GTK_WIDGET (view), NULL,
+ NULL, NULL);
}
}
diff --git a/src/nautilus-freedesktop-dbus.c b/src/nautilus-freedesktop-dbus.c
index c4657aba3..b88809908 100644
--- a/src/nautilus-freedesktop-dbus.c
+++ b/src/nautilus-freedesktop-dbus.c
@@ -114,6 +114,12 @@ skeleton_handle_show_folders_cb (NautilusFreedesktopFileManager1 *object,
return TRUE;
}
+static void
+properties_window_on_finished (gpointer user_data)
+{
+ g_application_release (g_application_get_default ());
+}
+
static gboolean
skeleton_handle_show_item_properties_cb (NautilusFreedesktopFileManager1 *object,
GDBusMethodInvocation *invocation,
@@ -133,7 +139,9 @@ skeleton_handle_show_item_properties_cb (NautilusFreedesktopFileManager1 *object
files = g_list_reverse (files);
- nautilus_properties_window_present (files, NULL, startup_id);
+ g_application_hold (g_application_get_default ());
+ nautilus_properties_window_present (files, NULL, startup_id,
+ properties_window_on_finished, NULL);
nautilus_file_list_free (files);
diff --git a/src/nautilus-pathbar.c b/src/nautilus-pathbar.c
index 630b8ed33..ea3d2b53f 100644
--- a/src/nautilus-pathbar.c
+++ b/src/nautilus-pathbar.c
@@ -211,7 +211,8 @@ action_pathbar_properties (GSimpleAction *action,
files = g_list_append (NULL, nautilus_file_ref (priv->context_menu_file));
- nautilus_properties_window_present (files, GTK_WIDGET (self), NULL);
+ nautilus_properties_window_present (files, GTK_WIDGET (self), NULL, NULL,
+ NULL);
nautilus_file_list_free (files);
}
diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c
index 8bd335a07..5405435cd 100644
--- a/src/nautilus-properties-window.c
+++ b/src/nautilus-properties-window.c
@@ -152,6 +152,9 @@ typedef struct
char *startup_id;
char *pending_key;
GHashTable *pending_files;
+ NautilusPropertiesWindowCallback callback;
+ gpointer callback_data;
+ NautilusPropertiesWindow *window;
} StartupData;
/* drag and drop definitions */
@@ -197,8 +200,6 @@ static void is_directory_ready_callback (NautilusFile *file,
gpointer data);
static void cancel_group_change_callback (GroupChange *change);
static void cancel_owner_change_callback (OwnerChange *change);
-static void parent_widget_destroyed_callback (GtkWidget *widget,
- gpointer callback_data);
static void select_image_button_callback (GtkWidget *widget,
NautilusPropertiesWindow *properties_window);
static void set_icon (const char *icon_path,
@@ -4811,12 +4812,15 @@ get_pending_key (GList *file_list)
}
static StartupData *
-startup_data_new (GList *original_files,
- GList *target_files,
- const char *pending_key,
- GtkWidget *parent_widget,
- GtkWindow *parent_window,
- const char *startup_id)
+startup_data_new (GList *original_files,
+ GList *target_files,
+ const char *pending_key,
+ GtkWidget *parent_widget,
+ GtkWindow *parent_window,
+ const char *startup_id,
+ NautilusPropertiesWindowCallback callback,
+ gpointer callback_data,
+ NautilusPropertiesWindow *window)
{
StartupData *data;
GList *l;
@@ -4830,6 +4834,9 @@ startup_data_new (GList *original_files,
data->pending_key = g_strdup (pending_key);
data->pending_files = g_hash_table_new (g_direct_hash,
g_direct_equal);
+ data->callback = callback;
+ data->callback_data = callback_data;
+ data->window = window;
for (l = data->target_files; l != NULL; l = l->next)
{
@@ -5149,7 +5156,7 @@ remove_window (NautilusPropertiesWindow *window)
}
}
-static GtkWindow *
+static NautilusPropertiesWindow *
get_existing_window (GList *file_list)
{
if (!file_list->next)
@@ -5160,10 +5167,28 @@ get_existing_window (GList *file_list)
return NULL;
}
+static void
+properties_window_finish (StartupData *data)
+{
+ if (data->parent_widget != NULL)
+ {
+ g_signal_handlers_disconnect_by_data (data->parent_widget,
+ data);
+ }
+ if (data->window != NULL)
+ {
+ g_signal_handlers_disconnect_by_data (data->window,
+ data);
+ }
+
+ remove_pending (data, TRUE, TRUE, FALSE);
+ startup_data_free (data);
+}
+
static void
cancel_create_properties_window_callback (gpointer callback_data)
{
- remove_pending ((StartupData *) callback_data, TRUE, FALSE, TRUE);
+ properties_window_finish ((StartupData *) callback_data);
}
static void
@@ -5172,7 +5197,7 @@ parent_widget_destroyed_callback (GtkWidget *widget,
{
g_assert (widget == ((StartupData *) callback_data)->parent_widget);
- remove_pending ((StartupData *) callback_data, TRUE, TRUE, FALSE);
+ properties_window_finish ((StartupData *) callback_data);
}
static void
@@ -5203,16 +5228,24 @@ remove_pending (StartupData *startup_data,
eel_timed_wait_stop
(cancel_create_properties_window_callback, startup_data);
}
- if (cancel_destroy_handler && startup_data->parent_widget)
+ g_hash_table_remove (pending_lists, startup_data->pending_key);
+}
+
+static gboolean
+widget_on_destroy (GtkWidget *widget,
+ gpointer user_data)
+{
+ StartupData *data = (StartupData *) user_data;
+
+
+ if (data->callback != NULL)
{
- g_signal_handlers_disconnect_by_func (startup_data->parent_widget,
- G_CALLBACK (parent_widget_destroyed_callback),
- startup_data);
+ data->callback (data->callback_data);
}
- g_hash_table_remove (pending_lists, startup_data->pending_key);
+ properties_window_finish (data);
- startup_data_free (startup_data);
+ return GDK_EVENT_PROPAGATE;
}
static void
@@ -5232,29 +5265,34 @@ is_directory_ready_callback (NautilusFile *file,
new_window = create_properties_window (startup_data);
add_window (new_window);
+ startup_data->window = new_window;
remove_pending (startup_data, FALSE, TRUE, TRUE);
gtk_window_present (GTK_WINDOW (new_window));
+ g_signal_connect(GTK_WIDGET (new_window), "destroy",
+ G_CALLBACK (widget_on_destroy), startup_data);
}
}
-
void
-nautilus_properties_window_present (GList *original_files,
- GtkWidget *parent_widget,
- const gchar *startup_id)
+nautilus_properties_window_present (GList *original_files,
+ GtkWidget *parent_widget,
+ const gchar *startup_id,
+ NautilusPropertiesWindowCallback callback,
+ gpointer callback_data)
{
GList *l, *next;
- GtkWidget *parent_window;
+ GtkWindow *parent_window;
StartupData *startup_data;
GList *target_files;
- GtkWindow *existing_window;
+ NautilusPropertiesWindow *existing_window;
char *pending_key;
g_return_if_fail (original_files != NULL);
g_return_if_fail (parent_widget == NULL || GTK_IS_WIDGET (parent_widget));
+
/* Create the hash tables first time through. */
if (windows == NULL)
{
@@ -5272,15 +5310,19 @@ nautilus_properties_window_present (GList *original_files,
{
if (parent_widget)
{
- gtk_window_set_screen (existing_window,
+ gtk_window_set_screen (GTK_WINDOW (existing_window),
gtk_widget_get_screen (parent_widget));
}
else if (startup_id)
{
- gtk_window_set_startup_id (existing_window, startup_id);
+ gtk_window_set_startup_id (GTK_WINDOW (existing_window), startup_id);
}
- gtk_window_present (existing_window);
+ gtk_window_present (GTK_WINDOW (existing_window));
+ startup_data = startup_data_new (NULL, NULL, NULL, NULL, NULL, NULL,
+ callback, callback_data, existing_window);
+ g_signal_connect(GTK_WIDGET (existing_window), "destroy",
+ G_CALLBACK (widget_on_destroy), startup_data);
return;
}
@@ -5290,6 +5332,9 @@ nautilus_properties_window_present (GList *original_files,
/* Look to see if we're already waiting for a window for this file. */
if (g_hash_table_lookup (pending_lists, pending_key) != NULL)
{
+ /* FIXME: No callback is done if this happen. In practice, it's a quite
+ * corner case
+ */
return;
}
@@ -5297,7 +5342,7 @@ nautilus_properties_window_present (GList *original_files,
if (parent_widget)
{
- parent_window = gtk_widget_get_ancestor (parent_widget, GTK_TYPE_WINDOW);
+ parent_window = GTK_WINDOW (gtk_widget_get_ancestor (parent_widget, GTK_TYPE_WINDOW));
}
else
{
@@ -5308,8 +5353,11 @@ nautilus_properties_window_present (GList *original_files,
target_files,
pending_key,
parent_widget,
- GTK_WINDOW (parent_window),
- startup_id);
+ parent_window,
+ startup_id,
+ callback,
+ callback_data,
+ NULL);
nautilus_file_list_free (target_files);
g_free (pending_key);
diff --git a/src/nautilus-properties-window.h b/src/nautilus-properties-window.h
index 9eff54c4e..e8d6a90e9 100644
--- a/src/nautilus-properties-window.h
+++ b/src/nautilus-properties-window.h
@@ -59,8 +59,12 @@ typedef struct NautilusPropertiesWindowClass NautilusPropertiesWindowClass;
GType nautilus_properties_window_get_type (void);
-void nautilus_properties_window_present (GList *files,
- GtkWidget *parent_widget,
- const gchar *startup_id);
+typedef void (* NautilusPropertiesWindowCallback) (gpointer callback_data);
+
+void nautilus_properties_window_present (GList *files,
+ GtkWidget *parent_widget,
+ const gchar *startup_id,
+ NautilusPropertiesWindowCallback callback,
+ gpointer callback_data);
#endif /* NAUTILUS_PROPERTIES_WINDOW_H */
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 41c4623be..a6ee4d489 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -1309,7 +1309,8 @@ action_properties (GSimpleAction *action,
file = nautilus_file_get (priv->selected_file);
list = g_list_append (NULL, file);
- nautilus_properties_window_present (list, GTK_WIDGET (window), NULL);
+ nautilus_properties_window_present (list, GTK_WIDGET (window), NULL, NULL,
+ NULL);
nautilus_file_list_free (list);
g_clear_object (&priv->selected_file);
--
2.17.1

View File

@ -0,0 +1,149 @@
From 80b807d9e52fdc3e5e0af5a2d4dd61fdb0a39bc8 Mon Sep 17 00:00:00 2001
From: Carlos Soriano <csoriano@redhat.com>
Date: Tue, 7 Aug 2018 21:08:21 +0200
Subject: [PATCH 07/11] dbus-manager: Keep application alive for operations
Operations started from Nautilus windows have the persistence handler,
however, when not using windows like when invoked through DBus the
application could die after a timeout.
This would stop the operation in the middle of its process, with
possible data loss.
Make sure we keep the application alive while this is happening.
---
src/nautilus-dbus-manager.c | 55 +++++++++++++++++++++++++++++++++++--
1 file changed, 52 insertions(+), 3 deletions(-)
diff --git a/src/nautilus-dbus-manager.c b/src/nautilus-dbus-manager.c
index 8135c9650..0d5137292 100644
--- a/src/nautilus-dbus-manager.c
+++ b/src/nautilus-dbus-manager.c
@@ -95,13 +95,29 @@ handle_copy_file (NautilusDBusFileOperations *object,
return TRUE; /* invocation was handled */
}
+static void
+undo_redo_on_finished (gpointer user_data)
+{
+ g_autoptr (NautilusFileUndoManager) undo_manager = NULL;
+ int *handler_id = (int *) user_data;
+
+ undo_manager = nautilus_file_undo_manager_get ();
+ g_signal_handler_disconnect (undo_manager, *handler_id);
+ g_application_release (g_application_get_default ());
+ g_free (handler_id);
+}
+
static gboolean
handle_redo (NautilusDBusFileOperations *object,
GDBusMethodInvocation *invocation)
{
g_autoptr (NautilusFileUndoManager) undo_manager = NULL;
+ gint *handler_id = g_new0(int, 1);
undo_manager = nautilus_file_undo_manager_get ();
+ *handler_id = g_signal_connect_swapped (undo_manager, "undo-changed",
+ G_CALLBACK (undo_redo_on_finished),
+ handler_id);
nautilus_file_undo_manager_redo (NULL);
nautilus_dbus_file_operations_complete_redo (object, invocation);
@@ -113,14 +129,26 @@ handle_undo (NautilusDBusFileOperations *object,
GDBusMethodInvocation *invocation)
{
g_autoptr (NautilusFileUndoManager) undo_manager = NULL;
+ gint *handler_id = g_new0(int, 1);
undo_manager = nautilus_file_undo_manager_get ();
+ *handler_id = g_signal_connect_swapped (undo_manager, "undo-changed",
+ G_CALLBACK (undo_redo_on_finished),
+ handler_id);
nautilus_file_undo_manager_undo (NULL);
nautilus_dbus_file_operations_complete_undo (object, invocation);
return TRUE; /* invocation was handled */
}
+static void
+create_folder_on_finished (GFile *new_file,
+ gboolean success,
+ gpointer callback_data)
+{
+ g_application_release (g_application_get_default ());
+}
+
static gboolean
handle_create_folder (NautilusDBusFileOperations *object,
GDBusMethodInvocation *invocation,
@@ -136,13 +164,22 @@ handle_create_folder (NautilusDBusFileOperations *object,
parent_file = g_file_get_parent (file);
parent_file_uri = g_file_get_uri (parent_file);
+ g_application_hold (g_application_get_default ());
nautilus_file_operations_new_folder (NULL, parent_file_uri, basename,
- NULL, NULL);
+ create_folder_on_finished, NULL);
nautilus_dbus_file_operations_complete_create_folder (object, invocation);
return TRUE; /* invocation was handled */
}
+static void
+copy_on_finished (GHashTable *debutting_uris,
+ gboolean success,
+ gpointer callback_data)
+{
+ g_application_release (g_application_get_default ());
+}
+
static gboolean
handle_copy_uris (NautilusDBusFileOperations *object,
GDBusMethodInvocation *invocation,
@@ -157,14 +194,16 @@ handle_copy_uris (NautilusDBusFileOperations *object,
source_files = g_list_prepend (source_files, g_strdup (sources[idx]));
}
+ g_application_hold (g_application_get_default ());
nautilus_file_operations_copy_move (source_files, destination,
- GDK_ACTION_COPY, NULL, NULL, NULL);
+ GDK_ACTION_COPY, NULL, copy_on_finished, NULL);
g_list_free_full (source_files, g_free);
nautilus_dbus_file_operations_complete_copy_uris (object, invocation);
return TRUE; /* invocation was handled */
}
+/* FIXME: Needs a callback for maintaining alive the application */
static gboolean
handle_empty_trash (NautilusDBusFileOperations *object,
GDBusMethodInvocation *invocation)
@@ -175,6 +214,14 @@ handle_empty_trash (NautilusDBusFileOperations *object,
return TRUE; /* invocation was handled */
}
+static void
+trash_on_finished (GHashTable *debutting_uris,
+ gboolean user_cancel,
+ gpointer callback_data)
+{
+ g_application_release (g_application_get_default ());
+}
+
static gboolean
handle_trash_files (NautilusDBusFileOperations *object,
GDBusMethodInvocation *invocation,
@@ -189,7 +236,9 @@ handle_trash_files (NautilusDBusFileOperations *object,
g_file_new_for_uri (sources[idx]));
}
- nautilus_file_operations_trash_or_delete (source_files, NULL, NULL, NULL);
+ g_application_hold (g_application_get_default ());
+ nautilus_file_operations_trash_or_delete (source_files, NULL,
+ trash_on_finished, NULL);
nautilus_dbus_file_operations_complete_trash_files (object, invocation);
return TRUE; /* invocation was handled */
--
2.17.1

View File

@ -0,0 +1,209 @@
From 474ed07f64df1381440b8692d7d500d26014c618 Mon Sep 17 00:00:00 2001
From: Carlos Soriano <csoriano@redhat.com>
Date: Tue, 7 Aug 2018 21:25:01 +0200
Subject: [PATCH 08/11] dbus-manager: Drop copy file operation
It was truly unreliable and not working clearly. We have a more powerful
and simpler API with CopyURIs, so there is no point to have this one.
This commits drops the DBus API. Note that the DBus version is not
bumped, I believe this DBus API is not used by any external service
given how broken was it.
---
data/dbus-interfaces.xml | 6 ---
src/nautilus-dbus-manager.c | 69 ++++++++++++++--------------------
src/nautilus-file-operations.c | 41 --------------------
src/nautilus-file-operations.h | 7 ----
4 files changed, 29 insertions(+), 94 deletions(-)
diff --git a/data/dbus-interfaces.xml b/data/dbus-interfaces.xml
index 2133bb99c..20ffadde1 100644
--- a/data/dbus-interfaces.xml
+++ b/data/dbus-interfaces.xml
@@ -29,12 +29,6 @@
</method>
<method name='EmptyTrash'>
</method>"
- <method name='CopyFile'>
- <arg type='s' name='SourceFileURI' direction='in'/>
- <arg type='s' name='SourceDisplayName' direction='in'/>
- <arg type='s' name='DestinationDirectoryURI' direction='in'/>
- <arg type='s' name='DestinationDisplayName' direction='in'/>
- </method>
<method name='TrashFiles'>
<arg type='as' name='URIs' direction='in'/>
</method>
diff --git a/src/nautilus-dbus-manager.c b/src/nautilus-dbus-manager.c
index 0d5137292..1ac6e12c2 100644
--- a/src/nautilus-dbus-manager.c
+++ b/src/nautilus-dbus-manager.c
@@ -61,40 +61,6 @@ nautilus_dbus_manager_dispose (GObject *object)
G_OBJECT_CLASS (nautilus_dbus_manager_parent_class)->dispose (object);
}
-static gboolean
-handle_copy_file (NautilusDBusFileOperations *object,
- GDBusMethodInvocation *invocation,
- const gchar *source_uri,
- const gchar *source_display_name,
- const gchar *dest_dir_uri,
- const gchar *dest_name)
-{
- GFile *source_file, *target_dir;
- const gchar *target_name = NULL, *source_name = NULL;
-
- source_file = g_file_new_for_uri (source_uri);
- target_dir = g_file_new_for_uri (dest_dir_uri);
-
- if (dest_name != NULL && dest_name[0] != '\0')
- {
- target_name = dest_name;
- }
-
- if (source_display_name != NULL && source_display_name[0] != '\0')
- {
- source_name = source_display_name;
- }
-
- nautilus_file_operations_copy_file (source_file, target_dir, source_name, target_name,
- NULL, NULL, NULL);
-
- g_object_unref (source_file);
- g_object_unref (target_dir);
-
- nautilus_dbus_file_operations_complete_copy_file (object, invocation);
- return TRUE; /* invocation was handled */
-}
-
static void
undo_redo_on_finished (gpointer user_data)
{
@@ -173,9 +139,9 @@ handle_create_folder (NautilusDBusFileOperations *object,
}
static void
-copy_on_finished (GHashTable *debutting_uris,
- gboolean success,
- gpointer callback_data)
+copy_move_on_finished (GHashTable *debutting_uris,
+ gboolean success,
+ gpointer callback_data)
{
g_application_release (g_application_get_default ());
}
@@ -196,7 +162,30 @@ handle_copy_uris (NautilusDBusFileOperations *object,
g_application_hold (g_application_get_default ());
nautilus_file_operations_copy_move (source_files, destination,
- GDK_ACTION_COPY, NULL, copy_on_finished, NULL);
+ GDK_ACTION_COPY, NULL, copy_move_on_finished, NULL);
+
+ g_list_free_full (source_files, g_free);
+ nautilus_dbus_file_operations_complete_copy_uris (object, invocation);
+ return TRUE; /* invocation was handled */
+}
+
+static gboolean
+handle_move_uris (NautilusDBusFileOperations *object,
+ GDBusMethodInvocation *invocation,
+ const gchar **sources,
+ const gchar *destination)
+{
+ GList *source_files = NULL;
+ gint idx;
+
+ for (idx = 0; sources[idx] != NULL; idx++)
+ {
+ source_files = g_list_prepend (source_files, g_strdup (sources[idx]));
+ }
+
+ g_application_hold (g_application_get_default ());
+ nautilus_file_operations_copy_move (source_files, destination,
+ GDK_ACTION_MOVE, NULL, copy_move_on_finished, NULL);
g_list_free_full (source_files, g_free);
nautilus_dbus_file_operations_complete_copy_uris (object, invocation);
@@ -254,8 +243,8 @@ nautilus_dbus_manager_init (NautilusDBusManager *self)
G_CALLBACK (handle_copy_uris),
self);
g_signal_connect (self->file_operations,
- "handle-copy-file",
- G_CALLBACK (handle_copy_file),
+ "handle-move-uris",
+ G_CALLBACK (handle_move_uris),
self);
g_signal_connect (self->file_operations,
"handle-empty-trash",
diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c
index cf5e7f46b..e306e7eff 100644
--- a/src/nautilus-file-operations.c
+++ b/src/nautilus-file-operations.c
@@ -5705,47 +5705,6 @@ copy_task_thread_func (GTask *task,
&source_info, &transfer_info);
}
-void
-nautilus_file_operations_copy_file (GFile *source_file,
- GFile *target_dir,
- const gchar *source_display_name,
- const gchar *new_name,
- GtkWindow *parent_window,
- NautilusCopyCallback done_callback,
- gpointer done_callback_data)
-{
- GTask *task;
- CopyMoveJob *job;
-
- job = op_job_new (CopyMoveJob, parent_window);
- job->done_callback = done_callback;
- job->done_callback_data = done_callback_data;
- job->files = g_list_append (NULL, g_object_ref (source_file));
- job->destination = g_object_ref (target_dir);
- /* Need to indicate the destination for the operation notification open
- * button. */
- nautilus_progress_info_set_destination (((CommonJob *) job)->progress, target_dir);
- job->target_name = g_strdup (new_name);
- job->debuting_files = g_hash_table_new_full (g_file_hash, (GEqualFunc) g_file_equal, g_object_unref, NULL);
-
- if (source_display_name != NULL)
- {
- gchar *path;
-
- path = g_build_filename ("/", source_display_name, NULL);
- job->fake_display_source = g_file_new_for_path (path);
-
- g_free (path);
- }
-
- inhibit_power_manager ((CommonJob *) job, _("Copying Files"));
-
- task = g_task_new (NULL, job->common.cancellable, copy_task_done, job);
- g_task_set_task_data (task, job, NULL);
- g_task_run_in_thread (task, copy_task_thread_func);
- g_object_unref (task);
-}
-
void
nautilus_file_operations_copy (GList *files,
GFile *target_dir,
diff --git a/src/nautilus-file-operations.h b/src/nautilus-file-operations.h
index e8c6ed393..2a9c6a6a0 100644
--- a/src/nautilus-file-operations.h
+++ b/src/nautilus-file-operations.h
@@ -57,13 +57,6 @@ void nautilus_file_operations_copy_move (const GList *item_uris,
GtkWidget *parent_view,
NautilusCopyCallback done_callback,
gpointer done_callback_data);
-void nautilus_file_operations_copy_file (GFile *source_file,
- GFile *target_dir,
- const gchar *source_display_name,
- const gchar *new_name,
- GtkWindow *parent_window,
- NautilusCopyCallback done_callback,
- gpointer done_callback_data);
void nautilus_file_operations_empty_trash (GtkWidget *parent_view);
void nautilus_file_operations_new_folder (GtkWidget *parent_view,
const char *parent_dir_uri,
--
2.17.1

View File

@ -0,0 +1,28 @@
From 60ba10283b631f08bd7e763a63a1a8e048b66379 Mon Sep 17 00:00:00 2001
From: Carlos Soriano <csoriano@gnome.org>
Date: Wed, 8 Aug 2018 14:07:48 +0200
Subject: [PATCH 09/11] dbus: Implement move operation
Analog to the copy operation.
---
data/dbus-interfaces.xml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/data/dbus-interfaces.xml b/data/dbus-interfaces.xml
index 20ffadde1..64176225c 100644
--- a/data/dbus-interfaces.xml
+++ b/data/dbus-interfaces.xml
@@ -27,6 +27,10 @@
<arg type='as' name='SourceFilesURIList' direction='in'/>
<arg type='s' name='DestinationDirectoryURI' direction='in'/>
</method>
+ <method name='MoveURIs'>
+ <arg type='as' name='SourceFilesURIList' direction='in'/>
+ <arg type='s' name='DestinationDirectoryURI' direction='in'/>
+ </method>
<method name='EmptyTrash'>
</method>"
<method name='TrashFiles'>
--
2.17.1

View File

@ -0,0 +1,45 @@
From 7cea30b7357cf246cbab67e895c90ebb5cc6a772 Mon Sep 17 00:00:00 2001
From: Carlos Soriano <csoriano@gnome.org>
Date: Wed, 8 Aug 2018 14:32:00 +0200
Subject: [PATCH 10/11] dbus-manager: Fix double free
nautilus_undo_manager_get doesn't return a new reference, so we
shouldn't use g_autoptr.
---
src/nautilus-dbus-manager.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/nautilus-dbus-manager.c b/src/nautilus-dbus-manager.c
index 1ac6e12c2..728b1dea2 100644
--- a/src/nautilus-dbus-manager.c
+++ b/src/nautilus-dbus-manager.c
@@ -64,7 +64,7 @@ nautilus_dbus_manager_dispose (GObject *object)
static void
undo_redo_on_finished (gpointer user_data)
{
- g_autoptr (NautilusFileUndoManager) undo_manager = NULL;
+ NautilusFileUndoManager *undo_manager = NULL;
int *handler_id = (int *) user_data;
undo_manager = nautilus_file_undo_manager_get ();
@@ -77,7 +77,7 @@ static gboolean
handle_redo (NautilusDBusFileOperations *object,
GDBusMethodInvocation *invocation)
{
- g_autoptr (NautilusFileUndoManager) undo_manager = NULL;
+ NautilusFileUndoManager *undo_manager = NULL;
gint *handler_id = g_new0(int, 1);
undo_manager = nautilus_file_undo_manager_get ();
@@ -94,7 +94,7 @@ static gboolean
handle_undo (NautilusDBusFileOperations *object,
GDBusMethodInvocation *invocation)
{
- g_autoptr (NautilusFileUndoManager) undo_manager = NULL;
+ NautilusFileUndoManager *undo_manager = NULL;
gint *handler_id = g_new0(int, 1);
undo_manager = nautilus_file_undo_manager_get ();
--
2.17.1

View File

@ -0,0 +1,36 @@
From 12fa036ee7689774cfdf941ae7fda04d18d34ae8 Mon Sep 17 00:00:00 2001
From: Carlos Soriano <csoriano@gnome.org>
Date: Wed, 8 Aug 2018 14:32:56 +0200
Subject: [PATCH 11/11] dbus-manager: Fix not holding application
The code was releasing it on the callback but forgot to put the hold
on the initial call.
---
src/nautilus-dbus-manager.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/nautilus-dbus-manager.c b/src/nautilus-dbus-manager.c
index 728b1dea2..f11ede0ad 100644
--- a/src/nautilus-dbus-manager.c
+++ b/src/nautilus-dbus-manager.c
@@ -80,6 +80,8 @@ handle_redo (NautilusDBusFileOperations *object,
NautilusFileUndoManager *undo_manager = NULL;
gint *handler_id = g_new0(int, 1);
+ g_application_hold (g_application_get_default ());
+
undo_manager = nautilus_file_undo_manager_get ();
*handler_id = g_signal_connect_swapped (undo_manager, "undo-changed",
G_CALLBACK (undo_redo_on_finished),
@@ -97,6 +99,8 @@ handle_undo (NautilusDBusFileOperations *object,
NautilusFileUndoManager *undo_manager = NULL;
gint *handler_id = g_new0(int, 1);
+ g_application_hold (g_application_get_default ());
+
undo_manager = nautilus_file_undo_manager_get ();
*handler_id = g_signal_connect_swapped (undo_manager, "undo-changed",
G_CALLBACK (undo_redo_on_finished),
--
2.17.1

View File

@ -0,0 +1,552 @@
From 228971be31f92625f641531e1b78b8c8e63677b0 Mon Sep 17 00:00:00 2001
From: Carlos Soriano <csoriano@redhat.com>
Date: Tue, 31 Jul 2018 22:10:03 +0200
Subject: [PATCH] clipboard: Use text based clipboard only
---
src/nautilus-canvas-view.c | 13 ++++++-------
src/nautilus-clipboard.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------------------------------------------
src/nautilus-clipboard.h | 5 +++--
src/nautilus-files-view.c | 112 +++++++++++++++++++++++++++++++++-------------------------------------------------------------------------------
src/nautilus-list-view.c | 13 ++++++-------
5 files changed, 102 insertions(+), 154 deletions(-)
diff --git a/src/nautilus-canvas-view.c b/src/nautilus-canvas-view.c
index f99ddd9..7de0808 100644
--- a/src/nautilus-canvas-view.c
+++ b/src/nautilus-canvas-view.c
@@ -549,9 +549,9 @@ nautilus_canvas_view_begin_loading (NautilusFilesView *view)
}
static void
-on_clipboard_contents_received (GtkClipboard *clipboard,
- GtkSelectionData *selection_data,
- gpointer user_data)
+on_clipboard_contents_received (GtkClipboard *clipboard,
+ const gchar *selection_data,
+ gpointer user_data)
{
NautilusCanvasView *canvas_view;
@@ -590,10 +590,9 @@ static void
update_clipboard_status (NautilusCanvasView *view)
{
g_object_ref (view); /* Need to keep the object alive until we get the reply */
- gtk_clipboard_request_contents (nautilus_clipboard_get (GTK_WIDGET (view)),
- nautilus_clipboard_get_atom (),
- on_clipboard_contents_received,
- view);
+ gtk_clipboard_request_text (nautilus_clipboard_get (GTK_WIDGET (view)),
+ on_clipboard_contents_received,
+ view);
}
static void
diff --git a/src/nautilus-clipboard.c b/src/nautilus-clipboard.c
index 267d7a3..752ff13 100644
--- a/src/nautilus-clipboard.c
+++ b/src/nautilus-clipboard.c
@@ -33,30 +33,32 @@
#include <gtk/gtk.h>
#include <string.h>
-static GdkAtom copied_files_atom;
-
typedef struct
{
gboolean cut;
GList *files;
} ClipboardInfo;
static GList *
-convert_lines_to_str_list (char **lines)
+convert_selection_data_to_str_list (const gchar *data)
{
int i;
GList *result;
+ size_t number_of_lines;
+ gchar **lines;
- if (lines[0] == NULL)
- {
- return NULL;
- }
-
+ lines = g_strsplit (data, "\n", 0);
result = NULL;
- for (i = 0; lines[i] != NULL; i++)
+ number_of_lines = g_strv_length (lines);
+ /* Also, this skips the last line, since it would be an
+ * empty string from the split */
+ for (i = 0; i < number_of_lines - 1; i++)
{
result = g_list_prepend (result, g_strdup (lines[i]));
}
+
+ g_strfreev (lines);
+
return g_list_reverse (result);
}
@@ -77,7 +79,8 @@ convert_file_list_to_string (ClipboardInfo *info,
}
else
{
- uris = g_string_new (info->cut ? "cut" : "copy");
+ uris = g_string_new ("x-special/nautilus-clipboard\n");
+ g_string_append (uris, info->cut ? "cut\n" : "copy\n");
}
for (i = 0, l = info->files; l != NULL; l = l->next, i++)
@@ -100,16 +103,12 @@ convert_file_list_to_string (ClipboardInfo *info,
g_string_append (uris, uri);
}
- /* skip newline for last element */
- if (i + 1 < g_list_length (info->files))
- {
- g_string_append_c (uris, '\n');
- }
+ g_string_append_c (uris, '\n');
}
else
{
- g_string_append_c (uris, '\n');
g_string_append (uris, uri);
+ g_string_append_c (uris, '\n');
}
g_free (uri);
@@ -120,43 +119,60 @@ convert_file_list_to_string (ClipboardInfo *info,
}
static GList *
-get_item_list_from_selection_data (GtkSelectionData *selection_data)
+get_item_list_from_selection_data (const gchar *selection_data)
{
- GList *items;
- char **lines;
+ GList *items = NULL;
- if (gtk_selection_data_get_data_type (selection_data) != copied_files_atom
- || gtk_selection_data_get_length (selection_data) <= 0)
+ if (selection_data != NULL)
{
- items = NULL;
- }
- else
- {
- gchar *data;
+ gboolean valid_data = TRUE;
/* Not sure why it's legal to assume there's an extra byte
* past the end of the selection data that it's safe to write
* to. But gtk_editable_selection_received does this, so I
* think it is OK.
*/
- data = (gchar *) gtk_selection_data_get_data (selection_data);
- data[gtk_selection_data_get_length (selection_data)] = '\0';
- lines = g_strsplit (data, "\n", 0);
- items = convert_lines_to_str_list (lines);
- g_strfreev (lines);
+ items = convert_selection_data_to_str_list (selection_data);
+ if (items == NULL || g_strcmp0 (items->data, "x-special/nautilus-clipboard") != 0)
+ {
+ valid_data = FALSE;
+ }
+ else if (items->next == NULL)
+ {
+ valid_data = FALSE;
+ }
+ else if (g_strcmp0 (items->next->data, "cut") != 0 &&
+ g_strcmp0 (items->next->data, "copy") != 0)
+ {
+ valid_data = FALSE;
+ }
+
+ if (!valid_data)
+ {
+ g_list_free_full (items, g_free);
+ items = NULL;
+ }
}
return items;
}
+gboolean
+nautilus_clipboard_is_data_valid_from_selection_data (const gchar *selection_data)
+{
+ return nautilus_clipboard_get_uri_list_from_selection_data (selection_data) != NULL;
+}
+
GList *
-nautilus_clipboard_get_uri_list_from_selection_data (GtkSelectionData *selection_data)
+nautilus_clipboard_get_uri_list_from_selection_data (const gchar *selection_data)
{
GList *items;
items = get_item_list_from_selection_data (selection_data);
if (items)
{
- /* Line 0 is "cut" or "copy", so uris start at line 1. */
+ /* Line 0 is x-special/nautilus-clipboard. */
+ items = g_list_remove (items, items->data);
+ /* Line 1 is "cut" or "copy", so uris start at line 2. */
items = g_list_remove (items, items->data);
}
@@ -174,13 +190,12 @@ void
nautilus_clipboard_clear_if_colliding_uris (GtkWidget *widget,
const GList *item_uris)
{
- GtkSelectionData *data;
+ g_autofree gchar *data = NULL;
GList *clipboard_item_uris, *l;
gboolean collision;
collision = FALSE;
- data = gtk_clipboard_wait_for_contents (nautilus_clipboard_get (widget),
- copied_files_atom);
+ data = gtk_clipboard_wait_for_text (nautilus_clipboard_get (widget));
if (data == NULL)
{
return;
@@ -210,14 +225,14 @@ nautilus_clipboard_clear_if_colliding_uris (GtkWidget *widget,
}
gboolean
-nautilus_clipboard_is_cut_from_selection_data (GtkSelectionData *selection_data)
+nautilus_clipboard_is_cut_from_selection_data (const gchar *selection_data)
{
GList *items;
gboolean is_cut_from_selection_data;
items = get_item_list_from_selection_data (selection_data);
is_cut_from_selection_data = items != NULL &&
- g_strcmp0 ((gchar *) items->data, "cut") == 0;
+ g_strcmp0 ((gchar *) items->next->data, "cut") == 0;
g_list_free_full (items, g_free);
@@ -262,17 +277,8 @@ on_get_clipboard (GtkClipboard *clipboard,
char *str;
gsize len;
- str = convert_file_list_to_string (clipboard_info, TRUE, &len);
- gtk_selection_data_set_text (selection_data, str, len);
- g_free (str);
- }
- else if (target == copied_files_atom)
- {
- char *str;
- gsize len;
-
str = convert_file_list_to_string (clipboard_info, FALSE, &len);
- gtk_selection_data_set (selection_data, copied_files_atom, 8, (guchar *) str, len);
+ gtk_selection_data_set_text (selection_data, str, len);
g_free (str);
}
}
@@ -303,7 +309,6 @@ nautilus_clipboard_prepare_for_files (GtkClipboard *clipboard,
clipboard_info->files = nautilus_file_list_copy (files);
target_list = gtk_target_list_new (NULL, 0);
- gtk_target_list_add (target_list, copied_files_atom, 0, 0);
gtk_target_list_add_uri_targets (target_list, 0);
gtk_target_list_add_text_targets (target_list, 0);
@@ -317,13 +322,3 @@ nautilus_clipboard_prepare_for_files (GtkClipboard *clipboard,
gtk_target_table_free (targets, n_targets);
}
-GdkAtom
-nautilus_clipboard_get_atom (void)
-{
- if (!copied_files_atom)
- {
- copied_files_atom = gdk_atom_intern_static_string ("x-special/gnome-copied-files");
- }
-
- return copied_files_atom;
-}
diff --git a/src/nautilus-clipboard.h b/src/nautilus-clipboard.h
index 613e983..3be19c9 100644
--- a/src/nautilus-clipboard.h
+++ b/src/nautilus-clipboard.h
@@ -28,11 +28,12 @@
void nautilus_clipboard_clear_if_colliding_uris (GtkWidget *widget,
const GList *item_uris);
GtkClipboard* nautilus_clipboard_get (GtkWidget *widget);
-GList* nautilus_clipboard_get_uri_list_from_selection_data (GtkSelectionData *selection_data);
-gboolean nautilus_clipboard_is_cut_from_selection_data (GtkSelectionData *selection_data);
+GList* nautilus_clipboard_get_uri_list_from_selection_data (const gchar *selection_data);
+gboolean nautilus_clipboard_is_cut_from_selection_data (const gchar *selection_data);
void nautilus_clipboard_prepare_for_files (GtkClipboard *clipboard,
GList *files,
gboolean cut);
GdkAtom nautilus_clipboard_get_atom (void);
+gboolean nautilus_clipboard_is_data_valid_from_selection_data (const gchar *selection_data);
#endif /* NAUTILUS_CLIPBOARD_H */
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 8aff33e..a74b691 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -2551,7 +2551,7 @@ action_open_item_new_window (GSimpleAction *action,
static void
handle_clipboard_data (NautilusFilesView *view,
- GtkSelectionData *selection_data,
+ const gchar *selection_data,
char *destination_uri,
GdkDragAction action)
{
@@ -2576,7 +2576,7 @@ handle_clipboard_data (NautilusFilesView *view,
static void
paste_clipboard_data (NautilusFilesView *view,
- GtkSelectionData *selection_data,
+ const gchar *selection_data,
char *destination_uri)
{
GdkDragAction action;
@@ -2594,9 +2594,9 @@ paste_clipboard_data (NautilusFilesView *view,
}
static void
-paste_clipboard_received_callback (GtkClipboard *clipboard,
- GtkSelectionData *selection_data,
- gpointer data)
+paste_clipboard_text_received_callback (GtkClipboard *clipboard,
+ const gchar *selection_data,
+ gpointer data)
{
NautilusFilesView *view;
NautilusFilesViewPrivate *priv;
@@ -2629,16 +2629,15 @@ action_paste_files (GSimpleAction *action,
view = NAUTILUS_FILES_VIEW (user_data);
g_object_ref (view);
- gtk_clipboard_request_contents (nautilus_clipboard_get (GTK_WIDGET (view)),
- nautilus_clipboard_get_atom (),
- paste_clipboard_received_callback,
- view);
+ gtk_clipboard_request_text (nautilus_clipboard_get (GTK_WIDGET (view)),
+ paste_clipboard_text_received_callback,
+ view);
}
static void
-create_links_clipboard_received_callback (GtkClipboard *clipboard,
- GtkSelectionData *selection_data,
- gpointer data)
+create_links_clipboard_received_callback (GtkClipboard *clipboard,
+ const gchar *selection_data,
+ gpointer data)
{
NautilusFilesView *view;
NautilusFilesViewPrivate *priv;
@@ -2671,10 +2670,9 @@ action_create_links (GSimpleAction *action,
view = NAUTILUS_FILES_VIEW (user_data);
g_object_ref (view);
- gtk_clipboard_request_contents (nautilus_clipboard_get (GTK_WIDGET (view)),
- nautilus_clipboard_get_atom (),
- create_links_clipboard_received_callback,
- view);
+ gtk_clipboard_request_text (nautilus_clipboard_get (GTK_WIDGET (view)),
+ create_links_clipboard_received_callback,
+ view);
}
static void
@@ -6016,9 +6014,9 @@ typedef struct
} PasteIntoData;
static void
-paste_into_clipboard_received_callback (GtkClipboard *clipboard,
- GtkSelectionData *selection_data,
- gpointer callback_data)
+paste_into_clipboard_received_callback (GtkClipboard *clipboard,
+ const gchar *selection_data,
+ gpointer callback_data)
{
NautilusFilesViewPrivate *priv;
PasteIntoData *data;
@@ -6058,10 +6056,9 @@ paste_into (NautilusFilesView *view,
data->view = g_object_ref (view);
data->target = nautilus_file_ref (target);
- gtk_clipboard_request_contents (nautilus_clipboard_get (GTK_WIDGET (view)),
- nautilus_clipboard_get_atom (),
- paste_into_clipboard_received_callback,
- data);
+ gtk_clipboard_request_text (nautilus_clipboard_get (GTK_WIDGET (view)),
+ paste_into_clipboard_received_callback,
+ data);
}
static void
@@ -6925,18 +6922,19 @@ can_paste_into_file (NautilusFile *file)
}
static void
-on_clipboard_contents_received (GtkClipboard *clipboard,
- GtkSelectionData *selection_data,
- gpointer user_data)
+on_clipboard_contents_received (GtkClipboard *clipboard,
+ const gchar *selection_data,
+ gpointer user_data)
{
NautilusFilesViewPrivate *priv;
NautilusFilesView *view;
gboolean can_link_from_copied_files;
gboolean settings_show_create_link;
gboolean is_read_only;
gboolean selection_contains_recent;
gboolean selection_contains_starred;
GAction *action;
+ gboolean is_data_valid;
view = NAUTILUS_FILES_VIEW (user_data);
priv = nautilus_files_view_get_instance_private (view);
@@ -6949,77 +6947,41 @@ on_clipboard_contents_received (GtkClipboard *clipboard,
return;
}
+ is_data_valid = nautilus_clipboard_is_data_valid_from_selection_data (selection_data);
settings_show_create_link = g_settings_get_boolean (nautilus_preferences,
NAUTILUS_PREFERENCES_SHOW_CREATE_LINK);
is_read_only = nautilus_files_view_is_read_only (view);
selection_contains_recent = showing_recent_directory (view);
selection_contains_starred = showing_starred_directory (view);
can_link_from_copied_files = !nautilus_clipboard_is_cut_from_selection_data (selection_data) &&
!selection_contains_recent && !selection_contains_starred &&
- !is_read_only && gtk_selection_data_get_length (selection_data) > 0;
+ !is_read_only && selection_data != NULL;
action = g_action_map_lookup_action (G_ACTION_MAP (priv->view_action_group),
"create-link");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
can_link_from_copied_files &&
settings_show_create_link);
- g_object_unref (view);
-}
-
-static void
-on_clipboard_targets_received (GtkClipboard *clipboard,
- GdkAtom *targets,
- int n_targets,
- gpointer user_data)
-{
- NautilusFilesViewPrivate *priv;
- NautilusFilesView *view;
- gboolean is_data_copied;
- int i;
- GAction *action;
-
- view = NAUTILUS_FILES_VIEW (user_data);
- priv = nautilus_files_view_get_instance_private (view);
- is_data_copied = FALSE;
-
- if (priv->slot == NULL ||
- !priv->active)
- {
- /* We've been destroyed or became inactive since call */
- g_object_unref (view);
- return;
- }
-
- if (targets)
- {
- for (i = 0; i < n_targets; i++)
- {
- if (targets[i] == nautilus_clipboard_get_atom ())
- {
- is_data_copied = TRUE;
- }
- }
- }
-
action = g_action_map_lookup_action (G_ACTION_MAP (priv->view_action_group),
"paste");
/* Take into account if the action was previously disabled for other reasons,
* like the directory not being writabble */
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
- is_data_copied && g_action_get_enabled (action));
+ is_data_valid && g_action_get_enabled (action));
action = g_action_map_lookup_action (G_ACTION_MAP (priv->view_action_group),
"paste-into");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
- is_data_copied && g_action_get_enabled (action));
+ is_data_valid && g_action_get_enabled (action));
action = g_action_map_lookup_action (G_ACTION_MAP (priv->view_action_group),
"create-link");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
- is_data_copied && g_action_get_enabled (action));
+ is_data_valid && g_action_get_enabled (action));
+
g_object_unref (view);
}
@@ -7565,18 +7527,10 @@ real_update_actions_state (NautilusFilesView *view)
!selection_contains_starred &&
priv->templates_present);
- /* Actions that are related to the clipboard need request, request the data
- * and update them once we have the data */
- g_object_ref (view); /* Need to keep the object alive until we get the reply */
- gtk_clipboard_request_targets (nautilus_clipboard_get (GTK_WIDGET (view)),
- on_clipboard_targets_received,
- view);
-
g_object_ref (view); /* Need to keep the object alive until we get the reply */
- gtk_clipboard_request_contents (nautilus_clipboard_get (GTK_WIDGET (view)),
- nautilus_clipboard_get_atom (),
- on_clipboard_contents_received,
- view);
+ gtk_clipboard_request_text (nautilus_clipboard_get (GTK_WIDGET (view)),
+ on_clipboard_contents_received,
+ view);
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group),
"select-all");
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index d2ba388..4f65080 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -3628,9 +3628,9 @@ list_view_scroll_to_file (NautilusFilesView *view,
}
static void
-on_clipboard_contents_received (GtkClipboard *clipboard,
- GtkSelectionData *selection_data,
- gpointer user_data)
+on_clipboard_contents_received (GtkClipboard *clipboard,
+ const gchar *selection_data,
+ gpointer user_data)
{
NautilusListView *view = NAUTILUS_LIST_VIEW (user_data);
@@ -3665,10 +3665,9 @@ static void
update_clipboard_status (NautilusListView *view)
{
g_object_ref (view); /* Need to keep the object alive until we get the reply */
- gtk_clipboard_request_contents (nautilus_clipboard_get (GTK_WIDGET (view)),
- nautilus_clipboard_get_atom (),
- on_clipboard_contents_received,
- view);
+ gtk_clipboard_request_text (nautilus_clipboard_get (GTK_WIDGET (view)),
+ on_clipboard_contents_received,
+ view);
}
static void
--
libgit2 0.26.0

View File

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

View File

@ -0,0 +1,59 @@
From f0e34498a2f2e2ec6644a3af47c1b56ac5b6dec3 Mon Sep 17 00:00:00 2001
From: Ernestas Kulik <ernestask@gnome.org>
Date: Thu, 2 Aug 2018 22:29:03 +0300
Subject: [PATCH] clipboard: Prevent crash when selection data is empty
Somehow, magically, it can happen that the clipboard contains an empty
string, which wreaks havoc in convert_selection_data_to_str_list(),
since the loop counter goes from 0 to the number of lines in the data
string minus one. This commit adds a check for the number of lines and
returns early. Additionally, this introduces automatic cleanup for a
variable and fixes mismatched types.
---
src/nautilus-clipboard.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/src/nautilus-clipboard.c b/src/nautilus-clipboard.c
index 752ff131f..2a77cf28f 100644
--- a/src/nautilus-clipboard.c
+++ b/src/nautilus-clipboard.c
@@ -42,23 +42,29 @@ typedef struct
static GList *
convert_selection_data_to_str_list (const gchar *data)
{
- int i;
+ g_auto (GStrv) lines;
+ guint number_of_lines;
GList *result;
- size_t number_of_lines;
- gchar **lines;
lines = g_strsplit (data, "\n", 0);
- result = NULL;
number_of_lines = g_strv_length (lines);
+ if (number_of_lines == 0)
+ {
+ /* An empty string will result in g_strsplit() returning an empty
+ * array, so, naturally, 0 - 1 = UINT32_MAX and we read all sorts
+ * of invalid memory.
+ */
+ return NULL;
+ }
+ result = NULL;
+
/* Also, this skips the last line, since it would be an
* empty string from the split */
- for (i = 0; i < number_of_lines - 1; i++)
+ for (guint i = 0; i < number_of_lines - 1; i++)
{
result = g_list_prepend (result, g_strdup (lines[i]));
}
- g_strfreev (lines);
-
return g_list_reverse (result);
}
--
2.17.2

2006
SPECS/nautilus.spec Normal file

File diff suppressed because it is too large Load Diff