diff options
author | Albert Vaca Cintora | 2023-10-12 03:08:51 +0200 |
---|---|---|
committer | Albert Vaca Cintora | 2023-10-12 03:08:51 +0200 |
commit | 26776193230b0d56f714d31d79c5e716ac413a26 (patch) | |
tree | fed7659a97fb15cd5474eba6651df5df4dab909c /nautilus-restore-typeahead.patch | |
parent | dc295b3191818d16550400e645e108d9e265baa3 (diff) | |
download | aur-26776193230b0d56f714d31d79c5e716ac413a26.tar.gz |
Release 45.0
Diffstat (limited to 'nautilus-restore-typeahead.patch')
-rw-r--r-- | nautilus-restore-typeahead.patch | 261 |
1 files changed, 104 insertions, 157 deletions
diff --git a/nautilus-restore-typeahead.patch b/nautilus-restore-typeahead.patch index 0c89695a0028..aa37e71598d8 100644 --- a/nautilus-restore-typeahead.patch +++ b/nautilus-restore-typeahead.patch @@ -1,5 +1,5 @@ diff --git a/data/org.gnome.nautilus.gschema.xml b/data/org.gnome.nautilus.gschema.xml -index 253bc67a1..1d216539b 100644 +index 94b17208d..438008f15 100644 --- a/data/org.gnome.nautilus.gschema.xml +++ b/data/org.gnome.nautilus.gschema.xml @@ -77,6 +77,11 @@ @@ -7,7 +7,7 @@ index 253bc67a1..1d216539b 100644 <description>If set to true, then Nautilus browser windows will always use a textual input entry for the location toolbar, instead of the pathbar.</description> </key> + <key type="b" name="type-ahead-search"> -+ <default>false</default> ++ <default>true</default> + <summary>Start searching on type ahead</summary> + <description>If set to true, typing on the files viewer will start searching. Otherwise it select first matching file.</description> + </key> @@ -15,10 +15,10 @@ index 253bc67a1..1d216539b 100644 <default>'local-only'</default> <summary>Where to perform recursive search</summary> diff --git a/src/nautilus-global-preferences.h b/src/nautilus-global-preferences.h -index 5a73717b3..31e22aa7b 100644 +index 9d39bbc03..27c2e54f1 100644 --- a/src/nautilus-global-preferences.h +++ b/src/nautilus-global-preferences.h -@@ -119,6 +119,7 @@ typedef enum +@@ -116,6 +116,7 @@ typedef enum /* Search behaviour */ #define NAUTILUS_PREFERENCES_RECURSIVE_SEARCH "recursive-search" @@ -27,10 +27,10 @@ index 5a73717b3..31e22aa7b 100644 /* Context menu options */ #define NAUTILUS_PREFERENCES_SHOW_DELETE_PERMANENTLY "show-delete-permanently" diff --git a/src/nautilus-preferences-window.c b/src/nautilus-preferences-window.c -index a436231cd..d22b513dd 100644 +index a1cd95823..b5e167120 100644 --- a/src/nautilus-preferences-window.c +++ b/src/nautilus-preferences-window.c -@@ -45,6 +45,8 @@ +@@ -41,6 +41,8 @@ "show_create_link_switch" #define NAUTILUS_PREFERENCES_DIALOG_LIST_VIEW_USE_TREE_WIDGET \ "use_tree_view_switch" @@ -39,7 +39,7 @@ index a436231cd..d22b513dd 100644 /* combo preferences */ #define NAUTILUS_PREFERENCES_DIALOG_OPEN_ACTION_COMBO \ -@@ -352,6 +354,9 @@ static void nautilus_preferences_window_setup(GtkBuilder *builder, +@@ -334,6 +336,9 @@ nautilus_preferences_window_setup (GtkBuilder *builder) bind_builder_bool (builder, nautilus_preferences, NAUTILUS_PREFERENCES_DIALOG_DELETE_PERMANENTLY_WIDGET, NAUTILUS_PREFERENCES_SHOW_DELETE_PERMANENTLY); @@ -50,132 +50,37 @@ index a436231cd..d22b513dd 100644 bind_builder_combo_row (builder, nautilus_preferences, NAUTILUS_PREFERENCES_DIALOG_OPEN_ACTION_COMBO, diff --git a/src/nautilus-query-editor.c b/src/nautilus-query-editor.c -index 7de9dddd6..dee287660 100644 +index 95b284b7d..4ca27b001 100644 --- a/src/nautilus-query-editor.c +++ b/src/nautilus-query-editor.c -@@ -52,6 +52,9 @@ struct _NautilusQueryEditor - guint search_changed_timeout_id; - gboolean change_frozen; +@@ -742,6 +742,12 @@ nautilus_query_editor_set_query (NautilusQueryEditor *self, -+ guint clear_type_ahead_timeout_id; -+ gboolean searching; -+ - GFile *location; - - NautilusQuery *query; -@@ -86,6 +89,9 @@ G_DEFINE_TYPE (NautilusQueryEditor, nautilus_query_editor, GTK_TYPE_WIDGET); - * so wait 400ms after typing, to improve performance by not spamming search engines: */ - #define SEARCH_CHANGED_TIMEOUT 400 - -+/* In type ahead mode, clear entry if it did not change for a while */ -+#define CLEAR_TYPE_AHEAD_TIMEOUT 1000 -+ - static void - update_fts_sensitivity (NautilusQueryEditor *editor) - { -@@ -139,6 +145,7 @@ nautilus_query_editor_dispose (GObject *object) - editor = NAUTILUS_QUERY_EDITOR (object); - - g_clear_handle_id (&editor->search_changed_timeout_id, g_source_remove); -+ g_clear_handle_id (&editor->clear_type_ahead_timeout_id, g_source_remove); - - gtk_widget_unparent (gtk_widget_get_first_child (GTK_WIDGET (editor))); - g_clear_pointer (&editor->tags_box, gtk_widget_unparent); -@@ -403,6 +410,25 @@ entry_changed_internal (NautilusQueryEditor *editor) - return G_SOURCE_REMOVE; - } - -+static void -+clear_type_ahead (NautilusQueryEditor *editor) -+{ -+ editor->change_frozen = TRUE; -+ gtk_editable_set_text (GTK_EDITABLE (editor->text), ""); -+ editor->change_frozen = FALSE; -+} -+ -+static gboolean -+clear_type_ahead_timeout_callback (NautilusQueryEditor *editor) -+{ -+ if (!editor->searching) -+ { -+ clear_type_ahead (editor); -+ } -+ editor->clear_type_ahead_timeout_id = 0; -+ return G_SOURCE_REMOVE; -+} -+ - static void - entry_changed_cb (GtkWidget *entry, - NautilusQueryEditor *editor) -@@ -412,10 +438,24 @@ entry_changed_cb (GtkWidget *entry, - return; - } - -+ g_clear_handle_id (&editor->clear_type_ahead_timeout_id, g_source_remove); - g_clear_handle_id (&editor->search_changed_timeout_id, g_source_remove); -- editor->search_changed_timeout_id = g_timeout_add (SEARCH_CHANGED_TIMEOUT, -- G_SOURCE_FUNC (entry_changed_internal), -- editor); -+ -+ /* In type ahead mode notify immediately that the entry changed, otherwise -+ * wait a few ms to not spam search engines. */ -+ if (editor->searching) -+ { -+ editor->search_changed_timeout_id = g_timeout_add (SEARCH_CHANGED_TIMEOUT, -+ G_SOURCE_FUNC (entry_changed_internal), -+ editor); -+ } -+ else -+ { -+ entry_changed_internal (editor); -+ editor->clear_type_ahead_timeout_id = g_timeout_add (CLEAR_TYPE_AHEAD_TIMEOUT, -+ G_SOURCE_FUNC (clear_type_ahead_timeout_callback), -+ editor); -+ } - } - - static GtkWidget * -@@ -673,6 +713,8 @@ nautilus_query_editor_init (NautilusQueryEditor *editor) - G_CALLBACK (search_popover_time_type_changed_cb), editor); - g_signal_connect (editor->popover, "notify::fts-enabled", - G_CALLBACK (search_popover_fts_changed_cb), editor); -+ -+ editor->searching = FALSE; - } + g_return_if_fail (NAUTILUS_IS_QUERY_EDITOR (self)); - static void -@@ -828,3 +870,15 @@ nautilus_query_editor_handle_event (NautilusQueryEditor *self, - - return gtk_event_controller_key_forward (controller, self->text); - } -+ -+void -+nautilus_query_editor_set_searching (NautilusQueryEditor *editor, -+ gboolean searching) -+{ -+ g_return_if_fail (NAUTILUS_IS_QUERY_EDITOR (editor)); -+ editor->searching = searching; -+ if (!editor->searching) -+ { -+ clear_type_ahead (editor); ++ /* Setting query to NULL causes reentry to set it to an empty query */ ++ if (self->change_frozen) { ++ g_set_object (&self->query, query); ++ return; + } -+} -diff --git a/src/nautilus-query-editor.h b/src/nautilus-query-editor.h -index 39b1f5e62..18eb4c9df 100644 ---- a/src/nautilus-query-editor.h -+++ b/src/nautilus-query-editor.h -@@ -69,3 +69,6 @@ nautilus_query_editor_handle_event (NautilusQueryEditor *self, - GtkEventControllerKey *controller, - guint keyval, - GdkModifierType state); + -+void nautilus_query_editor_set_searching (NautilusQueryEditor *editor, -+ gboolean searching); + if (query != NULL) + { + text = nautilus_query_get_text (query); diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c -index 1768675fe..aea84c26f 100644 +index ac367db12..567df1c88 100644 --- a/src/nautilus-window-slot.c +++ b/src/nautilus-window-slot.c -@@ -105,10 +105,6 @@ struct _NautilusWindowSlot +@@ -67,6 +67,9 @@ enum + + #define FILE_SHARING_SCHEMA_ID "org.gnome.desktop.file-sharing" + ++/* In type ahead mode, clear entry if it did not change for a while */ ++#define CLEAR_QUERY_EDITOR_TIMEOUT 1000 ++ + struct _NautilusWindowSlot + { + GtkBox parent_instance; +@@ -105,10 +108,7 @@ struct _NautilusWindowSlot /* Query editor */ NautilusQueryEditor *query_editor; NautilusQuery *pending_search_query; @@ -183,10 +88,11 @@ index 1768675fe..aea84c26f 100644 - gulong qe_cancel_id; - gulong qe_activated_id; - gulong qe_focus_view_id; ++ guint clear_query_editor_timeout_id; GtkLabel *search_info_label; GtkRevealer *search_info_label_revealer; -@@ -179,6 +175,7 @@ static void real_set_templates_menu (NautilusWindowSlot *self, +@@ -176,6 +176,7 @@ static void real_set_templates_menu (NautilusWindowSlot *self, GMenuModel *menu); static GMenuModel *real_get_templates_menu (NautilusWindowSlot *self); static void nautilus_window_slot_setup_extra_location_widgets (NautilusWindowSlot *self); @@ -194,7 +100,7 @@ index 1768675fe..aea84c26f 100644 void free_navigation_state (gpointer data) -@@ -447,6 +444,12 @@ query_editor_focus_view_callback (NautilusQueryEditor *editor, +@@ -426,6 +427,37 @@ query_editor_focus_view_callback (NautilusQueryEditor *editor, } } @@ -204,19 +110,44 @@ index 1768675fe..aea84c26f 100644 + return g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_TYPE_AHEAD_SEARCH); +} + ++static gboolean ++clear_query_editor_timeout_callback (NautilusWindowSlot *self) ++{ ++ nautilus_query_editor_set_query (self->query_editor, NULL); ++ self->clear_query_editor_timeout_id = 0; ++ return G_SOURCE_REMOVE; ++} ++ ++typedef struct { ++ GQuark attribute; ++ gboolean directories_first; ++ gboolean reversed; ++} FileCompareForTypeAheadContext; ++ ++static int ++file_compare_for_type_ahead (gconstpointer a, gconstpointer b, gpointer user_data) ++{ ++ FileCompareForTypeAheadContext *ctx = user_data; ++ return nautilus_file_compare_for_sort_by_attribute_q (NAUTILUS_FILE(a), ++ NAUTILUS_FILE(b), ++ ctx->attribute, ++ ctx->directories_first, ++ ctx->reversed); ++} ++ static void query_editor_changed_callback (NautilusQueryEditor *editor, NautilusQuery *query, -@@ -457,8 +460,47 @@ query_editor_changed_callback (NautilusQueryEditor *editor, +@@ -436,8 +468,61 @@ query_editor_changed_callback (NautilusQueryEditor *editor, view = nautilus_window_slot_get_current_view (self); - nautilus_view_set_search_query (view, query); -- nautilus_window_slot_open_location_full (self, nautilus_view_get_location (view), 0, NULL); -+ if (type_ahead_search () || nautilus_window_slot_get_searching (self)) +- nautilus_window_slot_set_location (self, nautilus_view_get_location (view)); ++ if (nautilus_window_slot_get_search_visible (self)) + { + nautilus_view_set_search_query (view, query); -+ nautilus_window_slot_open_location_full (self, nautilus_view_get_location (view), 0, NULL); ++ nautilus_window_slot_set_location (self, nautilus_view_get_location (view)); + } + else + { @@ -227,10 +158,10 @@ index 1768675fe..aea84c26f 100644 + g_autofree gchar *text_casefold = g_utf8_casefold (text, -1); + g_autofree gchar *text_collate = g_utf8_collate_key_for_filename (text_casefold, -1); + gsize text_len = strlen (text); -+ GList *files, *l; -+ GList *matches = NULL; ++ g_autolist (NautilusFile) files = nautilus_directory_get_file_list (directory); ++ g_autolist (NautilusFile) matches = NULL; ++ GList *l; + -+ files = nautilus_directory_get_file_list (directory); + for (l = files; l; l = l->next) + { + NautilusFile *file = NAUTILUS_FILE (l->data); @@ -245,19 +176,33 @@ index 1768675fe..aea84c26f 100644 + } + + /* Select the first match */ -+ matches = nautilus_file_list_sort_by_display_name (matches); -+ l = matches; -+ matches = g_list_remove_link (matches, l); -+ nautilus_view_set_selection (self->content_view, l); ++ { ++ FileCompareForTypeAheadContext ctx; ++ GActionGroup *action_group = nautilus_files_view_get_action_group (NAUTILUS_FILES_VIEW (view)); ++ g_autoptr (GVariant) value = g_action_group_get_action_state (action_group, "sort"); ++ const gchar *attribute_name; ++ g_autolist (NautilusFile) selection; ++ ++ g_variant_get (value, "(&sb)", &attribute_name, &ctx.reversed); ++ ctx.attribute = g_quark_from_string (attribute_name); ++ ctx.directories_first = nautilus_files_view_should_sort_directories_first (NAUTILUS_FILES_VIEW (view)); ++ matches = g_list_sort_with_data (matches, file_compare_for_type_ahead, &ctx); ++ ++ selection = matches; ++ matches = g_list_remove_link (matches, selection); ++ nautilus_view_set_selection (self->content_view, selection); ++ } + -+ nautilus_file_list_free (files); -+ nautilus_file_list_free (matches); -+ nautilus_file_list_free (l); ++ /* Reset timeout that clears type ahead query */ ++ g_clear_handle_id (&self->clear_query_editor_timeout_id, g_source_remove); ++ self->clear_query_editor_timeout_id = g_timeout_add (CLEAR_QUERY_EDITOR_TIMEOUT, ++ G_SOURCE_FUNC (clear_query_editor_timeout_callback), ++ self); + } } static void -@@ -468,11 +510,6 @@ hide_query_editor (NautilusWindowSlot *self) +@@ -447,11 +532,6 @@ hide_query_editor (NautilusWindowSlot *self) view = nautilus_window_slot_get_current_view (self); @@ -269,7 +214,7 @@ index 1768675fe..aea84c26f 100644 nautilus_query_editor_set_query (self->query_editor, NULL); if (nautilus_view_is_searching (view)) -@@ -534,31 +571,6 @@ show_query_editor (NautilusWindowSlot *self) +@@ -515,31 +595,6 @@ show_query_editor (NautilusWindowSlot *self) } gtk_widget_grab_focus (GTK_WIDGET (self->query_editor)); @@ -301,7 +246,7 @@ index 1768675fe..aea84c26f 100644 } static void -@@ -653,7 +665,7 @@ nautilus_window_slot_handle_event (NautilusWindowSlot *self, +@@ -634,7 +689,7 @@ nautilus_window_slot_handle_event (NautilusWindowSlot *self, state); } @@ -310,15 +255,7 @@ index 1768675fe..aea84c26f 100644 { nautilus_window_slot_set_search_visible (self, TRUE); } -@@ -684,6 +696,7 @@ nautilus_window_slot_set_searching (NautilusWindowSlot *self, - { - self->searching = searching; - g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SEARCHING]); -+ nautilus_query_editor_set_searching (self->query_editor, searching); - } - - static void -@@ -926,6 +939,15 @@ nautilus_window_slot_constructed (GObject *object) +@@ -886,6 +941,15 @@ nautilus_window_slot_constructed (GObject *object) gtk_box_append (GTK_BOX (self), extras_vbox); self->query_editor = NAUTILUS_QUERY_EDITOR (nautilus_query_editor_new ()); @@ -334,11 +271,21 @@ index 1768675fe..aea84c26f 100644 /* We want to keep alive the query editor betwen additions and removals on the * UI, specifically when the toolbar adds or removes it */ g_object_ref_sink (self->query_editor); +@@ -1972,6 +2036,9 @@ setup_view (NautilusWindowSlot *self, + + nautilus_window_slot_disconnect_content_view (self); + ++ nautilus_query_editor_set_query (self->query_editor, NULL); ++ g_clear_handle_id (&self->clear_query_editor_timeout_id, g_source_remove); ++ + self->new_content_view = view; + + nautilus_window_slot_connect_new_content_view (self); diff --git a/src/nautilus-window.c b/src/nautilus-window.c -index 0033dcf5d..0f1c1004e 100644 +index 9429500c0..d9f6003e2 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c -@@ -1531,6 +1531,7 @@ const GActionEntry win_entries[] = +@@ -1579,6 +1579,7 @@ const GActionEntry win_entries[] = { "forward", action_forward }, { "back-n", action_back_n, "u" }, { "forward-n", action_forward_n, "u" }, @@ -346,7 +293,7 @@ index 0033dcf5d..0f1c1004e 100644 { "up", action_up }, { "current-location-menu", action_show_current_location_menu }, { "open-location", action_open_location, "s" }, -@@ -1587,6 +1588,7 @@ nautilus_window_initialize_actions (NautilusWindow *window) +@@ -1644,6 +1645,7 @@ nautilus_window_initialize_actions (NautilusWindow *window) /* Only accesible by shorcuts */ nautilus_application_set_accelerators (app, "win.bookmark-current-location", ACCELS ("<control>d", "AddFavorite")); nautilus_application_set_accelerator (app, "win.up", "<alt>Up"); @@ -355,10 +302,10 @@ index 0033dcf5d..0f1c1004e 100644 nautilus_application_set_accelerator (app, "win.go-starred", "Favorites"); nautilus_application_set_accelerator (app, "win.tab-move-left", "<shift><control>Page_Up"); diff --git a/src/resources/ui/nautilus-preferences-window.ui b/src/resources/ui/nautilus-preferences-window.ui -index 9b2cd2edc..6ba51aaae 100644 +index cff1c278e..8ad928908 100644 --- a/src/resources/ui/nautilus-preferences-window.ui +++ b/src/resources/ui/nautilus-preferences-window.ui -@@ -50,6 +50,21 @@ +@@ -49,6 +49,21 @@ <property name="visible">True</property> </object> </child> |