[gimp/gtk3-port: 118/235] app: port GimpFgBgEditor to GtkStyleContext
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gtk3-port: 118/235] app: port GimpFgBgEditor to GtkStyleContext
- Date: Wed, 12 Jul 2017 21:34:06 +0000 (UTC)
commit 7131f37b1930debbe91dc2af926c7ba23c3a5505
Author: Michael Natterer <mitch gimp org>
Date: Sun Dec 19 14:10:43 2010 +0100
app: port GimpFgBgEditor to GtkStyleContext
app/widgets/gimpfgbgeditor.c | 73 +++++++++++++++++++++++------------------
1 files changed, 41 insertions(+), 32 deletions(-)
---
diff --git a/app/widgets/gimpfgbgeditor.c b/app/widgets/gimpfgbgeditor.c
index dcfcbd3..d08e1f0 100644
--- a/app/widgets/gimpfgbgeditor.c
+++ b/app/widgets/gimpfgbgeditor.c
@@ -260,26 +260,28 @@ static gboolean
gimp_fg_bg_editor_draw (GtkWidget *widget,
cairo_t *cr)
{
- GimpFgBgEditor *editor = GIMP_FG_BG_EDITOR (widget);
- GtkStyle *style = gtk_widget_get_style (widget);
- GtkAllocation allocation;
- gint width, height;
- gint default_w, default_h;
- gint swap_w, swap_h;
- gint rect_w, rect_h;
- GimpRGB color;
- GimpRGB transformed_color;
-
- if (! gtk_widget_is_drawable (widget))
- return FALSE;
+ GimpFgBgEditor *editor = GIMP_FG_BG_EDITOR (widget);
+ GtkStyleContext *style = gtk_widget_get_style_context (widget);
+ GtkAllocation allocation;
+ GtkBorder border;
+ gint width, height;
+ gint default_w, default_h;
+ gint swap_w, swap_h;
+ gint rect_w, rect_h;
+ GimpRGB color;
+ GimpRGB transformed_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);
+
width = allocation.width;
height = allocation.height;
- cairo_translate (cr, allocation.x, allocation.y);
-
/* draw the default colors pixbuf */
if (! editor->default_icon)
editor->default_icon = gimp_widget_load_icon (widget,
@@ -351,10 +353,10 @@ gimp_fg_bg_editor_draw (GtkWidget *widget,
gimp_cairo_set_source_rgb (cr, &transformed_color);
cairo_rectangle (cr,
- width - rect_w,
- height - rect_h,
- rect_w,
- rect_h);
+ width - rect_w + border.left,
+ height - rect_h + border.top,
+ rect_w - (border.left + border.right),
+ rect_h - (border.top + border.bottom));
cairo_fill (cr);
if (editor->color_config &&
@@ -375,12 +377,14 @@ gimp_fg_bg_editor_draw (GtkWidget *widget,
}
}
- gtk_paint_shadow (style, cr, GTK_STATE_NORMAL,
- editor->active_color == GIMP_ACTIVE_COLOR_FOREGROUND ?
- GTK_SHADOW_OUT : GTK_SHADOW_IN,
- widget, NULL,
- allocation.x + (width - rect_w),
- allocation.y + (height - rect_h),
+ gtk_style_context_set_state (style,
+ editor->active_color ==
+ GIMP_ACTIVE_COLOR_FOREGROUND ?
+ 0 : GTK_STATE_FLAG_ACTIVE);
+
+ gtk_render_frame (style, cr,
+ width - rect_w,
+ height - rect_h,
rect_w, rect_h);
@@ -403,8 +407,10 @@ gimp_fg_bg_editor_draw (GtkWidget *widget,
gimp_cairo_set_source_rgb (cr, &transformed_color);
cairo_rectangle (cr,
- 0, 0,
- rect_w, rect_h);
+ border.left,
+ border.top,
+ rect_w - (border.left + border.right),
+ rect_h - (border.top + border.bottom));
cairo_fill (cr);
if (editor->color_config &&
@@ -425,14 +431,17 @@ gimp_fg_bg_editor_draw (GtkWidget *widget,
}
}
- gtk_paint_shadow (style, cr, GTK_STATE_NORMAL,
- editor->active_color == GIMP_ACTIVE_COLOR_BACKGROUND ?
- GTK_SHADOW_OUT : GTK_SHADOW_IN,
- widget, NULL,
- allocation.x,
- allocation.y,
+ gtk_style_context_set_state (style,
+ editor->active_color ==
+ GIMP_ACTIVE_COLOR_BACKGROUND ?
+ 0 : GTK_STATE_FLAG_ACTIVE);
+
+ 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]