[gnome-games] gnomine: Remove games_settings_bind_window_state
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] gnomine: Remove games_settings_bind_window_state
- Date: Tue, 21 Aug 2012 04:47:51 +0000 (UTC)
commit d7808e2552d9ee4bcbf88a4a56602b2613bc282a
Author: Robert Ancell <robert ancell canonical com>
Date: Tue Aug 21 16:27:39 2012 +1200
gnomine: Remove games_settings_bind_window_state
gnomine/data/org.gnome.gnomine.gschema.xml.in | 16 +++++++++
gnomine/src/gnomine.vala | 42 +++++++++++++++++++++++-
2 files changed, 56 insertions(+), 2 deletions(-)
---
diff --git a/gnomine/data/org.gnome.gnomine.gschema.xml.in b/gnomine/data/org.gnome.gnomine.gschema.xml.in
index 11ad8fa..a434162 100644
--- a/gnomine/data/org.gnome.gnomine.gschema.xml.in
+++ b/gnomine/data/org.gnome.gnomine.gschema.xml.in
@@ -41,5 +41,21 @@
<_summary>Board size</_summary>
<_description>Size of the board (0-2 = small-large, 3=custom)</_description>
</key>
+ <key name="window-width" type="i">
+ <default>600</default>
+ <_summary>Width of the window in pixels</_summary>
+ </key>
+ <key name="window-height" type="i">
+ <default>400</default>
+ <_summary>Height of the window in pixels</_summary>
+ </key>
+ <key name="window-is-maximized" type="b">
+ <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/gnomine/src/gnomine.vala b/gnomine/src/gnomine.vala
index 66dbecd..6f85d07 100644
--- a/gnomine/src/gnomine.vala
+++ b/gnomine/src/gnomine.vala
@@ -22,8 +22,12 @@ public class GnoMine : Gtk.Application
private Gtk.Image cool_face_image;
private Gtk.Image worried_face_image;
+ private Gtk.ToolButton fullscreen_button;
+
/* Main window */
private Gtk.Window window;
+ private int window_width;
+ private int window_height;
private bool is_fullscreen;
private bool is_maximized;
@@ -125,8 +129,14 @@ public class GnoMine : Gtk.Application
window = new Gtk.ApplicationWindow (this);
window.window_state_event.connect (window_state_event_cb);
window.title = _("Mines");
+ 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-fullscreen"))
+ window.fullscreen ();
+ else if (settings.get_boolean ("window-is-maximized"))
+ window.maximize ();
- GnomeGamesSupport.settings_bind_window_state ("/org/gnome/gnomine/", window);
add_window (window);
GnomeGamesSupport.stock_init ();
@@ -179,7 +189,7 @@ public class GnoMine : Gtk.Application
pause_button.show ();
toolbar.insert (pause_button, -1);
- var fullscreen_button = new Gtk.ToolButton.from_stock (GnomeGamesSupport.STOCK_FULLSCREEN);
+ fullscreen_button = new Gtk.ToolButton.from_stock (GnomeGamesSupport.STOCK_FULLSCREEN);
fullscreen_button.action_name = "app.fullscreen";
fullscreen_button.show ();
toolbar.insert (fullscreen_button, -1);
@@ -317,12 +327,29 @@ public class GnoMine : Gtk.Application
tick_cb ();
}
+ private bool window_configure_event_cb (Gdk.EventConfigure event)
+ {
+ if (!is_maximized && !is_fullscreen)
+ {
+ window_width = event.width;
+ window_height = event.height;
+ }
+
+ return false;
+ }
+
private bool window_state_event_cb (Gdk.EventWindowState event)
{
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.stock_id = GnomeGamesSupport.STOCK_LEAVE_FULLSCREEN;
+ else
+ fullscreen_button.stock_id = GnomeGamesSupport.STOCK_FULLSCREEN;
+ }
return false;
}
@@ -346,6 +373,17 @@ public class GnoMine : Gtk.Application
set_face_image (smile_face_image);
}
+ protected override void shutdown ()
+ {
+ base.shutdown ();
+
+ /* Save window state */
+ 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);
+ }
+
public override void activate ()
{
window.show ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]