[gnome-mines] Mark the full field as exploded instead of separate tiles



commit 08d4ecbb3bd1cf9e5feeb689adbc3eea0ecd1fa8
Author: Robert Roth <robert roth off gmail com>
Date:   Wed Apr 23 15:41:49 2014 +0300

    Mark the full field as exploded instead of separate tiles

 data/gnome-mines.css.in |    4 ++--
 src/minefield-view.vala |    6 ++++--
 2 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/data/gnome-mines.css.in b/data/gnome-mines.css.in
index 317d72d..2352fd3 100644
--- a/data/gnome-mines.css.in
+++ b/data/gnome-mines.css.in
@@ -74,12 +74,12 @@ Changes are applied instantly and globally, for the whole application.
   font-size:32px;
 }
 
-.explodedField {
+.explodedField .tile {
   border-width:1px;
   border-color:red;
 }
 
-.completedField {
+.completedField .tile {
   border-width:1px;
   border-color:green;
 }
diff --git a/src/minefield-view.vala b/src/minefield-view.vala
index a3fa27f..e23d008 100644
--- a/src/minefield-view.vala
+++ b/src/minefield-view.vala
@@ -233,6 +233,8 @@ public class MinefieldView : Gtk.Grid
                 SignalHandler.disconnect_by_func (_minefield, null, this);
             }
             _minefield = value;
+            get_style_context ().remove_class ("explodedField");
+            get_style_context ().remove_class ("completedField");
             mines = new Tile[_minefield.width, _minefield.height];
             forall ( (child) => { remove (child);});
             for (int i = 0; i < _minefield.width; i++)
@@ -351,11 +353,11 @@ public class MinefieldView : Gtk.Grid
 
     private void explode_cb (Minefield minefield)
     {
+        get_style_context  ().add_class ("explodedField");
         /* Show the mines that we missed or the flags that were wrong */
         for (var x = 0; x < minefield.width; x++)
             for (var y = 0; y < minefield.height; y++)
             {
-                mines[x, y].add_class ("explodedField");
                 if (minefield.has_mine (x, y) || (!minefield.has_mine (x, y) && minefield.get_flag (x, y) == 
FlagType.FLAG))
                     redraw_sector_cb (x, y);
             }
@@ -363,7 +365,7 @@ public class MinefieldView : Gtk.Grid
 
     private void complete_cb (Minefield minefield)
     {
-        forall ( (child) => { ((Tile)child).add_class("completedField"); } );
+        get_style_context  ().add_class ("completedField");
     }
 
     public override void get_preferred_width (out int minimum, out int natural)


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