[gnome-klotski/arnaudb/wip/gtk4: 13/13] Avoid a bug.



commit 9ada137ef682aa3495260073f7b2d156ed5a06f5
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Tue Mar 10 18:07:10 2020 +0100

    Avoid a bug.
    
    https://gitlab.gnome.org/GNOME/gtk/issues/2489

 data/klotski.ui         |  4 ++--
 src/klotski-window.vala | 24 ++++++++++++++++++++----
 2 files changed, 22 insertions(+), 6 deletions(-)
---
diff --git a/data/klotski.ui b/data/klotski.ui
index ad66b6d..4926aa2 100644
--- a/data/klotski.ui
+++ b/data/klotski.ui
@@ -319,7 +319,7 @@
           </object>
         </child>
         <child type="end">
-          <object class="GtkMenuButton" id="menu_button">
+          <object class="GtkMenuButton">
             <property name="valign">center</property>
             <property name="can-focus">True</property>
             <property name="menu-model">app-menu</property>
@@ -327,7 +327,7 @@
           </object>
         </child>
         <child type="end">
-          <object class="GtkMenuButton">
+          <object class="GtkMenuButton" id="game_button">
 <!--            <property name="use-underline">True</property> FIXME 
https://gitlab.gnome.org/GNOME/gtk/issues/2489 -->
             <property name="valign">center</property>
             <!-- Translators: in the headerbar, button that allows via a popover to select a different 
puzzle (with a mnemonic that appears pressing Alt) -->
diff --git a/src/klotski-window.vala b/src/klotski-window.vala
index dfb1072..72a62d1 100644
--- a/src/klotski-window.vala
+++ b/src/klotski-window.vala
@@ -44,10 +44,11 @@ private class KlotskiWindow : ApplicationWindow
     private const string KEY_LEVEL = "level";
 
     /* Widgets */
-    [GtkChild] private HeaderBar headerbar;
-    [GtkChild] private Stack stack_packs;
-    [GtkChild] private Stack stack_puzzles;
-    [GtkChild] private Popover puzzles_popover;
+    [GtkChild] private HeaderBar    headerbar;
+    [GtkChild] private Stack        stack_packs;
+    [GtkChild] private Stack        stack_puzzles;
+    [GtkChild] private Popover      puzzles_popover;
+    [GtkChild] private MenuButton   game_button;
     private PuzzleView view;
 
     [GtkChild] private TreeView treeview_huarong;
@@ -528,6 +529,21 @@ private class KlotskiWindow : ApplicationWindow
         if (gdk_display != null) // else..?
             StyleContext.add_provider_for_display ((!) gdk_display, css_provider, 
STYLE_PROVIDER_PRIORITY_APPLICATION);
 
+        // https://gitlab.gnome.org/GNOME/gtk/issues/2489
+        Widget? widget = game_button.get_first_child ();
+        while (widget != null)
+        {
+            if ((!) widget is ToggleButton)
+            {
+                ((ToggleButton) (!) widget).set_use_underline (true);
+                string? label = game_button.get_label ();
+                if (label != null)
+                    ((ToggleButton) (!) widget).set_label ((!) label);
+                break;
+            }
+            widget = game_button.get_next_sibling ();
+        }
+
         settings = new GLib.Settings ("org.gnome.Klotski");
         set_default_size (settings.get_int ("window-width"), settings.get_int ("window-height"));
         if (settings.get_boolean ("window-is-maximized"))


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