Commit ffbe7f6e authored by Bastien Nocera's avatar Bastien Nocera

GtkEntry: Focus the entry without selecting the text

Focusing the text entry without selecting all the text is needed in
some places (GtkTreeView, and some uses of GtkSearchEntry) so
create a private helper to avoid replicating the hacks.
parent 875b1d07
......@@ -4725,6 +4725,15 @@ gtk_entry_focus_out (GtkWidget *widget,
return FALSE;
_gtk_entry_grab_focus (GtkEntry *entry,
gboolean select_all)
GTK_WIDGET_CLASS (gtk_entry_parent_class)->grab_focus (GTK_WIDGET (entry));
if (select_all)
gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
static void
gtk_entry_grab_focus (GtkWidget *widget)
......@@ -4732,8 +4741,6 @@ gtk_entry_grab_focus (GtkWidget *widget)
GtkEntryPrivate *priv = entry->priv;
gboolean select_on_focus;
GTK_WIDGET_CLASS (gtk_entry_parent_class)->grab_focus (widget);
if (priv->editable && !priv->in_click)
g_object_get (gtk_widget_get_settings (widget),
......@@ -4741,8 +4748,11 @@ gtk_entry_grab_focus (GtkWidget *widget)
if (select_on_focus)
gtk_editable_select_region (GTK_EDITABLE (widget), 0, -1);
_gtk_entry_grab_focus (entry, select_on_focus);
_gtk_entry_grab_focus (entry, FALSE);
......@@ -87,7 +87,8 @@ void _gtk_entry_get_borders (GtkEntry *entry,
GtkIMContext* _gtk_entry_get_im_context (GtkEntry *entry);
void _gtk_entry_set_is_cell_renderer (GtkEntry *entry,
gboolean is_cell_renderer);
void _gtk_entry_grab_focus (GtkEntry *entry,
gboolean select_all);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment