[gnome-taquin] Code improvements.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-taquin] Code improvements.
- Date: Tue, 12 Mar 2019 15:03:47 +0000 (UTC)
commit 39ab4f966a1cf7e851fa058155854f2521a8fc90
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Sat Mar 2 15:40:51 2019 +0100
Code improvements.
data/taquin.css | 2 +-
src/game-headerbar.vala | 11 ++++-----
src/game-view.vala | 62 +++++++++++++++++++++++++++----------------------
src/taquin-main.vala | 2 +-
4 files changed, 40 insertions(+), 37 deletions(-)
---
diff --git a/data/taquin.css b/data/taquin.css
index 4a0482b..b5f6ec7 100644
--- a/data/taquin.css
+++ b/data/taquin.css
@@ -25,7 +25,7 @@ button.unfullscreen-button {
.extra-thin-window.thin-window button.new-game-button { margin-right:-6px; }
/*\
-* * new-hame screen generics
+* * new-game screen generics
\*/
.main-grid { transition:padding 0.3s; padding:1.5rem; }
diff --git a/src/game-headerbar.vala b/src/game-headerbar.vala
index a16a8a5..89c3327 100644
--- a/src/game-headerbar.vala
+++ b/src/game-headerbar.vala
@@ -21,7 +21,7 @@
using Gtk;
[GtkTemplate (ui = "/org/gnome/Taquin/ui/game-headerbar.ui")]
-private class GameHeaderBar : BaseHeaderBar
+private class GameHeaderBar : BaseHeaderBar, AdaptativeWidget
{
[GtkChild] private MenuButton history_button;
[GtkChild] private Button new_game_button;
@@ -49,7 +49,6 @@ private class GameHeaderBar : BaseHeaderBar
GameWindowFlags flags,
NightLightMonitor _night_light_monitor)
{
- /* Translators: usual menu entry of the hamburger menu */
Object (about_action_label: _about_action_label,
night_light_monitor: _night_light_monitor,
has_keyboard_shortcuts: GameWindowFlags.SHORTCUTS in flags,
@@ -95,7 +94,7 @@ private class GameHeaderBar : BaseHeaderBar
}
/*\
- * * Showing the Stack
+ * * showing the stack
\*/
private bool current_view_is_new_game_screen = false;
@@ -104,8 +103,6 @@ private class GameHeaderBar : BaseHeaderBar
{
current_view_is_new_game_screen = true;
- set_subtitle (null); // TODO save / restore?
-
history_button.hide ();
if (!game_finished && back_button.visible)
@@ -135,7 +132,7 @@ private class GameHeaderBar : BaseHeaderBar
}
/*\
- * * Switching the Stack
+ * * switching the stack
\*/
internal void new_game ()
@@ -147,7 +144,7 @@ private class GameHeaderBar : BaseHeaderBar
}
/*\
- * * Some public calls
+ * * some public calls
\*/
internal void new_game_button_grab_focus ()
diff --git a/src/game-view.vala b/src/game-view.vala
index 391bc8e..1111d18 100644
--- a/src/game-view.vala
+++ b/src/game-view.vala
@@ -1,22 +1,22 @@
-/* -*- Mode: vala; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * Copyright (C) 2019 – Arnaud Bonatti <arnaud bonatti gmail com>
- *
- * This file is part of a GNOME game.
- *
- * This application is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This application is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this application. If not, see <http://www.gnu.org/licenses/>.
- */
+/* -*- Mode: vala; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ This file is part of a GNOME game.
+
+ Copyright 2019 Arnaud Bonatti
+
+ This game is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This game is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this game. If not, see <https://www.gnu.org/licenses/>.
+*/
using Gtk;
@@ -54,15 +54,18 @@ private class GameView : BaseView, AdaptativeWidget
if (GameWindowFlags.SHOW_START_BUTTON in flags)
{
/* Translators: when configuring a new game, label of the blue Start button (with a mnemonic
that appears pressing Alt) */
- start_game_button = new Button.with_mnemonic (_("_Start Game"));
- ((!) start_game_button).get_style_context ().add_class ("start-game-button");
- ((!) start_game_button).halign = Align.CENTER;
- ((!) start_game_button).set_action_name ("ui.start-or-restart");
+ Button _start_game_button = new Button.with_mnemonic (_("_Start Game"));
+ _start_game_button.halign = Align.CENTER;
+ _start_game_button.set_action_name ("ui.start-or-restart");
+
+ StyleContext context = _start_game_button.get_style_context ();
+ context.add_class ("start-game-button");
+ context.add_class ("suggested-action");
/* Translators: when configuring a new game, tooltip text of the blue Start button */
- // start_game_button.set_tooltip_text (_("Start a new game as configured"));
- ((StyleContext) ((!) start_game_button).get_style_context ()).add_class ("suggested-action");
- ((!) start_game_button).show ();
- new_game_box.pack_end ((!) start_game_button, false, false, 0);
+ // _start_game_button.set_tooltip_text (_("Start a new game as configured"));
+ _start_game_button.show ();
+ new_game_box.pack_end (_start_game_button, false, false, 0);
+ start_game_button = _start_game_button;
}
game_content = content;
@@ -88,7 +91,10 @@ private class GameView : BaseView, AdaptativeWidget
internal bool game_content_visible_if_true ()
{
- return game_stack.get_visible_child () == game_content;
+ Widget? visible_child = game_stack.get_visible_child ();
+ if (visible_child == null)
+ assert_not_reached ();
+ return (!) visible_child == game_content;
}
internal void configure_transition (StackTransitionType transition_type,
diff --git a/src/taquin-main.vala b/src/taquin-main.vala
index da52153..71823dd 100644
--- a/src/taquin-main.vala
+++ b/src/taquin-main.vala
@@ -447,7 +447,7 @@ private class Taquin : Gtk.Application, BaseApplication
copyright = "Copyright \xc2\xa9 2014-2019 – Arnaud Bonatti"; // TODO translation; autogen, to not
change each year?
documenters = { "Arnaud Bonatti" };
logo_icon_name = "org.gnome.Taquin";
- program_name = Taquin.PROGRAM_NAME;
+ program_name = PROGRAM_NAME;
/* Translators: about dialog text; this string should be replaced by a text crediting yourselves and
your translation team, or should be left empty. Do not translate literally! */
translator_credits = _("translator-credits");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]