combo box: Stop using ::key-press-event

Switch to using ::event.
This commit is contained in:
Matthias Clasen 2018-02-07 19:36:48 -05:00 committed by Carlos Garnacho
parent ec84fb90bf
commit df386f29ab
2 changed files with 20 additions and 17 deletions

View File

@ -278,8 +278,8 @@ 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_key_press (GtkWidget *widget,
GdkEventKey *event,
static gboolean gtk_combo_box_menu_event (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static void gtk_combo_box_menu_popup (GtkComboBox *combo_box);
@ -846,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_key_press);
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_show);
gtk_widget_class_bind_template_callback (widget_class, gtk_combo_box_menu_hide);
@ -1937,18 +1937,18 @@ gtk_combo_box_model_row_changed (GtkTreeModel *model,
}
static gboolean
gtk_combo_box_menu_key_press (GtkWidget *widget,
GdkEventKey *event,
gpointer data)
gtk_combo_box_menu_event (GtkWidget *widget,
GdkEvent *event,
gpointer data)
{
GtkComboBox *combo_box = GTK_COMBO_BOX (data);
if (!gtk_bindings_activate_event (G_OBJECT (widget), event))
if (!gtk_bindings_activate_event (G_OBJECT (widget), (GdkEventKey *)event))
{
/* The menu hasn't managed the
* event, forward it to the combobox
*/
gtk_bindings_activate_event (G_OBJECT (combo_box), event);
gtk_bindings_activate_event (G_OBJECT (combo_box), (GdkEventKey *)event);
}
return TRUE;
@ -2738,14 +2738,17 @@ gtk_combo_box_dispose (GObject* object)
}
static gboolean
gtk_cell_editable_key_press (GtkWidget *widget,
GdkEventKey *event,
gpointer data)
gtk_cell_editable_event (GtkWidget *widget,
GdkEvent *event,
gpointer data)
{
GtkComboBox *combo_box = GTK_COMBO_BOX (data);
guint keyval;
if (!gdk_event_get_keyval ((GdkEvent *) event, &keyval))
if (gdk_event_get_event_type (event) != GDK_KEY_PRESS)
return GDK_EVENT_PROPAGATE;
if (!gdk_event_get_keyval (event, &keyval))
return GDK_EVENT_PROPAGATE;
if (keyval == GDK_KEY_Escape)
@ -2783,8 +2786,8 @@ gtk_combo_box_start_editing (GtkCellEditable *cell_editable,
if (priv->cell_view)
{
g_signal_connect_object (priv->button, "key-press-event",
G_CALLBACK (gtk_cell_editable_key_press),
g_signal_connect_object (priv->button, "event",
G_CALLBACK (gtk_cell_editable_event),
cell_editable, 0);
gtk_widget_grab_focus (priv->button);
@ -2793,8 +2796,8 @@ gtk_combo_box_start_editing (GtkCellEditable *cell_editable,
{
child = gtk_bin_get_child (GTK_BIN (combo_box));
g_signal_connect_object (child, "key-press-event",
G_CALLBACK (gtk_cell_editable_key_press),
g_signal_connect_object (child, "event",
G_CALLBACK (gtk_cell_editable_event),
cell_editable, 0);
gtk_widget_grab_focus (child);

View File

@ -34,7 +34,7 @@
<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="key-press-event" handler="gtk_combo_box_menu_key_press" 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"/>
</object>