[Xfce4-commits] <exo:stephan/gtk3> Partially port ExoCellRendererIcon

Stephan Arts noreply at xfce.org
Sat May 5 16:14:01 CEST 2012


Updating branch refs/heads/stephan/gtk3
         to df1bce813f1c730c27b516d551cd928aa781d903 (commit)
       from f7cc8b5f39b6f9c936e81ee3f2553669f027a3a0 (commit)

commit df1bce813f1c730c27b516d551cd928aa781d903
Author: Stephan Arts <stephan at xfce.org>
Date:   Sat May 5 16:13:32 2012 +0200

    Partially port ExoCellRendererIcon

 exo/exo-cell-renderer-icon.c |   58 ++++++++++++++++++++++++------------------
 1 files changed, 33 insertions(+), 25 deletions(-)

diff --git a/exo/exo-cell-renderer-icon.c b/exo/exo-cell-renderer-icon.c
index 0e6ead7..e79da86 100644
--- a/exo/exo-cell-renderer-icon.c
+++ b/exo/exo-cell-renderer-icon.c
@@ -78,17 +78,16 @@ static void exo_cell_renderer_icon_set_property (GObject                  *objec
                                                  GParamSpec               *pspec);
 static void exo_cell_renderer_icon_get_size     (GtkCellRenderer          *renderer,
                                                  GtkWidget                *widget,
-                                                 GdkRectangle             *cell_area,
+                                                 const GdkRectangle       *cell_area,
                                                  gint                     *x_offset,
                                                  gint                     *y_offset,
                                                  gint                     *width,
                                                  gint                     *height);
 static void exo_cell_renderer_icon_render       (GtkCellRenderer          *renderer,
-                                                 GdkWindow                *window,
+                                                 cairo_t                  *cr,
                                                  GtkWidget                *widget,
-                                                 GdkRectangle             *background_area,
-                                                 GdkRectangle             *cell_area,
-                                                 GdkRectangle             *expose_area,
+                                                 const GdkRectangle       *background_area,
+                                                 const GdkRectangle       *cell_area,
                                                  GtkCellRendererState      flags);
 
 
@@ -316,29 +315,39 @@ exo_cell_renderer_icon_set_property (GObject      *object,
 
 
 static void
-exo_cell_renderer_icon_get_size (GtkCellRenderer *renderer,
-                                 GtkWidget       *widget,
-                                 GdkRectangle    *cell_area,
-                                 gint            *x_offset,
-                                 gint            *y_offset,
-                                 gint            *width,
-                                 gint            *height)
+exo_cell_renderer_icon_get_size (GtkCellRenderer       *renderer,
+                                 GtkWidget             *widget,
+                                 const GdkRectangle    *cell_area,
+                                 gint                  *x_offset,
+                                 gint                  *y_offset,
+                                 gint                  *width,
+                                 gint                  *height)
 {
   const ExoCellRendererIconPrivate *priv = EXO_CELL_RENDERER_ICON_GET_PRIVATE (renderer);
+  GdkRectangle                      aligned_area;
+  gint                              xpad;
+  gint                              ypad;
+  
+  gtk_cell_renderer_get_padding (renderer, &xpad, &ypad);
 
   if (cell_area != NULL)
     {
+      gtk_cell_renderer_get_aligned_area (renderer,
+                                          widget,
+                                          0,
+                                          cell_area,
+                                          &aligned_area);
       if (x_offset != NULL)
         {
-          *x_offset = ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) ? 1.0 - renderer->xalign : renderer->xalign)
+          *x_offset = ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) ? 1.0 - aligned_area.x: aligned_area.x)
                     * (cell_area->width - priv->size);
-          *x_offset = MAX (*x_offset, 0) + renderer->xpad;
+          *x_offset = MAX (*x_offset, 0) + xpad;
         }
 
       if (y_offset != NULL)
         {
-          *y_offset = renderer->yalign * (cell_area->height - priv->size);
-          *y_offset = MAX (*y_offset, 0) + renderer->ypad;
+          *y_offset = aligned_area.y * (cell_area->height - priv->size);
+          *y_offset = MAX (*y_offset, 0) + ypad;
         }
     }
   else
@@ -351,21 +360,20 @@ exo_cell_renderer_icon_get_size (GtkCellRenderer *renderer,
     }
 
   if (G_LIKELY (width != NULL))
-    *width = (gint) renderer->xpad * 2 + priv->size;
+    *width = (gint) xpad * 2 + priv->size;
 
   if (G_LIKELY (height != NULL))
-    *height = (gint) renderer->ypad * 2 + priv->size;
+    *height = (gint) ypad * 2 + priv->size;
 }
 
 
 
 static void
 exo_cell_renderer_icon_render (GtkCellRenderer     *renderer,
-                               GdkWindow           *window,
+                               cairo_t             *cr,
                                GtkWidget           *widget,
-                               GdkRectangle        *background_area,
-                               GdkRectangle        *cell_area,
-                               GdkRectangle        *expose_area,
+                               const GdkRectangle  *background_area,
+                               const GdkRectangle  *cell_area,
                                GtkCellRendererState flags)
 {
   const ExoCellRendererIconPrivate *priv = EXO_CELL_RENDERER_ICON_GET_PRIVATE (renderer);
@@ -494,14 +502,14 @@ exo_cell_renderer_icon_render (GtkCellRenderer     *renderer,
   icon_area.y = cell_area->y + (cell_area->height - icon_area.height) / 2;
 
   /* check whether the icon is affected by the expose event */
-  if (gdk_rectangle_intersect (expose_area, &icon_area, &draw_area))
+  if (gdk_rectangle_intersect (&icon_area, &draw_area, NULL))
     {
       /* colorize the icon if we should follow the selection state */
       if ((flags & (GTK_CELL_RENDERER_SELECTED | GTK_CELL_RENDERER_PRELIT)) != 0 && priv->follow_state)
         {
           if ((flags & GTK_CELL_RENDERER_SELECTED) != 0)
             {
-              state = GTK_WIDGET_HAS_FOCUS (widget) ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE;
+              state = gtk_widget_has_focus (widget) ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE;
               temp = exo_gdk_pixbuf_colorize (icon, &widget->style->base[state]);
               g_object_unref (G_OBJECT (icon));
               icon = temp;
@@ -516,7 +524,7 @@ exo_cell_renderer_icon_render (GtkCellRenderer     *renderer,
         }
 
       /* check if we should render an insensitive icon */
-      if (G_UNLIKELY (GTK_WIDGET_STATE (widget) == GTK_STATE_INSENSITIVE || !renderer->sensitive))
+      if (G_UNLIKELY (gtk_widget_get_state (widget) == GTK_STATE_INSENSITIVE || !gtk_cell_renderer_get_sensitive (renderer)))
         {
           /* allocate an icon source */
           icon_source = gtk_icon_source_new ();


More information about the Xfce4-commits mailing list