[gimp/gtk3-port: 126/234] app: port the about dialog to GtkStyleContext
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gtk3-port: 126/234] app: port the about dialog to GtkStyleContext
- Date: Tue, 9 May 2017 22:27:39 +0000 (UTC)
commit fda03f46f2eca17c51d63201dcd7cdbbd3a86260
Author: Michael Natterer <mitch gimp org>
Date: Mon Dec 20 22:29:15 2010 +0100
app: port the about dialog to GtkStyleContext
app/dialogs/about-dialog.c | 80 ++++++++++++++++++++++++++-----------------
1 files changed, 48 insertions(+), 32 deletions(-)
---
diff --git a/app/dialogs/about-dialog.c b/app/dialogs/about-dialog.c
index f16a1f6..e27cd6d 100644
--- a/app/dialogs/about-dialog.c
+++ b/app/dialogs/about-dialog.c
@@ -284,15 +284,20 @@ about_dialog_anim_draw (GtkWidget *widget,
cairo_t *cr,
GimpAboutDialog *dialog)
{
- GtkStyle *style = gtk_widget_get_style (widget);
- GtkAllocation allocation;
- gint x, y;
- gint width, height;
+ GtkStyleContext *style = gtk_widget_get_style_context (widget);
+ GtkAllocation allocation;
+ GdkRGBA color;
+ gint x, y;
+ gint width, height;
if (! dialog->visible)
return FALSE;
- gdk_cairo_set_source_color (cr, &style->text[GTK_STATE_NORMAL]);
+ gtk_style_context_save (style);
+ gtk_style_context_add_class (style, GTK_STYLE_CLASS_ENTRY);
+ gtk_style_context_get_color (style, 0, &color);
+ gdk_cairo_set_source_rgba (cr, &color);
+ gtk_style_context_restore (style);
gtk_widget_get_allocation (widget, &allocation);
pango_layout_get_pixel_size (dialog->layout, &width, &height);
@@ -345,14 +350,15 @@ insert_spacers (const gchar *string)
}
static inline void
-mix_colors (const GdkColor *start,
- const GdkColor *end,
- GdkColor *target,
- gdouble pos)
+mix_colors (const GdkRGBA *start,
+ const GdkRGBA *end,
+ GdkRGBA *target,
+ gdouble pos)
{
target->red = start->red * (1.0 - pos) + end->red * pos;
target->green = start->green * (1.0 - pos) + end->green * pos;
target->blue = start->blue * (1.0 - pos) + end->blue * pos;
+ target->alpha = start->alpha * (1.0 - pos) + end->alpha * pos;
}
static void
@@ -360,22 +366,26 @@ decorate_text (GimpAboutDialog *dialog,
gint anim_type,
gdouble time)
{
- GtkStyle *style = gtk_widget_get_style (dialog->anim_area);
- const gchar *text;
- const gchar *ptr;
- gint letter_count = 0;
- gint text_length = 0;
- gint text_bytelen = 0;
- gint cluster_start, cluster_end;
- gunichar unichr;
- PangoAttrList *attrlist = NULL;
- PangoAttribute *attr;
- PangoRectangle irect = {0, 0, 0, 0};
- PangoRectangle lrect = {0, 0, 0, 0};
- GdkColor mix;
-
- mix_colors (style->bg + GTK_STATE_NORMAL,
- style->fg + GTK_STATE_NORMAL, &mix, time);
+ GtkStyleContext *style = gtk_widget_get_style_context (dialog->anim_area);
+ const gchar *text;
+ const gchar *ptr;
+ gint letter_count = 0;
+ gint text_length = 0;
+ gint text_bytelen = 0;
+ gint cluster_start, cluster_end;
+ gunichar unichr;
+ PangoAttrList *attrlist = NULL;
+ PangoAttribute *attr;
+ PangoRectangle irect = {0, 0, 0, 0};
+ PangoRectangle lrect = {0, 0, 0, 0};
+ GdkRGBA fg;
+ GdkRGBA bg;
+ GdkRGBA mix;
+
+ gtk_style_context_get_color (style, 0, &fg);
+ gtk_style_context_get_background_color (style, 0, &bg);
+
+ mix_colors (&bg, &fg, &mix, time);
text = pango_layout_get_text (dialog->layout);
g_return_if_fail (text != NULL);
@@ -391,14 +401,18 @@ decorate_text (GimpAboutDialog *dialog,
switch (anim_type)
{
case 0: /* Fade in */
- attr = pango_attr_foreground_new (mix.red, mix.green, mix.blue);
+ attr = pango_attr_foreground_new (mix.red * 0xffff,
+ mix.green * 0xffff,
+ mix.blue * 0xffff);
attr->start_index = 0;
attr->end_index = text_bytelen;
pango_attr_list_insert (attrlist, attr);
break;
case 1: /* Fade in, spread */
- attr = pango_attr_foreground_new (mix.red, mix.green, mix.blue);
+ attr = pango_attr_foreground_new (mix.red * 0xffff,
+ mix.green * 0xffff,
+ mix.blue * 0xffff);
attr->start_index = 0;
attr->end_index = text_bytelen;
pango_attr_list_change (attrlist, attr);
@@ -424,7 +438,9 @@ decorate_text (GimpAboutDialog *dialog,
break;
case 2: /* Fade in, sinewave */
- attr = pango_attr_foreground_new (mix.red, mix.green, mix.blue);
+ attr = pango_attr_foreground_new (mix.red * 0xffff,
+ mix.green * 0xffff,
+ mix.blue * 0xffff);
attr->start_index = 0;
attr->end_index = text_bytelen;
pango_attr_list_change (attrlist, attr);
@@ -471,15 +487,15 @@ decorate_text (GimpAboutDialog *dialog,
else
pos = ((gdouble) (letter_count - border)) / 15;
- mix_colors (style->fg + GTK_STATE_NORMAL,
- style->bg + GTK_STATE_NORMAL,
- &mix, pos);
+ mix_colors (&fg, &bg, &mix, pos);
ptr = g_utf8_next_char (ptr);
cluster_end = ptr - text;
- attr = pango_attr_foreground_new (mix.red, mix.green, mix.blue);
+ attr = pango_attr_foreground_new (mix.red * 0xffff,
+ mix.green * 0xffff,
+ mix.blue * 0xffff);
attr->start_index = cluster_start;
attr->end_index = cluster_end;
pango_attr_list_change (attrlist, attr);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]