[gimp/gtk3-port: 111/228] libgimpwidgets: port GimpColorArea to GtkStyleContext



commit 7ac4156233b2704bc426490eded33060b52fcbda
Author: Michael Natterer <mitch gimp org>
Date:   Wed Dec 15 13:32:23 2010 +0100

    libgimpwidgets: port GimpColorArea to GtkStyleContext

 libgimpwidgets/gimpcolorarea.c |   37 +++++++++++++++++++++----------------
 1 files changed, 21 insertions(+), 16 deletions(-)
---
diff --git a/libgimpwidgets/gimpcolorarea.c b/libgimpwidgets/gimpcolorarea.c
index 120d1ea..e03eaf9 100644
--- a/libgimpwidgets/gimpcolorarea.c
+++ b/libgimpwidgets/gimpcolorarea.c
@@ -342,8 +342,8 @@ static gboolean
 gimp_color_area_draw (GtkWidget *widget,
                       cairo_t   *cr)
 {
-  GimpColorArea   *area  = GIMP_COLOR_AREA (widget);
-  GtkStyle        *style = gtk_widget_get_style (widget);
+  GimpColorArea   *area    = GIMP_COLOR_AREA (widget);
+  GtkStyleContext *context = gtk_widget_get_style_context (widget);
   cairo_surface_t *buffer;
 
   if (! area->buf || ! gtk_widget_is_drawable (widget))
@@ -364,9 +364,13 @@ gimp_color_area_draw (GtkWidget *widget,
 
   if (area->draw_border)
     {
+      GdkRGBA color;
+
       cairo_set_line_width (cr, 1.0);
-      gdk_cairo_set_source_color (cr,
-                                  &style->fg[gtk_widget_get_state (widget)]);
+
+      gtk_style_context_get_color (context, gtk_widget_get_state_flags (widget),
+                                   &color);
+      gdk_cairo_set_source_rgba (cr, &color);
 
       cairo_rectangle (cr, 0.5, 0.5, area->width - 1, area->height - 1);
 
@@ -525,15 +529,16 @@ gimp_color_area_render_buf (GtkWidget         *widget,
                             guint              rowstride,
                             GimpRGB           *color)
 {
-  GtkStyle *style = gtk_widget_get_style (widget);
-  guint     x, y;
-  guint     check_size = 0;
-  guchar    light[3];
-  guchar    dark[3];
-  guchar    opaque[3];
-  guchar    insens[3];
-  guchar   *p;
-  gdouble   frac;
+  GtkStyleContext *context = gtk_widget_get_style_context (widget);
+  GdkRGBA          bg;
+  guint            x, y;
+  guint            check_size = 0;
+  guchar           light[3];
+  guchar           dark[3];
+  guchar           opaque[3];
+  guchar           insens[3];
+  guchar          *p;
+  gdouble          frac;
 
   switch (type)
     {
@@ -552,9 +557,9 @@ gimp_color_area_render_buf (GtkWidget         *widget,
 
   gimp_rgb_get_uchar (color, opaque, opaque + 1, opaque + 2);
 
-  insens[0] = style->bg[GTK_STATE_INSENSITIVE].red   >> 8;
-  insens[1] = style->bg[GTK_STATE_INSENSITIVE].green >> 8;
-  insens[2] = style->bg[GTK_STATE_INSENSITIVE].blue  >> 8;
+  gtk_style_context_get_background_color (context, GTK_STATE_FLAG_INSENSITIVE,
+                                          &bg);
+  gimp_rgb_get_uchar ((GimpRGB *) &bg, insens, insens + 1, insens + 2);
 
   if (insensitive || check_size == 0 || color->a == 1.0)
     {



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