[five-or-more/arnaudb/wip/gtk4: 23/29] Make things mostly work.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [five-or-more/arnaudb/wip/gtk4: 23/29] Make things mostly work.
- Date: Fri, 27 Mar 2020 15:48:34 +0000 (UTC)
commit d7caf8ec274f7ead6e44ec0f00caf11707e26224
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Fri Mar 13 12:09:58 2020 +0100
Make things mostly work.
src/main.vala | 17 ++++++++++-------
src/window.vala | 24 +++++++++---------------
2 files changed, 19 insertions(+), 22 deletions(-)
---
diff --git a/src/main.vala b/src/main.vala
index 7436a68..a5027d9 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -62,27 +62,30 @@ private class FiveOrMoreApp: Gtk.Application
Object (application_id: "org.gnome.five-or-more", flags: ApplicationFlags.FLAGS_NONE);
}
- protected override void activate ()
- {
- window.show ();
- }
-
protected override void startup ()
{
base.startup ();
settings = new Settings ("org.gnome.five-or-more");
- window = new GameWindow (this, settings);
-
add_action_entries (action_entries, this);
+
+ window = new GameWindow (settings);
+ add_window (window);
+
set_accels_for_action ("app.new-game", {"<Primary>n"});
set_accels_for_action ("app.quit", {"<Primary>q"});
set_accels_for_action ("app.help", {"F1"});
+
var board_size_action = lookup_action("change-size");
BoardSize size = (BoardSize)settings.get_int (FiveOrMoreApp.KEY_SIZE);
((SimpleAction)board_size_action).set_state (new Variant.string(size.to_string()));
}
+ protected override void activate ()
+ {
+ window.present ();
+ }
+
private void new_game_cb ()
{
if (window == null)
diff --git a/src/window.vala b/src/window.vala
index aed8f6c..3f071f0 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -38,7 +38,7 @@ private class GameWindow : ApplicationWindow
[GtkChild]
private Games.GridFrame grid_frame;
- private GLib.Settings? settings = null;
+ public GLib.Settings settings { private get; protected construct; }
private bool window_tiled;
internal bool window_maximized { internal get; private set; }
internal int window_width { internal get; private set; }
@@ -57,26 +57,18 @@ private class GameWindow : ApplicationWindow
construct
{
- size_allocate.connect (on_size_allocate);
- map.connect (init_state_watcher);
- }
-
- internal GameWindow (Gtk.Application app, GLib.Settings settings)
- {
- Object (application: app);
-
- this.settings = settings;
game = new Game (settings);
theme = new ThemeRenderer (settings);
+ size_allocate.connect (on_size_allocate);
+ map.connect (init_state_watcher);
+
set_default_size (settings.get_int ("window-width"), settings.get_int ("window-height"));
if (settings.get_boolean ("window-is-maximized"))
maximize ();
NextPiecesWidget next_pieces_widget = new NextPiecesWidget (settings, game, theme);
preview_hbox.add (next_pieces_widget);
- next_pieces_widget.realize ();
- next_pieces_widget.show ();
grid_frame.set (game.n_cols, game.n_rows);
game.board.board_changed.connect (() => { grid_frame.set (game.n_cols, game.n_rows); });
@@ -86,9 +78,6 @@ private class GameWindow : ApplicationWindow
View game_view = new View (settings, game, theme);
grid_frame.add (game_view);
- game_view.show ();
-
- grid_frame.show ();
var importer = new Games.Scores.DirectoryImporter ();
highscores = new Games.Scores.Context.with_importer ("five-or-more",
@@ -101,6 +90,11 @@ private class GameWindow : ApplicationWindow
game.game_over.connect (score_cb);
}
+ internal GameWindow (GLib.Settings settings)
+ {
+ Object (settings: settings);
+ }
+
private void init_state_watcher ()
{
Gdk.Surface? nullable_surface = get_surface (); // TODO report bug, get_surface() returns a
nullable Surface
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]