[gnumeric] ItemBar: simplify color handling.



commit 7fd445b4bd8c4ca65a39e610e103eb7961f24aa0
Author: Morten Welinder <terra gnome org>
Date:   Sat Mar 23 15:33:10 2013 -0400

    ItemBar: simplify color handling.

 ChangeLog      |    5 +++++
 src/item-bar.c |   28 ++++++++++++----------------
 2 files changed, 17 insertions(+), 16 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0413d80..31c6b40 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-03-23  Morten Welinder  <terra gnome org>
+
+       * src/item-bar.c (ib_draw_cell): There's no point in going to and
+       from GOColor here.  Just use the color as-is.
+
 2013-03-19  Morten Welinder  <terra gnome org>
 
        * src/application.c (install_icons): Install also the icon themed
diff --git a/src/item-bar.c b/src/item-bar.c
index 648d637..390ab81 100644
--- a/src/item-bar.c
+++ b/src/item-bar.c
@@ -256,8 +256,7 @@ ib_draw_cell (ItemBar const * const ib, cairo_t *cr,
        GtkStyleContext *ctxt = gtk_widget_get_style_context (widget);
        PangoFont *font;
        PangoRectangle size;
-       GOColor color, font_color;
-       GdkRGBA rgba;
+       GdkRGBA color, font_color;
        int ascent;
 
        /* add "button" to the context path */
@@ -268,36 +267,33 @@ ib_draw_cell (ItemBar const * const ib, cairo_t *cr,
        case COL_ROW_NO_SELECTION:
                font   = ib->normal_font;
                gtk_style_context_set_state (ctxt, GTK_STATE_FLAG_NORMAL);
-               gtk_style_context_get_background_color (ctxt, GTK_STATE_FLAG_NORMAL, &rgba);
-               color = GO_COLOR_FROM_GDK_RGBA (rgba);
-               gtk_style_context_get_color (ctxt, GTK_STATE_FLAG_NORMAL, &rgba);
-               font_color = GO_COLOR_FROM_GDK_RGBA (rgba);
+               gtk_style_context_get_background_color (ctxt, GTK_STATE_FLAG_NORMAL, &color);
+               gtk_style_context_get_color (ctxt, GTK_STATE_FLAG_NORMAL,
+                                            &font_color);
                ascent = ib->normal_font_ascent;
                break;
 
        case COL_ROW_PARTIAL_SELECTION:
                font   = ib->bold_font;
                gtk_style_context_set_state (ctxt, GTK_STATE_FLAG_PRELIGHT);
-               gtk_style_context_get_background_color (ctxt, GTK_STATE_FLAG_PRELIGHT, &rgba);
-               color = GO_COLOR_FROM_GDK_RGBA (rgba);
-               gtk_style_context_get_color (ctxt, GTK_STATE_FLAG_PRELIGHT, &rgba);
-               font_color = GO_COLOR_FROM_GDK_RGBA (rgba);
+               gtk_style_context_get_background_color (ctxt, GTK_STATE_FLAG_PRELIGHT, &color);
+               gtk_style_context_get_color (ctxt, GTK_STATE_FLAG_PRELIGHT,
+                                            &font_color);
                ascent = ib->bold_font_ascent;
                break;
 
        case COL_ROW_FULL_SELECTION:
                font   = ib->bold_font;
                gtk_style_context_set_state (ctxt, GTK_STATE_FLAG_ACTIVE);
-               gtk_style_context_get_background_color (ctxt, GTK_STATE_FLAG_ACTIVE, &rgba);
-               color = GO_COLOR_FROM_GDK_RGBA (rgba);
-               gtk_style_context_get_color (ctxt, GTK_STATE_FLAG_ACTIVE, &rgba);
-               font_color = GO_COLOR_FROM_GDK_RGBA (rgba);
+               gtk_style_context_get_background_color (ctxt, GTK_STATE_FLAG_ACTIVE, &color);
+               gtk_style_context_get_color (ctxt, GTK_STATE_FLAG_ACTIVE,
+                                            &font_color);
                ascent = ib->bold_font_ascent;
                break;
        }
        /* When we are really small leave out the shadow and the text */
        cairo_save (cr);
-       cairo_set_source_rgba (cr, GO_COLOR_TO_CAIRO (color));
+       gdk_cairo_set_source_rgba (cr, &color);
        if (rect->width <= 2 || rect->height <= 2) {
                cairo_rectangle (cr, rect->x, rect->y, rect->width, rect->height);
                cairo_fill (cr);
@@ -320,7 +316,7 @@ ib_draw_cell (ItemBar const * const ib, cairo_t *cr,
 
        cairo_save (cr);
        cairo_clip (cr);
-       cairo_set_source_rgba (cr, GO_COLOR_TO_CAIRO (font_color));
+       gdk_cairo_set_source_rgba (cr, &font_color);
        cairo_translate (cr,
                                         rect->x + (rect->width - PANGO_PIXELS (size.width)) / 2,
                                         rect->y + (rect->height - PANGO_PIXELS (size.height)) / 2 + ascent);


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