[gtk/widget-class-actions: 12/12] window: Add a focus.move action



commit 972f7ba13d9f1e354feb531e47e706aa31da09fd
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Jun 17 12:20:36 2019 +0000

    window: Add a focus.move action
    
    This is a first step towards redoing bindings with actions.

 gtk/gtkwindow.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 5a4f8f76f5..15f8972cd8 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -495,6 +495,14 @@ static void        gtk_window_set_theme_variant         (GtkWindow  *window);
 static void gtk_window_activate_default_activate (GtkWidget *widget,
                                                   const char *action_name,
                                                   GVariant *parameter);
+static void gtk_window_activate_focus_move (GtkWidget *widget,
+                                            const char *action_name,
+                                            GVariant  *parameter);
+
+static void gtk_window_query_action (GtkWidget           *widget,
+                                     const char          *action_name,
+                                     gboolean            *enabled,
+                                     const GVariantType **parameter_type);
 
 static void        gtk_window_do_popup         (GtkWindow      *window,
                                                 GdkEventButton *event);
@@ -1203,6 +1211,9 @@ gtk_window_class_init (GtkWindowClass *klass)
 
   gtk_widget_class_install_action (widget_class, "default.activate",
                                    gtk_window_activate_default_activate);
+  gtk_widget_class_install_stateful_action (widget_class, "focus.move",
+                                            gtk_window_activate_focus_move,
+                                            "i", NULL, NULL);
 }
 
 /**
@@ -1780,6 +1791,17 @@ gtk_window_activate_default_activate (GtkWidget  *widget,
   gtk_window_real_activate_default (GTK_WINDOW (widget));
 }
 
+static void
+gtk_window_activate_focus_move (GtkWidget  *widget,
+                                const char *action_name,
+                                GVariant   *parameter)
+{
+  gtk_window_move_focus (widget,
+                         CLAMP (g_variant_get_int32 (parameter),
+                                GTK_DIR_TAB_FORWARD,
+                                GTK_DIR_RIGHT));
+}
+
 static void
 gtk_window_init (GtkWindow *window)
 {


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