[gnome-taquin] Create headerbar and game_view on the fly.



commit edfa7b70d63bae3d181038fc91b16735539cc565
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Sat Jan 12 15:11:04 2019 +0100

    Create headerbar and game_view on the fly.
    
    That is needed for subclassing BaseWindow.

 data/taquin.ui           | 17 -----------------
 src/game-headerbar.vala  |  2 +-
 src/game-view.vala       |  2 +-
 src/game-window.vala     | 19 +++++++++++--------
 src/taquin.gresource.xml |  1 -
 5 files changed, 13 insertions(+), 28 deletions(-)
---
diff --git a/src/game-headerbar.vala b/src/game-headerbar.vala
index 2f1fbc8..0c7eae5 100644
--- a/src/game-headerbar.vala
+++ b/src/game-headerbar.vala
@@ -28,7 +28,7 @@ private class GameHeaderBar : HeaderBar
     [GtkChild] private Button       back_button;
     [GtkChild] private MenuButton   info_button;
 
-    internal void add_controls (GameWindowFlags flags)
+    internal GameHeaderBar (GameWindowFlags flags)
     {
         if (GameWindowFlags.SHOW_UNDO in flags)
         {
diff --git a/src/game-view.vala b/src/game-view.vala
index 120e76a..04bd5bd 100644
--- a/src/game-view.vala
+++ b/src/game-view.vala
@@ -38,7 +38,7 @@ private class GameView : Stack
         add (new_game_box);
     }
 
-    internal void set_content (GameWindowFlags flags, Box new_game_screen, Widget content)
+    internal GameView (GameWindowFlags flags, Box new_game_screen, Widget content)
     {
         new_game_box.pack_start (new_game_screen, true, true, 0);
 
diff --git a/src/game-window.vala b/src/game-window.vala
index e344c61..3d722c3 100644
--- a/src/game-window.vala
+++ b/src/game-window.vala
@@ -28,8 +28,7 @@ public enum GameWindowFlags {
     SHOW_START_BUTTON;
 }
 
-[GtkTemplate (ui = "/org/gnome/Taquin/ui/game-window.ui")]
-public class GameWindow : ApplicationWindow
+private class GameWindow : ApplicationWindow
 {
     /* settings */
     private bool tiled_state;
@@ -40,11 +39,19 @@ public class GameWindow : ApplicationWindow
     private bool game_finished = false;
 
     /* private widgets */
-    [GtkChild] private GameHeaderBar    headerbar;
-    [GtkChild] private GameView         game_view;
+    private GameHeaderBar   headerbar;
+    private GameView        game_view;
 
     public GameWindow (string? css_resource, string name, int width, int height, bool maximized, bool 
start_now, GameWindowFlags flags, Box new_game_screen, Widget view_content)
     {
+        headerbar = new GameHeaderBar (flags);
+        headerbar.show ();
+        game_view = new GameView (flags, new_game_screen, view_content);
+        game_view.show ();
+        set_titlebar (headerbar);
+        add (game_view);
+
+        /* CSS */
         if (css_resource != null)
         {
             CssProvider css_provider = new CssProvider ();
@@ -55,10 +62,6 @@ public class GameWindow : ApplicationWindow
         /* window actions */
         install_win_action_entries ();
 
-        /* add widgets */
-        game_view.set_content (flags, new_game_screen, view_content);
-        headerbar.add_controls (flags);
-
         /* window config */
         set_title (name);
         headerbar.set_title (name);
diff --git a/src/taquin.gresource.xml b/src/taquin.gresource.xml
index 431ef28..c8c96e1 100644
--- a/src/taquin.gresource.xml
+++ b/src/taquin.gresource.xml
@@ -6,7 +6,6 @@
   </gresource>
   <gresource prefix="/org/gnome/Taquin/ui">
     <file preprocess="xml-stripblanks" alias="game-headerbar.ui">../data/game-headerbar.ui</file>
-    <file preprocess="xml-stripblanks" alias="game-window.ui">../data/taquin.ui</file>
     <file preprocess="xml-stripblanks" alias="taquin-screens.ui">../data/taquin-screens.ui</file>
     <file alias="taquin.css">../data/taquin.css</file>
   </gresource>


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