entries: Fix mnemonic activation

Since entries are no longer can-focus, the default
mnemonic_activate handler refuses to act on them.
This commit is contained in:
Matthias Clasen 2019-03-03 22:14:19 -05:00
parent bed4c68041
commit 02318dbda7
4 changed files with 63 additions and 0 deletions

View File

@ -332,6 +332,18 @@ gtk_entry_grab_focus (GtkWidget *widget)
gtk_widget_grab_focus (priv->text);
}
static gboolean
gtk_entry_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling)
{
GtkEntry *entry = GTK_ENTRY (widget);
GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
gtk_widget_grab_focus (priv->text);
return TRUE;
}
static void
gtk_entry_class_init (GtkEntryClass *class)
{
@ -351,6 +363,7 @@ gtk_entry_class_init (GtkEntryClass *class)
widget_class->query_tooltip = gtk_entry_query_tooltip;
widget_class->direction_changed = gtk_entry_direction_changed;
widget_class->grab_focus = gtk_entry_grab_focus;
widget_class->mnemonic_activate = gtk_entry_mnemonic_activate;
quark_entry_completion = g_quark_from_static_string ("gtk-entry-completion-key");

View File

@ -226,6 +226,18 @@ gtk_password_entry_grab_focus (GtkWidget *widget)
gtk_widget_grab_focus (priv->entry);
}
static gboolean
gtk_password_entry_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling)
{
GtkPasswordEntry *entry = GTK_PASSWORD_ENTRY (widget);
GtkPasswordEntryPrivate *priv = gtk_password_entry_get_instance_private (entry);
gtk_widget_grab_focus (priv->entry);
return TRUE;
}
static void
gtk_password_entry_class_init (GtkPasswordEntryClass *klass)
{
@ -242,6 +254,7 @@ gtk_password_entry_class_init (GtkPasswordEntryClass *klass)
widget_class->size_allocate = gtk_password_entry_size_allocate;
widget_class->get_accessible = gtk_password_entry_get_accessible;
widget_class->grab_focus = gtk_password_entry_grab_focus;
widget_class->mnemonic_activate = gtk_password_entry_mnemonic_activate;
gtk_editable_install_properties (object_class, 1);

View File

@ -258,6 +258,18 @@ gtk_search_entry_grab_focus (GtkWidget *widget)
gtk_text_grab_focus_without_selecting (GTK_TEXT (priv->entry));
}
static void
gtk_search_entry_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling)
{
GtkSearchEntry *entry = GTK_SEARCH_ENTRY (widget);
GtkSearchEntryPrivate *priv = gtk_search_entry_get_instance_private (entry);
gtk_widget_grab_focus (priv->entry);
return TRUE;
}
static void
gtk_search_entry_class_init (GtkSearchEntryClass *klass)
{
@ -273,6 +285,7 @@ gtk_search_entry_class_init (GtkSearchEntryClass *klass)
widget_class->size_allocate = gtk_search_entry_size_allocate;
widget_class->get_accessible = gtk_search_entry_get_accessible;
widget_class->grab_focus = gtk_search_entry_grab_focus;
widget_class->mnemonic_activate = gtk_search_entry_mnemonic_activate;
klass->stop_search = gtk_search_entry_stop_search;

View File

@ -304,6 +304,28 @@ G_DEFINE_TYPE_WITH_CODE (GtkSpinButton, gtk_spin_button, GTK_TYPE_WIDGET,
"change-value", 1, \
GTK_TYPE_SCROLL_TYPE, scroll)
static void
gtk_spin_button_grab_focus (GtkWidget *widget)
{
GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget);
GtkSpinButtonPrivate *priv = gtk_spin_button_get_instance_private (spin_button);
gtk_widget_grab_focus (priv->entry);
}
static gboolean
gtk_spin_button_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling)
{
GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget);
GtkSpinButtonPrivate *priv = gtk_spin_button_get_instance_private (spin_button);
gtk_widget_grab_focus (priv->entry);
return TRUE;
}
static void
gtk_spin_button_class_init (GtkSpinButtonClass *class)
{
@ -321,6 +343,8 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class)
widget_class->size_allocate = gtk_spin_button_size_allocate;
widget_class->grab_notify = gtk_spin_button_grab_notify;
widget_class->state_flags_changed = gtk_spin_button_state_flags_changed;
widget_class->grab_focus = gtk_spin_button_grab_focus;
widget_class->mnemonic_activate = gtk_spin_button_mnemonic_activate;
class->input = NULL;
class->output = NULL;