[gnome-chess/chess-telepathy-networking-support-664946-rebase: 49/64] [glchess] abstract out update_history_model() from update_history_panel()
- From: Chandni Verma <vchandni src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-chess/chess-telepathy-networking-support-664946-rebase: 49/64] [glchess] abstract out update_history_model() from update_history_panel()
- Date: Sun, 23 Dec 2012 03:42:44 +0000 (UTC)
commit f3a3b260ed44bdf5ae5b04f12f3692584ce8cfce
Author: Chandni Verma <chandniverma2112 gmail com>
Date: Thu Sep 20 17:13:01 2012 +0530
[glchess] abstract out update_history_model() from update_history_panel()
This decouples model from view
src/gnome-chess-application.vala | 31 +++++++++++++++++++------------
1 files changed, 19 insertions(+), 12 deletions(-)
---
diff --git a/src/gnome-chess-application.vala b/src/gnome-chess-application.vala
index baa223e..99cabbb 100644
--- a/src/gnome-chess-application.vala
+++ b/src/gnome-chess-application.vala
@@ -376,6 +376,24 @@ public class Application : Gtk.Application
}
}
+ protected void update_history_model (ChessGame game, ChessScene scene, Gtk.TreeModel history_model)
+ {
+ /* Set move text for all moves (it may have changed format) */
+ var n_moves = (int) game.n_moves;
+
+ int i = n_moves;
+ foreach (var state in game.move_stack)
+ {
+ if (state.last_move != null)
+ {
+ Gtk.TreeIter iter;
+ if ((history_model as Gtk.ListStore).iter_nth_child (out iter, null, i))
+ set_move_text (iter, state.last_move, scene, history_model);
+ }
+ i--;
+ }
+ }
+
protected void update_history_panel (ChessGame? game, ChessScene scene, Gtk.TreeModel history_model)
{
if (game == null)
@@ -391,18 +409,7 @@ public class Application : Gtk.Application
next_move_button.sensitive = move_number < n_moves;
last_move_button.sensitive = n_moves > 0 && move_number != n_moves;
- /* Set move text for all moves (it may have changed format) */
- int i = n_moves;
- foreach (var state in game.move_stack)
- {
- if (state.last_move != null)
- {
- Gtk.TreeIter iter;
- if ((history_model as Gtk.ListStore).iter_nth_child (out iter, null, i))
- set_move_text (iter, state.last_move, scene, history_model);
- }
- i--;
- }
+ update_history_model (game, scene, history_model);
history_combo.set_active (move_number);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]