[gtk+] textview: Draw drag icons using Cairo



commit 3e469d737e04c6f5a9b39b7c73feb3e5680783e8
Author: Benjamin Otte <otte redhat com>
Date:   Fri Jul 16 01:45:06 2010 +0200

    textview: Draw drag icons using Cairo

 gtk/gtktextutil.c |   43 +++++++++++++++++++------------------------
 1 files changed, 19 insertions(+), 24 deletions(-)
---
diff --git a/gtk/gtktextutil.c b/gtk/gtktextutil.c
index 11ec8d2..61eade8 100644
--- a/gtk/gtktextutil.c
+++ b/gtk/gtktextutil.c
@@ -211,6 +211,7 @@ _gtk_text_util_create_drag_icon (GtkWidget *widget,
   GdkDrawable  *drawable = NULL;
   PangoContext *context;
   PangoLayout  *layout;
+  cairo_t      *cr;
   gint          pixmap_height, pixmap_width;
   gint          layout_width, layout_height;
 
@@ -239,13 +240,10 @@ _gtk_text_util_create_drag_icon (GtkWidget *widget,
                              pixmap_width  + 2,
                              pixmap_height + 2,
                              -1);
+  cr = gdk_cairo_create (drawable);
 
-  gdk_draw_rectangle (drawable,
-                      widget->style->base_gc [gtk_widget_get_state (widget)],
-                      TRUE,
-                      0, 0,
-                      pixmap_width + 1,
-                      pixmap_height + 1);
+  gdk_cairo_set_source_color (cr, &widget->style->base [gtk_widget_get_state (widget)]);
+  cairo_paint (cr);
 
   gdk_draw_layout (drawable,
                    widget->style->text_gc [gtk_widget_get_state (widget)],
@@ -253,13 +251,12 @@ _gtk_text_util_create_drag_icon (GtkWidget *widget,
                    1 + DRAG_ICON_LAYOUT_BORDER,
                    layout);
 
-  gdk_draw_rectangle (drawable,
-                      widget->style->black_gc,
-                      FALSE,
-                      0, 0,
-                      pixmap_width + 1,
-                      pixmap_height + 1);
+  cairo_set_source_rgb (cr, 0, 0, 0);
+  cairo_rectangle (cr, 0.5, 0.5, pixmap_width + 1, pixmap_height + 1);
+  cairo_set_line_width (cr, 1.0);
+  cairo_stroke (cr);
 
+  cairo_destroy (cr);
   g_object_unref (layout);
 
   return drawable;
@@ -293,6 +290,7 @@ _gtk_text_util_create_rich_drag_icon (GtkWidget     *widget,
   GtkTextAttributes *style;
   PangoContext      *ltr_context, *rtl_context;
   GtkTextIter        iter;
+  cairo_t           *cr;
 
    g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
    g_return_val_if_fail (GTK_IS_TEXT_BUFFER (buffer), NULL);
@@ -355,12 +353,10 @@ _gtk_text_util_create_rich_drag_icon (GtkWidget     *widget,
    drawable = gdk_pixmap_new (widget->window,
                               pixmap_width  + 2, pixmap_height + 2, -1);
 
-   gdk_draw_rectangle (drawable,
-                       widget->style->base_gc [gtk_widget_get_state (widget)],
-                       TRUE,
-                       0, 0,
-                       pixmap_width + 1,
-                       pixmap_height + 1);
+   cr = gdk_cairo_create (drawable);
+
+   gdk_cairo_set_source_color (cr, &widget->style->base [gtk_widget_get_state (widget)]);
+   cairo_paint (cr);
 
    gtk_text_layout_draw (layout, widget, drawable,
                          widget->style->text_gc [gtk_widget_get_state (widget)],
@@ -369,13 +365,12 @@ _gtk_text_util_create_rich_drag_icon (GtkWidget     *widget,
                          0, 0,
                          pixmap_width, pixmap_height, NULL);
 
-   gdk_draw_rectangle (drawable,
-                       widget->style->black_gc,
-                       FALSE,
-                       0, 0,
-                       pixmap_width + 1,
-                       pixmap_height + 1);
+   cairo_set_source_rgb (cr, 0, 0, 0);
+   cairo_rectangle (cr, 0.5, 0.5, pixmap_width + 1, pixmap_height + 1);
+   cairo_set_line_width (cr, 1.0);
+   cairo_stroke (cr);
 
+   cairo_destroy (cr);
    g_object_unref (layout);
    g_object_unref (new_buffer);
 



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