[gnome-2048] Add unfullscreen button.



commit 84080302e51d52ac1b9023d5c5e935d15ba88844
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Thu Feb 21 16:36:06 2019 +0100

    Add unfullscreen button.

 data/mainwindow.ui   | 38 ++++++++++++++++++++++++++++++++------
 src/game-window.vala | 13 +++++++++++--
 2 files changed, 43 insertions(+), 8 deletions(-)
---
diff --git a/data/mainwindow.ui b/data/mainwindow.ui
index cbf177d..d26886f 100644
--- a/data/mainwindow.ui
+++ b/data/mainwindow.ui
@@ -31,18 +31,44 @@
       </object>
     </child>
     <child>
-      <object class="GtkGrid">
+      <object class="GtkOverlay">
         <property name="visible">True</property>
-        <property name="can-focus">False</property>
         <child>
-          <object class="GtkAspectFrame">
+          <object class="GtkGrid">
             <property name="visible">True</property>
             <property name="can-focus">False</property>
-            <property name="label-xalign">0</property>
-            <property name="shadow-type">none</property>
             <child>
-              <object class="GtkClutterEmbed" id="_embed">
+              <object class="GtkAspectFrame">
                 <property name="visible">True</property>
+                <property name="can-focus">False</property>
+                <property name="label-xalign">0</property>
+                <property name="shadow-type">none</property>
+                <child>
+                  <object class="GtkClutterEmbed" id="_embed">
+                    <property name="visible">True</property>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child type="overlay">
+          <object class="GtkButton" id="_unfullscreen_button">
+            <property name="visible">False</property>
+            <property name="halign">end</property>
+            <property name="valign">start</property>
+            <property name="action-name">ui.unfullscreen</property>
+            <property name="margin">6</property>
+            <style>
+              <class name="image-button"/>
+              <!-- class name="unfullscreen-button"/ -->
+              <class name="flat"/>
+            </style>
+            <child>
+              <object class="GtkImage">
+                <property name="icon-name">view-restore-symbolic</property>
+                <property name="visible">True</property>
+                <property name="icon-size">1</property>
               </object>
             </child>
           </object>
diff --git a/src/game-window.vala b/src/game-window.vala
index ac33207..438c03d 100644
--- a/src/game-window.vala
+++ b/src/game-window.vala
@@ -28,6 +28,8 @@ private class GameWindow : ApplicationWindow
     [GtkChild] private GameHeaderBar    _header_bar;
     [GtkChild] private GtkClutter.Embed _embed;
 
+    [GtkChild] private Button           _unfullscreen_button;
+
     private Game _game;
 
     construct
@@ -42,7 +44,7 @@ private class GameWindow : ApplicationWindow
         _create_scores_dialog ();   // the library forbids to delay the dialog creation
 
         notify ["has-toplevel-focus"].connect (() => _embed.grab_focus ());
-        show_all ();
+        show ();
 
         if (!_game.restore_game (ref _settings))
             new_game_cb ();
@@ -176,8 +178,13 @@ private class GameWindow : ApplicationWindow
             _this._window_maximized = (event.new_window_state & Gdk.WindowState.MAXIMIZED) != 0;
 
         /* fullscreen: saved as maximized */
+        bool window_fullscreen = _this._window_fullscreen;
         if ((event.changed_mask & Gdk.WindowState.FULLSCREEN) != 0)
             _this._window_fullscreen = (event.new_window_state & Gdk.WindowState.FULLSCREEN) != 0;
+        if (window_fullscreen && !_this._window_fullscreen)
+            _this._unfullscreen_button.hide ();
+        else if (!window_fullscreen && _this._window_fullscreen)
+            _this._unfullscreen_button.show ();
 
         /* tiled: not saved, but should not change saved window size */
         Gdk.WindowState tiled_state = Gdk.WindowState.TILED
@@ -218,7 +225,9 @@ private class GameWindow : ApplicationWindow
         { "toggle-hamburger",   toggle_hamburger_menu       },
 
         { "scores",             scores_cb                   },
-        { "about",              about_cb                    }
+        { "about",              about_cb                    },
+
+        { "unfullscreen",       unfullscreen                }
     };
 
     private void undo_cb (/* SimpleAction action, Variant? variant */)


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