[gtk/wip/matthiasc/context-menu: 31/38] popover: Bring back the activate-default signal



commit 78ebd0411bce207f055791e3ed5cb8656ca9fe01
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Jun 12 16:54:57 2019 +0000

    popover: Bring back the activate-default signal
    
    As long as key bindings only work via action
    signals, we need a signal here in order to
    override the Enter/Space bindings for popover
    menus.

 gtk/gtkpopover.c | 26 ++++++++++++++++++++++----
 gtk/gtkpopover.h |  3 ++-
 2 files changed, 24 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c
index 660688836d..d4d2470ef6 100644
--- a/gtk/gtkpopover.c
+++ b/gtk/gtkpopover.c
@@ -166,6 +166,7 @@ typedef struct {
 
 enum {
   CLOSED,
+  ACTIVATE_DEFAULT,
   LAST_SIGNAL
 };
 
@@ -489,11 +490,8 @@ allocate_contents (GtkGizmo *gizmo,
 }
 
 static void
-activate_default_cb (GSimpleAction *action,
-                     GVariant      *parameter,
-                     gpointer       data)
+gtk_popover_activate_default (GtkPopover *popover)
 {
-  GtkPopover *popover = data;
   GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover);
   GtkWidget *focus_widget;
 
@@ -509,6 +507,14 @@ activate_default_cb (GSimpleAction *action,
     gtk_widget_activate (focus_widget);
 }
 
+static void
+activate_default_cb (GSimpleAction *action,
+                     GVariant      *parameter,
+                     gpointer       data)
+{
+  gtk_popover_activate_default (GTK_POPOVER (data));
+}
+
 static void
 add_actions (GtkPopover *popover)
 {
@@ -1353,6 +1359,8 @@ gtk_popover_class_init (GtkPopoverClass *klass)
   container_class->add = gtk_popover_add;
   container_class->remove = gtk_popover_remove;
 
+  klass->activate_default = gtk_popover_activate_default;
+
   properties[PROP_RELATIVE_TO] =
       g_param_spec_object ("relative-to",
                            P_("Relative to"),
@@ -1407,6 +1415,16 @@ gtk_popover_class_init (GtkPopoverClass *klass)
                   G_TYPE_NONE,
                   0);
 
+  signals[ACTIVATE_DEFAULT] =
+    g_signal_new (I_("activate-default"),
+                  G_TYPE_FROM_CLASS (object_class),
+                  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+                  G_STRUCT_OFFSET (GtkPopoverClass, activate_default),
+                  NULL, NULL,
+                  NULL,
+                  G_TYPE_NONE,
+                  0);
+
   gtk_widget_class_set_css_name (widget_class, "popover");
 }
 
diff --git a/gtk/gtkpopover.h b/gtk/gtkpopover.h
index 615cd9a79e..301fa298f7 100644
--- a/gtk/gtkpopover.h
+++ b/gtk/gtkpopover.h
@@ -48,7 +48,8 @@ struct _GtkPopoverClass
 {
   GtkBinClass parent_class;
 
-  void (* closed) (GtkPopover *popover);
+  void (* closed)           (GtkPopover *popover);
+  void (* activate_default) (GtkPopover *popover);
 
   /*< private >*/
 


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