[gtk+] Use GtkRGBA for the cursor color priv api.



commit 9e203417752584b923cf5baec8940836ff2c0bcb
Author: Paolo Borelli <pborelli gnome org>
Date:   Sat Jan 29 12:38:50 2011 +0100

    Use GtkRGBA for the cursor color priv api.

 gtk/gtkentry.c         |    4 ++--
 gtk/gtkstyle.c         |   41 +++++++++++++++++++----------------------
 gtk/gtktextdisplay.c   |    4 ++--
 gtk/gtkwidgetprivate.h |    2 +-
 4 files changed, 24 insertions(+), 27 deletions(-)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 38dbe9d..a54f821 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -5805,7 +5805,7 @@ gtk_entry_draw_cursor (GtkEntry  *entry,
     }
   else /* overwrite_mode */
     {
-      GdkColor cursor_color;
+      GdkRGBA cursor_color;
       GdkRectangle rect;
       gint x, y;
 
@@ -5819,7 +5819,7 @@ gtk_entry_draw_cursor (GtkEntry  *entry,
       rect.height = PANGO_PIXELS (cursor_rect.height);
 
       _gtk_widget_get_cursor_color (widget, &cursor_color);
-      gdk_cairo_set_source_color (cr, &cursor_color);
+      gdk_cairo_set_source_rgba (cr, &cursor_color);
       gdk_cairo_rectangle (cr, &rect);
       cairo_fill (cr);
 
diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c
index b9312c8..a234a34 100644
--- a/gtk/gtkstyle.c
+++ b/gtk/gtkstyle.c
@@ -3974,7 +3974,7 @@ gtk_paint_spinner (GtkStyle           *style,
 static void
 get_cursor_color (GtkStyleContext *context,
                   gboolean         primary,
-                  GdkColor        *color)
+                  GdkRGBA         *color)
 {
   GdkColor *style_color;
 
@@ -3985,36 +3985,33 @@ get_cursor_color (GtkStyleContext *context,
 
   if (style_color)
     {
-      *color = *style_color;
-      gdk_color_free (style_color);
-    }
-  else if (primary)
-    {
-      GdkRGBA fg;
+      color->red = style_color->red / 65535;
+      color->green = style_color->green / 65535;
+      color->blue = style_color->blue / 65535;
+      color->alpha = 1;
 
-      gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &fg);
-
-      color->red = fg.red * 65535;
-      color->green = fg.green * 65535;
-      color->blue = fg.blue * 65535;
+      gdk_color_free (style_color);
     }
   else
     {
-      GdkRGBA fg;
-      GdkRGBA bg;
+      gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, color);
+
+      if (!primary)
+      {
+        GdkRGBA bg;
 
-      gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &fg);
-      gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &bg);
+        gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &bg);
 
-      color->red = (fg.red + bg.red) * 0.5 * 65535;
-      color->green = (fg.green + bg.green) * 0.5 * 65535;
-      color->blue = (fg.blue + bg.blue) * 0.5 * 65535;
+        color->red = (color->red + bg.red) * 0.5;
+        color->green = (color->green + bg.green) * 0.5;
+        color->blue = (color->blue + bg.blue) * 0.5;
+      }
     }
 }
 
 void
 _gtk_widget_get_cursor_color (GtkWidget *widget,
-                              GdkColor  *color)
+                              GdkRGBA   *color)
 {
   GtkStyleContext *context;
 
@@ -4053,7 +4050,7 @@ gtk_draw_insertion_cursor (GtkWidget          *widget,
   gfloat cursor_aspect_ratio;
   gint offset;
   GtkStyleContext *context;
-  GdkColor color;
+  GdkRGBA color;
 
   g_return_if_fail (GTK_IS_WIDGET (widget));
   g_return_if_fail (cr != NULL);
@@ -4063,7 +4060,7 @@ gtk_draw_insertion_cursor (GtkWidget          *widget,
   context = gtk_widget_get_style_context (widget);
 
   get_cursor_color (context, is_primary, &color);
-  gdk_cairo_set_source_color (cr, &color);
+  gdk_cairo_set_source_rgba (cr, &color);
 
   /* When changing the shape or size of the cursor here,
    * propagate the changes to gtktextview.c:text_window_invalidate_cursors().
diff --git a/gtk/gtktextdisplay.c b/gtk/gtktextdisplay.c
index 7af3857..a41f5b8 100644
--- a/gtk/gtktextdisplay.c
+++ b/gtk/gtktextdisplay.c
@@ -780,7 +780,7 @@ render_para (GtkTextRenderer    *text_renderer,
 		    (at_last_line && line_display->insert_index == byte_offset + line->length)))
 	    {
 	      GdkRectangle cursor_rect;
-              GdkColor cursor_color;
+              GdkRGBA cursor_color;
               cairo_t *cr = text_renderer->cr;
 
 	      /* we draw text using base color on filled cursor rectangle of cursor color
@@ -797,7 +797,7 @@ render_para (GtkTextRenderer    *text_renderer,
               gdk_cairo_rectangle (cr, &cursor_rect);
               cairo_clip (cr);
 
-              gdk_cairo_set_source_color (cr, &cursor_color);
+              gdk_cairo_set_source_rgba (cr, &cursor_color);
               cairo_paint (cr);
 
               /* draw text under the cursor if any */
diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h
index 4ba0f66..b98e2c9 100644
--- a/gtk/gtkwidgetprivate.h
+++ b/gtk/gtkwidgetprivate.h
@@ -94,7 +94,7 @@ gboolean _gtk_widget_get_translation_to_window (GtkWidget      *widget,
                                                 int            *y);
 
 void  _gtk_widget_get_cursor_color (GtkWidget *widget,
-                                    GdkColor  *color);
+                                    GdkRGBA  *color);
 
 G_END_DECLS
 



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