[gtk/default-handling: 5/18] window: Add a gtk.activate-default action
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/default-handling: 5/18] window: Add a gtk.activate-default action
- Date: Sun, 28 Apr 2019 19:32:14 +0000 (UTC)
commit 28ed465382b3eaadff1a782dd3a590bf49cbd972
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Apr 27 03:12:54 2019 +0000
window: Add a gtk.activate-default action
Activating this action will replace other
activate_default apis. It is more flexible,
since intermediate widgets can intercept the
action and do their own handling.
gtk/gtkwindow.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 1f6f486cbf..c6bd84f4a7 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -1775,6 +1775,31 @@ gtk_window_capture_motion (GtkWidget *widget,
gtk_widget_set_cursor (widget, NULL);
}
+static void
+activate_default_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer data)
+{
+ gtk_window_activate_default (GTK_WINDOW (data));
+}
+
+static void
+add_actions (GtkWindow *window)
+{
+ GActionEntry entries[] = {
+ { "activate-default", 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),
+ window);
+ gtk_widget_insert_action_group (GTK_WIDGET (window), "gtk", actions);
+ g_object_unref (actions);
+}
+
static void
gtk_window_init (GtkWindow *window)
{
@@ -1868,6 +1893,8 @@ gtk_window_init (GtkWindow *window)
g_signal_connect_swapped (priv->key_controller, "focus-out",
G_CALLBACK (gtk_window_focus_out), window);
gtk_widget_add_controller (widget, priv->key_controller);
+
+ add_actions (window);
}
static GtkGesture *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]