[gtk/widget-class-actions: 7/8] widget: Turn popup-menu binding into action



commit 8634082fe3699f9ec39375df264c7e7134082fa7
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Jun 17 15:52:21 2019 +0000

    widget: Turn popup-menu binding into action
    
    This is a trial for seeing how this works in practice.

 gtk/gtkwidget.c | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 5f1850994e..2ae0313d56 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -718,6 +718,10 @@ static void add_parent_surface_transform_changed_listener (GtkWidget *widget);
 static gboolean gtk_widget_activate_accels (GtkWidget      *widget,
                                             const GdkEvent *event);
 
+static void gtk_widget_activate_menu_popup (GtkWidget  *widget,
+                                            const char *action_name,
+                                            GVariant   *parameter);
+
 
 /* --- variables --- */
 static gint             GtkWidget_private_offset = 0;
@@ -870,7 +874,6 @@ static void
 gtk_widget_class_init (GtkWidgetClass *klass)
 {
   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-  GtkBindingSet *binding_set;
 
   g_type_class_adjust_private_offset (klass, &GtkWidget_private_offset);
   gtk_widget_parent_class = g_type_class_peek_parent (klass);
@@ -2126,11 +2129,11 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                               G_TYPE_FROM_CLASS (klass),
                               _gtk_marshal_BOOLEAN__UINTv);
 
-  binding_set = gtk_binding_set_by_class (klass);
-  gtk_binding_entry_add_signal (binding_set, GDK_KEY_F10, GDK_SHIFT_MASK,
-                                "popup-menu", 0);
-  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Menu, 0,
-                                "popup-menu", 0);
+  gtk_widget_class_install_action (klass, "menu.popup",
+                                   gtk_widget_activate_menu_popup);
+
+  gtk_widget_class_bind_action (klass, GDK_KEY_Menu, 0, "menu.popup", NULL);
+  gtk_widget_class_bind_action (klass, GDK_KEY_Menu, GDK_SHIFT_MASK, "menu.popup", NULL);
 
   gtk_widget_class_set_accessible_type (klass, GTK_TYPE_WIDGET_ACCESSIBLE);
   gtk_widget_class_set_css_name (klass, I_("widget"));
@@ -12468,6 +12471,17 @@ gtk_widget_activate_default (GtkWidget *widget)
   gtk_widget_activate_action (widget, "default.activate", NULL);
 }
 
+
+static void
+gtk_widget_activate_menu_popup (GtkWidget  *widget,
+                                const char *action_name,
+                                GVariant   *parameter)
+{
+  gboolean handled;
+
+  g_signal_emit (widget, widget_signals[POPUP_MENU], 0, &handled);
+}
+
 void
 gtk_widget_cancel_event_sequence (GtkWidget             *widget,
                                   GtkGesture            *gesture,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]