[Xfce4-commits] <xfce4-panel:devel> * Fix warning committed yesterday. * Run construct after realized.

Nick Schermer nick at xfce.org
Tue Aug 11 20:24:41 CEST 2009


Updating branch refs/heads/devel
         to 94a125b781fa88e8a90fc70ef705fbbc68721d78 (commit)
       from d3a5d2a11318fe3934f490bf76418c4de2004d7f (commit)

commit 94a125b781fa88e8a90fc70ef705fbbc68721d78
Author: Nick Schermer <nick at xfce.org>
Date:   Thu Oct 9 21:04:29 2008 +0200

    * Fix warning committed yesterday.
    * Run construct after realized.

 libxfce4panel/xfce-panel-plugin.c |   43 +++++++++++++++++++++++-------------
 libxfce4panel/xfce-panel-plugin.h |    3 +-
 2 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/libxfce4panel/xfce-panel-plugin.c b/libxfce4panel/xfce-panel-plugin.c
index 41c2579..6251a3e 100644
--- a/libxfce4panel/xfce-panel-plugin.c
+++ b/libxfce4panel/xfce-panel-plugin.c
@@ -39,7 +39,6 @@ typedef const gchar *(*ProviderToPlugin) (XfcePanelPluginProvider *provider);
 static void         xfce_panel_plugin_class_init             (XfcePanelPluginClass         *klass);
 static void         xfce_panel_plugin_init                   (XfcePanelPlugin              *plugin);
 static void         xfce_panel_plugin_provider_init          (XfcePanelPluginProviderIface *iface);
-static void         xfce_panel_plugin_constructed            (GObject                      *object);
 static void         xfce_panel_plugin_get_property           (GObject                      *object,
                                                               guint                         prop_id,
                                                               GValue                       *value,
@@ -50,6 +49,7 @@ static void         xfce_panel_plugin_set_property           (GObject
                                                               GParamSpec                   *pspec);
 static void         xfce_panel_plugin_dispose                (GObject                      *object);
 static void         xfce_panel_plugin_finalize               (GObject                      *object);
+static void         xfce_panel_plugin_realize                (GtkWidget                    *widget);
 static gboolean     xfce_panel_plugin_button_press_event     (GtkWidget                    *widget,
                                                               GdkEventButton               *event);
 static void         xfce_panel_plugin_menu_properties        (XfcePanelPlugin              *plugin);
@@ -107,8 +107,9 @@ struct _XfcePanelPluginPrivate
   GtkOrientation       orientation;
   XfceScreenPosition   screen_position;
 
-  /* prevent free_data in dispose from running twice */
+  /* we only want to trigger these functions once */
   guint                disposed : 1;
+  guint                constructed : 1;
 
   /* plugin menu */
   GtkMenu             *menu;
@@ -144,13 +145,13 @@ xfce_panel_plugin_class_init (XfcePanelPluginClass *klass)
   klass->construct = NULL;
 
   gobject_class = G_OBJECT_CLASS (klass);
-  gobject_class->constructed = xfce_panel_plugin_constructed;
   gobject_class->get_property = xfce_panel_plugin_get_property;
   gobject_class->set_property = xfce_panel_plugin_set_property;
   gobject_class->dispose = xfce_panel_plugin_dispose;
   gobject_class->finalize = xfce_panel_plugin_finalize;
 
   gtkwidget_class = GTK_WIDGET_CLASS (klass);
+  gtkwidget_class->realize = xfce_panel_plugin_realize;
   gtkwidget_class->button_press_event = xfce_panel_plugin_button_press_event;
 
   /**
@@ -382,6 +383,7 @@ xfce_panel_plugin_init (XfcePanelPlugin *plugin)
   plugin->priv->menu_blocked = 0;
   plugin->priv->registered_menus = 0;
   plugin->priv->disposed = FALSE;
+  plugin->priv->constructed = FALSE;
 
   /* hide the event box window to make the plugin transparent */
   gtk_event_box_set_visible_window (GTK_EVENT_BOX (plugin), FALSE);
@@ -403,19 +405,6 @@ xfce_panel_plugin_provider_init (XfcePanelPluginProviderIface *iface)
 
 
 static void
-xfce_panel_plugin_constructed (GObject *object)
-{
-  XfcePanelPluginClass *klass = XFCE_PANEL_PLUGIN_GET_CLASS (object);
-
-  /* check if there is a construct class attached to this plugin,
-   * if there is, execute it */
-  if (klass->construct != NULL)
-    (*klass->construct) (XFCE_PANEL_PLUGIN (object));
-}
-
-
-
-static void
 xfce_panel_plugin_get_property (GObject    *object,
                                 guint       prop_id,
                                 GValue     *value,
@@ -522,6 +511,28 @@ xfce_panel_plugin_finalize (GObject *object)
 
 
 
+static void
+xfce_panel_plugin_realize (GtkWidget *widget)
+{
+  XfcePanelPluginClass *klass = XFCE_PANEL_PLUGIN_GET_CLASS (widget);
+  XfcePanelPlugin      *plugin = XFCE_PANEL_PLUGIN (widget);
+  
+  /* allow gtk to realize the plugin */
+  (*GTK_WIDGET_CLASS (xfce_panel_plugin_parent_class)->realize) (widget);
+
+  /* check if there is a construct function attached to this plugin */
+  if (klass->construct != NULL && !plugin->priv->constructed)
+    {
+      /* run the construct function */
+      (*klass->construct) (XFCE_PANEL_PLUGIN (widget));
+      
+      /* don't run the construct function again on another realize */
+      plugin->priv->constructed = TRUE;
+    }
+}
+
+
+
 static gboolean
 xfce_panel_plugin_button_press_event (GtkWidget      *widget,
                                       GdkEventButton *event)
diff --git a/libxfce4panel/xfce-panel-plugin.h b/libxfce4panel/xfce-panel-plugin.h
index fbbdb6c..1716a0e 100644
--- a/libxfce4panel/xfce-panel-plugin.h
+++ b/libxfce4panel/xfce-panel-plugin.h
@@ -89,8 +89,7 @@ const gchar         *xfce_panel_plugin_get_display_name    (XfcePanelPlugin   *p
 
 const gchar         *xfce_panel_plugin_get_id              (XfcePanelPlugin   *plugin);
 
-const gchar * const *xfce_panel_plugin_get_arguments       (XfcePanelPlugin   *plugin,
-                                                           gchar           ***arguments);
+const gchar * const *xfce_panel_plugin_get_arguments       (XfcePanelPlugin   *plugin);
 
 gint                 xfce_panel_plugin_get_size            (XfcePanelPlugin   *plugin);
 



More information about the Xfce4-commits mailing list