[gtk+/rendering-cleanup-next: 22/153] cellview: Port to draw vfunc



commit 8cd424dacee65a6e6dbc29cbd8caf211dd95b734
Author: Benjamin Otte <otte redhat com>
Date:   Fri Sep 3 18:41:52 2010 +0200

    cellview: Port to draw vfunc

 gtk/gtkcellview.c |   40 ++++++++++++++++------------------------
 1 files changed, 16 insertions(+), 24 deletions(-)
---
diff --git a/gtk/gtkcellview.c b/gtk/gtkcellview.c
index 475a9f1..9b55608 100644
--- a/gtk/gtkcellview.c
+++ b/gtk/gtkcellview.c
@@ -73,8 +73,10 @@ static void        gtk_cell_view_set_property             (GObject          *obj
 static void        gtk_cell_view_finalize                 (GObject          *object);
 static void        gtk_cell_view_size_allocate            (GtkWidget        *widget,
                                                            GtkAllocation    *allocation);
-static gboolean    gtk_cell_view_expose                   (GtkWidget        *widget,
-                                                           GdkEventExpose   *event);
+static gboolean    gtk_cell_view_draw                     (GtkWidget        *widget,
+                                                           cairo_t          *cr,
+                                                           int               width,
+                                                           int               height);
 static void        gtk_cell_view_set_value                (GtkCellView     *cell_view,
                                                            GtkCellRenderer *renderer,
                                                            gchar           *property,
@@ -168,7 +170,7 @@ gtk_cell_view_class_init (GtkCellViewClass *klass)
   gobject_class->set_property = gtk_cell_view_set_property;
   gobject_class->finalize = gtk_cell_view_finalize;
 
-  widget_class->expose_event = gtk_cell_view_expose;
+  widget_class->draw = gtk_cell_view_draw;
   widget_class->size_allocate = gtk_cell_view_size_allocate;
 
   /* properties */
@@ -426,32 +428,24 @@ gtk_cell_view_size_allocate (GtkWidget     *widget,
 }
 
 static gboolean
-gtk_cell_view_expose (GtkWidget      *widget,
-                      GdkEventExpose *event)
+gtk_cell_view_draw (GtkWidget *widget,
+                    cairo_t   *cr,
+                    int        width,
+                    int        height)
 {
-  GtkAllocation allocation;
   GList *list;
   GtkCellView *cellview;
   GdkRectangle area;
   GtkCellRendererState state;
   gboolean rtl = (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL);
   GtkPackType packing;
-  cairo_t *cr;
 
   cellview = GTK_CELL_VIEW (widget);
 
-  if (!gtk_widget_is_drawable (widget))
-    return FALSE;
-
-  gtk_widget_get_allocation (widget, &allocation);
-  cr = gdk_cairo_create (event->window);
-  gdk_cairo_region (cr, event->region);
-  cairo_clip (cr);
-
   /* "blank" background */
   if (cellview->priv->background_set)
     {
-      gdk_cairo_rectangle (cr, &allocation);
+      cairo_rectangle (cr, 0, 0, width, height);
       cairo_set_source_rgb (cr,
 			    cellview->priv->background.red / 65535.,
 			    cellview->priv->background.green / 65535.,
@@ -466,10 +460,10 @@ gtk_cell_view_expose (GtkWidget      *widget,
     return FALSE;
 
   /* render cells */
-  area = allocation;
-
-  /* we draw on our very own window, initialize x and y to zero */
-  area.y = allocation.y;
+  area.x = 0;
+  area.y = 0;
+  area.width = width;
+  area.height = height;
 
   if (gtk_widget_get_state (widget) == GTK_STATE_PRELIGHT)
     state = GTK_CELL_RENDERER_PRELIT;
@@ -481,9 +475,9 @@ gtk_cell_view_expose (GtkWidget      *widget,
   for (packing = GTK_PACK_START; packing <= GTK_PACK_END; ++packing)
     {
       if (packing == GTK_PACK_START)
-	area.x = allocation.x + (rtl ? allocation.width : 0);
+	area.x = rtl ? width : 0;
       else
-	area.x = rtl ? allocation.x : (allocation.x + allocation.width);
+	area.x = rtl ? 0 : width;
 
       for (list = cellview->priv->cell_list; list; list = list->next)
 	{
@@ -518,8 +512,6 @@ gtk_cell_view_expose (GtkWidget      *widget,
 	}
     }
 
-  cairo_destroy (cr);
-
   return FALSE;
 }
 



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