[gtk/matthiasc/for-master: 16/16] modelbutton: Unify activation code paths
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 16/16] modelbutton: Unify activation code paths
- Date: Thu, 7 May 2020 00:27:50 +0000 (UTC)
commit 236fc57329f74573da10f4dfd97e99c9e2b8ec0d
Author: Matthias Clasen <mclasen redhat com>
Date: Wed May 6 20:25:42 2020 -0400
modelbutton: Unify activation code paths
Opening submenus by Enter or Space wasn't working,
because we had different code paths for activation
via keynav and via click. Unify them.
gtk/gtkmodelbutton.c | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtkmodelbutton.c b/gtk/gtkmodelbutton.c
index 1579c1335f..e8fe1bebaf 100644
--- a/gtk/gtkmodelbutton.c
+++ b/gtk/gtkmodelbutton.c
@@ -183,7 +183,14 @@ struct _GtkModelButton
guint iconic : 1;
};
-typedef GtkWidgetClass GtkModelButtonClass;
+typedef struct _GtkModelButtonClass GtkModelButtonClass;
+
+struct _GtkModelButtonClass
+{
+ GtkWidgetClass parent_class;
+
+ void (* clicked) (GtkModelButton *button);
+};
static void gtk_model_button_actionable_iface_init (GtkActionableInterface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkModelButton, gtk_model_button, GTK_TYPE_WIDGET,
@@ -968,11 +975,7 @@ close_menu (GtkModelButton *self)
}
static void
-gtk_model_button_clicked (GtkGestureClick *gesture,
- guint n_press,
- double x,
- double y,
- GtkModelButton *self)
+gtk_model_button_clicked (GtkModelButton *self)
{
if (self->menu_name != NULL)
{
@@ -994,8 +997,6 @@ gtk_model_button_clicked (GtkGestureClick *gesture,
close_menu (self);
}
- g_signal_emit (self, signals[SIGNAL_CLICKED], 0);
-
if (self->action_helper)
gtk_action_helper_activate (self->action_helper);
}
@@ -1094,6 +1095,8 @@ gtk_model_button_class_init (GtkModelButtonClass *class)
widget_class->focus = gtk_model_button_focus;
widget_class->get_accessible = gtk_model_button_get_accessible;
+ class->clicked = gtk_model_button_clicked;
+
/**
* GtkModelButton:role:
*
@@ -1221,7 +1224,7 @@ gtk_model_button_class_init (GtkModelButtonClass *class)
signals[SIGNAL_CLICKED] = g_signal_new (I_("clicked"),
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
- 0,
+ G_STRUCT_OFFSET (GtkModelButtonClass, clicked),
NULL, NULL,
NULL,
G_TYPE_NONE, 0);
@@ -1365,6 +1368,12 @@ focus_in_cb (GtkEventController *controller,
gtk_popover_menu_set_active_item (GTK_POPOVER_MENU (popover), target);
}
+static void
+emit_clicked (GtkModelButton *button)
+{
+ g_signal_emit (button, signals[SIGNAL_CLICKED], 0);
+}
+
static void
gtk_model_button_init (GtkModelButton *self)
{
@@ -1398,7 +1407,7 @@ gtk_model_button_init (GtkModelButton *self)
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture), FALSE);
gtk_gesture_single_set_exclusive (GTK_GESTURE_SINGLE (gesture), TRUE);
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), GDK_BUTTON_PRIMARY);
- g_signal_connect (gesture, "released", G_CALLBACK (gtk_model_button_clicked), self);
+ g_signal_connect_swapped (gesture, "released", G_CALLBACK (emit_clicked), self);
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture), GTK_PHASE_CAPTURE);
gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (gesture));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]