[gtk+/rendering-cleanup: 53/89] ruler: Replace gdk_draw_drawable calls with Cairo



commit ff5fc80ee42069b012238c3e6f474ac8d6ff3e1d
Author: Benjamin Otte <otte redhat com>
Date:   Wed Jul 14 22:43:08 2010 +0200

    ruler: Replace gdk_draw_drawable calls with Cairo
    
    and get rid of the custom GC

 gtk/gtkruler.c |   40 +++++++++++++++-------------------------
 1 files changed, 15 insertions(+), 25 deletions(-)
---
diff --git a/gtk/gtkruler.c b/gtk/gtkruler.c
index 2e40781..af81331 100644
--- a/gtk/gtkruler.c
+++ b/gtk/gtkruler.c
@@ -475,12 +475,6 @@ gtk_ruler_unrealize (GtkWidget *widget)
       ruler->backing_store = NULL;
     }
 
-  if (ruler->non_gr_exp_gc)
-    {
-      g_object_unref (ruler->non_gr_exp_gc);
-      ruler->non_gr_exp_gc = NULL;
-    }
-
   GTK_WIDGET_CLASS (gtk_ruler_parent_class)->unrealize (widget);
 }
 
@@ -554,15 +548,15 @@ gtk_ruler_expose (GtkWidget      *widget,
   if (gtk_widget_is_drawable (widget))
     {
       GtkRuler *ruler = GTK_RULER (widget);
+      cairo_t *cr;
 
       gtk_ruler_draw_ticks (ruler);
       
-      gdk_draw_drawable (widget->window,
-			 ruler->non_gr_exp_gc,
-			 ruler->backing_store,
-			 0, 0, 0, 0,
-			 widget->allocation.width,
-			 widget->allocation.height);
+      cr = gdk_cairo_create (widget->window);
+      gdk_cairo_set_source_pixmap (cr, ruler->backing_store, 0, 0);
+      gdk_cairo_rectangle (cr, &event->area);
+      cairo_fill (cr);
+      cairo_destroy (cr);
       
       gtk_ruler_draw_pos (ruler);
     }
@@ -596,12 +590,6 @@ gtk_ruler_make_pixmap (GtkRuler *ruler)
 
   ruler->xsrc = 0;
   ruler->ysrc = 0;
-
-  if (!ruler->non_gr_exp_gc)
-    {
-      ruler->non_gr_exp_gc = gdk_gc_new (widget->window);
-      gdk_gc_set_exposures (ruler->non_gr_exp_gc, FALSE);
-    }
 }
 
 static void
@@ -858,13 +846,15 @@ gtk_ruler_real_draw_pos (GtkRuler *ruler)
 	  cairo_t *cr = gdk_cairo_create (widget->window);
 
 	  /*  If a backing store exists, restore the ruler  */
-	  if (ruler->backing_store)
-	    gdk_draw_drawable (widget->window,
-			       widget->style->black_gc,
-			       ruler->backing_store,
-			       ruler->xsrc, ruler->ysrc,
-			       ruler->xsrc, ruler->ysrc,
-			       bs_width, bs_height);
+	  if (ruler->backing_store) {
+            cairo_t *cr = gdk_cairo_create (widget->window);
+
+            gdk_cairo_set_source_pixmap (cr, ruler->backing_store, 0, 0);
+            cairo_rectangle (cr, ruler->xsrc, ruler->ysrc, bs_width, bs_height);
+            cairo_fill (cr);
+
+            cairo_destroy (cr);
+          }
 
           if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
             {



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