[gimp/gtk3-port: 150/240] libgimpwidgets: move all GimpCellRendererToggle members to a private struct



commit 328e3839060a7c362594cb2e0699970c6c4fefb9
Author: Michael Natterer <mitch gimp org>
Date:   Fri Dec 31 18:15:15 2010 +0100

    libgimpwidgets: move all GimpCellRendererToggle members to a private struct

 libgimpwidgets/gimpcellrenderertoggle.c |   68 +++++++++++++++---------------
 libgimpwidgets/gimpcellrenderertoggle.h |    6 +--
 2 files changed, 35 insertions(+), 39 deletions(-)
---
diff --git a/libgimpwidgets/gimpcellrenderertoggle.c b/libgimpwidgets/gimpcellrenderertoggle.c
index b86ba92..f42c4a6 100644
--- a/libgimpwidgets/gimpcellrenderertoggle.c
+++ b/libgimpwidgets/gimpcellrenderertoggle.c
@@ -62,8 +62,12 @@ typedef struct _GimpCellRendererTogglePrivate GimpCellRendererTogglePrivate;
 
 struct _GimpCellRendererTogglePrivate
 {
-  gchar    *icon_name;
-  gboolean  override_background;
+  gchar       *icon_name;
+  gchar       *stock_id;
+  GtkIconSize  stock_size;
+  gboolean     override_background;
+
+  GdkPixbuf   *pixbuf;
 };
 
 #define GET_PRIVATE(obj) \
