[gimp/gtk3-port: 179/234] app: port GimpColorFrame away from GtkStyle, using a new style property



commit 7b225ae6a864fee63efbe849256503e6b62d76de
Author: Michael Natterer <mitch gimp org>
Date:   Sun Feb 6 17:18:47 2011 +0100

    app: port GimpColorFrame away from GtkStyle, using a new style property

 app/widgets/gimpcolorframe.c |   22 ++++++++++++++++++++--
 themes/Small/gimp.css        |    4 ++++
 themes/System/gimp.css       |    4 ++++
 3 files changed, 28 insertions(+), 2 deletions(-)
---
diff --git a/app/widgets/gimpcolorframe.c b/app/widgets/gimpcolorframe.c
index e41a0cd..167c504 100644
--- a/app/widgets/gimpcolorframe.c
+++ b/app/widgets/gimpcolorframe.c
@@ -121,6 +121,12 @@ gimp_color_frame_class_init (GimpColorFrameClass *klass)
                                                          NULL, NULL,
                                                          FALSE,
                                                          GIMP_PARAM_READWRITE));
+
+  gtk_widget_class_install_style_property (widget_class,
+                                           g_param_spec_boxed ("number-color",
+                                                               NULL, NULL,
+                                                               GDK_TYPE_RGBA,
+                                                               GIMP_PARAM_READWRITE));
 }
 
 static void
@@ -317,21 +323,31 @@ gimp_color_frame_draw (GtkWidget *widget,
 
   if (frame->has_number)
     {
-      GtkStyle      *style = gtk_widget_get_style (widget);
       GtkAllocation  allocation;
       GtkAllocation  menu_allocation;
       GtkAllocation  color_area_allocation;
       GtkAllocation  coords_box_allocation;
+      GdkRGBA       *color;
       gchar          buf[8];
       gint           w, h;
       gdouble        scale;
 
+      cairo_save (cr);
+
       gtk_widget_get_allocation (widget, &allocation);
       gtk_widget_get_allocation (frame->menu, &menu_allocation);
       gtk_widget_get_allocation (frame->color_area, &color_area_allocation);
       gtk_widget_get_allocation (frame->coords_box, &coords_box_allocation);
 
-      gdk_cairo_set_source_color (cr, &style->light[GTK_STATE_NORMAL]);
+      gtk_widget_style_get (widget,
+                            "number-color", &color,
+                            NULL);
+
+      if (color)
+        {
+          gdk_cairo_set_source_rgba (cr, color);
+          gdk_rgba_free (color);
+        }
 
       g_snprintf (buf, sizeof (buf), "%d", frame->number);
 
@@ -356,6 +372,8 @@ gimp_color_frame_draw (GtkWidget *widget,
                       color_area_allocation.height / 2.0 +
                       coords_box_allocation.height / 2.0) / scale - h / 2.0);
       pango_cairo_show_layout (cr, frame->number_layout);
+
+      cairo_restore (cr);
     }
 
   return GTK_WIDGET_CLASS (parent_class)->draw (widget, cr);
diff --git a/themes/Small/gimp.css b/themes/Small/gimp.css
index a8ceef6..f513c5e 100644
--- a/themes/Small/gimp.css
+++ b/themes/Small/gimp.css
@@ -64,6 +64,10 @@ GimpDisplayShell {
   -GtkButton-focus-padding:       0;
 }
 
+GimpColorFrame {
+  -GimpColorFrame-number-color: lighter (@bg_color);
+}
+
 GimpOverlayFrame {
   -GtkButton-focus-line-width: 1;
 }
diff --git a/themes/System/gimp.css b/themes/System/gimp.css
index cb6aa45..58cc23c 100644
--- a/themes/System/gimp.css
+++ b/themes/System/gimp.css
@@ -64,6 +64,10 @@ GimpDisplayShell {
   -GtkButton-focus-padding:       0;
 }
 
+GimpColorFrame {
+  -GimpColorFrame-number-color: lighter (@bg_color);
+}
+
 GimpOverlayFrame {
   -GtkButton-focus-line-width: 1;
 }


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