[glade3] * gladeui/glade-cell-renderer-icon.[ch]: Privatizing members.



commit 0d8967939862e502ab51b8fa5b9f5b2f55ad9289
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Tue Jan 4 16:27:50 2011 +0900

    	* gladeui/glade-cell-renderer-icon.[ch]: Privatizing members.

 ChangeLog                          |    2 +
 gladeui/glade-app.c                |   17 ++++++-------
 gladeui/glade-base-editor.h        |   18 +++++++-------
 gladeui/glade-cell-renderer-icon.c |   45 ++++++++++++++++++++++++-----------
 gladeui/glade-cell-renderer-icon.h |   10 ++++----
 5 files changed, 55 insertions(+), 37 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 27ee39a..4be10b7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,8 @@
 
 	* gladeui/glade-app.h: Cleanup a bit, and removed an unused prototype.
 
+	* gladeui/glade-cell-renderer-icon.[ch]: Privatizing members.
+
 2011-01-03  Tristan Van Berkom <tristanvb openismus com>
 
 	* gladeui/glade-app.[ch]:
diff --git a/gladeui/glade-app.c b/gladeui/glade-app.c
index 7995270..dd24926 100644
--- a/gladeui/glade-app.c
+++ b/gladeui/glade-app.c
@@ -53,8 +53,6 @@
 
 #define GLADE_CONFIG_FILENAME "glade-3.conf"
 
