[gtk/shortcuts-rebased-again: 147/171] popover: Switch activate-default to an action



commit b050572918485652971a9489cdb862d876a8dd0f
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Jun 23 17:20:38 2019 +0000

    popover: Switch activate-default to an action
    
    This matches what we already did for GtkWindow.

 gtk/gtkpopover.c     | 45 ++++++---------------------------------------
 gtk/gtkpopovermenu.c | 20 ++++++++++----------
 2 files changed, 16 insertions(+), 49 deletions(-)
---
diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c
index 6052bd80bd..f2d252c8af 100644
--- a/gtk/gtkpopover.c
+++ b/gtk/gtkpopover.c
@@ -486,8 +486,11 @@ allocate_contents (GtkGizmo *gizmo,
 }
 
 static void
-gtk_popover_activate_default (GtkPopover *popover)
+gtk_popover_activate_default_activate (GtkWidget  *widget,
+                                       const char *action_name,
+                                       GVariant   *parameter)
 {
+  GtkPopover *popover = GTK_POPOVER (widget);
   GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover);
   GtkWidget *focus_widget;
 
@@ -503,31 +506,6 @@ gtk_popover_activate_default (GtkPopover *popover)
     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)
-{
-  GActionEntry entries[] = {
-    { "activate", activate_default_cb, NULL, NULL, NULL },
-  };
-
-  GActionGroup *actions;
-
-  actions = G_ACTION_GROUP (g_simple_action_group_new ());
-  g_action_map_add_action_entries (G_ACTION_MAP (actions),
-                                   entries, G_N_ELEMENTS (entries),
-                                   popover);
-  gtk_widget_insert_action_group (GTK_WIDGET (popover), "default", actions);
-  g_object_unref (actions);
-}
-
 static void
 node_style_changed_cb (GtkCssNode        *node,
                        GtkCssStyleChange *change,
@@ -579,8 +557,6 @@ gtk_popover_init (GtkPopover *popover)
 
   context = gtk_widget_get_style_context (GTK_WIDGET (popover));
   gtk_style_context_add_class (context, GTK_STYLE_CLASS_BACKGROUND);
-
-  add_actions (popover);
 }
 
 static void
@@ -1328,8 +1304,6 @@ 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"),
@@ -1384,15 +1358,8 @@ 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_install_action (widget_class, "default.activate", NULL,
+                                  gtk_popover_activate_default_activate);
 
   gtk_widget_class_set_css_name (widget_class, "popover");
 }
diff --git a/gtk/gtkpopovermenu.c b/gtk/gtkpopovermenu.c
index 735b51980f..29cbccd1cb 100644
--- a/gtk/gtkpopovermenu.c
+++ b/gtk/gtkpopovermenu.c
@@ -445,16 +445,16 @@ gtk_popover_menu_class_init (GtkPopoverMenuClass *klass)
   add_tab_bindings (widget_class, GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
   add_tab_bindings (widget_class, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
 
-  gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_Return, 0,
-                                "activate-default", NULL);
-  gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_ISO_Enter, 0,
-                                "activate-default", NULL);
-  gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_KP_Enter, 0,
-                                "activate-default", NULL);
-  gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_space, 0,
-                                "activate-default", NULL);
-  gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_KP_Space, 0,
-                                "activate-default", NULL);
+  gtk_widget_class_bind_action (widget_class, GDK_KEY_Return, 0,
+                                "default.activate", NULL);
+  gtk_widget_class_bind_action (widget_class, GDK_KEY_ISO_Enter, 0,
+                                "default.activate", NULL);
+  gtk_widget_class_bind_action (widget_class, GDK_KEY_KP_Enter, 0,
+                                "default.activate", NULL);
+  gtk_widget_class_bind_action (widget_class, GDK_KEY_space, 0,
+                                "default.activate", NULL);
+  gtk_widget_class_bind_action (widget_class, GDK_KEY_KP_Space, 0,
+                                "default.activate", NULL);
 }
 
 /**


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