[gnome-mines] Extend css to cover the tile themed images



commit 0357a30dc03d4b5276a0a9ce169494763d35219b
Author: Yanko Kaneti <yaneti declera com>
Date:   Fri Oct 12 09:22:57 2018 +0300

    Extend css to cover the tile themed images
    
    Remove all code for explicit icon image handling
    and use the css machinery for the separate tile classes.

 src/gnome-mines.css  | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/gnome-mines.vala |  3 ---
 src/tile.vala        | 21 --------------------
 3 files changed, 56 insertions(+), 24 deletions(-)
---
diff --git a/src/gnome-mines.css b/src/gnome-mines.css
index 8fafc03..b641ce6 100644
--- a/src/gnome-mines.css
+++ b/src/gnome-mines.css
@@ -60,6 +60,62 @@
   transition-duration:0.4s;
 }
 
+.mine {
+  background-image: -gtk-icontheme('mine');
+}
+
+.flag {
+  background-image: -gtk-icontheme('flag');
+}
+
+.incorrect {
+  background-image: -gtk-icontheme('incorrect');
+}
+
+.maybe {
+  background-image: -gtk-icontheme('maybe');
+}
+
+.overmine {
+  background-image: -gtk-icontheme('overmine');
+}
+
+.exploded {
+  background-image: -gtk-icontheme('exploded');
+}
+
+.1mines {
+  background-image: -gtk-icontheme('1mines');
+}
+
+.2mines {
+  background-image: -gtk-icontheme('2mines');
+}
+
+.3mines {
+  background-image: -gtk-icontheme('3mines');
+}
+
+.4mines {
+  background-image: -gtk-icontheme('4mines');
+}
+
+.5mines {
+  background-image: -gtk-icontheme('5mines');
+}
+
+.6mines {
+  background-image: -gtk-icontheme('6mines');
+}
+
+.7mines {
+  background-image: -gtk-icontheme('7mines');
+}
+
+.8mines {
+  background-image: -gtk-icontheme('8mines');
+}
+
 .count:not(.cursor):hover {
   background-color:#dededc;
 }
diff --git a/src/gnome-mines.vala b/src/gnome-mines.vala
index e14a6ff..6c263d1 100644
--- a/src/gnome-mines.vala
+++ b/src/gnome-mines.vala
@@ -154,9 +154,6 @@ public class Mines : Gtk.Application
             window.queue_draw ();
         }
         Gtk.StyleContext.reset_widgets (Gdk.Screen.get_default ());
-
-        if (theme_dialog != null)
-            theme_dialog.queue_draw ();
     }
 
     protected override void startup ()
diff --git a/src/tile.vala b/src/tile.vala
index 3c5d809..51f0d83 100644
--- a/src/tile.vala
+++ b/src/tile.vala
@@ -5,12 +5,6 @@ public class Tile : Gtk.Button
     public signal void tile_mouse_over (int x, int y);
     public signal void tile_pressed (int x, int y, Gdk.EventButton event);
     public signal void tile_released (int x, int y, Gdk.EventButton event);
-    private static string[] IMAGE_CLASSES = {"mine", "flag", "incorrect",
-                                             "maybe", "overmine",
-                                             "exploded", "1mines", "2mines",
-                                             "3mines", "4mines", "5mines",
-                                             "6mines", "7mines", "8mines"};
-    private Gtk.Image scaling_image;
 
     public int row
     {
@@ -25,14 +19,8 @@ public class Tile : Gtk.Button
     {
         _row = prow;
         _column = pcol;
-        scaling_image = new Gtk.Image ();
         can_focus = false;
         add_class ("tile");
-        set_image (scaling_image);
-        size_allocate.connect ((allocation) =>
-        {
-            scaling_image.set_pixel_size (allocation.height/3*2);
-        });
         button_press_event.connect ((event) =>
         {
             /* By default windows with both button press and button release
@@ -53,20 +41,11 @@ public class Tile : Gtk.Button
     public void add_class (string style_class)
     {
         get_style_context ().add_class (style_class);
-        if (style_class in IMAGE_CLASSES) {
-            scaling_image.set_from_icon_name (style_class, Gtk.IconSize.DND);
-            scaling_image.set_pixel_size (get_allocated_height ()/3*2);
-            set_image (scaling_image);
-        }
     }
 
     public void remove_class (string style_class)
     {
         get_style_context ().remove_class (style_class);
-        if (style_class in IMAGE_CLASSES) {
-            scaling_image = new Gtk.Image ();
-            set_image (scaling_image);
-        }
     }
 }
 


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