[gnome-tetravex] Show scores for current puzzle size.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-tetravex] Show scores for current puzzle size.
- Date: Thu, 19 Sep 2019 16:36:46 +0000 (UTC)
commit 61ee34bbc0ff1c4844919b1d90c0fbaf394826ab
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Thu Sep 19 18:32:54 2019 +0200
Show scores for current puzzle size.
src/gnome-tetravex.vala | 2 +-
src/score-dialog.vala | 41 +++++++++++++++++++++++------------------
2 files changed, 24 insertions(+), 19 deletions(-)
---
diff --git a/src/gnome-tetravex.vala b/src/gnome-tetravex.vala
index a425a78..48e44a4 100644
--- a/src/gnome-tetravex.vala
+++ b/src/gnome-tetravex.vala
@@ -371,7 +371,7 @@ private class Tetravex : Gtk.Application
return ResponseType.REJECT;
scores_dialog_visible = true;
- ScoreDialog dialog = new ScoreDialog (history, selected_entry, show_quit);
+ ScoreDialog dialog = new ScoreDialog (history, puzzle.size, selected_entry, show_quit);
dialog.modal = true;
dialog.transient_for = window;
diff --git a/src/score-dialog.vala b/src/score-dialog.vala
index a0f59f1..45350a4 100644
--- a/src/score-dialog.vala
+++ b/src/score-dialog.vala
@@ -20,7 +20,7 @@ private class ScoreDialog : Dialog
private ComboBox size_combo;
private TreeView scores;
- internal ScoreDialog (History history, HistoryEntry? selected_entry = null, bool show_quit = false)
+ internal ScoreDialog (History history, uint8 size, HistoryEntry? selected_entry = null, bool show_quit =
false)
{
this.history = history;
history.entry_added.connect (entry_added_cb);
@@ -91,9 +91,13 @@ private class ScoreDialog : Dialog
entries.sort (compare_entries);
foreach (HistoryEntry entry in entries)
entry_added_cb (entry);
+
+ TreeIter iter;
+ if (get_size_iter (size, out iter))
+ size_combo.set_active_iter (iter);
}
- internal void set_size (uint8 size)
+ private void set_size (uint8 size)
{
score_model.clear ();
@@ -169,22 +173,7 @@ private class ScoreDialog : Dialog
{
/* Ignore if already have an entry for this */
TreeIter iter;
- bool have_size_entry = false;
- if (size_model.get_iter_first (out iter))
- {
- do
- {
- int size;
- size_model.@get (iter, 1, out size, -1);
- if (size == entry.size)
- {
- have_size_entry = true;
- break;
- }
- } while (size_model.iter_next (ref iter));
- }
-
- if (!have_size_entry)
+ if (!get_size_iter (entry.size, out iter))
{
/* Translators: this string creates the options of the combobox seen in the Scores dialog; the
%u are replaced by the board size; it allows to choose for which board size you want to see the scores, for
example between "2 × 2" and "3 × 3" */
string label = _("%u × %u").printf (entry.size, entry.size);
@@ -201,4 +190,20 @@ private class ScoreDialog : Dialog
size_combo.set_active_iter (iter);
}
}
+
+ private bool get_size_iter (uint8 requested_size, out TreeIter iter)
+ {
+ if (size_model.get_iter_first (out iter))
+ {
+ do
+ {
+ int size;
+ size_model.@get (iter, 1, out size, -1);
+ if (size == requested_size)
+ return true;
+ }
+ while (size_model.iter_next (ref iter));
+ }
+ return false;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]