[gnome-games/sudoku-css-theming: 2/4] First attempt at theming...



commit 5aec30d3b9d0569dc361cb27ee8afbe1cb5dc357
Author: John Stowers <john stowers gmail com>
Date:   Thu May 12 20:33:38 2011 +1200

    First attempt at theming...

 gnome-sudoku/src/lib/number_box.py |   48 ++++++++++++++++++++++++++++++------
 1 files changed, 40 insertions(+), 8 deletions(-)
---
diff --git a/gnome-sudoku/src/lib/number_box.py b/gnome-sudoku/src/lib/number_box.py
index db120f0..1029a70 100644
--- a/gnome-sudoku/src/lib/number_box.py
+++ b/gnome-sudoku/src/lib/number_box.py
@@ -85,6 +85,7 @@ class NumberBox (Gtk.DrawingArea):
     shadow_color = None
     border_color = None
 
+    __gtype_name__ = 'NumberBox'
     __gsignals__ = {
         'value-about-to-change':(GObject.SignalFlags.RUN_LAST, None, ()),
         'notes-about-to-change':(GObject.SignalFlags.RUN_LAST, None, ()),
@@ -120,10 +121,22 @@ class NumberBox (Gtk.DrawingArea):
         #should probbably do this in style-updated (but that gets called heaps
         #because of how the background override is done...
         style_ctx = self.get_style_context()
-        style_ctx.add_class(Gtk.STYLE_CLASS_BUTTON)
+        #style_ctx.add_class(Gtk.STYLE_CLASS_BUTTON)
         self._layout = self.create_pango_layout(text)
         self._top_note_layout = Pango.Layout(self.create_pango_context())
         self._bottom_note_layout = Pango.Layout(self.create_pango_context())
+
+        p = Gtk.CssProvider()
+        p.load_from_data("""
+NumberBox {
+    background-color: rgb(255, 0, 0);
+}
+
+NumberBox.entry {
+    background-color: rgb(0, 255, 0);
+}
+""", -1)
+        style_ctx.add_provider(p, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
         
     def set_parent_win(self, new_parent):
         self.parent_win = new_parent
@@ -492,9 +505,15 @@ class NumberBox (Gtk.DrawingArea):
         h = self.get_allocated_height()
         style_ctx = self.get_style_context()
 
-        print style_ctx.list_classes()
         print self.get_state_flags()
 
+        #CSS should be NumberBox {}
+        #use .entry class for the hints
+        #use :prelight etc for colors
+
+        print self.class_path()
+        print self.path()
+
         Gtk.render_background(style_ctx, cr, 0, 0, w, h)
 
         if self.is_focus():
@@ -519,18 +538,31 @@ class NumberBox (Gtk.DrawingArea):
             self.draw_note_area_highlight_box(cr, style_ctx)
 
     def draw_note_area_highlight_box (self, cr, style_ctx):
+        style_ctx.save()
+        style_ctx.add_class(Gtk.STYLE_CLASS_ENTRY)    
         # top rectangle
-        Gtk.render_focus(style_ctx, cr,
+        #Gtk.render_focus(style_ctx, cr,
+        #            NORMAL_LINE_WIDTH*0.5,
+        #            NORMAL_LINE_WIDTH*0.5,
+        #            BASE_SIZE-NORMAL_LINE_WIDTH,
+        #            BORDER_WIDTH-NORMAL_LINE_WIDTH)
+        Gtk.render_background(style_ctx, cr,
                     NORMAL_LINE_WIDTH*0.5,
                     NORMAL_LINE_WIDTH*0.5,
                     BASE_SIZE-NORMAL_LINE_WIDTH,
                     BORDER_WIDTH-NORMAL_LINE_WIDTH)
         # bottom rectangle
-        Gtk.render_focus(style_ctx, cr,
-                    NORMAL_LINE_WIDTH*0.5,
-                    BASE_SIZE - BORDER_WIDTH-(NORMAL_LINE_WIDTH*0.5),
-                    BASE_SIZE-NORMAL_LINE_WIDTH,
-                    BASE_SIZE-NORMAL_LINE_WIDTH)
+        #Gtk.render_focus(style_ctx, cr,
+        #            NORMAL_LINE_WIDTH*0.5,
+        #            BASE_SIZE - BORDER_WIDTH-(NORMAL_LINE_WIDTH*0.5),
+        #            BASE_SIZE-NORMAL_LINE_WIDTH,
+        #            BASE_SIZE-NORMAL_LINE_WIDTH)
+        Gtk.render_background(style_ctx, cr,
+                     NORMAL_LINE_WIDTH*0.5,
+                     BASE_SIZE - BORDER_WIDTH-(NORMAL_LINE_WIDTH*0.5),
+                     BASE_SIZE-NORMAL_LINE_WIDTH,
+                     BASE_SIZE-NORMAL_LINE_WIDTH)
+        style_ctx.restore()
 
     def draw_text (self, cr, style_ctx):
         font = style_ctx.get_font(self.get_state_flags())



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