[gnome-sudoku] Unbreak adaptive mode



commit 54876ccec241d998fdab8e152e2105375331b573
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sat Dec 26 14:29:18 2020 -0600

    Unbreak adaptive mode
    
    This code can simply move to SudokuWindow.

 data/sudoku-window.ui  |  1 +
 src/gnome-sudoku.vala  | 38 --------------------------------------
 src/sudoku-window.vala | 35 +++++++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+), 38 deletions(-)
---
diff --git a/data/sudoku-window.ui b/data/sudoku-window.ui
index 6b11bc81..ea9e95e9 100644
--- a/data/sudoku-window.ui
+++ b/data/sudoku-window.ui
@@ -173,6 +173,7 @@
             <property name="homogeneous">False</property>
             <property name="transition-type">crossfade</property>
             <property name="interpolate-size">True</property>
+            <signal name="draw" handler="main_squeezer_draw_cb" swapped="no"/>
             <child>
               <object class="GtkBox" id="start_box">
                 <property name="visible">True</property>
diff --git a/src/gnome-sudoku.vala b/src/gnome-sudoku.vala
index bba966c8..8760e4c5 100644
--- a/src/gnome-sudoku.vala
+++ b/src/gnome-sudoku.vala
@@ -498,44 +498,6 @@ public class Sudoku : Gtk.Application
                                );
     }
 
-#if 0
-    // Unused?
-    private bool draw_cb ()
-    {
-        return check_layout_change ();
-    }
-
-    private bool check_layout_change ()
-    {
-        var layout = main_squeezer.visible_child;
-        if (! (layout is AspectFrame))
-            return false;
-        var changed = layout != previous_layout;
-        if (changed)
-            set_layout ((AspectFrame) layout);
-        return changed;
-    }
-
-    private void set_layout (AspectFrame new_layout)
-    {
-        if (new_layout == frame_h)
-        {
-            controls_box.halign = Align.END;
-            controls_box.orientation = Orientation.VERTICAL;
-            game_box.orientation = Orientation.HORIZONTAL;
-        }
-        else
-        {
-            controls_box.halign = Align.CENTER;
-            controls_box.orientation = Orientation.VERTICAL;
-            game_box.orientation = Orientation.VERTICAL;
-        }
-        previous_layout.remove (game_box);
-        new_layout.add (game_box);
-        previous_layout = new_layout;
-    }
-#endif
-
     public static int main (string[] args)
     {
         return new Sudoku ().run (args);
diff --git a/src/sudoku-window.vala b/src/sudoku-window.vala
index 10615856..dcd8cc0e 100644
--- a/src/sudoku-window.vala
+++ b/src/sudoku-window.vala
@@ -264,4 +264,39 @@ public class SudokuWindow : ApplicationWindow
         else
             clock_label.set_text ("%02d∶\xE2\x80\x8E%02d".printf (minutes, seconds));
     }
+
+    private void set_layout (AspectFrame new_layout)
+    {
+        if (new_layout == frame_h)
+        {
+            controls_box.halign = Align.END;
+            controls_box.orientation = Orientation.VERTICAL;
+            game_box.orientation = Orientation.HORIZONTAL;
+        }
+        else
+        {
+            controls_box.halign = Align.CENTER;
+            controls_box.orientation = Orientation.VERTICAL;
+            game_box.orientation = Orientation.VERTICAL;
+        }
+        previous_layout.remove (game_box);
+        new_layout.add (game_box);
+        previous_layout = new_layout;
+    }
+
+    private bool check_layout_change ()
+    {
+        var layout = main_squeezer.visible_child;
+        if (!(layout is AspectFrame))
+            return false;
+        var changed = layout != previous_layout;
+        if (changed)
+            set_layout ((AspectFrame) layout);
+        return changed;
+    }
+
+    [GtkCallback] private bool main_squeezer_draw_cb ()
+    {
+        return check_layout_change ();
+    }
 }


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