[gnome-chess] Use a button for pause/resume
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-chess] Use a button for pause/resume
- Date: Sun, 16 Feb 2014 22:49:44 +0000 (UTC)
commit d96bd1e2aa9f83a4addc2d53a50f9b966a87df5e
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Sun Feb 16 16:23:33 2014 -0600
Use a button for pause/resume
data/gnome-chess.ui | 16 ++++++++++++++++
src/gnome-chess.vala | 22 ++++++++++++++++++++++
2 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/data/gnome-chess.ui b/data/gnome-chess.ui
index ea523b7..b25aad3 100644
--- a/data/gnome-chess.ui
+++ b/data/gnome-chess.ui
@@ -51,6 +51,22 @@
</object>
</child>
<child>
+ <object class="GtkButton" id="pause_button">
+ <property name="visible">True</property>
+ <property name="valign">center</property>
+ <property name="action-name">win.pause-resume</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage" id="pause_image">
+ <property name="visible">True</property>
+ <property name="icon_size">1</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
<object class="GtkMenuButton" id="gear_button">
<property name="visible">True</property>
<property name="valign">center</property>
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index af27573..6236860 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -19,6 +19,7 @@ public class Application : Gtk.Application
private Gtk.Container view_container;
private ChessScene scene;
private ChessView view;
+ private Gtk.Button pause_resume_button;
private Gtk.MenuButton menu_button;
private Gtk.Widget first_move_button;
private Gtk.Widget prev_move_button;
@@ -130,6 +131,7 @@ public class Application : Gtk.Application
}
window = (Gtk.ApplicationWindow) builder.get_object ("gnome_chess_app");
var undo_move_image = (Gtk.Image) builder.get_object ("undo_move_image");
+ pause_resume_button = (Gtk.Button) builder.get_object ("pause_button");
menu_button = (Gtk.MenuButton) builder.get_object ("gear_button");
first_move_button = (Gtk.Widget) builder.get_object ("first_move_button");
prev_move_button = (Gtk.Widget) builder.get_object ("prev_move_button");
@@ -146,6 +148,8 @@ public class Application : Gtk.Application
headerbar = (Gtk.HeaderBar) builder.get_object ("headerbar");
builder.connect_signals (this);
+ update_pause_resume_button ();
+
bool rtl = Gtk.Widget.get_default_direction () == Gtk.TextDirection.RTL;
first_move_image.icon_name = rtl ? "go-first-rtl-symbolic" : "go-first-symbolic";
@@ -574,6 +578,7 @@ public class Application : Gtk.Application
update_history_panel ();
update_action_status ();
+ update_pause_resume_button ();
update_headerbar_title ();
white_time_label.queue_draw ();
@@ -1080,6 +1085,22 @@ public class Application : Gtk.Application
add_accelerator ("Pause", "win." + PAUSE_RESUME_ACTION_NAME, null);
}
+ private void update_pause_resume_button ()
+ {
+ if (game != null && game.is_paused)
+ {
+ pause_resume_button.image = new Gtk.Image.from_icon_name ("media-playback-start-symbolic",
+ Gtk.IconSize.BUTTON);
+ pause_resume_button.tooltip_text = _("Unpause the game");
+ }
+ else
+ {
+ pause_resume_button.image = new Gtk.Image.from_icon_name ("media-playback-pause-symbolic",
+ Gtk.IconSize.BUTTON);
+ pause_resume_button.tooltip_text = _("Pause the game");
+ }
+ }
+
private void game_end_cb (ChessGame game)
{
disable_window_action (RESIGN_ACTION_NAME);
@@ -1350,6 +1371,7 @@ public class Application : Gtk.Application
else
game.pause ();
+ update_pause_resume_button ();
update_history_panel ();
update_action_status ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]