[gnome-tetravex] More strings in Scores dialog.



commit 629c7fc9242699e30c43095e9ad3d96befd1d56f
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Wed Sep 18 20:37:16 2019 +0200

    More strings in Scores dialog.

 src/score-dialog.vala | 87 ++++++++++++++++++++++++++++++---------------------
 1 file changed, 51 insertions(+), 36 deletions(-)
---
diff --git a/src/score-dialog.vala b/src/score-dialog.vala
index 9eaf393..4fae064 100644
--- a/src/score-dialog.vala
+++ b/src/score-dialog.vala
@@ -9,16 +9,18 @@
  * license.
  */
 
-private class ScoreDialog : Gtk.Dialog
+using Gtk;
+
+private class ScoreDialog : Dialog
 {
     private History history;
     private HistoryEntry? selected_entry = null;
     private Gtk.ListStore size_model;
     private Gtk.ListStore score_model;
-    private Gtk.ComboBox size_combo;
-    private Gtk.TreeView scores;
+    private ComboBox size_combo;
+    private TreeView scores;
 
-    public ScoreDialog (History history, HistoryEntry? selected_entry = null, bool show_quit = false)
+    internal ScoreDialog (History history, HistoryEntry? selected_entry = null, bool show_quit = false)
     {
         this.history = history;
         history.entry_added.connect (entry_added_cb);
@@ -26,56 +28,58 @@ private class ScoreDialog : Gtk.Dialog
 
         if (show_quit)
         {
-            /* Translators: label of a button of the Scores dialog, is it is displayed at the end of a game; 
quits the application */
-            add_button (_("Quit"), Gtk.ResponseType.CLOSE);
+            /* Translators: label of a button of the Scores dialog, as it is displayed at the end of a game; 
quits the application */
+            add_button (_("Quit"), ResponseType.CLOSE);
 
 
-            /* Translators: label of a button of the Scores dialog, is it is displayed at the end of a game; 
starts a new game */
-            add_button (_("New Game"), Gtk.ResponseType.OK);
+            /* Translators: label of a button of the Scores dialog, as it is displayed at the end of a game; 
starts a new game */
+            add_button (_("New Game"), ResponseType.OK);
         }
         else
-            /* Translators: label of a button of the Scores dialog, is it is displayed when called from the 
hamburger menu; closes the dialog */
-            add_button (_("OK"), Gtk.ResponseType.DELETE_EVENT);
+        {
+            /* Translators: label of a button of the Scores dialog, as it is displayed when called from the 
hamburger menu; closes the dialog */
+            add_button (_("OK"), ResponseType.DELETE_EVENT);
+        }
         set_size_request (200, 300);
 
-        var vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 5);
+        Box vbox = new Box (Orientation.VERTICAL, 5);
         vbox.border_width = 6;
         vbox.show ();
         get_content_area ().pack_start (vbox, true, true, 0);
 
-        var hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
+        Box hbox = new Box (Orientation.HORIZONTAL, 6);
         hbox.show ();
         vbox.pack_start (hbox, false, false, 0);
 
         /* Translators: in the Scores dialog, label introducing the combobox that allows showing scores for 
various sizes */
-        var label = new Gtk.Label (_("Size:"));
+        Label label = new Label (_("Size:"));
         label.show ();
         hbox.pack_start (label, false, false, 0);
 
         size_model = new Gtk.ListStore (2, typeof (string), typeof (int));
 
-        size_combo = new Gtk.ComboBox ();
+        size_combo = new ComboBox ();
         size_combo.changed.connect (size_changed_cb);
         size_combo.model = size_model;
-        var renderer = new Gtk.CellRendererText ();
+        CellRendererText renderer = new CellRendererText ();
         size_combo.pack_start (renderer, true);
         size_combo.add_attribute (renderer, "text", 0);
         size_combo.show ();
         hbox.pack_start (size_combo, true, true, 0);
 
-        var scroll = new Gtk.ScrolledWindow (null, null);
-        scroll.shadow_type = Gtk.ShadowType.ETCHED_IN;
-        scroll.set_policy (Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
+        ScrolledWindow scroll = new ScrolledWindow (null, null);
+        scroll.shadow_type = ShadowType.ETCHED_IN;
+        scroll.set_policy (PolicyType.NEVER, PolicyType.AUTOMATIC);
         scroll.show ();
         vbox.pack_start (scroll, true, true, 0);
 
         score_model = new Gtk.ListStore (3, typeof (string), typeof (string), typeof (int));
 
-        scores = new Gtk.TreeView ();
-        renderer = new Gtk.CellRendererText ();
+        scores = new TreeView ();
+        renderer = new CellRendererText ();
         /* Translators: in the Scores dialog, in the scores list, label of the column displaying when games 
were played */
         scores.insert_column_with_attributes (-1, _("Date"), renderer, "text", 0, "weight", 2);
-        renderer = new Gtk.CellRendererText ();
+        renderer = new CellRendererText ();
         renderer.xalign = 1.0f;
         /* Translators: in the Scores dialog, in the scores list, label of the column displaying the 
duration of played games */
         scores.insert_column_with_attributes (-1, _("Time"), renderer, "text", 1, "weight", 2);
@@ -83,7 +87,7 @@ private class ScoreDialog : Gtk.Dialog
         scores.show ();
         scroll.add (scores);
 
-        foreach (var entry in history.entries)
+        foreach (HistoryEntry entry in history.entries)
             entry_added_cb (entry);
     }
 
@@ -91,34 +95,44 @@ private class ScoreDialog : Gtk.Dialog
     {
         score_model.clear ();
 
-        var entries = history.entries.copy ();
+        List<unowned HistoryEntry> entries = history.entries.copy ();
         entries.sort (compare_entries);
 
-        foreach (var entry in entries)
+        foreach (HistoryEntry entry in entries)
         {
             if (entry.size != size)
                 continue;
 
-            var date_label = entry.date.format ("%d/%m/%Y");
+            /* Translators: that is the date at which a game was played, as seen in the Scores dialog; the 
%d will be replaced by the day number (two digits, padded with 0 in needed), the %m by the month number (two 
digits, padded with 0 in needed), and the %Y by the year (four digits); other replacements are possible, see 
documentation of g_date_time_format(); you're free here! */
+            string date_label = entry.date.format (_("%d/%m/%Y"));
+
+            string time_label;
+            if (entry.duration >= 3600)
+                /* Translators: that is the duration of a game, as seen in the Scores dialog, if game has 
taken one hour or more; the %u are replaced by the hours (h), minutes (m) and seconds (s); as an example, you 
might want to use "%u:%.2u:%.2u", that is quite international (the ".2" meaning "two digits, padding with 0") 
*/
+                time_label = _("%uh %um %us").printf (entry.duration / 3600, (entry.duration / 60) % 60, 
entry.duration % 60);
+
+            else if (entry.duration >= 60)
+                /* Translators: that is the duration of a game, as seen in the Scores dialog, if game has 
taken between one minute and one hour; the %u are replaced by the minutes (m) and seconds (s); as an example, 
you might want to use "%.2u:%.2u", that is quite international (the ".2" meaning "two digits, padding with 
0") */
+                time_label = _("%um %us").printf (entry.duration / 60, entry.duration % 60);
 
-            var time_label = "%us".printf (entry.duration);
-            if (entry.duration >= 60)
-                time_label = "%um %us".printf (entry.duration / 60, entry.duration % 60);
+            else
+                /* Translators: that is the duration of a game, as seen in the Scores dialog, if game has 
taken less than one minute; the %u is replaced by the number of seconds (s) it has taken; as an example, you 
might want to use "00:%.2u", that is quite international (the ".2" meaning "two digits, padding with 0") */
+                time_label = _("%us").printf (entry.duration);
 
             int weight = Pango.Weight.NORMAL;
             if (entry == selected_entry)
                 weight = Pango.Weight.BOLD;
 
-            Gtk.TreeIter iter;
+            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;
+                TreeIter piter = iter;
                 if (score_model.iter_previous (ref piter))
                 {
-                    var ppiter = piter;
+                    TreeIter ppiter = piter;
                     if (score_model.iter_previous (ref ppiter))
                         piter = ppiter;
                 }
@@ -138,9 +152,9 @@ private class ScoreDialog : Gtk.Dialog
         return a.date.compare (b.date);
     }
 
-    private void size_changed_cb (Gtk.ComboBox combo)
+    private void size_changed_cb (ComboBox combo)
     {
-        Gtk.TreeIter iter;
+        TreeIter iter;
         if (!combo.get_active_iter (out iter))
             return;
 
@@ -152,8 +166,8 @@ private class ScoreDialog : Gtk.Dialog
     private void entry_added_cb (HistoryEntry entry)
     {
         /* Ignore if already have an entry for this */
-        Gtk.TreeIter iter;
-        var have_size_entry = false;
+        TreeIter iter;
+        bool have_size_entry = false;
         if (size_model.get_iter_first (out iter))
         {
             do
@@ -170,7 +184,8 @@ private class ScoreDialog : Gtk.Dialog
 
         if (!have_size_entry)
         {
-            var label = "%hu × %hu".printf (entry.size, entry.size);
+            /* 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);
 
             size_model.append (out iter);
             size_model.@set (iter, 0, label, 1, entry.size);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]