[iagno] Add unfullscreen button.



commit b4c8d6473750872b6d9655bb4c337e3eaea70211
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Thu Feb 21 16:21:32 2019 +0100

    Add unfullscreen button.

 data/iagno.css       |   4 ++
 data/ui/iagno.ui     | 125 ++++++++++++++++++++++++++++++---------------------
 src/game-window.vala |   9 +++-
 3 files changed, 87 insertions(+), 51 deletions(-)
---
diff --git a/data/iagno.css b/data/iagno.css
index c263b58..cfe1e9e 100644
--- a/data/iagno.css
+++ b/data/iagno.css
@@ -16,6 +16,10 @@
  * with this application. If not, see <http://www.gnu.org/licenses/>.
  */
 
+button.unfullscreen-button {
+  margin:6px;
+}
+
 /* Labels' tweaks */
 label.bold-label {
   font-weight: bold;
diff --git a/data/ui/iagno.ui b/data/ui/iagno.ui
index 464823f..f47e115 100644
--- a/data/ui/iagno.ui
+++ b/data/ui/iagno.ui
@@ -84,77 +84,102 @@
       </object>
     </child>
     <child>
-      <object class="GtkStack" id="stack">
+      <object class="GtkOverlay">
         <property name="visible">True</property>
-        <property name="homogeneous">True</property>
         <child>
-          <object class="GtkBox" id="new_game_box">
-            <property name="orientation">vertical</property>
+          <object class="GtkStack" id="stack">
             <property name="visible">True</property>
-            <property name="halign">center</property>
-            <property name="valign">center</property>
-            <property name="margin">25</property>
-            <property name="width-request">350</property>
-            <property name="height-request">350</property>
-            <property name="spacing">6</property>
-          </object>
-          <packing>
-            <property name="name">start-box</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkAspectFrame">
-            <property name="visible">True</property>
-            <property name="shadow-type">GTK_SHADOW_NONE</property>
-            <property name="obey-child">false</property>
-            <property name="ratio">1.4</property>
-            <property name="margin">25</property>
+            <property name="homogeneous">True</property>
+            <child>
+              <object class="GtkBox" id="new_game_box">
+                <property name="orientation">vertical</property>
+                <property name="visible">True</property>
+                <property name="halign">center</property>
+                <property name="valign">center</property>
+                <property name="margin">25</property>
+                <property name="width-request">350</property>
+                <property name="height-request">350</property>
+                <property name="spacing">6</property>
+              </object>
+              <packing>
+                <property name="name">start-box</property>
+              </packing>
+            </child>
             <child>
-              <object class="GtkBox" id="game_box">
+              <object class="GtkAspectFrame">
                 <property name="visible">True</property>
-                <property name="orientation">horizontal</property>
-                <property name="spacing">25</property>
+                <property name="shadow-type">GTK_SHADOW_NONE</property>
+                <property name="obey-child">false</property>
+                <property name="ratio">1.4</property>
+                <property name="margin">25</property>
                 <child>
-                  <object class="GtkBox" id="side_box">
+                  <object class="GtkBox" id="game_box">
                     <property name="visible">True</property>
-                    <property name="orientation">vertical</property>
-                    <property name="spacing">6</property>
+                    <property name="orientation">horizontal</property>
+                    <property name="spacing">25</property>
                     <child>
-                      <object class="GtkButton" id="new_game_button">
+                      <object class="GtkBox" id="side_box">
                         <property name="visible">True</property>
-                        <property name="use-underline">True</property>
-                        <!-- Translators: during a game, label of the Start Over button (with a mnemonic 
that appears pressing Alt) -->
-                        <property name="label" translatable="yes">_New Game</property>
-                        <property name="halign">center</property>
-                        <property name="valign">center</property>
-                        <property name="action-name">win.new-game</property>
-                        <!-- Translators: during a game, tooltip text of the Start Over button -->
-                        <property name="tooltip-text" translatable="yes">Start a new game</property>
-                        <property name="width-request">120</property>
-                        <property name="height-request">60</property>
+                        <property name="orientation">vertical</property>
+                        <property name="spacing">6</property>
+                        <child>
+                          <object class="GtkButton" id="new_game_button">
+                            <property name="visible">True</property>
+                            <property name="use-underline">True</property>
+                            <!-- Translators: during a game, label of the Start Over button (with a mnemonic 
that appears pressing Alt) -->
+                            <property name="label" translatable="yes">_New Game</property>
+                            <property name="halign">center</property>
+                            <property name="valign">center</property>
+                            <property name="action-name">win.new-game</property>
+                            <!-- Translators: during a game, tooltip text of the Start Over button -->
+                            <property name="tooltip-text" translatable="yes">Start a new game</property>
+                            <property name="width-request">120</property>
+                            <property name="height-request">60</property>
+                          </object>
+                          <packing>
+                            <property name="pack-type">end</property>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="padding">0</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
                       </object>
                       <packing>
                         <property name="pack-type">end</property>
                         <property name="expand">False</property>
-                        <property name="fill">False</property>
+                        <property name="fill">True</property>
                         <property name="padding">0</property>
-                        <property name="position">1</property>
                       </packing>
                     </child>
                   </object>
-                  <packing>
-                    <property name="pack-type">end</property>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="padding">0</property>
-                  </packing>
                 </child>
               </object>
+              <packing>
+                <property name="name">frame</property>
+              </packing>
+            </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">win.unfullscreen</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>
-          <packing>
-            <property name="name">frame</property>
-          </packing>
         </child>
       </object>
     </child>
diff --git a/src/game-window.vala b/src/game-window.vala
index e00e89d..c7c23f1 100644
--- a/src/game-window.vala
+++ b/src/game-window.vala
@@ -47,6 +47,7 @@ private class GameWindow : ApplicationWindow
     private Button? start_game_button = null;
     [GtkChild] private Button new_game_button;
     [GtkChild] private Button back_button;
+    [GtkChild] private Button unfullscreen_button;
 
     [GtkChild] private Box controls_box;
     [GtkChild] private Box game_box;
@@ -75,7 +76,8 @@ private class GameWindow : ApplicationWindow
      // { "redo", redo_cb },
         { "hint", hint_cb },
 
-        { "toggle-hamburger", toggle_hamburger }
+        { "toggle-hamburger", toggle_hamburger },
+        { "unfullscreen", unfullscreen }
     };
 
     private SimpleAction back_action;
@@ -205,8 +207,13 @@ private class GameWindow : ApplicationWindow
             window_is_maximized = (event.new_window_state & Gdk.WindowState.MAXIMIZED) != 0;
 
         /* fullscreen: saved as maximized */
+        bool window_was_fullscreen = window_is_fullscreen;
         if ((event.changed_mask & Gdk.WindowState.FULLSCREEN) != 0)
             window_is_fullscreen = (event.new_window_state & Gdk.WindowState.FULLSCREEN) != 0;
+        if (window_was_fullscreen && !window_is_fullscreen)
+            unfullscreen_button.hide ();
+        else if (!window_was_fullscreen && window_is_fullscreen)
+            unfullscreen_button.show ();
 
         /* tiled: not saved, but should not change saved window size */
         Gdk.WindowState tiled_state = Gdk.WindowState.TILED


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