[gimp/gtk3-port: 122/454] app: port GimpDashEditor to GtkStyleContext
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gtk3-port: 122/454] app: port GimpDashEditor to GtkStyleContext
- Date: Wed, 16 May 2018 21:30:56 +0000 (UTC)
commit 38cb69bdabb3324dae4b851497996f58f1442009
Author: Michael Natterer <mitch gimp org>
Date: Sun Dec 19 14:59:10 2010 +0100
app: port GimpDashEditor to GtkStyleContext
app/widgets/gimpdasheditor.c | 41 +++++++++++++++++++++++++++++++----------
1 files changed, 31 insertions(+), 10 deletions(-)
---
diff --git a/app/widgets/gimpdasheditor.c b/app/widgets/gimpdasheditor.c
index aa2345f..5ccf304 100644
--- a/app/widgets/gimpdasheditor.c
+++ b/app/widgets/gimpdasheditor.c
@@ -245,19 +245,38 @@ static gboolean
gimp_dash_editor_draw (GtkWidget *widget,
cairo_t *cr)
{
- GimpDashEditor *editor = GIMP_DASH_EDITOR (widget);
- GtkStyle *style = gtk_widget_get_style (widget);
- GtkAllocation allocation;
- gint x;
- gint w, h;
+ GimpDashEditor *editor = GIMP_DASH_EDITOR (widget);
+ GtkStyleContext *style = gtk_widget_get_style_context (widget);
+ GtkAllocation allocation;
+ GdkRGBA fg_color;
+ GdkRGBA bg_color;
+ GdkRGBA mid_color;
+ gint x;
+ gint w, h;
gtk_widget_get_allocation (widget, &allocation);
+ gtk_style_context_save (style);
+
+ gtk_style_context_add_class (style, GTK_STYLE_CLASS_ENTRY);
+
update_blocksize (editor);
+ gtk_style_context_get_color (style,
+ gtk_widget_get_state_flags (widget),
+ &fg_color);
+ gtk_style_context_get_background_color (style,
+ gtk_widget_get_state_flags (widget),
+ &bg_color);
+
+ mid_color.red = (fg_color.red + bg_color.red) / 2.0;
+ mid_color.green = (fg_color.green + bg_color.green) / 2.0;
+ mid_color.blue = (fg_color.blue + bg_color.blue) / 2.0;
+ mid_color.alpha = (fg_color.alpha + bg_color.alpha) / 2.0;
+
/* draw the background */
- gdk_cairo_set_source_color (cr, &style->base[GTK_STATE_NORMAL]);
+ gdk_cairo_set_source_rgba (cr, &bg_color);
cairo_paint (cr);
w = editor->block_width;
@@ -281,7 +300,7 @@ gimp_dash_editor_draw (GtkWidget *widget,
cairo_rectangle (cr, x, editor->y0, w, h);
}
- gdk_cairo_set_source_color (cr, &style->text_aa[GTK_STATE_NORMAL]);
+ gdk_cairo_set_source_rgba (cr, &mid_color);
cairo_fill (cr);
for (; x < editor->x0 + editor->n_segments * w; x += w)
@@ -292,7 +311,7 @@ gimp_dash_editor_draw (GtkWidget *widget,
cairo_rectangle (cr, x, editor->y0, w, h);
}
- gdk_cairo_set_source_color (cr, &style->text[GTK_STATE_NORMAL]);
+ gdk_cairo_set_source_rgba (cr, &fg_color);
cairo_fill (cr);
for (; x < allocation.width + w; x += w)
@@ -303,7 +322,7 @@ gimp_dash_editor_draw (GtkWidget *widget,
cairo_rectangle (cr, x, editor->y0, w, h);
}
- gdk_cairo_set_source_color (cr, &style->text_aa[GTK_STATE_NORMAL]);
+ gdk_cairo_set_source_rgba (cr, &mid_color);
cairo_fill (cr);
/* draw rulers */
@@ -338,10 +357,12 @@ gimp_dash_editor_draw (GtkWidget *widget,
cairo_move_to (cr, editor->x0 - 0.5, editor->y0 - 1);
cairo_move_to (cr, editor->x0 - 0.5, editor->y0 + h);
- gdk_cairo_set_source_color (cr, &style->text_aa[GTK_STATE_NORMAL]);
+ gdk_cairo_set_source_rgba (cr, &mid_color);
cairo_set_line_width (cr, 1.0);
cairo_stroke (cr);
+ gtk_style_context_restore (style);
+
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]