[gimp/gtk3-port: 141/223] app: port GimpSpinScale to GtkStyleContext



commit a3ef9a15d265e6e075484ccf1eacec2f52432b00
Author: Michael Natterer <mitch gimp org>
Date:   Wed Dec 22 23:32:42 2010 +0100

    app: port GimpSpinScale to GtkStyleContext

 app/widgets/gimpspinscale.c |   25 +++++++++++--------------
 1 files changed, 11 insertions(+), 14 deletions(-)
---
diff --git a/app/widgets/gimpspinscale.c b/app/widgets/gimpspinscale.c
index 9534117..43bb9ad 100644
--- a/app/widgets/gimpspinscale.c
+++ b/app/widgets/gimpspinscale.c
@@ -79,8 +79,7 @@ static void       gimp_spin_scale_get_property   (GObject          *object,
                                                   GValue           *value,
                                                   GParamSpec       *pspec);
 
-static void       gimp_spin_scale_style_set      (GtkWidget        *widget,
-                                                  GtkStyle         *prev_style);
+static void       gimp_spin_scale_style_updated  (GtkWidget        *widget);
 static gboolean   gimp_spin_scale_draw           (GtkWidget        *widget,
                                                   cairo_t          *cr);
 static gboolean   gimp_spin_scale_button_press   (GtkWidget        *widget,
@@ -112,7 +111,7 @@ gimp_spin_scale_class_init (GimpSpinScaleClass *klass)
   object_class->set_property         = gimp_spin_scale_set_property;
   object_class->get_property         = gimp_spin_scale_get_property;
 
-  widget_class->style_set            = gimp_spin_scale_style_set;
+  widget_class->style_updated        = gimp_spin_scale_style_updated;
   widget_class->draw                 = gimp_spin_scale_draw;
   widget_class->button_press_event   = gimp_spin_scale_button_press;
   widget_class->button_release_event = gimp_spin_scale_button_release;
@@ -208,19 +207,18 @@ gimp_spin_scale_get_property (GObject    *object,
 }
 
 static void
-gimp_spin_scale_style_set (GtkWidget *widget,
-                           GtkStyle  *prev_style)
+gimp_spin_scale_style_updated (GtkWidget *widget)
 {
   GimpSpinScalePrivate *private = GET_PRIVATE (widget);
-  GtkStyle             *style   = gtk_widget_get_style (widget);
   PangoContext         *context = gtk_widget_get_pango_context (widget);
   PangoFontMetrics     *metrics;
   gint                  height;
   GtkBorder             border;
 
-  GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
+  GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
 
-  metrics = pango_context_get_metrics (context, style->font_desc,
+  metrics = pango_context_get_metrics (context,
+                                       pango_context_get_font_description (context),
                                        pango_context_get_language (context));
 
   height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics));
@@ -246,8 +244,9 @@ gimp_spin_scale_draw (GtkWidget *widget,
                       cairo_t   *cr)
 {
   GimpSpinScalePrivate *private = GET_PRIVATE (widget);
-  GtkStyle             *style   = gtk_widget_get_style (widget);
+  GtkStyleContext      *style   = gtk_widget_get_style_context (widget);
   GtkAllocation         allocation;
+  GdkRGBA               color;
   gboolean              rtl;
 
   cairo_save (cr);
@@ -262,8 +261,9 @@ gimp_spin_scale_draw (GtkWidget *widget,
 
   cairo_rectangle (cr, 0.5, 0.5,
                    allocation.width - 1.0, allocation.height - 1.0);
-  gdk_cairo_set_source_color (cr,
-                              &style->text[gtk_widget_get_state (widget)]);
+  gtk_style_context_get_color (style, gtk_widget_get_state_flags (widget),
+                               &color);
+  gdk_cairo_set_source_rgba (cr, &color);
   cairo_stroke (cr);
 
   if (private->label)
@@ -295,9 +295,6 @@ gimp_spin_scale_draw (GtkWidget *widget,
             cairo_move_to (cr, 2, 2);
         }
 
-      gdk_cairo_set_source_color (cr,
-                                  &style->text[gtk_widget_get_state (widget)]);
-
       pango_cairo_show_layout (cr, private->layout);
     }
 



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