[glade3] * gladeui/glade-placeholder.[ch], gladeui/glade-popup.c: Privatized GladePlaceholder members.



commit 0523a44db9680a39fed35f02b832201f237488e5
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Wed Jan 5 17:36:59 2011 +0900

    	* gladeui/glade-placeholder.[ch], gladeui/glade-popup.c:
    	Privatized GladePlaceholder members.

 ChangeLog                   |    3 +
 gladeui/glade-placeholder.c |  107 ++++++++++++++++++++++++++----------------
 gladeui/glade-placeholder.h |   29 ++++++-----
 gladeui/glade-popup.c       |    4 +-
 4 files changed, 87 insertions(+), 56 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1d8a09b..b63f42b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,6 +15,9 @@
 	* gladeui/glade-command.[ch], gladeui/glade-project.c, src/glade-window.c:
 	Privatized GladeCommand members.
 
+	* gladeui/glade-placeholder.[ch], gladeui/glade-popup.c:
+	Privatized GladePlaceholder members.
+
 2011-01-04  Johannes Schmid <jhs gnome org>
 
 	* data/gladeui-2.0.pc.in: Fix include paths and library name
diff --git a/gladeui/glade-placeholder.c b/gladeui/glade-placeholder.c
index 793b9d8..ee2d139 100644
--- a/gladeui/glade-placeholder.c
+++ b/gladeui/glade-placeholder.c
@@ -76,6 +76,14 @@ static gboolean glade_placeholder_button_press (GtkWidget * widget,
 
 static gboolean glade_placeholder_popup_menu (GtkWidget * widget);
 
+
+struct _GladePlaceholderPrivate
+{
+  GList *packing_actions;
+
+  GdkWindow *event_window;
+};
+
 enum
 {
   PROP_0,
@@ -87,7 +95,8 @@ enum
 
 G_DEFINE_TYPE_WITH_CODE (GladePlaceholder, glade_placeholder, GTK_TYPE_WIDGET,
                          G_IMPLEMENT_INTERFACE (GTK_TYPE_SCROLLABLE, NULL))
-     static void glade_placeholder_class_init (GladePlaceholderClass * klass)
+
+static void glade_placeholder_class_init (GladePlaceholderClass * klass)
 {
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -116,6 +125,8 @@ G_DEFINE_TYPE_WITH_CODE (GladePlaceholder, glade_placeholder, GTK_TYPE_WIDGET,
                                     "hscroll-policy");
   g_object_class_override_property (object_class, PROP_VSCROLL_POLICY,
                                     "vscroll-policy");
+
+  g_type_class_add_private (klass, sizeof (GladePlaceholderPrivate));
 }
 
 static void
@@ -126,26 +137,31 @@ glade_placeholder_notify_parent (GObject * gobject,
   GladeWidgetAdaptor *parent_adaptor = NULL;
   GladeWidget *parent = glade_placeholder_get_parent (placeholder);
 
-  if (placeholder->packing_actions)
+  if (placeholder->priv->packing_actions)
     {
-      g_list_foreach (placeholder->packing_actions, (GFunc) g_object_unref,
+      g_list_foreach (placeholder->priv->packing_actions, (GFunc) g_object_unref,
                       NULL);
-      g_list_free (placeholder->packing_actions);
-      placeholder->packing_actions = NULL;
+      g_list_free (placeholder->priv->packing_actions);
+      placeholder->priv->packing_actions = NULL;
     }
 
   if (parent)
     parent_adaptor = glade_widget_get_adaptor (parent);
 
   if (parent_adaptor)
-    placeholder->packing_actions =
+    placeholder->priv->packing_actions =
       glade_widget_adaptor_pack_actions_new (parent_adaptor);
 }
 
 static void
 glade_placeholder_init (GladePlaceholder * placeholder)
 {
-  placeholder->packing_actions = NULL;
+  placeholder->priv = 
+    G_TYPE_INSTANCE_GET_PRIVATE (placeholder,
+				 GLADE_TYPE_PLACEHOLDER,
+				 GladePlaceholderPrivate);
+
+  placeholder->priv->packing_actions = NULL;
 
   gtk_widget_set_can_focus (GTK_WIDGET (placeholder), TRUE);
   gtk_widget_set_has_window (GTK_WIDGET (placeholder), FALSE);
@@ -159,17 +175,6 @@ glade_placeholder_init (GladePlaceholder * placeholder)
   gtk_widget_show (GTK_WIDGET (placeholder));
 }
 
-/**
- * glade_placeholder_new:
- * 
- * Returns: a new #GladePlaceholder cast as a #GtkWidget
- */
-GtkWidget *
-glade_placeholder_new (void)
-{
-  return g_object_new (GLADE_TYPE_PLACEHOLDER, NULL);
-}
-
 static void
 glade_placeholder_finalize (GObject * object)
 {
@@ -178,11 +183,10 @@ glade_placeholder_finalize (GObject * object)
   g_return_if_fail (GLADE_IS_PLACEHOLDER (object));
   placeholder = GLADE_PLACEHOLDER (object);
 
-  if (placeholder->packing_actions)
+  if (placeholder->priv->packing_actions)
     {
-      g_list_foreach (placeholder->packing_actions, (GFunc) g_object_unref,
-                      NULL);
-      g_list_free (placeholder->packing_actions);
+      g_list_foreach (placeholder->priv->packing_actions, (GFunc) g_object_unref, NULL);
+      g_list_free (placeholder->priv->packing_actions);
     }
 
   G_OBJECT_CLASS (glade_placeholder_parent_class)->finalize (object);
@@ -260,10 +264,10 @@ glade_placeholder_realize (GtkWidget * widget)
   window = gtk_widget_get_parent_window (widget);
   gtk_widget_set_window (widget, g_object_ref (window));
 
-  placeholder->event_window =
+  placeholder->priv->event_window =
       gdk_window_new (gtk_widget_get_parent_window (widget), &attributes,
                       attributes_mask);
-  gdk_window_set_user_data (placeholder->event_window, widget);
+  gdk_window_set_user_data (placeholder->priv->event_window, widget);
 
   gtk_widget_style_attach (widget);
 }
@@ -275,11 +279,11 @@ glade_placeholder_unrealize (GtkWidget * widget)
 
   placeholder = GLADE_PLACEHOLDER (widget);
 
-  if (placeholder->event_window)
+  if (placeholder->priv->event_window)
     {
-      gdk_window_set_user_data (placeholder->event_window, NULL);
-      gdk_window_destroy (placeholder->event_window);
-      placeholder->event_window = NULL;
+      gdk_window_set_user_data (placeholder->priv->event_window, NULL);
+      gdk_window_destroy (placeholder->priv->event_window);
+      placeholder->priv->event_window = NULL;
     }
 
   GTK_WIDGET_CLASS (glade_placeholder_parent_class)->unrealize (widget);
@@ -292,9 +296,9 @@ glade_placeholder_map (GtkWidget * widget)
 
   placeholder = GLADE_PLACEHOLDER (widget);
 
-  if (placeholder->event_window)
+  if (placeholder->priv->event_window)
     {
-      gdk_window_show (placeholder->event_window);
+      gdk_window_show (placeholder->priv->event_window);
     }
 
   GTK_WIDGET_CLASS (glade_placeholder_parent_class)->map (widget);
@@ -307,9 +311,9 @@ glade_placeholder_unmap (GtkWidget * widget)
 
   placeholder = GLADE_PLACEHOLDER (widget);
 
-  if (placeholder->event_window)
+  if (placeholder->priv->event_window)
     {
-      gdk_window_hide (placeholder->event_window);
+      gdk_window_hide (placeholder->priv->event_window);
     }
 
   GTK_WIDGET_CLASS (glade_placeholder_parent_class)->unmap (widget);
@@ -326,20 +330,12 @@ glade_placeholder_size_allocate (GtkWidget * widget, GtkAllocation * allocation)
 
   if (gtk_widget_get_realized (widget))
     {
-      gdk_window_move_resize (placeholder->event_window,
+      gdk_window_move_resize (placeholder->priv->event_window,
                               allocation->x, allocation->y,
                               allocation->width, allocation->height);
     }
 }
 
-GladeProject *
-glade_placeholder_get_project (GladePlaceholder * placeholder)
-{
-  GladeWidget *parent;
-  parent = glade_placeholder_get_parent (placeholder);
-  return parent ? glade_widget_get_project (parent) : NULL;
-}
-
 static void
 glade_placeholder_draw_background (GtkWidget * widget, cairo_t * cr)
 {
@@ -485,6 +481,26 @@ glade_placeholder_popup_menu (GtkWidget * widget)
   return TRUE;
 }
 
+
+/**
+ * glade_placeholder_new:
+ * 
+ * Returns: a new #GladePlaceholder cast as a #GtkWidget
+ */
+GtkWidget *
+glade_placeholder_new (void)
+{
+  return g_object_new (GLADE_TYPE_PLACEHOLDER, NULL);
+}
+
+GladeProject *
+glade_placeholder_get_project (GladePlaceholder * placeholder)
+{
+  GladeWidget *parent;
+  parent = glade_placeholder_get_parent (placeholder);
+  return parent ? glade_widget_get_project (parent) : NULL;
+}
+
 GladeWidget *
 glade_placeholder_get_parent (GladePlaceholder * placeholder)
 {
@@ -501,3 +517,12 @@ glade_placeholder_get_parent (GladePlaceholder * placeholder)
     }
   return parent;
 }
+
+GList *
+glade_placeholder_packing_actions (GladePlaceholder *placeholder)
+{
+  g_return_val_if_fail (GLADE_IS_PLACEHOLDER (placeholder), NULL);
+
+  return placeholder->priv->packing_actions;
+}
+
diff --git a/gladeui/glade-placeholder.h b/gladeui/glade-placeholder.h
index bddc579..37bb405 100644
--- a/gladeui/glade-placeholder.h
+++ b/gladeui/glade-placeholder.h
@@ -36,31 +36,34 @@ G_BEGIN_DECLS
 #define GLADE_IS_PLACEHOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_PLACEHOLDER))
 #define GLADE_PLACEHOLDER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_TYPE_PLACEHOLDER, GladePlaceholderClass))
 
-typedef struct _GladePlaceholder      GladePlaceholder;
-typedef struct _GladePlaceholderClass GladePlaceholderClass;
+typedef struct _GladePlaceholder        GladePlaceholder;
+typedef struct _GladePlaceholderClass   GladePlaceholderClass;
+typedef struct _GladePlaceholderPrivate GladePlaceholderPrivate;
 
 struct _GladePlaceholder
 {
-	GtkWidget widget;
+  GtkWidget widget;
 	
-	GList *packing_actions;
-
-	GdkWindow *event_window;
+  GladePlaceholderPrivate *priv;
 };
 
 struct _GladePlaceholderClass
 {
-	GtkWidgetClass parent_class;
-};
+  GtkWidgetClass parent_class;
 
+  void   (* glade_reserved1)   (void);
+  void   (* glade_reserved2)   (void);
+  void   (* glade_reserved3)   (void);
+  void   (* glade_reserved4)   (void);
+};
 
-GType        glade_placeholder_get_type   (void) G_GNUC_CONST;
-
-GtkWidget   *glade_placeholder_new        (void);
 
-GladeProject* glade_placeholder_get_project (GladePlaceholder *placeholder);
+GType         glade_placeholder_get_type        (void) G_GNUC_CONST;
 
-GladeWidget *glade_placeholder_get_parent (GladePlaceholder *placeholder);
+GtkWidget    *glade_placeholder_new             (void);
+GladeProject *glade_placeholder_get_project     (GladePlaceholder *placeholder);
+GladeWidget  *glade_placeholder_get_parent      (GladePlaceholder *placeholder);
+GList        *glade_placeholder_packing_actions (GladePlaceholder *placeholder);
 
 G_END_DECLS
 
diff --git a/gladeui/glade-popup.c b/gladeui/glade-popup.c
index 5b66850..64561b1 100644
--- a/gladeui/glade-popup.c
+++ b/gladeui/glade-popup.c
@@ -496,7 +496,7 @@ glade_popup_create_menu (GladeWidget      *widget,
                G_CALLBACK (glade_popup_menuitem_activated), widget);
         }
 
-      if (placeholder->packing_actions)
+      if (glade_placeholder_packing_actions (placeholder))
         {
           GtkWidget *separator = gtk_menu_item_new ();
           gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), separator);
@@ -505,7 +505,7 @@ glade_popup_create_menu (GladeWidget      *widget,
           glade_popup_action_populate_menu_real
               (popup_menu,
                widget,
-               placeholder->packing_actions,
+               glade_placeholder_packing_actions (placeholder),
                G_CALLBACK (glade_popup_menuitem_ph_packing_activated),
                placeholder);
         }



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