@@ -182,13 +186,12 @@ gimp_cell_renderer_toggle_init (GimpCellRendererToggle *toggle)
 static void
 gimp_cell_renderer_toggle_finalize (GObject *object)
 {
-  GimpCellRendererToggle        *toggle = GIMP_CELL_RENDERER_TOGGLE (object);
-  GimpCellRendererTogglePrivate *priv   = GET_PRIVATE (object);
+  GimpCellRendererTogglePrivate *priv = GET_PRIVATE (object);
 
-  g_clear_pointer (&priv->icon_name,  g_free);
-  g_clear_pointer (&toggle->stock_id, g_free);
+  g_clear_pointer (&priv->icon_name, g_free);
+  g_clear_pointer (&priv->stock_id,  g_free);
 
-  g_clear_object (&toggle->pixbuf);
+  g_clear_object (&priv->pixbuf);
 
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
@@ -199,8 +202,7 @@ gimp_cell_renderer_toggle_get_property (GObject    *object,
                                         GValue     *value,
                                         GParamSpec *pspec)
 {
-  GimpCellRendererToggle        *toggle = GIMP_CELL_RENDERER_TOGGLE (object);
-  GimpCellRendererTogglePrivate *priv   = GET_PRIVATE (object);
+  GimpCellRendererTogglePrivate *priv = GET_PRIVATE (object);
 
   switch (param_id)
     {
@@ -209,11 +211,11 @@ gimp_cell_renderer_toggle_get_property (GObject    *object,
       break;
 
     case PROP_STOCK_ID:
-      g_value_set_string (value, toggle->stock_id);
+      g_value_set_string (value, priv->stock_id);
       break;
 
     case PROP_STOCK_SIZE:
-      g_value_set_int (value, toggle->stock_size);
+      g_value_set_int (value, priv->stock_size);
       break;
 
     case PROP_OVERRIDE_BACKGROUND:
@@ -232,8 +234,7 @@ gimp_cell_renderer_toggle_set_property (GObject      *object,
                                         const GValue *value,
                                         GParamSpec   *pspec)
 {
-  GimpCellRendererToggle        *toggle = GIMP_CELL_RENDERER_TOGGLE (object);
-  GimpCellRendererTogglePrivate *priv   = GET_PRIVATE (object);
+  GimpCellRendererTogglePrivate *priv = GET_PRIVATE (object);
 
   switch (param_id)
     {
@@ -244,13 +245,13 @@ gimp_cell_renderer_toggle_set_property (GObject      *object,
       break;
 
     case PROP_STOCK_ID:
-      if (toggle->stock_id)
-        g_free (toggle->stock_id);
-      toggle->stock_id = g_value_dup_string (value);
+      if (priv->stock_id)
+        g_free (priv->stock_id);
+      priv->stock_id = g_value_dup_string (value);
       break;
 
     case PROP_STOCK_SIZE:
-      toggle->stock_size = g_value_get_int (value);
+      priv->stock_size = g_value_get_int (value);
       break;
 
     case PROP_OVERRIDE_BACKGROUND:
@@ -262,7 +263,7 @@ gimp_cell_renderer_toggle_set_property (GObject      *object,
       break;
     }
 
-  g_clear_object (&toggle->pixbuf);
+  g_clear_object (&priv->pixbuf);
 }
 
 static void
@@ -287,7 +288,7 @@ gimp_cell_renderer_toggle_get_size (GtkCellRenderer    *cell,
   gint                           xpad;
   gint                           ypad;
 
-  if (! priv->icon_name && ! toggle->stock_id)
+  if (! priv->icon_name && ! priv->stock_id)
     {
       GTK_CELL_RENDERER_CLASS (parent_class)->get_size (cell,
                                                         widget,
@@ -302,11 +303,11 @@ gimp_cell_renderer_toggle_get_size (GtkCellRenderer    *cell,
   gtk_cell_renderer_get_alignment (cell, &xalign, &yalign);
   gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
 
-  if (! toggle->pixbuf)
+  if (! priv->pixbuf)
     gimp_cell_renderer_toggle_create_pixbuf (toggle, widget);
 
-  pixbuf_width  = gdk_pixbuf_get_width  (toggle->pixbuf);
-  pixbuf_height = gdk_pixbuf_get_height (toggle->pixbuf);
+  pixbuf_width  = gdk_pixbuf_get_width  (priv->pixbuf);
+  pixbuf_height = gdk_pixbuf_get_height (priv->pixbuf);
 
   calc_width  = pixbuf_width  + (gint) xpad * 2;
   calc_height = pixbuf_height + (gint) ypad * 2;
@@ -351,7 +352,6 @@ gimp_cell_renderer_toggle_render (GtkCellRenderer      *cell,
                                   const GdkRectangle   *cell_area,
                                   GtkCellRendererState  flags)
 {
-  GimpCellRendererToggle        *toggle  = GIMP_CELL_RENDERER_TOGGLE (cell);
   GimpCellRendererTogglePrivate *priv    = GET_PRIVATE (cell);
   GtkStyleContext               *context = gtk_widget_get_style_context (widget);
   GdkRectangle                   toggle_rect;
@@ -360,7 +360,7 @@ gimp_cell_renderer_toggle_render (GtkCellRenderer      *cell,
   gint                           xpad;
   gint                           ypad;
 
-  if (! priv->icon_name && ! toggle->stock_id)
+  if (! priv->icon_name && ! priv->stock_id)
     {
       GTK_CELL_RENDERER_CLASS (parent_class)->render (cell, cr, widget,
                                                       background_area,
@@ -453,11 +453,11 @@ gimp_cell_renderer_toggle_render (GtkCellRenderer      *cell,
       toggle_rect.width  -= border.left + border.right;
       toggle_rect.height -= border.top + border.bottom;
 
-      gdk_cairo_set_source_pixbuf (cr, toggle->pixbuf,
+      gdk_cairo_set_source_pixbuf (cr, priv->pixbuf,
                                    toggle_rect.x, toggle_rect.y);
       cairo_paint (cr);
 
-      g_object_get (toggle,
+      g_object_get (cell,
                     "inconsistent", &inconsistent,
                     NULL);
 
@@ -514,29 +514,29 @@ gimp_cell_renderer_toggle_create_pixbuf (GimpCellRendererToggle *toggle,
 {
   GimpCellRendererTogglePrivate *priv = GET_PRIVATE (toggle);
 
-  g_clear_object (&toggle->pixbuf);
+  g_clear_object (&priv->pixbuf);
 
   if (priv->icon_name)
     {
       gint width, height;
 
       if (! gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (widget),
-                                               toggle->stock_size,
+                                               priv->stock_size,
                                                &width, &height))
         {
           width  = 20;
           height = 20;
         }
 
-      toggle->pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
-                                                 priv->icon_name,
-                                                 MIN (width, height), 0, NULL);
+      priv->pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+                                               priv->icon_name,
+                                               MIN (width, height), 0, NULL);
     }
   else
     {
-      toggle->pixbuf = gtk_widget_render_icon_pixbuf (widget,
-                                                      toggle->stock_id,
-                                                      toggle->stock_size);
+      priv->pixbuf = gtk_widget_render_icon_pixbuf (widget,
+                                                    priv->stock_id,
+                                                    priv->stock_size);
     }
 }
 
diff --git a/libgimpwidgets/gimpcellrenderertoggle.h b/libgimpwidgets/gimpcellrenderertoggle.h
index 16dd185..f83a543 100644
--- a/libgimpwidgets/gimpcellrenderertoggle.h
+++ b/libgimpwidgets/gimpcellrenderertoggle.h
@@ -41,11 +41,7 @@ typedef struct _GimpCellRendererToggleClass GimpCellRendererToggleClass;
 
 struct _GimpCellRendererToggle
 {
-  GtkCellRendererToggle       parent_instance;
-
-  gchar                      *stock_id;
-  GtkIconSize                 stock_size;
-  GdkPixbuf                  *pixbuf;
+  GtkCellRendererToggle  parent_instance;
 };
 
 struct _GimpCellRendererToggleClass


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