[gnome-games] gnomine: Simplify board size label code
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] gnomine: Simplify board size label code
- Date: Tue, 7 Feb 2012 06:21:28 +0000 (UTC)
commit 8459a41753038da61f7f24fa49b9eb60f021c4c5
Author: Robert Ancell <robert ancell canonical com>
Date: Tue Feb 7 16:51:38 2012 +1100
gnomine: Simplify board size label code
gnomine/src/gnomine.vala | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/gnomine/src/gnomine.vala b/gnomine/src/gnomine.vala
index 2c33b0b..da7a854 100644
--- a/gnomine/src/gnomine.vala
+++ b/gnomine/src/gnomine.vala
@@ -180,7 +180,7 @@ public class GnoMine : Gtk.Application
button_small.clicked.connect (small_size_clicked_cb);
label = new Gtk.Label (null);
- label.set_markup ("<span fgcolor='#0000ff'><span size='x-large' weight='ultrabold'>8 x 8</span>\n" + _("Mines") + ": <b>10</b></span>");
+ label.set_markup (make_minefield_description ("#0000ff", 8, 8, 10));
label.set_justify (Gtk.Justification.CENTER);
button_small.add (label);
@@ -189,7 +189,7 @@ public class GnoMine : Gtk.Application
button_medium.clicked.connect (medium_size_clicked_cb);
label = new Gtk.Label (null);
- label.set_markup ("<span fgcolor='#00a000'><span size='x-large' weight='ultrabold'>16 x 16</span>\n" + _("Mines") + ": <b>40</b></span>");
+ label.set_markup (make_minefield_description ("#00a000", 16, 16, 40));
label.set_justify (Gtk.Justification.CENTER);
button_medium.add (label);
@@ -198,7 +198,7 @@ public class GnoMine : Gtk.Application
button_large.clicked.connect (large_size_clicked_cb);
label = new Gtk.Label (null);
- label.set_markup ("<span fgcolor='#ff0000'><span size='x-large' weight='ultrabold'>30 x 16</span>\n" + _("Mines") + ": <b>99</b></span>");
+ label.set_markup (make_minefield_description ("#ff0000", 30, 16, 99));
label.set_justify (Gtk.Justification.CENTER);
button_large.add (label);
@@ -274,6 +274,13 @@ public class GnoMine : Gtk.Application
custom_game_screen.hide ();
view_box.pack_start (custom_game_screen, true, false);
}
+
+ private string make_minefield_description (string color, int width, int height, int n_mines)
+ {
+ var size_label = "%d à %d".printf (width, height);
+ var mines_label = ngettext ("<b>%d</d> mine", "<b>%d</b> mines", n_mines).printf (n_mines);
+ return "<span fgcolor='%s'><span size='x-large' weight='ultrabold'>%s</span>\n%s</span>".printf (color, size_label, mines_label);
+ }
private const Gtk.ActionEntry actions[] =
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]