[gnome-chess] Hide timers in untimed games
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-chess] Hide timers in untimed games
- Date: Fri, 4 Dec 2020 20:56:48 +0000 (UTC)
commit ed38dbe57bc6809cf24c65fd8cceba84e04a75fc
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Fri Dec 4 12:54:18 2020 -0600
Hide timers in untimed games
There's no need to show the timers at all if the game is untimed.
Fixes #39
data/gnome-chess.ui | 2 +-
src/gnome-chess.vala | 8 +++++---
2 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/data/gnome-chess.ui b/data/gnome-chess.ui
index b1194fc..94d30ce 100644
--- a/data/gnome-chess.ui
+++ b/data/gnome-chess.ui
@@ -308,7 +308,7 @@
</packing>
</child>
<child>
- <object class="GtkBox">
+ <object class="GtkBox" id="clock_box">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="spacing">6</property>
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index cb2ed83..3cf5d22 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -39,6 +39,7 @@ public class ChessApplication : Gtk.Application
private Widget next_move_button;
private Widget last_move_button;
private ComboBox history_combo;
+ private Box clock_box;
private Widget white_time_label;
private Widget black_time_label;
private Widget timer_increment_label;
@@ -169,6 +170,7 @@ Copyright © 2015–2016 Sahil Sareen""";
next_move_button = (Widget) builder.get_object ("next_move_button");
last_move_button = (Widget) builder.get_object ("last_move_button");
history_combo = (ComboBox) builder.get_object ("history_combo");
+ clock_box = (Box) builder.get_object ("clock_box");
white_time_label = (Widget) builder.get_object ("white_time_label");
black_time_label = (Widget) builder.get_object ("black_time_label");
view_container = (Container) builder.get_object ("view_container");
@@ -626,6 +628,8 @@ Copyright © 2015–2016 Sahil Sareen""";
pgn_game.clock_type = clock_type.to_string ();
}
+ clock_box.visible = game.clock != null;
+
if (game.clock != null)
{
game.clock.extra_seconds = (int) timer_increment_adj_value;
@@ -1596,10 +1600,8 @@ Copyright © 2015–2016 Sahil Sareen""";
}
private string make_clock_text (ChessClock? clock, Color color)
+ requires (clock != null)
{
- if (clock == null)
- return "∞";
-
int time;
if (color == Color.WHITE)
time = game.clock.white_remaining_seconds;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]