[gnome-2048/arnaudb/wip/gtk4: 40/48] Uncomment another thing.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-2048/arnaudb/wip/gtk4: 40/48] Uncomment another thing.
- Date: Wed, 29 Jul 2020 15:38:30 +0000 (UTC)
commit dc578f24ee31e362210c10b99ecd913e380774bc
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Wed Jul 15 18:30:37 2020 +0200
Uncomment another thing.
src/game.vala | 33 ++++++++++++++++++++++-----------
1 file changed, 22 insertions(+), 11 deletions(-)
---
diff --git a/src/game.vala b/src/game.vala
index 8834468..5fdd4a9 100644
--- a/src/game.vala
+++ b/src/game.vala
@@ -77,6 +77,8 @@ private class Game : Gtk.Widget
Gtk.BinLayout layout = new Gtk.BinLayout ();
set_layout_manager (layout);
+ map.connect (_init_state_watcher);
+
add_css_class ("background-grid");
_background_grid = new Gtk.Grid ();
@@ -117,8 +119,6 @@ private class Game : Gtk.Widget
uint8 cols = (uint8) settings.get_int ("cols"); // schema ranges cols
uint8 rows = (uint8) settings.get_int ("rows"); // and rows from 1 to 9
_init_grid (rows, cols, out _grid, ref settings);
-
-// size_allocate.connect (_on_size_allocate);
}
private static void _init_grid (uint8 rows, uint8 cols, out Grid grid, ref GLib.Settings settings)
@@ -131,16 +131,27 @@ private class Game : Gtk.Widget
* * view
\*/
-// private void _on_size_allocate (Gtk.Widget widget, int width, int height, int baseline)
-// {
-// width = _width;
-// height = _height;
+ private inline void _init_state_watcher ()
+ {
+ Gtk.Native? native = get_native ();
+ if (native == null)
+ assert_not_reached ();
+ Gdk.Surface? nullable_surface = ((!) native).get_surface ();
+ if (nullable_surface == null)
+ assert_not_reached ();
+ ((!) nullable_surface).size_changed.connect (_on_size_changed);
+ }
-// if (_background_init_done)
-// _resize_view ();
-// else
-// _init_background ();
-// }
+ private inline void _on_size_changed (Gdk.Surface _surface, int _width, int _height)
+ {
+ width = _width;
+ height = _height;
+
+ if (_background_init_done)
+ _resize_view ();
+ else
+ _init_background ();
+ }
/*\
* * others
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]