[atomix] Grab focus on menu close (#17)



commit e7ac9508613fb6a421c4395b4ef9163f88d868c1
Author: Robert Roth <robert roth bee-tf ro>
Date:   Mon Mar 11 21:47:39 2019 +0200

    Grab focus on menu close (#17)

 src/main.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
---
diff --git a/src/main.c b/src/main.c
index 6866144..f8fb353 100644
--- a/src/main.c
+++ b/src/main.c
@@ -373,6 +373,13 @@ static void atomix_exit (void)
 
 }
 
+static void on_menu_toggled (GtkToggleButton *button,
+                             gpointer user_data)
+{
+  if (!gtk_toggle_button_get_active(button))
+    gtk_widget_grab_focus (GTK_WIDGET (app->fi_matrix));
+}
+
 static void game_init (void)
 {
   g_return_if_fail (app != NULL);
@@ -648,6 +655,9 @@ static AtomixApp *create_gui (GApplication *app_instance)
   primary_menu_button = GTK_WIDGET (gtk_builder_get_object (builder, "primary-menu-button"));
   gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (primary_menu_button), G_MENU_MODEL (menu));
 
+  g_signal_connect (G_OBJECT (primary_menu_button), "toggled",
+                    (GCallback) on_menu_toggled, app);
+
   g_object_unref (builder);
 
   return app;


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