[gnome-mines/wip/theming-support] Added preview dialog
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-mines/wip/theming-support] Added preview dialog
- Date: Sun, 4 Jan 2015 00:59:48 +0000 (UTC)
commit a7fb691f0916c788f9cbcb849628fcc9ee22277a
Author: Robert Roth <robert roth off gmail com>
Date: Sun Jan 4 02:58:55 2015 +0200
Added preview dialog
po/POTFILES.in | 2 +
src/Makefile.am | 3 +-
src/theme-selector-dialog.vala | 67 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 71 insertions(+), 1 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 18706db..6f4dc93 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -10,3 +10,5 @@ src/history.vala
src/minefield.vala
src/minefield-view.vala
src/score-dialog.vala
+src/tile.vala
+src/theme-selector-dialog.vala
diff --git a/src/Makefile.am b/src/Makefile.am
index 43bdc4d..667aec9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -7,7 +7,8 @@ gnome_mines_SOURCES = \
minefield.vala \
minefield-view.vala \
score-dialog.vala \
- tile.vala
+ tile.vala \
+ theme-selector-dialog.vala
gnome_mines_CFLAGS = \
-DVERSION=\"$(VERSION)\" \
diff --git a/src/theme-selector-dialog.vala b/src/theme-selector-dialog.vala
new file mode 100644
index 0000000..32a12ee
--- /dev/null
+++ b/src/theme-selector-dialog.vala
@@ -0,0 +1,67 @@
+private class PreviewField : Minefield
+{
+ public PreviewField ()
+ {
+ base (7, 7, 20);
+
+ place_mines (0, 0);
+ }
+
+ protected new void place_mines (uint x, uint y)
+ {
+ for (int i = 0; i < 7; i++)
+ locations[i, 0].has_mine = i >= 5;
+ for (int i = 0; i < 7; i++)
+ locations[i, 1].has_mine = false;
+ for (int i = 0; i < 7; i++)
+ locations[i, 2].has_mine = i == 0 || i == 3;
+ for (int i = 0; i < 7; i++)
+ locations[i, 3].has_mine = i == 0 || i == 2;
+ for (int i = 0; i < 7; i++)
+ locations[i, 4].has_mine = i == 0 || i == 2 || i > 3;
+ for (int i = 0; i < 7; i++)
+ locations[i, 5].has_mine = i % 2 == 0;
+ for (int i = 0; i < 7; i++)
+ locations[i, 6].has_mine = i != 1;
+
+ }
+
+}
+
+public class ThemeSelectorDialog : Gtk.Dialog
+{
+
+ public ThemeSelectorDialog ( )
+ {
+ set_default_size (300, 332);
+ title = _("Select theme");
+ var frame = new Gtk.AspectFrame (null, 0.5f, 0.5f, 1.0f, false);
+ frame.border_width = 6;
+ get_content_area ().pack_start (frame, true, true, 0);
+
+ var settings = new Settings ("org.gnome.mines");
+ settings.delay ();
+
+ var view = new MinefieldView (settings);
+ view.minefield = new PreviewField ();
+ frame.add (view);
+ frame.show_all ();
+
+ reveal_nonmines (view);
+ }
+
+ private void reveal_nonmines (MinefieldView view)
+ {
+ for (int i = 0; i < 7; i ++)
+ for (int j = 0; j < 6; j ++)
+ {
+ if (!view.minefield.has_mine (i, j)) {
+ view.minefield.clear_mine (i, j);
+ view.multi_release (i, j);
+ } else {
+ view.toggle_mark (i, j);
+ }
+ }
+ }
+
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]