[gtk/gtk3_fix_chooser_dead_tilde_trigger_location: 1/2] filechooserentry: unselect text when unfocused
- From: Nelson Ben <nbenitez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/gtk3_fix_chooser_dead_tilde_trigger_location: 1/2] filechooserentry: unselect text when unfocused
- Date: Sun, 21 Aug 2022 19:23:20 +0000 (UTC)
commit 1ef483988b65e02193e8fa5cfb37028c9b746904
Author: Nelson Benítez León <nbenitezl gmail com>
Date: Tue Aug 16 16:13:21 2022 -0400
filechooserentry: unselect text when unfocused
There's no gain in keeping text selected while entry is
unfocused other than confusing users which (misguided by
the strong selection color) think the entry is focused
and so when start typing to edit the text an unexpected
search dialog appears.
Fixes #326
Fixes #665
gtk/gtkfilechooserentry.c | 15 ++++++++++++++-
gtk/gtkfilechooserwidget.c | 3 ---
2 files changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c
index 02f9d5542f..01479fdef8 100644
--- a/gtk/gtkfilechooserentry.c
+++ b/gtk/gtkfilechooserentry.c
@@ -115,6 +115,7 @@ static void set_completion_folder (GtkFileChooserEntry *chooser_entry,
static void finished_loading_cb (GtkFileSystemModel *model,
GError *error,
GtkFileChooserEntry *chooser_entry);
+static void _gtk_file_chooser_entry_unselect_text (GtkFileChooserEntry *chooser_entry);
G_DEFINE_TYPE (GtkFileChooserEntry, _gtk_file_chooser_entry, GTK_TYPE_ENTRY)
@@ -483,7 +484,6 @@ static void
gtk_file_chooser_entry_grab_focus (GtkWidget *widget)
{
GTK_WIDGET_CLASS (_gtk_file_chooser_entry_parent_class)->grab_focus (widget);
- _gtk_file_chooser_entry_select_filename (GTK_FILE_CHOOSER_ENTRY (widget));
}
static void
@@ -543,6 +543,7 @@ gtk_file_chooser_entry_focus_out_event (GtkWidget *widget,
GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (widget);
set_complete_on_load (chooser_entry, FALSE);
+ _gtk_file_chooser_entry_unselect_text (chooser_entry);
return GTK_WIDGET_CLASS (_gtk_file_chooser_entry_parent_class)->focus_out_event (widget, event);
}
@@ -1050,6 +1051,18 @@ _gtk_file_chooser_entry_select_filename (GtkFileChooserEntry *chooser_entry)
gtk_editable_select_region (GTK_EDITABLE (chooser_entry), 0, (gint) len);
}
+/*
+ * _gtk_file_chooser_entry_unselect_text:
+ * @chooser_entry: a #GtkFileChooserEntry
+ *
+ * Unselects any existing text selection.
+ */
+static void
+_gtk_file_chooser_entry_unselect_text (GtkFileChooserEntry *chooser_entry)
+{
+ gtk_editable_select_region (GTK_EDITABLE (chooser_entry), 0, 0);
+}
+
void
_gtk_file_chooser_entry_set_local_only (GtkFileChooserEntry *chooser_entry,
gboolean local_only)
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index 6a29f3fcf8..f8cfcb4732 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -5466,9 +5466,6 @@ update_chooser_entry (GtkFileChooserWidget *impl)
g_signal_handlers_block_by_func (priv->location_entry, G_CALLBACK (location_entry_changed_cb),
impl);
gtk_entry_set_text (GTK_ENTRY (priv->location_entry), priv->browse_files_last_selected_name);
g_signal_handlers_unblock_by_func (priv->location_entry, G_CALLBACK
(location_entry_changed_cb), impl);
-
- if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
- _gtk_file_chooser_entry_select_filename (GTK_FILE_CHOOSER_ENTRY (priv->location_entry));
}
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]