Commit b0505729 authored by Matthias Clasen's avatar Matthias Clasen

popover: Switch activate-default to an action

This matches what we already did for GtkWindow.
parent f6f8f4b7
......@@ -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");
}
......
......@@ -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);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment