diff options
author | Nelson Benítez León <nbenitezl@gmail.com> | 2022-08-16 16:13:21 -0400 |
---|---|---|
committer | Nelson Benítez León <nbenitezl@gmail.com> | 2022-08-16 16:32:05 -0400 |
commit | 884d08b9edad5593da60007067d201c6cfbf44c6 (patch) | |
tree | 2d9e5629f5c07d2b67c8411d22ad81425e4b021e | |
parent | 187093f2a141d6b3ee04f8a307bd1e8556021cbe (diff) | |
download | gtk+-gtk3_fix_chooser_entry_selection.tar.gz |
filechooserentry: unselect text when unfocusedgtk3_fix_chooser_entry_selection
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
-rw-r--r-- | gtk/gtkfilechooserentry.c | 15 | ||||
-rw-r--r-- | 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; |