-#define GLADE_APP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GLADE_TYPE_APP, GladeAppPrivate))
-
 enum
 {
   SIGNAL_EDITOR_CREATED,
@@ -127,7 +125,7 @@ glade_app_constructor (GType type,
 static void
 glade_app_dispose (GObject * app)
 {
-  GladeAppPrivate *priv = GLADE_APP_GET_PRIVATE (app);
+  GladeAppPrivate *priv = GLADE_APP (app)->priv;
 
   if (priv->clipboard)
     {
@@ -283,8 +281,9 @@ static void
 glade_app_init (GladeApp * app)
 {
   static gboolean initialized = FALSE;
-
-  app->priv = GLADE_APP_GET_PRIVATE (app);
+  GladeAppPrivate *priv =
+    GLADE_APP (app)->priv = 
+    G_TYPE_INSTANCE_GET_PRIVATE ((app), GLADE_TYPE_APP, GladeAppPrivate);
 
   singleton_app = app;
 
@@ -300,16 +299,16 @@ glade_app_init (GladeApp * app)
       initialized = TRUE;
     }
 
-  app->priv->accel_group = NULL;
+  priv->accel_group = NULL;
 
   /* Initialize app objects */
-  app->priv->catalogs = (GList *) glade_catalog_load_all ();
+  priv->catalogs = (GList *) glade_catalog_load_all ();
 
   /* Create clipboard */
-  app->priv->clipboard = glade_clipboard_new ();
+  priv->clipboard = glade_clipboard_new ();
 
   /* Load the configuration file */
-  app->priv->config = glade_app_config_load (app);
+  priv->config = glade_app_config_load (app);
 }
 
 static void
diff --git a/gladeui/glade-base-editor.h b/gladeui/glade-base-editor.h
index c412172..f99a3b3 100644
--- a/gladeui/glade-base-editor.h
+++ b/gladeui/glade-base-editor.h
@@ -40,21 +40,21 @@ typedef struct _GladeBaseEditorClass   GladeBaseEditorClass;
 
 struct _GladeBaseEditor
 {
-	GtkVBox parent;
+  GtkVBox parent;
 
-	GladeBaseEditorPrivate *priv;
+  GladeBaseEditorPrivate *priv;
 };
 
 struct _GladeBaseEditorClass
 {
-	GtkVBoxClass parent_class;
-
-	void          (*child_selected)   (GladeBaseEditor *, GladeWidget *);
-	gboolean      (*change_type)      (GladeBaseEditor *, GladeWidget *, GType);
-	gchar *       (*get_display_name) (GladeBaseEditor *, GladeWidget *);
-	GladeWidget * (*build_child)      (GladeBaseEditor *, GladeWidget *, GType);
-	gboolean      (*delete_child)     (GladeBaseEditor *, GladeWidget *, GladeWidget *);
-	gboolean      (*move_child)       (GladeBaseEditor *, GladeWidget *, GladeWidget *);
+  GtkVBoxClass parent_class;
+
+  void          (*child_selected)   (GladeBaseEditor *, GladeWidget *);
+  gboolean      (*change_type)      (GladeBaseEditor *, GladeWidget *, GType);
+  gchar *       (*get_display_name) (GladeBaseEditor *, GladeWidget *);
+  GladeWidget * (*build_child)      (GladeBaseEditor *, GladeWidget *, GType);
+  gboolean      (*delete_child)     (GladeBaseEditor *, GladeWidget *, GladeWidget *);
+  gboolean      (*move_child)       (GladeBaseEditor *, GladeWidget *, GladeWidget *);
 };
 
 
diff --git a/gladeui/glade-cell-renderer-icon.c b/gladeui/glade-cell-renderer-icon.c
index a4ea913..656df56 100644
--- a/gladeui/glade-cell-renderer-icon.c
+++ b/gladeui/glade-cell-renderer-icon.c
@@ -41,6 +41,12 @@ static gboolean glade_cell_renderer_icon_activate (GtkCellRenderer * cell,
                                                    cell_area,
                                                    GtkCellRendererState flags);
 
+struct _GladeCellRendererIconPrivate 
+{
+  guint active : 1;
+  guint activatable : 1;
+};
+
 enum
 {
   ACTIVATE,
@@ -59,11 +65,16 @@ static guint icon_cell_signals[LAST_SIGNAL] = { 0 };
 
 G_DEFINE_TYPE (GladeCellRendererIcon, glade_cell_renderer_icon,
                GTK_TYPE_CELL_RENDERER_PIXBUF)
-     static void glade_cell_renderer_icon_init (GladeCellRendererIcon *
-                                                cellicon)
+
+static void glade_cell_renderer_icon_init (GladeCellRendererIcon *cellicon)
 {
-  cellicon->activatable = TRUE;
-  cellicon->active = FALSE;
+  cellicon->priv =
+    G_TYPE_INSTANCE_GET_PRIVATE ((cellicon), 
+				 GLADE_TYPE_CELL_RENDERER_ICON, 
+				 GladeCellRendererIconPrivate);
+
+  cellicon->priv->activatable = TRUE;
+  cellicon->priv->active = FALSE;
 
   g_object_set (G_OBJECT (cellicon), "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE,
                 NULL);
@@ -104,6 +115,8 @@ glade_cell_renderer_icon_class_init (GladeCellRendererIconClass * class)
                     G_STRUCT_OFFSET (GladeCellRendererIconClass, activate),
                     NULL, NULL,
                     glade_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
+
+  g_type_class_add_private (class, sizeof (GladeCellRendererIconPrivate));
 }
 
 static void
@@ -116,10 +129,10 @@ glade_cell_renderer_icon_get_property (GObject * object,
   switch (param_id)
     {
       case PROP_ACTIVE:
-        g_value_set_boolean (value, cellicon->active);
+        g_value_set_boolean (value, cellicon->priv->active);
         break;
       case PROP_ACTIVATABLE:
-        g_value_set_boolean (value, cellicon->activatable);
+        g_value_set_boolean (value, cellicon->priv->activatable);
         break;
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -138,10 +151,10 @@ glade_cell_renderer_icon_set_property (GObject * object,
   switch (param_id)
     {
       case PROP_ACTIVE:
-        cellicon->active = g_value_get_boolean (value);
+        cellicon->priv->active = g_value_get_boolean (value);
         break;
       case PROP_ACTIVATABLE:
-        cellicon->activatable = g_value_get_boolean (value);
+        cellicon->priv->activatable = g_value_get_boolean (value);
         break;
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -167,7 +180,7 @@ glade_cell_renderer_icon_activate (GtkCellRenderer * cell,
   GladeCellRendererIcon *cellicon;
 
   cellicon = GLADE_CELL_RENDERER_ICON (cell);
-  if (cellicon->activatable)
+  if (cellicon->priv->activatable)
     {
       g_signal_emit (cell, icon_cell_signals[ACTIVATE], 0, path);
       return TRUE;
@@ -181,7 +194,7 @@ glade_cell_renderer_icon_get_active (GladeCellRendererIcon * icon)
 {
   g_return_val_if_fail (GLADE_IS_CELL_RENDERER_ICON (icon), FALSE);
 
-  return icon->active;
+  return icon->priv->active;
 }
 
 void
@@ -190,7 +203,11 @@ glade_cell_renderer_icon_set_active (GladeCellRendererIcon * icon,
 {
   g_return_if_fail (GLADE_IS_CELL_RENDERER_ICON (icon));
 
-  g_object_set (icon, "active", setting ? TRUE : FALSE, NULL);
+  if (icon->priv->active != setting)
+    {
+      icon->priv->active = setting ? TRUE : FALSE;
+      g_object_notify (G_OBJECT (icon), "active");
+    }
 }
 
 gboolean
@@ -198,7 +215,7 @@ glade_cell_renderer_icon_get_activatable (GladeCellRendererIcon * icon)
 {
   g_return_val_if_fail (GLADE_IS_CELL_RENDERER_ICON (icon), FALSE);
 
-  return icon->activatable;
+  return icon->priv->activatable;
 }
 
 void
@@ -207,9 +224,9 @@ glade_cell_renderer_icon_set_activatable (GladeCellRendererIcon * icon,
 {
   g_return_if_fail (GLADE_IS_CELL_RENDERER_ICON (icon));
 
-  if (icon->activatable != setting)
+  if (icon->priv->activatable != setting)
     {
-      icon->activatable = setting ? TRUE : FALSE;
+      icon->priv->activatable = setting ? TRUE : FALSE;
       g_object_notify (G_OBJECT (icon), "activatable");
     }
 }
diff --git a/gladeui/glade-cell-renderer-icon.h b/gladeui/glade-cell-renderer-icon.h
index aad3069..966f24d 100644
--- a/gladeui/glade-cell-renderer-icon.h
+++ b/gladeui/glade-cell-renderer-icon.h
@@ -35,15 +35,15 @@ G_BEGIN_DECLS
 #define GLADE_IS_CELL_RENDERER_ICON_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_CELL_RENDERER_ICON))
 #define GLADE_CELL_RENDERER_ICON_GET_CLASS(obj)         (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_TYPE_CELL_RENDERER_ICON, GladeCellRendererIconClass))
 
-typedef struct _GladeCellRendererIcon GladeCellRendererIcon;
-typedef struct _GladeCellRendererIconClass GladeCellRendererIconClass;
+typedef struct _GladeCellRendererIcon        GladeCellRendererIcon;
+typedef struct _GladeCellRendererIconClass   GladeCellRendererIconClass;
+typedef struct _GladeCellRendererIconPrivate GladeCellRendererIconPrivate;
 
 struct _GladeCellRendererIcon
 {
   GtkCellRendererPixbuf parent;
 
-  guint active : 1;
-  guint activatable : 1;
+  GladeCellRendererIconPrivate *priv;
 };
 
 struct _GladeCellRendererIconClass
@@ -51,7 +51,7 @@ struct _GladeCellRendererIconClass
   GtkCellRendererPixbufClass parent_class;
 
   void (* activate) (GladeCellRendererIcon *cell_renderer_icon,
-		     const gchar         *path);
+		     const gchar           *path);
 };
 
 GType            glade_cell_renderer_icon_get_type       (void) G_GNUC_CONST;



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