[nautilus/2094-search-button-doesn-t-focus-the-search-entry] query-editor: Stop using GtkSearchEntry
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/2094-search-button-doesn-t-focus-the-search-entry] query-editor: Stop using GtkSearchEntry
- Date: Thu, 21 Apr 2022 08:53:12 +0000 (UTC)
commit 120107dc3241e9dd737a7aabc36900963cef6012
Author: António Fernandes <antoniof gnome org>
Date: Thu Apr 21 09:25:28 2022 +0100
query-editor: Stop using GtkSearchEntry
It doesn't have a ::grab_focus_without_selecting() method, which is
breaking keyboard focus expectations. Also, GtkSearchEntry is just
a placeholder until we have a tagged search entry.
Therefore, use GtkEntry and make it look and behave like a search
entry would, except for the delayed "search-changed" signal. That's
to be implemented later along with the tags anyway.
Closes https://gitlab.gnome.org/GNOME/nautilus/-/issues/2094
src/nautilus-query-editor.c | 41 ++++++++++++++++++++++++++++++-----------
1 file changed, 30 insertions(+), 11 deletions(-)
---
diff --git a/src/nautilus-query-editor.c b/src/nautilus-query-editor.c
index 98d69f3b0..e98223120 100644
--- a/src/nautilus-query-editor.c
+++ b/src/nautilus-query-editor.c
@@ -294,6 +294,10 @@ nautilus_query_editor_class_init (NautilusQueryEditorClass *class)
gtk_signal_action_new ("focus-view"));
gtk_widget_class_add_shortcut (widget_class, shortcut);
+ shortcut = gtk_shortcut_new (gtk_keyval_trigger_new (GDK_KEY_Escape, 0),
+ gtk_signal_action_new ("cancel"));
+ gtk_widget_class_add_shortcut (widget_class, shortcut);
+
/**
* NautilusQueryEditor::location:
*
@@ -395,13 +399,6 @@ entry_changed_cb (GtkWidget *entry,
nautilus_query_editor_changed (editor);
}
-static void
-nautilus_query_editor_on_stop_search (GtkWidget *entry,
- NautilusQueryEditor *editor)
-{
- g_signal_emit (editor, signals[CANCEL], 0);
-}
-
/* Type */
static void
@@ -564,11 +561,23 @@ entry_tag_close_button_clicked (NautilusQueryEditor *editor,
}
#endif
+static void
+on_clear_icon_release (GtkEntry *entry,
+ GtkEntryIconPosition icon_pos,
+ gpointer user_data)
+{
+ if (icon_pos == GTK_ENTRY_ICON_SECONDARY)
+ {
+ gtk_editable_set_text (GTK_EDITABLE (entry), "");
+ }
+}
+
static void
setup_widgets (NautilusQueryEditor *editor)
{
GtkWidget *hbox;
GtkWidget *vbox;
+ GtkEntry *entry;
/* vertical box that holds the search entry and the label below */
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
@@ -583,9 +592,21 @@ setup_widgets (NautilusQueryEditor *editor)
#if 0 && TAGGED_ENTRY_NEEDS_GTK4_REIMPLEMENTATION
editor->entry = GTK_WIDGET (gd_tagged_entry_new ());
#else
- editor->entry = gtk_search_entry_new ();
+ editor->entry = gtk_entry_new ();
+ entry = GTK_ENTRY (editor->entry);
#endif
gtk_widget_set_hexpand (editor->entry, TRUE);
+ gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_PRIMARY,
+ "system-search-symbolic");
+
+ gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_SECONDARY,
+ (gtk_widget_get_direction (editor->entry) == GTK_TEXT_DIR_RTL ?
+ "edit-clear-rtl-symbolic" :
+ "edit-clear-symbolic"));
+ gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_SECONDARY,
+ _("Clear search query"));
+ gtk_entry_set_icon_activatable (entry, GTK_ENTRY_ICON_SECONDARY, TRUE);
+ g_signal_connect (entry, "icon-release", G_CALLBACK (on_clear_icon_release), NULL);
gtk_box_append (GTK_BOX (hbox), editor->entry);
@@ -622,10 +643,8 @@ setup_widgets (NautilusQueryEditor *editor)
g_signal_connect (editor->entry, "activate",
G_CALLBACK (entry_activate_cb), editor);
- g_signal_connect (editor->entry, "search-changed",
+ g_signal_connect (editor->entry, "changed",
G_CALLBACK (entry_changed_cb), editor);
- g_signal_connect (editor->entry, "stop-search",
- G_CALLBACK (nautilus_query_editor_on_stop_search), editor);
g_signal_connect (editor->popover, "date-range",
G_CALLBACK (search_popover_date_range_changed_cb), editor);
g_signal_connect (editor->popover, "mime-type",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]