]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkcellrendererpixbuf.c
The render vfunc takes a GdkDrawable* instead of a GdkWindow*, because
[~andy/gtk] / gtk / gtkcellrendererpixbuf.c
index daecc3ddd9534c2e81ea8fbd5bcf96a822d7206e..64fa881354748cf6a07730d60dafc74e0669c1df 100644 (file)
@@ -42,7 +42,7 @@ static void gtk_cell_renderer_pixbuf_get_size   (GtkCellRenderer            *cel
                                                 gint                       *width,
                                                 gint                       *height);
 static void gtk_cell_renderer_pixbuf_render     (GtkCellRenderer            *cell,
-                                                GdkWindow                  *window,
+                                                GdkDrawable                *window,
                                                 GtkWidget                  *widget,
                                                 GdkRectangle               *background_area,
                                                 GdkRectangle               *cell_area,
@@ -279,17 +279,14 @@ gtk_cell_renderer_pixbuf_set_property (GObject      *object,
       if (cellinfo->stock_id)
         g_free (cellinfo->stock_id);
       cellinfo->stock_id = g_strdup (g_value_get_string (value));
-      g_object_notify (G_OBJECT (object), "stock_id");
       break;
     case PROP_STOCK_SIZE:
       cellinfo->stock_size = g_value_get_enum (value);
-      g_object_notify (G_OBJECT (object), "stock_size");
       break;
     case PROP_STOCK_DETAIL:
       if (cellinfo->stock_detail)
         g_free (cellinfo->stock_detail);
       cellinfo->stock_detail = g_strdup (g_value_get_string (value));
-      g_object_notify (G_OBJECT (object), "stock_detail");
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -348,7 +345,7 @@ gtk_cell_renderer_pixbuf_get_size (GtkCellRenderer *cell,
 {
   GtkCellRendererPixbuf *cellpixbuf = (GtkCellRendererPixbuf *) cell;
   GtkCellRendererPixbufInfo *cellinfo = g_object_get_data (G_OBJECT (cell), CELLINFO_KEY);
-  gint pixbuf_width = 0;
+  gint pixbuf_width  = 0;
   gint pixbuf_height = 0;
   gint calc_width;
   gint calc_height;
@@ -358,22 +355,22 @@ gtk_cell_renderer_pixbuf_get_size (GtkCellRenderer *cell,
 
   if (cellpixbuf->pixbuf)
     {
-      pixbuf_width = gdk_pixbuf_get_width (cellpixbuf->pixbuf);
+      pixbuf_width  = gdk_pixbuf_get_width (cellpixbuf->pixbuf);
       pixbuf_height = gdk_pixbuf_get_height (cellpixbuf->pixbuf);
     }
   if (cellpixbuf->pixbuf_expander_open)
     {
-      pixbuf_width = MAX (pixbuf_width, gdk_pixbuf_get_width (cellpixbuf->pixbuf_expander_open));
+      pixbuf_width  = MAX (pixbuf_width, gdk_pixbuf_get_width (cellpixbuf->pixbuf_expander_open));
       pixbuf_height = MAX (pixbuf_height, gdk_pixbuf_get_height (cellpixbuf->pixbuf_expander_open));
     }
   if (cellpixbuf->pixbuf_expander_closed)
     {
-      pixbuf_width = MAX (pixbuf_width, gdk_pixbuf_get_width (cellpixbuf->pixbuf_expander_closed));
+      pixbuf_width  = MAX (pixbuf_width, gdk_pixbuf_get_width (cellpixbuf->pixbuf_expander_closed));
       pixbuf_height = MAX (pixbuf_height, gdk_pixbuf_get_height (cellpixbuf->pixbuf_expander_closed));
     }
   
-  calc_width = (gint) GTK_CELL_RENDERER (cellpixbuf)->xpad * 2 + pixbuf_width;
-  calc_height = (gint) GTK_CELL_RENDERER (cellpixbuf)->ypad * 2 + pixbuf_height;
+  calc_width  = (gint) cell->xpad * 2 + pixbuf_width;
+  calc_height = (gint) cell->ypad * 2 + pixbuf_height;
   
   if (x_offset) *x_offset = 0;
   if (y_offset) *y_offset = 0;
@@ -382,17 +379,20 @@ gtk_cell_renderer_pixbuf_get_size (GtkCellRenderer *cell,
     {
       if (x_offset)
        {
-         *x_offset = GTK_CELL_RENDERER (cellpixbuf)->xalign * (cell_area->width - calc_width - (2 * GTK_CELL_RENDERER (cellpixbuf)->xpad));
-         *x_offset = MAX (*x_offset, 0) + GTK_CELL_RENDERER (cellpixbuf)->xpad;
+         *x_offset = (((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) ?
+                        1.0 - cell->xalign : cell->xalign) * 
+                       (cell_area->width - calc_width - 2 * cell->xpad));
+         *x_offset = MAX (*x_offset, 0) + cell->xpad;
        }
       if (y_offset)
        {
-         *y_offset = GTK_CELL_RENDERER (cellpixbuf)->yalign * (cell_area->height - calc_height - (2 * GTK_CELL_RENDERER (cellpixbuf)->ypad));
-         *y_offset = MAX (*y_offset, 0) + GTK_CELL_RENDERER (cellpixbuf)->ypad;
+         *y_offset = (cell->yalign *
+                       (cell_area->height - calc_height - 2 * cell->ypad));
+          *y_offset = MAX (*y_offset, 0) + cell->ypad;
        }
     }
 
-  if (calc_width)
+  if (width)
     *width = calc_width;
   
   if (height)
@@ -443,10 +443,11 @@ gtk_cell_renderer_pixbuf_render (GtkCellRenderer      *cell,
   
   pix_rect.x += cell_area->x;
   pix_rect.y += cell_area->y;
-  pix_rect.width -= cell->xpad * 2;
+  pix_rect.width  -= cell->xpad * 2;
   pix_rect.height -= cell->ypad * 2;
 
-  if (gdk_rectangle_intersect (cell_area, &pix_rect, &draw_rect))
+  if (gdk_rectangle_intersect (cell_area, &pix_rect, &draw_rect) &&
+      gdk_rectangle_intersect (expose_area, &draw_rect, &draw_rect))
     gdk_draw_pixbuf (window,
                     widget->style->black_gc,
                     pixbuf,