[gnome-chess] Don't change UI when focus lost
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-chess] Don't change UI when focus lost
- Date: Fri, 2 Aug 2013 13:22:15 +0000 (UTC)
commit b30e47a81ae4875409be9ff50964c4bda0c7c9c3
Author: Michael Catanzaro <mike catanzaro gmail com>
Date: Wed Jul 31 22:07:05 2013 -0500
Don't change UI when focus lost
Just stop counting down
https://bugzilla.gnome.org/show_bug.cgi?id=701578
data/gnome-chess.ui | 2 +-
src/gnome-chess.vala | 31 +++++++++++++++++++------------
2 files changed, 20 insertions(+), 13 deletions(-)
---
diff --git a/data/gnome-chess.ui b/data/gnome-chess.ui
index d419cee..82e3573 100644
--- a/data/gnome-chess.ui
+++ b/data/gnome-chess.ui
@@ -165,7 +165,7 @@
<property name="use_underline">True</property>
<property name="stock_id">gtk-media-pause</property>
<accelerator key="p" signal="clicked" modifiers="GDK_CONTROL_MASK"/>
- <signal name="clicked" handler="pause_game_cb" swapped="no"/>
+ <signal name="clicked" handler="pause_game_button_pressed_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index 8cfaede..079a20d 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -96,16 +96,16 @@ public class Application : Gtk.Application
public bool on_window_focus_out (Gdk.EventFocus focus)
{
- if (!is_paused)
- pause_game_cb (pause_button);
+ if (((Gtk.ToolButton) pause_button).stock_id == "gtk-media-pause" )
+ set_paused_state (true);
return false;
}
public bool on_window_focus_in (Gdk.EventFocus focus)
{
- if (is_paused)
- pause_game_cb (pause_button);
+ if (((Gtk.ToolButton) pause_button).stock_id == "gtk-media-pause" )
+ set_paused_state (false);
return false;
}
@@ -1198,16 +1198,14 @@ public class Application : Gtk.Application
history_combo.sensitive = widget_sensitivity[SensitivityIndex.HISTORY];
}
- [CCode (cname = "G_MODULE_EXPORT pause_game_cb", instance_pos = -1)]
- public void pause_game_cb (Gtk.Widget widget)
+ [CCode (cname = "G_MODULE_EXPORT pause_game_button_pressed_cb", instance_pos = -1)]
+ public void pause_game_button_pressed_cb (Gtk.Widget widget)
{
- is_paused = !is_paused;
- game.is_paused = is_paused;
+ set_paused_state (!is_paused);
+
Gtk.ToolButton tool_button = (Gtk.ToolButton) pause_button;
if (is_paused)
{
- if (game.clock != null)
- game.clock.toggle_paused (true);
tool_button.stock_id = "gtk-media-play";
tool_button.label = "Start";
stash_button_sensitivity ();
@@ -1222,14 +1220,23 @@ public class Application : Gtk.Application
}
else
{
- if (game.clock != null)
- game.clock.toggle_paused (false);
tool_button.stock_id = "gtk-media-pause";
tool_button.label = "Pause";
revert_button_sensitivity ();
}
}
+ public void set_paused_state (bool paused)
+ {
+ if (paused != is_paused)
+ {
+ is_paused = paused;
+ game.is_paused = paused;
+ if (game.clock != null)
+ game.clock.toggle_paused (paused);
+ }
+ }
+
public void quit_cb ()
{
quit_game ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]