[gnome-tetravex] Revert "remove fullscreen"



commit 348df0bb38990430d687567fcfb92a06d6ba90d7
Author: Thomas Hindoe Paaboel Andersen <phomes gmail com>
Date:   Sun Oct 13 12:44:43 2013 +0200

    Revert "remove fullscreen"
    
    This reverts commit bf33798982c7dec6237d1c7c3b81293a2025b584.

 data/org.gnome.tetravex.gschema.xml |    4 +++
 src/gnome-tetravex.vala             |   37 ++++++++++++++++++++++++++++++++--
 2 files changed, 38 insertions(+), 3 deletions(-)
---
diff --git a/data/org.gnome.tetravex.gschema.xml b/data/org.gnome.tetravex.gschema.xml
index 9915401..ae6ea08 100644
--- a/data/org.gnome.tetravex.gschema.xml
+++ b/data/org.gnome.tetravex.gschema.xml
@@ -18,5 +18,9 @@
       <default>false</default>
       <summary>true if the window is maximized</summary>
     </key>
+    <key name="window-is-fullscreen" type="b">
+      <default>false</default>
+      <summary>true if the window is fullscren</summary>
+    </key>
   </schema>
 </schemalist>
diff --git a/src/gnome-tetravex.vala b/src/gnome-tetravex.vala
index 85817a1..fe77623 100644
--- a/src/gnome-tetravex.vala
+++ b/src/gnome-tetravex.vala
@@ -23,14 +23,17 @@ public class Tetravex : Gtk.Application
     private Gtk.ApplicationWindow window;
     private int window_width;
     private int window_height;
+    private bool is_fullscreen;
     private bool is_maximized;
 
     Gtk.Button pause_button;
+    Gtk.Button fullscreen_button;
 
     private const GLib.ActionEntry[] action_entries =
     {
         { "new-game",      new_game_cb                                            },
         { "pause",         pause_cb                                               },
+        { "fullscreen",    fullscreen_cb                                          },
         { "solve",         solve_cb                                               },
         { "scores",        scores_cb                                              },
         { "quit",          quit_cb                                                },
@@ -58,6 +61,7 @@ public class Tetravex : Gtk.Application
         add_action_entries (action_entries, this);
         add_accelerator ("<Primary>n", "app.new-game", null);
         add_accelerator ("Pause", "app.pause", null);
+        add_accelerator ("F11", "app.fullscreen", null);
         add_accelerator ("F1", "app.help", null);
         add_accelerator ("<Primary>q", "app.quit", null);
 
@@ -84,7 +88,9 @@ public class Tetravex : Gtk.Application
         window.configure_event.connect (window_configure_event_cb);
         window.window_state_event.connect (window_state_event_cb);
         window.set_default_size (settings.get_int ("window-width"), settings.get_int ("window-height"));     
   
-        if (settings.get_boolean ("window-is-maximized"))
+        if (settings.get_boolean ("window-is-fullscreen"))
+            window.fullscreen ();
+        else if (settings.get_boolean ("window-is-maximized"))
             window.maximize ();
 
         (lookup_action ("size") as SimpleAction).set_state ("%d".printf (settings.get_int (KEY_GRID_SIZE)));
@@ -95,6 +101,11 @@ public class Tetravex : Gtk.Application
         headerbar.show ();
         window.set_titlebar (headerbar);
 
+        fullscreen_button = new Gtk.Button.from_icon_name ("view-fullscreen-symbolic", Gtk.IconSize.BUTTON);
+        fullscreen_button.action_name = "app.fullscreen";
+        fullscreen_button.show ();
+        headerbar.pack_start (fullscreen_button);
+
         var grid = builder.get_object ("grid") as Gtk.Grid;
 
         view = new PuzzleView ();
@@ -129,7 +140,7 @@ public class Tetravex : Gtk.Application
 
     private bool window_configure_event_cb (Gdk.EventConfigure event)
     {
-        if (!is_maximized)
+        if (!is_maximized && !is_fullscreen)
         {
             window_width = event.width;
             window_height = event.height;
@@ -142,7 +153,18 @@ public class Tetravex : Gtk.Application
     {
         if ((event.changed_mask & Gdk.WindowState.MAXIMIZED) != 0)
             is_maximized = (event.new_window_state & Gdk.WindowState.MAXIMIZED) != 0;
-
+        if ((event.changed_mask & Gdk.WindowState.FULLSCREEN) != 0)
+        {
+            is_fullscreen = (event.new_window_state & Gdk.WindowState.FULLSCREEN) != 0;
+            if (is_fullscreen)
+            {
+                fullscreen_button.image = new Gtk.Image.from_icon_name ("view-restore-symbolic", 
Gtk.IconSize.BUTTON);
+            }
+            else
+            {
+                fullscreen_button.image = new Gtk.Image.from_icon_name ("view-fullscreen-symbolic", 
Gtk.IconSize.BUTTON);
+            }
+        }
         return false;
     }
 
@@ -154,6 +176,7 @@ public class Tetravex : Gtk.Application
         settings.set_int ("window-width", window_width);
         settings.set_int ("window-height", window_height);
         settings.set_boolean ("window-is-maximized", is_maximized);
+        settings.set_boolean ("window-is-fullscreen", is_fullscreen);
     }
 
     protected override void activate ()
@@ -327,6 +350,14 @@ public class Tetravex : Gtk.Application
         }
     }
 
+    private void fullscreen_cb ()
+    {
+        if (is_fullscreen)
+            window.unfullscreen ();
+        else
+            window.fullscreen ();
+    }
+
     private void radio_cb (SimpleAction action, Variant? parameter)
     {
         action.change_state (parameter);


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