From fb9bfe37609f829d219b398df3e4883cca307316 Mon Sep 17 00:00:00 2001 From: Packit Service Date: Jan 08 2021 06:12:18 +0000 Subject: Prepare for a new update Reverting patches so we can apply the latest update and changes can be seen in the spec file and sources. --- diff --git a/data/dbus-interfaces.xml b/data/dbus-interfaces.xml index f6a82df..35fb994 100644 --- a/data/dbus-interfaces.xml +++ b/data/dbus-interfaces.xml @@ -27,26 +27,13 @@ - - - - " - - - - - - - - - - - - - + + + + + - diff --git a/data/org.gnome.Nautilus.appdata.xml.in.in b/data/org.gnome.Nautilus.appdata.xml.in.in index 164ea50..30648b3 100644 --- a/data/org.gnome.Nautilus.appdata.xml.in.in +++ b/data/org.gnome.Nautilus.appdata.xml.in.in @@ -3,11 +3,11 @@ @appid@.desktop CC0-1.0 GPL-2.0+ - Files + Nautilus Access and organize files

- Files, also known as Nautilus, is the default file manager of the GNOME desktop. + Nautilus, also known as Files, is the default file manager of the GNOME desktop. It provides a simple and integrated way of managing your files and browsing your file system.

@@ -25,24 +25,6 @@ Notifications SearchProvider - - - https://static.gnome.org/appdata/nautilus/nautilus-201901141.png - Tile View - - - https://static.gnome.org/appdata/nautilus/nautilus-201901142.png - List View - - - https://static.gnome.org/appdata/nautilus/nautilus-201901143.png - Search - - - https://static.gnome.org/appdata/nautilus/nautilus-201901144.png - Other Locations - - System @@ -53,4 +35,3 @@ https://wiki.gnome.org/action/show/Apps/Nautilus nautilus - diff --git a/docs/meson.build b/docs/meson.build index a54574f..b039cb6 100644 --- a/docs/meson.build +++ b/docs/meson.build @@ -1,4 +1,3 @@ install_man('nautilus.1') -install_man('nautilus-autorun-software.1') subdir('reference') diff --git a/docs/nautilus-autorun-software.1 b/docs/nautilus-autorun-software.1 deleted file mode 100644 index 9ecbd4a..0000000 --- a/docs/nautilus-autorun-software.1 +++ /dev/null @@ -1,26 +0,0 @@ -.TH nautilus-autorun-software 1 "3 July 2019" - -.SH NAME -Run Software \- helper tool - -.SH SYNOPSIS -.B nautilus-autorun-software -.RI "" "mount-uri" -.br - -.SH DESCRIPTION -.B nautilus-autorun-software -is a helper tool for the GNOME desktop to start software from media with -Autostart files. -.br - -It is the default "x-content/unix-software" handler for the GNOME desktop. -.br - -.SH SEE ALSO -Autostart files are described at -https://specifications.freedesktop.org/autostart-spec/autostart-spec-latest.html - -.SH BUGS -Bug reports can be found and filed at -https://gitlab.gnome.org/GNOME/nautilus/issues diff --git a/docs/nautilus.1 b/docs/nautilus.1 index a868c72..70304a1 100644 --- a/docs/nautilus.1 +++ b/docs/nautilus.1 @@ -38,6 +38,11 @@ Perform a quick set of self-check tests. Show the version of the program. .TP +.BR \-g ", " \-\-geometry=\fIGEOMETRY\fR +Create the initial window with the given geometry. \fBDeprecated\fR - the geometry +is saved and loaded using GSettings. + +.TP .BR \-w ", " \-\-new-window Always open a new window for browsing specified URIs. diff --git a/meson.build b/meson.build index 066fab8..4b64239 100644 --- a/meson.build +++ b/meson.build @@ -30,6 +30,19 @@ add_project_arguments( '-Wall', '-Wduplicated-branches', '-Wlogical-op', + '-Werror=declaration-after-statement', + '-Werror=empty-body', + '-Werror=format=2', + '-Werror=implicit-function-declaration', + '-Werror=init-self', + '-Werror=missing-include-dirs', + '-Werror=missing-prototypes', + '-Werror=pointer-arith', + '-Werror=sequence-point', + '-Werror=shadow', + '-Werror=strict-prototypes', + '-Werror=undef', + '-Werror=uninitialized', ]), language: 'c' ) diff --git a/src/gtk/nautilusgtkplacesview.c b/src/gtk/nautilusgtkplacesview.c index 041849f..de0610e 100644 --- a/src/gtk/nautilusgtkplacesview.c +++ b/src/gtk/nautilusgtkplacesview.c @@ -401,9 +401,6 @@ nautilus_gtk_places_view_destroy (GtkWidget *widget) if (priv->network_monitor) g_signal_handlers_disconnect_by_func (priv->network_monitor, update_places, widget); - if (priv->server_list_monitor) - g_signal_handlers_disconnect_by_func (priv->server_list_monitor, server_file_changed_cb, widget); - g_cancellable_cancel (priv->cancellable); g_cancellable_cancel (priv->networks_fetching_cancellable); @@ -1408,7 +1405,6 @@ pulse_entry_cb (gpointer user_data) { gtk_entry_set_progress_pulse_step (GTK_ENTRY (priv->address_entry), 0.0); gtk_entry_set_progress_fraction (GTK_ENTRY (priv->address_entry), 0.0); - priv->entry_pulse_timeout_id = 0; return G_SOURCE_REMOVE; } diff --git a/src/gtk/nautilusgtkplacesview.ui b/src/gtk/nautilusgtkplacesview.ui index 601fce2..c366fde 100644 --- a/src/gtk/nautilusgtkplacesview.ui +++ b/src/gtk/nautilusgtkplacesview.ui @@ -1,5 +1,4 @@ - @@ -12,52 +11,265 @@ completion_store - 1 - True - False + 1 + 1 + 0 + + + address_entry + + + 1 + 18 + vertical + 6 + + + 1 + 1 + Server Addresses + + + + + + + + + 1 + 1 + Server addresses are made up of a protocol prefix and an address. Examples: + 1 + 40 + 40 + 0 + + + 1 + + + + + 1 + 1 + smb://gnome.org, ssh://192.168.0.1, ftp://[2001:db8::1] + 1 + 40 + 40 + 0 + + + 2 + + + + + 1 + 12 + 1 + 6 + 12 + + + 1 + 1 + Available Protocols + 0 + + + + + + 0 + 0 + + + + + 1 + AppleTalk + 0 + + + 0 + 1 + + + + + 1 + File Transfer Protocol + 0 + + + 0 + 2 + + + + + 1 + Network File System + 0 + + + 0 + 3 + + + + + 1 + Samba + 0 + + + 0 + 4 + + + + + 1 + SSH File Transfer Protocol + 0 + + + 0 + 5 + + + + + 1 + WebDAV + 0 + + + 0 + 6 + + + + + 1 + Prefix + 0 + + + + + + 1 + 0 + + + + + 1 + afp:// + 0 + + + 1 + 1 + + + + + 1 + ftp:// or ftps:// + 0 + + + 1 + 2 + + + + + 1 + nfs:// + 0 + + + 1 + 3 + + + + + 1 + smb:// + 0 + + + 1 + 4 + + + + + 1 + sftp:// or ssh:// + 0 + + + 1 + 5 + + + + + 1 + dav:// or davs:// + 0 + + + 1 + 6 + + + + + 3 + + + + - False - True - False + 1 - True - False + 1 + 1 center - True vertical 18 - True - False - 48 - network-server-symbolic + 1 + 48 + network-server-symbolic - - False - True - 0 - - True - False + 1 No recent servers found - False - True 1 @@ -68,44 +280,36 @@ - True - False - 12 + 1 + 12 vertical 12 - True - False + 1 Recent Servers - - False - True - 0 - - True - True - True - in - 250 - 200 + 1 + 1 + 1 + in + 250 + 200 - True - False - none + 1 + none - True - True - none + 1 + 1 + none @@ -113,15 +317,12 @@ - False - True 1 list - 1 @@ -129,37 +330,32 @@ - - False - address_entry - - - True - False - 18 - vertical - 6 - - - True - False - True - Server Addresses - - - - - - - False - True - 0 - - - - - True - False - True - Server addresses are made up of a protocol prefix and an address. Examples: - True - 40 - 40 - 0 - - - False - True - 1 - - - - - True - False - True - smb://gnome.org, ssh://192.168.0.1, ftp://[2001:db8::1] - True - 40 - 40 - 0 - - - False - True - 2 - - - - - True - False - 12 - True - 6 - 12 - - - True - False - True - Available Protocols - 0 - - - - - - 0 - 0 - - - - - True - False - AppleTalk - 0 - - - 0 - 1 - - - - - True - False - File Transfer Protocol - 0 - - - 0 - 2 - - - - - True - False - Samba - 0 - - - 0 - 4 - - - - - True - False - SSH File Transfer Protocol - 0 - - - 0 - 5 - - - - - True - False - WebDAV - 0 - - - 0 - 6 - - - - - True - False - Prefix - 0 - - - - - - 1 - 0 - - - - - True - False - afp:// - 0 - - - 1 - 1 - - - - - True - False - ftp:// or ftps:// - 0 - - - 1 - 2 - - - - - True - False - smb:// - 0 - - - 1 - 4 - - - - - True - False - sftp:// or ssh:// - 0 - - - 1 - 5 - - - - - True - False - dav:// or davs:// - 0 - - - 1 - 6 - - - - - - - - - - - False - True - 3 - - - - - diff --git a/src/nautilus-canvas-view.c b/src/nautilus-canvas-view.c index 7de0808..f99ddd9 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, - const gchar *selection_data, - gpointer user_data) +on_clipboard_contents_received (GtkClipboard *clipboard, + GtkSelectionData *selection_data, + gpointer user_data) { NautilusCanvasView *canvas_view; @@ -590,9 +590,10 @@ 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_text (nautilus_clipboard_get (GTK_WIDGET (view)), - on_clipboard_contents_received, - view); + gtk_clipboard_request_contents (nautilus_clipboard_get (GTK_WIDGET (view)), + nautilus_clipboard_get_atom (), + on_clipboard_contents_received, + view); } static void diff --git a/src/nautilus-clipboard.c b/src/nautilus-clipboard.c index 2a77cf2..267d7a3 100644 --- a/src/nautilus-clipboard.c +++ b/src/nautilus-clipboard.c @@ -33,6 +33,8 @@ #include #include +static GdkAtom copied_files_atom; + typedef struct { gboolean cut; @@ -40,31 +42,21 @@ typedef struct } ClipboardInfo; static GList * -convert_selection_data_to_str_list (const gchar *data) +convert_lines_to_str_list (char **lines) { - g_auto (GStrv) lines; - guint number_of_lines; + int i; GList *result; - lines = g_strsplit (data, "\n", 0); - number_of_lines = g_strv_length (lines); - if (number_of_lines == 0) + if (lines[0] == NULL) { - /* 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 (guint i = 0; i < number_of_lines - 1; i++) + result = NULL; + for (i = 0; lines[i] != NULL; i++) { result = g_list_prepend (result, g_strdup (lines[i])); } - return g_list_reverse (result); } @@ -85,8 +77,7 @@ convert_file_list_to_string (ClipboardInfo *info, } else { - uris = g_string_new ("x-special/nautilus-clipboard\n"); - g_string_append (uris, info->cut ? "cut\n" : "copy\n"); + uris = g_string_new (info->cut ? "cut" : "copy"); } for (i = 0, l = info->files; l != NULL; l = l->next, i++) @@ -109,12 +100,16 @@ convert_file_list_to_string (ClipboardInfo *info, g_string_append (uris, uri); } - g_string_append_c (uris, '\n'); + /* skip newline for last element */ + if (i + 1 < g_list_length (info->files)) + { + g_string_append_c (uris, '\n'); + } } else { - g_string_append (uris, uri); g_string_append_c (uris, '\n'); + g_string_append (uris, uri); } g_free (uri); @@ -125,60 +120,43 @@ convert_file_list_to_string (ClipboardInfo *info, } static GList * -get_item_list_from_selection_data (const gchar *selection_data) +get_item_list_from_selection_data (GtkSelectionData *selection_data) { - GList *items = NULL; + GList *items; + char **lines; - if (selection_data != NULL) + if (gtk_selection_data_get_data_type (selection_data) != copied_files_atom + || gtk_selection_data_get_length (selection_data) <= 0) { - gboolean valid_data = TRUE; + items = NULL; + } + else + { + gchar *data; /* 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. */ - 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; - } + 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); } 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 (const gchar *selection_data) +nautilus_clipboard_get_uri_list_from_selection_data (GtkSelectionData *selection_data) { GList *items; items = get_item_list_from_selection_data (selection_data); if (items) { - /* 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. */ + /* Line 0 is "cut" or "copy", so uris start at line 1. */ items = g_list_remove (items, items->data); } @@ -196,12 +174,13 @@ void nautilus_clipboard_clear_if_colliding_uris (GtkWidget *widget, const GList *item_uris) { - g_autofree gchar *data = NULL; + GtkSelectionData *data; GList *clipboard_item_uris, *l; gboolean collision; collision = FALSE; - data = gtk_clipboard_wait_for_text (nautilus_clipboard_get (widget)); + data = gtk_clipboard_wait_for_contents (nautilus_clipboard_get (widget), + copied_files_atom); if (data == NULL) { return; @@ -231,14 +210,14 @@ nautilus_clipboard_clear_if_colliding_uris (GtkWidget *widget, } gboolean -nautilus_clipboard_is_cut_from_selection_data (const gchar *selection_data) +nautilus_clipboard_is_cut_from_selection_data (GtkSelectionData *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->next->data, "cut") == 0; + g_strcmp0 ((gchar *) items->data, "cut") == 0; g_list_free_full (items, g_free); @@ -283,10 +262,19 @@ on_get_clipboard (GtkClipboard *clipboard, char *str; gsize len; - str = convert_file_list_to_string (clipboard_info, FALSE, &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); + g_free (str); + } } static void @@ -315,6 +303,7 @@ 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); @@ -328,3 +317,13 @@ 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 3be19c9..613e983 100644 --- a/src/nautilus-clipboard.h +++ b/src/nautilus-clipboard.h @@ -28,12 +28,11 @@ 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 (const gchar *selection_data); -gboolean nautilus_clipboard_is_cut_from_selection_data (const gchar *selection_data); +GList* nautilus_clipboard_get_uri_list_from_selection_data (GtkSelectionData *selection_data); +gboolean nautilus_clipboard_is_cut_from_selection_data (GtkSelectionData *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-dbus-manager.c b/src/nautilus-dbus-manager.c index 7185256..3611a23 100644 --- a/src/nautilus-dbus-manager.c +++ b/src/nautilus-dbus-manager.c @@ -26,8 +26,6 @@ #include "nautilus-generated.h" #include "nautilus-file-operations.h" -#include "nautilus-file-undo-manager.h" -#include "nautilus-file.h" #define DEBUG_FLAG NAUTILUS_DEBUG_DBUS #include "nautilus-debug.h" @@ -62,95 +60,40 @@ nautilus_dbus_manager_dispose (GObject *object) G_OBJECT_CLASS (nautilus_dbus_manager_parent_class)->dispose (object); } -static void -undo_redo_on_finished (gpointer user_data) -{ - 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) +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) { - NautilusFileUndoManager *undo_manager = NULL; - gint *handler_id = g_new0(int, 1); - - g_application_hold (g_application_get_default ()); + GFile *source_file, *target_dir; + const gchar *target_name = NULL, *source_name = NULL; - 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); + source_file = g_file_new_for_uri (source_uri); + target_dir = g_file_new_for_uri (dest_dir_uri); - nautilus_dbus_file_operations_complete_redo (object, invocation); - return TRUE; /* invocation was handled */ -} + if (dest_name != NULL && dest_name[0] != '\0') + { + target_name = dest_name; + } -static gboolean -handle_undo (NautilusDBusFileOperations *object, - GDBusMethodInvocation *invocation) -{ - NautilusFileUndoManager *undo_manager = NULL; - gint *handler_id = g_new0(int, 1); + if (source_display_name != NULL && source_display_name[0] != '\0') + { + source_name = source_display_name; + } - g_application_hold (g_application_get_default ()); + nautilus_file_operations_copy_file (source_file, target_dir, source_name, target_name, + NULL, NULL, NULL); - 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); + g_object_unref (source_file); + g_object_unref (target_dir); - nautilus_dbus_file_operations_complete_undo (object, invocation); + nautilus_dbus_file_operations_complete_copy_file (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, - 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); - - g_application_hold (g_application_get_default ()); - nautilus_file_operations_new_folder (NULL, parent_file_uri, basename, - create_folder_on_finished, NULL); - - nautilus_dbus_file_operations_complete_create_folder (object, invocation); - return TRUE; /* invocation was handled */ -} - -static void -copy_move_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, @@ -158,46 +101,26 @@ handle_copy_uris (NautilusDBusFileOperations *object, const gchar *destination) { GList *source_files = NULL; + GFile *dest_dir; 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_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; + dest_dir = g_file_new_for_uri (destination); for (idx = 0; sources[idx] != NULL; idx++) { - source_files = g_list_prepend (source_files, g_strdup (sources[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_copy_move (source_files, destination, - GDK_ACTION_MOVE, NULL, copy_move_on_finished, NULL); + 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); - 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) @@ -209,75 +132,6 @@ handle_empty_trash (NautilusDBusFileOperations *object, } 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, - 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])); - } - - 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 */ -} - -static void -rename_file_on_finished (NautilusFile *file, - GFile *result_location, - GError *error, - gpointer callback_data) -{ - g_application_release (g_application_get_default ()); -} - -static gboolean -handle_rename_file (NautilusDBusFileOperations *object, - GDBusMethodInvocation *invocation, - const gchar *uri, - const gchar *new_name) -{ - NautilusFile *file = NULL; - - file = nautilus_file_get_by_uri (uri); - - g_application_hold (g_application_get_default ()); - nautilus_file_rename (file, new_name, - rename_file_on_finished, NULL); - - nautilus_dbus_file_operations_complete_rename_file (object, invocation); - - 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) { self->file_operations = nautilus_dbus_file_operations_skeleton_new (); @@ -287,33 +141,13 @@ nautilus_dbus_manager_init (NautilusDBusManager *self) G_CALLBACK (handle_copy_uris), self); g_signal_connect (self->file_operations, - "handle-move-uris", - G_CALLBACK (handle_move_uris), + "handle-copy-file", + G_CALLBACK (handle_copy_file), self); g_signal_connect (self->file_operations, "handle-empty-trash", G_CALLBACK (handle_empty_trash), self); - g_signal_connect (self->file_operations, - "handle-trash-files", - G_CALLBACK (handle_trash_files), - self); - g_signal_connect (self->file_operations, - "handle-create-folder", - G_CALLBACK (handle_create_folder), - self); - g_signal_connect (self->file_operations, - "handle-rename-file", - G_CALLBACK (handle_rename_file), - 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 @@ -336,28 +170,12 @@ nautilus_dbus_manager_register (NautilusDBusManager *self, GDBusConnection *connection, GError **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; + return g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self->file_operations), + connection, "/org/gnome/Nautilus" PROFILE, error); } 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); } diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c index 4d38a0d..4d84b98 100644 --- a/src/nautilus-file-operations.c +++ b/src/nautilus-file-operations.c @@ -5706,6 +5706,47 @@ copy_task_thread_func (GTask *task, } 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, GtkWindow *parent_window, @@ -7164,7 +7205,7 @@ retry: { res = g_file_copy (job->src, dest, - G_FILE_COPY_TARGET_DEFAULT_PERMS, + G_FILE_COPY_NONE, common->cancellable, NULL, NULL, &error); @@ -7283,17 +7324,19 @@ retry: { g_autofree char *filename2 = NULL; g_autofree char *suffix = NULL; + NautilusFile *file; - filename_base = filename; - if (job->src != NULL) + file = nautilus_file_get (job->src); + if (nautilus_file_is_directory (file)) { - g_autoptr (NautilusFile) file = NULL; - file = nautilus_file_get (job->src); - if (!nautilus_file_is_directory (file)) - { - filename_base = eel_filename_strip_extension (filename); - } + filename_base = filename; } + else + { + filename_base = eel_filename_strip_extension (filename); + } + + nautilus_file_unref (file); offset = strlen (filename_base); suffix = g_strdup (filename + offset); @@ -7334,21 +7377,21 @@ retry: { g_autofree char *suffix = NULL; g_autofree gchar *filename2 = NULL; + NautilusFile *file; g_clear_object (&dest); - filename_base = filename; - if (job->src != NULL) + file = nautilus_file_get (job->src); + if (nautilus_file_is_directory (file)) { - g_autoptr (NautilusFile) file = NULL; - - file = nautilus_file_get (job->src); - if (!nautilus_file_is_directory (file)) - { - filename_base = eel_filename_strip_extension (filename); - } + filename_base = filename; + } + else + { + filename_base = eel_filename_strip_extension (filename); } + nautilus_file_unref (file); offset = strlen (filename_base); suffix = g_strdup (filename + offset); diff --git a/src/nautilus-file-operations.h b/src/nautilus-file-operations.h index 2a9c6a6..e8c6ed3 100644 --- a/src/nautilus-file-operations.h +++ b/src/nautilus-file-operations.h @@ -57,6 +57,13 @@ 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, diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c index 92a2484..0c7380a 100644 --- a/src/nautilus-files-view.c +++ b/src/nautilus-files-view.c @@ -1644,12 +1644,12 @@ pattern_select_response_cb (GtkWidget *dialog, selection = nautilus_directory_match_pattern (directory, gtk_entry_get_text (GTK_ENTRY (entry))); - nautilus_files_view_call_set_selection (view, selection); - nautilus_files_view_reveal_selection (view); - if (selection) { + nautilus_files_view_call_set_selection (view, selection); nautilus_file_list_free (selection); + + nautilus_files_view_reveal_selection (view); } /* fall through */ } @@ -2435,16 +2435,14 @@ 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, - NULL, NULL); + nautilus_properties_window_present (files, GTK_WIDGET (view), NULL); nautilus_file_list_free (files); } } else { - nautilus_properties_window_present (selection, GTK_WIDGET (view), NULL, - NULL, NULL); + nautilus_properties_window_present (selection, GTK_WIDGET (view), NULL); } } @@ -2553,7 +2551,7 @@ action_open_item_new_window (GSimpleAction *action, static void handle_clipboard_data (NautilusFilesView *view, - const gchar *selection_data, + GtkSelectionData *selection_data, char *destination_uri, GdkDragAction action) { @@ -2578,7 +2576,7 @@ handle_clipboard_data (NautilusFilesView *view, static void paste_clipboard_data (NautilusFilesView *view, - const gchar *selection_data, + GtkSelectionData *selection_data, char *destination_uri) { GdkDragAction action; @@ -2596,9 +2594,9 @@ paste_clipboard_data (NautilusFilesView *view, } static void -paste_clipboard_text_received_callback (GtkClipboard *clipboard, - const gchar *selection_data, - gpointer data) +paste_clipboard_received_callback (GtkClipboard *clipboard, + GtkSelectionData *selection_data, + gpointer data) { NautilusFilesView *view; NautilusFilesViewPrivate *priv; @@ -2631,15 +2629,16 @@ action_paste_files (GSimpleAction *action, view = NAUTILUS_FILES_VIEW (user_data); g_object_ref (view); - gtk_clipboard_request_text (nautilus_clipboard_get (GTK_WIDGET (view)), - paste_clipboard_text_received_callback, - view); + gtk_clipboard_request_contents (nautilus_clipboard_get (GTK_WIDGET (view)), + nautilus_clipboard_get_atom (), + paste_clipboard_received_callback, + view); } static void -create_links_clipboard_received_callback (GtkClipboard *clipboard, - const gchar *selection_data, - gpointer data) +create_links_clipboard_received_callback (GtkClipboard *clipboard, + GtkSelectionData *selection_data, + gpointer data) { NautilusFilesView *view; NautilusFilesViewPrivate *priv; @@ -2672,9 +2671,10 @@ action_create_links (GSimpleAction *action, view = NAUTILUS_FILES_VIEW (user_data); g_object_ref (view); - gtk_clipboard_request_text (nautilus_clipboard_get (GTK_WIDGET (view)), - create_links_clipboard_received_callback, - view); + gtk_clipboard_request_contents (nautilus_clipboard_get (GTK_WIDGET (view)), + nautilus_clipboard_get_atom (), + create_links_clipboard_received_callback, + view); } static void @@ -6020,9 +6020,9 @@ typedef struct } PasteIntoData; static void -paste_into_clipboard_received_callback (GtkClipboard *clipboard, - const gchar *selection_data, - gpointer callback_data) +paste_into_clipboard_received_callback (GtkClipboard *clipboard, + GtkSelectionData *selection_data, + gpointer callback_data) { NautilusFilesViewPrivate *priv; PasteIntoData *data; @@ -6062,9 +6062,10 @@ paste_into (NautilusFilesView *view, data->view = g_object_ref (view); data->target = nautilus_file_ref (target); - gtk_clipboard_request_text (nautilus_clipboard_get (GTK_WIDGET (view)), - paste_into_clipboard_received_callback, - data); + gtk_clipboard_request_contents (nautilus_clipboard_get (GTK_WIDGET (view)), + nautilus_clipboard_get_atom (), + paste_into_clipboard_received_callback, + data); } static void @@ -6928,9 +6929,9 @@ can_paste_into_file (NautilusFile *file) } static void -on_clipboard_contents_received (GtkClipboard *clipboard, - const gchar *selection_data, - gpointer user_data) +on_clipboard_contents_received (GtkClipboard *clipboard, + GtkSelectionData *selection_data, + gpointer user_data) { NautilusFilesViewPrivate *priv; NautilusFilesView *view; @@ -6940,7 +6941,6 @@ on_clipboard_contents_received (GtkClipboard *clipboard, 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); @@ -6953,7 +6953,6 @@ 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); @@ -6961,7 +6960,7 @@ on_clipboard_contents_received (GtkClipboard *clipboard, 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 && selection_data != NULL; + !is_read_only && gtk_selection_data_get_length (selection_data) > 0; action = g_action_map_lookup_action (G_ACTION_MAP (priv->view_action_group), "create-link"); @@ -6969,25 +6968,62 @@ on_clipboard_contents_received (GtkClipboard *clipboard, 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_valid && g_action_get_enabled (action)); + is_data_copied && 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_valid && g_action_get_enabled (action)); + is_data_copied && 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_valid && g_action_get_enabled (action)); - + is_data_copied && g_action_get_enabled (action)); g_object_unref (view); } @@ -7533,10 +7569,18 @@ 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_text (nautilus_clipboard_get (GTK_WIDGET (view)), - on_clipboard_contents_received, - view); + gtk_clipboard_request_contents (nautilus_clipboard_get (GTK_WIDGET (view)), + nautilus_clipboard_get_atom (), + on_clipboard_contents_received, + view); action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group), "select-all"); diff --git a/src/nautilus-freedesktop-dbus.c b/src/nautilus-freedesktop-dbus.c index b888099..c4657ab 100644 --- a/src/nautilus-freedesktop-dbus.c +++ b/src/nautilus-freedesktop-dbus.c @@ -114,12 +114,6 @@ 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, @@ -139,9 +133,7 @@ skeleton_handle_show_item_properties_cb (NautilusFreedesktopFileManager1 *object files = g_list_reverse (files); - g_application_hold (g_application_get_default ()); - nautilus_properties_window_present (files, NULL, startup_id, - properties_window_on_finished, NULL); + nautilus_properties_window_present (files, NULL, startup_id); nautilus_file_list_free (files); diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c index 4f65080..d2ba388 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, - const gchar *selection_data, - gpointer user_data) +on_clipboard_contents_received (GtkClipboard *clipboard, + GtkSelectionData *selection_data, + gpointer user_data) { NautilusListView *view = NAUTILUS_LIST_VIEW (user_data); @@ -3665,9 +3665,10 @@ 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_text (nautilus_clipboard_get (GTK_WIDGET (view)), - on_clipboard_contents_received, - view); + gtk_clipboard_request_contents (nautilus_clipboard_get (GTK_WIDGET (view)), + nautilus_clipboard_get_atom (), + on_clipboard_contents_received, + view); } static void diff --git a/src/nautilus-mime-actions.c b/src/nautilus-mime-actions.c index 3bb2cab..043cb2a 100644 --- a/src/nautilus-mime-actions.c +++ b/src/nautilus-mime-actions.c @@ -1199,6 +1199,14 @@ search_for_application_dbus_call_notify_cb (GDBusProxy *proxy, g_variant_unref (variant); + /* activate the file again */ + nautilus_mime_activate_files (parameters_install->parent_window, + parameters_install->slot, + parameters_install->files, + parameters_install->activation_directory, + parameters_install->flags, + parameters_install->user_confirmation); + activate_parameters_install_free (parameters_install); } diff --git a/src/nautilus-pathbar.c b/src/nautilus-pathbar.c index ea3d2b5..630b8ed 100644 --- a/src/nautilus-pathbar.c +++ b/src/nautilus-pathbar.c @@ -211,8 +211,7 @@ 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, NULL, - NULL); + nautilus_properties_window_present (files, GTK_WIDGET (self), NULL); nautilus_file_list_free (files); } diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c index 0f61326..8bd335a 100644 --- a/src/nautilus-properties-window.c +++ b/src/nautilus-properties-window.c @@ -152,10 +152,6 @@ typedef struct char *startup_id; char *pending_key; GHashTable *pending_files; - NautilusPropertiesWindowCallback callback; - gpointer callback_data; - NautilusPropertiesWindow *window; - gboolean cancelled; } StartupData; /* drag and drop definitions */ @@ -201,6 +197,8 @@ 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, @@ -1143,6 +1141,10 @@ properties_window_update (NautilusPropertiesWindow *window, { dirty_target = TRUE; } + if (changed_file != NULL) + { + start_deep_count_for_file (window, changed_file); + } } if (dirty_original) @@ -4809,15 +4811,12 @@ 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, - NautilusPropertiesWindowCallback callback, - gpointer callback_data, - NautilusPropertiesWindow *window) +startup_data_new (GList *original_files, + GList *target_files, + const char *pending_key, + GtkWidget *parent_widget, + GtkWindow *parent_window, + const char *startup_id) { StartupData *data; GList *l; @@ -4831,9 +4830,6 @@ 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) { @@ -5153,7 +5149,7 @@ remove_window (NautilusPropertiesWindow *window) } } -static NautilusPropertiesWindow * +static GtkWindow * get_existing_window (GList *file_list) { if (!file_list->next) @@ -5165,36 +5161,9 @@ get_existing_window (GList *file_list) } static void -properties_window_finish (StartupData *data) -{ - gboolean cancel_timed_wait; - - 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); - } - - cancel_timed_wait = (data->window == NULL && !data->cancelled); - remove_pending (data, TRUE, cancel_timed_wait, FALSE); - - startup_data_free (data); -} - -static void cancel_create_properties_window_callback (gpointer callback_data) { - StartupData *data; - - data = callback_data; - data->cancelled = TRUE; - - properties_window_finish (data); + remove_pending ((StartupData *) callback_data, TRUE, FALSE, TRUE); } static void @@ -5203,7 +5172,7 @@ parent_widget_destroyed_callback (GtkWidget *widget, { g_assert (widget == ((StartupData *) callback_data)->parent_widget); - properties_window_finish ((StartupData *) callback_data); + remove_pending ((StartupData *) callback_data, TRUE, TRUE, FALSE); } static void @@ -5234,27 +5203,16 @@ remove_pending (StartupData *startup_data, eel_timed_wait_stop (cancel_create_properties_window_callback, startup_data); } - if (startup_data->pending_key != NULL) - { - 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) + if (cancel_destroy_handler && startup_data->parent_widget) { - data->callback (data->callback_data); + g_signal_handlers_disconnect_by_func (startup_data->parent_widget, + G_CALLBACK (parent_widget_destroyed_callback), + startup_data); } - properties_window_finish (data); + g_hash_table_remove (pending_lists, startup_data->pending_key); - return GDK_EVENT_PROPAGATE; + startup_data_free (startup_data); } static void @@ -5274,34 +5232,29 @@ 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, - NautilusPropertiesWindowCallback callback, - gpointer callback_data) +nautilus_properties_window_present (GList *original_files, + GtkWidget *parent_widget, + const gchar *startup_id) { GList *l, *next; - GtkWindow *parent_window; + GtkWidget *parent_window; StartupData *startup_data; GList *target_files; - NautilusPropertiesWindow *existing_window; + GtkWindow *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) { @@ -5319,19 +5272,15 @@ nautilus_properties_window_present (GList *original_f { if (parent_widget) { - gtk_window_set_screen (GTK_WINDOW (existing_window), + gtk_window_set_screen (existing_window, gtk_widget_get_screen (parent_widget)); } else if (startup_id) { - gtk_window_set_startup_id (GTK_WINDOW (existing_window), startup_id); + gtk_window_set_startup_id (existing_window, startup_id); } - 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); + gtk_window_present (existing_window); return; } @@ -5341,9 +5290,6 @@ nautilus_properties_window_present (GList *original_f /* 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; } @@ -5351,7 +5297,7 @@ nautilus_properties_window_present (GList *original_f if (parent_widget) { - parent_window = GTK_WINDOW (gtk_widget_get_ancestor (parent_widget, GTK_TYPE_WINDOW)); + parent_window = gtk_widget_get_ancestor (parent_widget, GTK_TYPE_WINDOW); } else { @@ -5362,11 +5308,8 @@ nautilus_properties_window_present (GList *original_f target_files, pending_key, parent_widget, - parent_window, - startup_id, - callback, - callback_data, - NULL); + GTK_WINDOW (parent_window), + startup_id); 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 e8d6a90..9eff54c 100644 --- a/src/nautilus-properties-window.h +++ b/src/nautilus-properties-window.h @@ -59,12 +59,8 @@ typedef struct NautilusPropertiesWindowClass NautilusPropertiesWindowClass; GType nautilus_properties_window_get_type (void); -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); +void nautilus_properties_window_present (GList *files, + GtkWidget *parent_widget, + const gchar *startup_id); #endif /* NAUTILUS_PROPERTIES_WINDOW_H */ diff --git a/src/nautilus-search-engine-tracker.c b/src/nautilus-search-engine-tracker.c index 0dac3a3..2e701a9 100644 --- a/src/nautilus-search-engine-tracker.c +++ b/src/nautilus-search-engine-tracker.c @@ -286,12 +286,6 @@ search_finished_idle (gpointer user_data) return FALSE; } -/* This is used to compensate rank if fts:rank is not set (resp. fts:match is - * not used). The value was determined experimentally. I am convinced that - * fts:rank is currently always set to 5.0 in case of filename match. - */ -#define FILENAME_RANK "5.0" - static void nautilus_search_engine_tracker_start (NautilusSearchProvider *provider) { @@ -340,11 +334,7 @@ nautilus_search_engine_tracker_start (NautilusSearchProvider *provider) mimetypes = nautilus_query_get_mime_types (tracker->query); mime_count = g_list_length (mimetypes); - sparql = g_string_new ("SELECT DISTINCT" - " nie:url(?urn)" - " xsd:double(COALESCE(?rank2, ?rank1)) AS ?rank" - " nfo:fileLastModified(?urn)" - " nfo:fileLastAccessed(?urn)"); + sparql = g_string_new ("SELECT DISTINCT nie:url(?urn) fts:rank(?urn) nfo:fileLastModified(?urn) nfo:fileLastAccessed(?urn)"); if (tracker->fts_enabled) { @@ -359,30 +349,16 @@ nautilus_search_engine_tracker_start (NautilusSearchProvider *provider) " tracker:available true;" " nie:url ?url"); - if (mime_count > 0) + if (*search_text) { - g_string_append (sparql, "; nie:mimeType ?mime"); + g_string_append_printf (sparql, "; fts:match '\"%s\"*'", search_text); } - if (tracker->fts_enabled) + if (mime_count > 0) { - /* Use fts:match only for content search to not lose some filename results due to stop words. */ - g_string_append_printf (sparql, - " {" - " ?urn fts:match '\"nie:plainTextContent\" : \"%s\"*' ." - " BIND(fts:rank(?urn) AS ?rank1) ." - " } UNION", - search_text); + g_string_append (sparql, "; nie:mimeType ?mime"); } - g_string_append_printf (sparql, - " {" - " ?urn nfo:fileName ?filename ." - " FILTER(fn:contains(fn:lower-case(?filename), '%s')) ." - " BIND(" FILENAME_RANK " AS ?rank2) ." - " }", - search_text); - g_string_append_printf (sparql, " . FILTER( "); if (!tracker->recursive) @@ -394,6 +370,11 @@ nautilus_search_engine_tracker_start (NautilusSearchProvider *provider) g_string_append_printf (sparql, "tracker:uri-is-descendant('%s', ?url)", location_uri); } + if (!tracker->fts_enabled) + { + g_string_append_printf (sparql, " && fn:contains(fn:lower-case(nfo:fileName(?urn)), '%s')", search_text); + } + date_range = nautilus_query_get_date_range (tracker->query); if (date_range) { @@ -450,7 +431,7 @@ nautilus_search_engine_tracker_start (NautilusSearchProvider *provider) g_string_append (sparql, ")\n"); } - g_string_append (sparql, ")} ORDER BY DESC (?rank)"); + g_string_append (sparql, ")} ORDER BY DESC (fts:rank(?urn))"); tracker->cancellable = g_cancellable_new (); tracker_sparql_connection_query_async (tracker->connection, diff --git a/src/nautilus-window.c b/src/nautilus-window.c index e4ea4da..1f8d520 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -1309,8 +1309,7 @@ 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, NULL, - NULL); + nautilus_properties_window_present (list, GTK_WIDGET (window), NULL); nautilus_file_list_free (list); g_clear_object (&priv->selected_file); @@ -2413,9 +2412,8 @@ nautilus_window_constructed (GObject *self) nautilus_window_set_up_sidebar (window); - g_signal_connect_object (nautilus_file_undo_manager_get (), "undo-changed", - G_CALLBACK (nautilus_window_on_undo_changed), self, - G_CONNECT_AFTER); + g_signal_connect_after (nautilus_file_undo_manager_get (), "undo-changed", + G_CALLBACK (nautilus_window_on_undo_changed), self); /* Is required that the UI is constructed before initializating the actions, since * some actions trigger UI widgets to show/hide. */ @@ -3087,7 +3085,6 @@ nautilus_window_show_about_dialog (NautilusWindow *window) "program-name", program_name, "version", VERSION, "comments", _("Access and organize your files."), - "website", "https://wiki.gnome.org/action/show/Apps/Files", "copyright", "Copyright © 1999–2018 The Files Authors", "license-type", GTK_LICENSE_GPL_3_0, "artists", artists,