[gnome-chess/mcatanzaro/gtk4] progress
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-chess/mcatanzaro/gtk4] progress
- Date: Wed, 23 Dec 2020 00:46:08 +0000 (UTC)
commit 4341c120cb1855ae27ad3e1a275654bcdd3d6920
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Tue Dec 22 17:44:45 2020 -0600
progress
src/gnome-chess.vala | 45 ++++++++++++++++++++-------------------------
1 file changed, 20 insertions(+), 25 deletions(-)
---
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index 5d6bfde..27a378d 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -21,11 +21,6 @@ public class ChessApplication : Gtk.Application
}
private LayoutMode layout_mode;
- private bool is_tiled;
- private bool is_maximized;
- private int window_width;
- private int window_height;
-
private GLib.Settings settings;
private unowned ApplicationWindow window;
private Box main_box;
@@ -185,6 +180,9 @@ Copyright © 2015–2016 Sahil Sareen""";
set_accels_for_action ("win." + PAUSE_RESUME_ACTION_NAME, { "<Control>p",
"Pause" });
+ window.notify["default-height"].connect (window_state_changed_cb);
+ window.notify["default-width"].connect (window_state_changed_cb);
+
add_window (window);
scene = new ChessScene ();
@@ -257,15 +255,6 @@ Copyright © 2015–2016 Sahil Sareen""";
opponent_engine.stop ();
base.shutdown ();
-
-#if 0
- /* Save window state */
- settings.delay ();
- settings.set_int ("width", window_width);
- settings.set_int ("height", window_height);
- settings.set_boolean ("maximized", is_maximized);
- settings.apply ();
-#endif
}
private void set_layout_mode (LayoutMode new_layout_mode)
@@ -275,26 +264,25 @@ Copyright © 2015–2016 Sahil Sareen""";
layout_mode = new_layout_mode;
- navigation_box.set_orientation (layout_mode == LayoutMode.NORMAL ? Orientation.HORIZONTAL :
Orientation.VERTICAL);
+ Idle.add(() => {
+ navigation_box.set_orientation (layout_mode == LayoutMode.NORMAL ? Orientation.HORIZONTAL :
Orientation.VERTICAL);
+ return Source.REMOVE;
+ });
}
-#if 0
- /* We have to create a ChessApplicationWindow class to override this,
- * since the signal has been removed.
- */
- private override void size_allocate (int width, int height, int baseline)
+ private void window_state_changed_cb ()
{
- base.size_allocate (width, height, baseline);
+ if (window.fullscreened || window.maximized)
+ return;
- if (fullscreened || maximized)
+ if (window.default_width == 0 || window.default_height == 0)
return;
- if (default_width <= 500 && layout_mode == LayoutMode.NORMAL)
+ if (window.default_width <= 500 && layout_mode == LayoutMode.NORMAL)
set_layout_mode (LayoutMode.NARROW);
- else if (default_width > 500 && layout_mode == LayoutMode.NARROW)
+ else if (window.default_width > 500 && layout_mode == LayoutMode.NARROW)
set_layout_mode (LayoutMode.NORMAL);
}
-#endif
[CCode (cname = "queen_selected_cb", instance_pos = -1)]
public void queen_selected_cb (Button button)
@@ -420,6 +408,13 @@ return null;
autosave ();
+ /* Save window state */
+ settings.delay ();
+ settings.set_int ("width", window.default_width);
+ settings.set_int ("height", window.default_height);
+ settings.set_boolean ("maximized", window.maximized);
+ settings.apply ();
+
window.destroy ();
window = null;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]