[gimp/gtk3-port: 158/246] app: port GimpFgBgView to GtkStyleContext



commit 1f27112bfb8d550d0f19ca14307cefbca39aab45
Author: Michael Natterer <mitch gimp org>
Date:   Sun Dec 19 14:11:16 2010 +0100

    app: port GimpFgBgView to GtkStyleContext

 app/widgets/gimpfgbgview.c |   45 ++++++++++++++++++++++++++++---------------
 1 files changed, 29 insertions(+), 16 deletions(-)
---
diff --git a/app/widgets/gimpfgbgview.c b/app/widgets/gimpfgbgview.c
index 512621a..535dd7b 100644
--- a/app/widgets/gimpfgbgview.c
+++ b/app/widgets/gimpfgbgview.c
@@ -144,14 +144,21 @@ static gboolean
 gimp_fg_bg_view_draw (GtkWidget *widget,
                       cairo_t   *cr)
 {
-  GimpFgBgView *view  = GIMP_FG_BG_VIEW (widget);
-  GtkStyle     *style = gtk_widget_get_style (widget);
-  GtkAllocation allocation;
-  gint          rect_w, rect_h;
-  GimpRGB       color;
+  GimpFgBgView    *view   = GIMP_FG_BG_VIEW (widget);
+  GtkStyleContext *style  = gtk_widget_get_style_context (widget);
+  GtkAllocation    allocation;
+  GtkBorder        border;
+  gint             rect_w, rect_h;
+  GimpRGB          color;
 
   gtk_widget_get_allocation (widget, &allocation);
 
+  gtk_style_context_save (style);
+  gtk_style_context_add_class (style, GTK_STYLE_CLASS_BUTTON);
+
+  gtk_style_context_get_border (style, gtk_widget_get_state_flags (widget),
+                                &border);
+
   rect_w = allocation.width  * 3 / 4;
   rect_h = allocation.height * 3 / 4;
 
@@ -163,16 +170,16 @@ gimp_fg_bg_view_draw (GtkWidget *widget,
       gimp_cairo_set_source_rgb (cr, &color);
 
       cairo_rectangle (cr,
-                       allocation.width  - rect_w + 1,
-                       allocation.height - rect_h + 1,
-                       rect_w - 2,
-                       rect_h - 2);
+                       allocation.width  - rect_w + border.left,
+                       allocation.height - rect_h + border.top,
+                       rect_w - (border.left + border.right),
+                       rect_h - (border.top + border.bottom));
       cairo_fill (cr);
     }
 
-  gtk_paint_shadow (style, cr, GTK_STATE_NORMAL,
-                    GTK_SHADOW_IN,
-                    widget, NULL,
+  gtk_style_context_set_state (style, GTK_STATE_FLAG_ACTIVE);
+
+  gtk_render_frame (style, cr,
                     allocation.width  - rect_w,
                     allocation.height - rect_h,
                     rect_w, rect_h);
@@ -184,15 +191,21 @@ gimp_fg_bg_view_draw (GtkWidget *widget,
       gimp_context_get_foreground (view->context, &color);
       gimp_cairo_set_source_rgb (cr, &color);
 
-      cairo_rectangle (cr, 1, 1, rect_w - 2, rect_h - 2);
+      cairo_rectangle (cr,
+                       border.left,
+                       border.top,
+                       rect_w - (border.left + border.right),
+                       rect_h - (border.top + border.bottom));
       cairo_fill (cr);
     }
 
-  gtk_paint_shadow (style, cr, GTK_STATE_NORMAL,
-                    GTK_SHADOW_OUT,
-                    widget, NULL,
+  gtk_style_context_set_state (style, 0);
+
+  gtk_render_frame (style, cr,
                     0, 0, rect_w, rect_h);
 
+  gtk_style_context_restore (style);
+
   return TRUE;
 }
 



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