mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-15 21:20:09 +00:00
gtkcombobox: Use controller to handle combobox keybindings in menus
Instead of an ::event callback.
This commit is contained in:
parent
7ef95734af
commit
cdfde6673d
@ -39,6 +39,7 @@
|
||||
#include "gtktogglebutton.h"
|
||||
#include "gtktreemenu.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkeventcontrollerkey.h"
|
||||
|
||||
#include "a11y/gtkcomboboxaccessible.h"
|
||||
|
||||
@ -275,9 +276,11 @@ static void gtk_combo_box_menu_activate (GtkWidget *menu,
|
||||
const gchar *path,
|
||||
GtkComboBox *combo_box);
|
||||
static void gtk_combo_box_update_sensitivity (GtkComboBox *combo_box);
|
||||
static gboolean gtk_combo_box_menu_event (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data);
|
||||
static gboolean gtk_combo_box_menu_key (GtkEventControllerKey *key,
|
||||
guint keyval,
|
||||
guint keycode,
|
||||
GdkModifierType modifiers,
|
||||
GtkComboBox *combo_box);
|
||||
static void gtk_combo_box_menu_popup (GtkComboBox *combo_box);
|
||||
|
||||
/* cell layout */
|
||||
@ -843,7 +846,7 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
|
||||
gtk_widget_class_bind_template_child_internal_private (widget_class, GtkComboBox, popup_widget);
|
||||
gtk_widget_class_bind_template_callback (widget_class, gtk_combo_box_button_toggled);
|
||||
gtk_widget_class_bind_template_callback (widget_class, gtk_combo_box_menu_activate);
|
||||
gtk_widget_class_bind_template_callback (widget_class, gtk_combo_box_menu_event);
|
||||
gtk_widget_class_bind_template_callback (widget_class, gtk_combo_box_menu_key);
|
||||
gtk_widget_class_bind_template_callback (widget_class, gtk_combo_box_menu_show);
|
||||
gtk_widget_class_bind_template_callback (widget_class, gtk_combo_box_menu_hide);
|
||||
|
||||
@ -1931,21 +1934,26 @@ gtk_combo_box_model_row_changed (GtkTreeModel *model,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_combo_box_menu_event (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data)
|
||||
gtk_combo_box_menu_key (GtkEventControllerKey *key,
|
||||
guint keyval,
|
||||
guint keycode,
|
||||
GdkModifierType modifiers,
|
||||
GtkComboBox *combo_box)
|
||||
{
|
||||
GtkComboBox *combo_box = GTK_COMBO_BOX (data);
|
||||
GtkWidget *widget;
|
||||
GdkEvent *event;
|
||||
|
||||
widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (key));
|
||||
event = gtk_get_current_event ();
|
||||
|
||||
if (!gtk_bindings_activate_event (G_OBJECT (widget), (GdkEventKey *)event))
|
||||
{
|
||||
/* The menu hasn't managed the
|
||||
* event, forward it to the combobox
|
||||
*/
|
||||
return gtk_bindings_activate_event (G_OBJECT (combo_box), (GdkEventKey *)event);
|
||||
gtk_event_controller_key_forward (key, GTK_WIDGET (combo_box));
|
||||
}
|
||||
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
g_object_unref (event);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -34,8 +34,13 @@
|
||||
<object class="GtkTreeMenu" id="popup_widget">
|
||||
<property name="cell-area">area</property>
|
||||
<signal name="menu-activate" handler="gtk_combo_box_menu_activate" swapped="no"/>
|
||||
<signal name="event" handler="gtk_combo_box_menu_event" swapped="no"/>
|
||||
<signal name="show" handler="gtk_combo_box_menu_show" swapped="no"/>
|
||||
<signal name="hide" handler="gtk_combo_box_menu_hide" swapped="no"/>
|
||||
<child>
|
||||
<object class="GtkEventControllerKey">
|
||||
<signal name="key-pressed" handler="gtk_combo_box_menu_key" swapped="no"/>
|
||||
<signal name="key-released" handler="gtk_combo_box_menu_key" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
|
Loading…
Reference in New Issue
Block a user