[gnome-mahjongg] Scores dialog: scroll to new high score
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-mahjongg] Scores dialog: scroll to new high score
- Date: Tue, 19 Nov 2013 04:20:03 +0000 (UTC)
commit 6fe6672b9c9fc0bea5aee4900d02587e412a81c7
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Mon Nov 18 22:19:17 2013 -0600
Scores dialog: scroll to new high score
Done by Isaac Lenton
https://bugzilla.gnome.org/show_bug.cgi?id=711736
src/gnome-mahjongg.vala | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/src/gnome-mahjongg.vala b/src/gnome-mahjongg.vala
index 0d6ce92..3684cd6 100644
--- a/src/gnome-mahjongg.vala
+++ b/src/gnome-mahjongg.vala
@@ -770,6 +770,7 @@ public class ScoreDialog : Gtk.Dialog
private Gtk.ListStore size_model;
private Gtk.ListStore score_model;
private Gtk.ComboBox size_combo;
+ private Gtk.TreeView scores;
public ScoreDialog (History history, HistoryEntry? selected_entry = null, bool show_quit = false)
{
@@ -818,7 +819,7 @@ public class ScoreDialog : Gtk.Dialog
score_model = new Gtk.ListStore (3, typeof (string), typeof (string), typeof (int));
- var scores = new Gtk.TreeView ();
+ scores = new Gtk.TreeView ();
renderer = new Gtk.CellRendererText ();
scores.insert_column_with_attributes (-1, _("Date"), renderer, "text", 0, "weight", 2);
renderer = new Gtk.CellRendererText ();
@@ -857,6 +858,20 @@ public class ScoreDialog : Gtk.Dialog
Gtk.TreeIter iter;
score_model.append (out iter);
score_model.set (iter, 0, date_label, 1, time_label, 2, weight);
+
+ if (entry == selected_entry)
+ {
+ var piter = iter;
+ if (score_model.iter_previous (ref piter))
+ {
+ var ppiter = piter;
+ if (score_model.iter_previous (ref ppiter))
+ piter = ppiter;
+ }
+ else
+ piter = iter;
+ scores.scroll_to_cell (score_model.get_path (piter), null, false, 0, 0);
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]