[Xfce4-commits] <libxfce4ui:master> Cleanup the heading code.

Nick Schermer noreply at xfce.org
Sun May 29 17:48:01 CEST 2011


Updating branch refs/heads/master
         to 6e48a2717dea7dacedd3ce13185ebef22a95714b (commit)
       from 70a055c7f942f50d35b2c8652944cb33c46683ad (commit)

commit 6e48a2717dea7dacedd3ce13185ebef22a95714b
Author: Nick Schermer <nick at xfce.org>
Date:   Sun May 29 17:44:11 2011 +0200

    Cleanup the heading code.
    
    With the assumption this widget will not be made public
    anymore, we can strip a bunch of code. Also attach
    the window signals later in the titled-dialog so they are
    not triggered before we're actually going to show the window.

 libxfce4ui/libxfce4ui-private.h |   12 ++
 libxfce4ui/xfce-heading.c       |  374 +++++---------------------------------
 libxfce4ui/xfce-heading.h       |   16 --
 libxfce4ui/xfce-titled-dialog.c |   33 +++-
 4 files changed, 86 insertions(+), 349 deletions(-)

diff --git a/libxfce4ui/libxfce4ui-private.h b/libxfce4ui/libxfce4ui-private.h
index 7b9d2e3..8ab5b31 100644
--- a/libxfce4ui/libxfce4ui-private.h
+++ b/libxfce4ui/libxfce4ui-private.h
@@ -31,6 +31,18 @@ G_BEGIN_DECLS
 /* support for canonical representations of strings */
 #define I_(string) (g_intern_static_string ((string)))
 
+#ifndef NDEBUG
+#define _libxfce4ui_assert(expr)                 g_assert (expr)
+#define _libxfce4ui_assert_not_reached()         g_assert_not_reached ()
+#define _libxfce4ui_return_if_fail(expr)         g_return_if_fail (expr)
+#define _libxfce4ui_return_val_if_fail(expr,val) g_return_val_if_fail (expr,val)
+#else
+#define _libxfce4ui_assert(expr)                 G_STMT_START{ (void)0; }G_STMT_END
+#define _libxfce4ui_assert_not_reached()         G_STMT_START{ (void)0; }G_STMT_END
+#define _libxfce4ui_return_if_fail(expr)         G_STMT_START{ (void)0; }G_STMT_END
+#define _libxfce4ui_return_val_if_fail(expr,val) G_STMT_START{ (void)0; }G_STMT_END
+#endif
+
 G_END_DECLS
 
 #endif /* !__LIBXFCE4UI_PRIVATE_H__ */
diff --git a/libxfce4ui/xfce-heading.c b/libxfce4ui/xfce-heading.c
index 1fef083..df29216 100644
--- a/libxfce4ui/xfce-heading.c
+++ b/libxfce4ui/xfce-heading.c
@@ -38,50 +38,32 @@
 #define XFCE_HEADING_SPACING    12
 #define XFCE_HEADING_ICON_SIZE  48
 
-#define XFCE_HEADING_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), XFCE_TYPE_HEADING, XfceHeadingPrivate))
-
-
-
-/* Property identifiers */
-enum
-{
-  PROP_0,
-  PROP_ICON,
-  PROP_ICON_NAME,
-  PROP_SUBTITLE,
-  PROP_TITLE,
-};
-
-
 
 static void         _xfce_heading_finalize       (GObject          *object);
-static void         _xfce_heading_get_property   (GObject          *object,
-                                                 guint             prop_id,
-                                                 GValue           *value,
-                                                 GParamSpec       *pspec);
-static void         _xfce_heading_set_property   (GObject          *object,
-                                                 guint             prop_id,
-                                                 const GValue     *value,
-                                                 GParamSpec       *pspec);
 static void         _xfce_heading_realize        (GtkWidget        *widget);
 static void         _xfce_heading_size_request   (GtkWidget        *widget,
-                                                 GtkRequisition   *requisition);
+                                                  GtkRequisition   *requisition);
 static void         _xfce_heading_style_set      (GtkWidget        *widget,
-                                                 GtkStyle         *previous_style);
+                                                  GtkStyle         *previous_style);
 static gboolean     _xfce_heading_expose_event   (GtkWidget        *widget,
-                                                 GdkEventExpose   *event);
+                                                  GdkEventExpose   *event);
 static AtkObject   *_xfce_heading_get_accessible (GtkWidget        *widget);
 static PangoLayout *_xfce_heading_make_layout    (XfceHeading      *heading);
 static GdkPixbuf   *_xfce_heading_make_pixbuf    (XfceHeading      *heading);
-static GdkPixbuf   *_xfce_heading_get_icon       (XfceHeading      *heading);
-static const gchar *_xfce_heading_get_icon_name  (XfceHeading      *heading);
-static const gchar *_xfce_heading_get_subtitle   (XfceHeading      *heading);
-static const gchar *_xfce_heading_get_title      (XfceHeading      *heading);
 
 
 
-struct _XfceHeadingPrivate
+struct _XfceHeadingClass
 {
+  /*< private >*/
+  GtkWidgetClass __parent__;
+};
+
+struct _XfceHeading
+{
+  /*< private >*/
+  GtkWidget  __parent__;
+
   GdkPixbuf *icon;
   gchar     *icon_name;
   gchar     *subtitle;
@@ -100,13 +82,8 @@ _xfce_heading_class_init (XfceHeadingClass *klass)
   GtkWidgetClass *gtkwidget_class;
   GObjectClass   *gobject_class;
 
-  /* add our private data to the class */
-  g_type_class_add_private (klass, sizeof (XfceHeadingPrivate));
-
   gobject_class = G_OBJECT_CLASS (klass);
   gobject_class->finalize = _xfce_heading_finalize;
-  gobject_class->get_property = _xfce_heading_get_property;
-  gobject_class->set_property = _xfce_heading_set_property;
 
   gtkwidget_class = GTK_WIDGET_CLASS (klass);
   gtkwidget_class->realize = _xfce_heading_realize;
@@ -114,76 +91,6 @@ _xfce_heading_class_init (XfceHeadingClass *klass)
   gtkwidget_class->style_set = _xfce_heading_style_set;
   gtkwidget_class->expose_event = _xfce_heading_expose_event;
   gtkwidget_class->get_accessible = _xfce_heading_get_accessible;
-
-  /**
-   * XfceHeading:icon:
-   *
-   * The #GdkPixbuf to display as icon, or %NULL to use the
-   * "icon-name" property.
-   *
-   * Since: 4.4.0
-   **/
-  g_object_class_install_property (gobject_class,
-                                   PROP_ICON,
-                                   g_param_spec_object ("icon",
-                                                        "icon",
-                                                        "icon",
-                                                        GDK_TYPE_PIXBUF,
-                                                        G_PARAM_READWRITE
-                                                        | G_PARAM_STATIC_STRINGS));
-
-  /**
-   * XfceHeading:icon-name:
-   *
-   * If the "icon" property value is %NULL this is the name of
-   * the icon to display instead (looked up using the icon theme).
-   * If this property is also %NULL or the specified icon does not
-   * exist in the selected icon theme, no icon will be displayed.
-   *
-   * Since: 4.4.0
-   **/
-  g_object_class_install_property (gobject_class,
-                                   PROP_ICON_NAME,
-                                   g_param_spec_string ("icon-name",
-                                                        "icon-name",
-                                                        "icon-name",
-                                                        NULL,
-                                                        G_PARAM_READWRITE
-                                                        | G_PARAM_STATIC_STRINGS));
-
-  /**
-   * XfceHeading:subtitle:
-   *
-   * The sub title that should be displayed below the
-   * title. May be %NULL or the empty string to display
-   * only the title.
-   *
-   * Since: 4.4.0
-   **/
-  g_object_class_install_property (gobject_class,
-                                   PROP_SUBTITLE,
-                                   g_param_spec_string ("subtitle",
-                                                        "subtitle",
-                                                        "subtitle",
-                                                        NULL,
-                                                        G_PARAM_READWRITE
-                                                        | G_PARAM_STATIC_STRINGS));
-
-  /**
-   * XfceHeading:title:
-   *
-   * The title text to display in the heading.
-   *
-   * Since: 4.4.0
-   **/
-  g_object_class_install_property (gobject_class,
-                                   PROP_TITLE,
-                                   g_param_spec_string ("title",
-                                                        "title",
-                                                        "title",
-                                                        NULL,
-                                                        G_PARAM_READWRITE
-                                                        | G_PARAM_STATIC_STRINGS));
 }
 
 
@@ -191,9 +98,6 @@ _xfce_heading_class_init (XfceHeadingClass *klass)
 static void
 _xfce_heading_init (XfceHeading *heading)
 {
-  /* setup the private data */
-  heading->priv = XFCE_HEADING_GET_PRIVATE (heading);
-
   /* setup the widget parameters */
   GTK_WIDGET_UNSET_FLAGS (heading, GTK_NO_WINDOW);
 }
@@ -206,12 +110,12 @@ _xfce_heading_finalize (GObject *object)
   XfceHeading *heading = XFCE_HEADING (object);
 
   /* release the private data */
-  if (G_UNLIKELY (heading->priv->icon != NULL))
-    g_object_unref (G_OBJECT (heading->priv->icon));
+  if (G_UNLIKELY (heading->icon != NULL))
+    g_object_unref (G_OBJECT (heading->icon));
 
-  g_free (heading->priv->icon_name);
-  g_free (heading->priv->subtitle);
-  g_free (heading->priv->title);
+  g_free (heading->icon_name);
+  g_free (heading->subtitle);
+  g_free (heading->title);
 
   (*G_OBJECT_CLASS (_xfce_heading_parent_class)->finalize) (object);
 }
@@ -219,74 +123,6 @@ _xfce_heading_finalize (GObject *object)
 
 
 static void
-_xfce_heading_get_property (GObject    *object,
-                           guint       prop_id,
-                           GValue     *value,
-                           GParamSpec *pspec)
-{
-  XfceHeading *heading = XFCE_HEADING (object);
-
-  switch (prop_id)
-    {
-    case PROP_ICON:
-      g_value_set_object (value, _xfce_heading_get_icon (heading));
-      break;
-
-    case PROP_ICON_NAME:
-      g_value_set_string (value, _xfce_heading_get_icon_name (heading));
-      break;
-
-    case PROP_SUBTITLE:
-      g_value_set_string (value, _xfce_heading_get_subtitle (heading));
-      break;
-
-    case PROP_TITLE:
-      g_value_set_string (value, _xfce_heading_get_title (heading));
-      break;
-
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-      break;
-    }
-}
-
-
-
-static void
-_xfce_heading_set_property (GObject      *object,
-                           guint         prop_id,
-                           const GValue *value,
-                           GParamSpec   *pspec)
-{
-  XfceHeading *heading = XFCE_HEADING (object);
-
-  switch (prop_id)
-    {
-    case PROP_ICON:
-      _xfce_heading_set_icon (heading, g_value_get_object (value));
-      break;
-
-    case PROP_ICON_NAME:
-      _xfce_heading_set_icon_name (heading, g_value_get_string (value));
-      break;
-
-    case PROP_SUBTITLE:
-      _xfce_heading_set_subtitle (heading, g_value_get_string (value));
-      break;
-
-    case PROP_TITLE:
-      _xfce_heading_set_title (heading, g_value_get_string (value));
-      break;
-
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-      break;
-    }
-}
-
-
-
-static void
 _xfce_heading_realize (GtkWidget *widget)
 {
   GdkWindowAttr attributes;
@@ -322,7 +158,7 @@ _xfce_heading_realize (GtkWidget *widget)
 
 static void
 _xfce_heading_size_request (GtkWidget      *widget,
-                           GtkRequisition *requisition)
+                            GtkRequisition *requisition)
 {
   XfceHeading *heading = XFCE_HEADING (widget);
   PangoLayout *layout;
@@ -359,7 +195,7 @@ _xfce_heading_size_request (GtkWidget      *widget,
 
 static void
 _xfce_heading_style_set (GtkWidget *widget,
-                        GtkStyle  *previous_style)
+                         GtkStyle  *previous_style)
 {
   /* check if we're already realized */
   if (GTK_WIDGET_REALIZED (widget))
@@ -373,7 +209,7 @@ _xfce_heading_style_set (GtkWidget *widget,
 
 static gboolean
 _xfce_heading_expose_event (GtkWidget      *widget,
-                           GdkEventExpose *event)
+                            GdkEventExpose *event)
 {
   XfceHeading *heading = XFCE_HEADING (widget);
   PangoLayout *layout;
@@ -421,7 +257,8 @@ _xfce_heading_expose_event (GtkWidget      *widget,
   y = (widget->allocation.height - height) / 2;
 
   /* render the title */
-  gtk_paint_layout (widget->style, widget->window, GTK_WIDGET_STATE (widget), TRUE, &event->area,
+  gtk_paint_layout (widget->style, widget->window,
+                    GTK_WIDGET_STATE (widget), TRUE, &event->area,
                     widget, "heading", (rtl ? x - width : x), y, layout);
 
   /* release the layout */
@@ -456,20 +293,20 @@ _xfce_heading_make_layout (XfceHeading *heading)
 
   /* generate the full text */
   text = g_string_sized_new (128);
-  if (G_LIKELY (heading->priv->title != NULL))
+  if (G_LIKELY (heading->title != NULL))
     {
       /* add the main title */
-      title_length = strlen (heading->priv->title);
-      g_string_append (text, heading->priv->title);
+      title_length = strlen (heading->title);
+      g_string_append (text, heading->title);
     }
-  if (heading->priv->subtitle != NULL && *heading->priv->subtitle != '\0')
+  if (heading->subtitle != NULL && *heading->subtitle != '\0')
     {
       /* add an empty line between the title and the subtitle */
-      if (G_LIKELY (heading->priv->title != NULL))
+      if (G_LIKELY (heading->title != NULL))
         g_string_append (text, "\n");
 
       /* add the subtitle */
-      g_string_append (text, heading->priv->subtitle);
+      g_string_append (text, heading->subtitle);
     }
 
   /* allocate and setup a new layout from the widget's context */
@@ -503,19 +340,19 @@ _xfce_heading_make_pixbuf (XfceHeading *heading)
   GdkPixbuf    *pixbuf = NULL;
   GdkScreen    *screen;
 
-  if (G_UNLIKELY (heading->priv->icon != NULL))
+  if (G_UNLIKELY (heading->icon != NULL))
     {
       /* just use the specified icon */
-      pixbuf = g_object_ref (G_OBJECT (heading->priv->icon));
+      pixbuf = g_object_ref (G_OBJECT (heading->icon));
     }
-  else if (G_LIKELY (heading->priv->icon_name != NULL))
+  else if (G_LIKELY (heading->icon_name != NULL))
     {
       /* determine the icon theme for the current screen */
       screen = gtk_widget_get_screen (GTK_WIDGET (heading));
       icon_theme = gtk_icon_theme_get_for_screen (screen);
 
       /* try to load the icon from the icon theme */
-      pixbuf = gtk_icon_theme_load_icon (icon_theme, heading->priv->icon_name,
+      pixbuf = gtk_icon_theme_load_icon (icon_theme, heading->icon_name,
                                          XFCE_HEADING_ICON_SIZE,
                                          GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
     }
@@ -526,40 +363,6 @@ _xfce_heading_make_pixbuf (XfceHeading *heading)
 
 
 /**
- * _xfce_heading_new:
- *
- * Allocates a new #XfceHeading instance.
- *
- * Return value: the newly allocated #XfceHeading.
- **/
-GtkWidget*
-_xfce_heading_new (void)
-{
-  return g_object_new (XFCE_TYPE_HEADING, NULL);
-}
-
-
-
-/**
- * _xfce_heading_get_icon:
- * @heading : a #XfceHeading.
- *
- * Returns the #GdkPixbuf that was set as icon for
- * @heading or %NULL if no icon is set. The returned
- * #GdkPixbuf object is owned by @heading.
- *
- * Return value: the icon for @heading, or %NULL.
- **/
-static GdkPixbuf*
-_xfce_heading_get_icon (XfceHeading *heading)
-{
-  g_return_val_if_fail (XFCE_IS_HEADING (heading), NULL);
-  return heading->priv->icon;
-}
-
-
-
-/**
  * _xfce_heading_set_icon:
  * @heading : a #XfceHeading.
  * @icon    : the new icon or %NULL.
@@ -572,53 +375,30 @@ void
 _xfce_heading_set_icon (XfceHeading *heading,
                         GdkPixbuf   *icon)
 {
-  g_return_if_fail (XFCE_IS_HEADING (heading));
-  g_return_if_fail (icon == NULL || GDK_IS_PIXBUF (icon));
+  _libxfce4ui_return_if_fail (XFCE_IS_HEADING (heading));
+  _libxfce4ui_return_if_fail (icon == NULL || GDK_IS_PIXBUF (icon));
 
   /* check if we have a new icon */
-  if (G_LIKELY (heading->priv->icon != icon))
+  if (G_LIKELY (heading->icon != icon))
     {
       /* disconnect from the previous icon */
-      if (G_LIKELY (heading->priv->icon != NULL))
-        g_object_unref (G_OBJECT (heading->priv->icon));
+      if (G_LIKELY (heading->icon != NULL))
+        g_object_unref (G_OBJECT (heading->icon));
 
       /* activate the new icon */
-      heading->priv->icon = icon;
+      heading->icon = icon;
 
       /* connect to the new icon */
       if (G_LIKELY (icon != NULL))
         g_object_ref (G_OBJECT (icon));
 
-      /* schedule a resize */
       gtk_widget_queue_resize (GTK_WIDGET (heading));
-
-      /* notify listeners */
-      g_object_notify (G_OBJECT (heading), "icon");
     }
 }
 
 
 
 /**
- * _xfce_heading_get_icon_name:
- * @heading : a #XfceHeading.
- *
- * Returns the icon name previously set by a call to
- * _xfce_heading_set_icon_name() or %NULL if no icon name
- * is set for @heading.
- *
- * Return value: the icon name for @heading, or %NULL.
- **/
-static const gchar*
-_xfce_heading_get_icon_name (XfceHeading *heading)
-{
-  g_return_val_if_fail (XFCE_IS_HEADING (heading), NULL);
-  return heading->priv->icon_name;
-}
-
-
-
-/**
  * _xfce_heading_set_icon_name:
  * @heading   : a #XfceHeading.
  * @icon_name : the new icon name, or %NULL.
@@ -631,38 +411,13 @@ void
 _xfce_heading_set_icon_name (XfceHeading *heading,
                              const gchar *icon_name)
 {
-  g_return_if_fail (XFCE_IS_HEADING (heading));
-
-  /* release the previous icon name */
-  g_free (heading->priv->icon_name);
+  _libxfce4ui_return_if_fail (XFCE_IS_HEADING (heading));
 
   /* activate the new icon name */
-  heading->priv->icon_name = g_strdup (icon_name);
+  g_free (heading->icon_name);
+  heading->icon_name = g_strdup (icon_name);
 
-  /* schedule a resize */
   gtk_widget_queue_resize (GTK_WIDGET (heading));
-
-  /* notify listeners */
-  g_object_notify (G_OBJECT (heading), "icon-name");
-}
-
-
-
-/**
- * _xfce_heading_get_subtitle:
- * @heading : a #XfceHeading.
- *
- * Returns the sub title displayed below the
- * main title of the @heading, or %NULL if
- * no subtitle is set.
- *
- * Return value: the subtitle of @heading, or %NULL.
- **/
-static const gchar*
-_xfce_heading_get_subtitle (XfceHeading *heading)
-{
-  g_return_val_if_fail (XFCE_IS_HEADING (heading), NULL);
-  return heading->priv->subtitle;
 }
 
 
@@ -679,37 +434,14 @@ void
 _xfce_heading_set_subtitle (XfceHeading *heading,
                             const gchar *subtitle)
 {
-  g_return_if_fail (XFCE_IS_HEADING (heading));
-  g_return_if_fail (subtitle == NULL || g_utf8_validate (subtitle, -1, NULL));
-
-  /* release the previous subtitle */
-  g_free (heading->priv->subtitle);
+  _libxfce4ui_return_if_fail (XFCE_IS_HEADING (heading));
+  _libxfce4ui_return_if_fail (subtitle == NULL || g_utf8_validate (subtitle, -1, NULL));
 
   /* activate the new subtitle */
-  heading->priv->subtitle = g_strdup (subtitle);
+  g_free (heading->subtitle);
+  heading->subtitle = g_strdup (subtitle);
 
-  /* schedule a resize */
   gtk_widget_queue_resize (GTK_WIDGET (heading));
-
-  /* notify listeners */
-  g_object_notify (G_OBJECT (heading), "subtitle");
-}
-
-
-
-/**
- * _xfce_heading_get_title:
- * @heading : a #XfceHeading.
- *
- * Returns the title displayed by the @heading.
- *
- * Return value: the title displayed by the @heading.
- **/
-static const gchar*
-_xfce_heading_get_title (XfceHeading *heading)
-{
-  g_return_val_if_fail (XFCE_IS_HEADING (heading), NULL);
-  return heading->priv->title;
 }
 
 
@@ -726,20 +458,14 @@ void
 _xfce_heading_set_title (XfceHeading *heading,
                          const gchar *title)
 {
-  g_return_if_fail (XFCE_IS_HEADING (heading));
-  g_return_if_fail (title == NULL || g_utf8_validate (title, -1, NULL));
-
-  /* release the previous title */
-  g_free (heading->priv->title);
+  _libxfce4ui_return_if_fail (XFCE_IS_HEADING (heading));
+  _libxfce4ui_return_if_fail (title == NULL || g_utf8_validate (title, -1, NULL));
 
   /* activate the new title */
-  heading->priv->title = g_strdup (title);
+  g_free (heading->title);
+  heading->title = g_strdup (title);
 
-  /* schedule a resize */
   gtk_widget_queue_resize (GTK_WIDGET (heading));
-
-  /* notify listeners */
-  g_object_notify (G_OBJECT (heading), "title");
 }
 
 
diff --git a/libxfce4ui/xfce-heading.h b/libxfce4ui/xfce-heading.h
index 4859589..03bd379 100644
--- a/libxfce4ui/xfce-heading.h
+++ b/libxfce4ui/xfce-heading.h
@@ -28,7 +28,6 @@
 
 G_BEGIN_DECLS
 
-typedef struct _XfceHeadingPrivate XfceHeadingPrivate;
 typedef struct _XfceHeadingClass   XfceHeadingClass;
 typedef struct _XfceHeading        XfceHeading;
 
@@ -39,23 +38,8 @@ typedef struct _XfceHeading        XfceHeading;
 #define XFCE_IS_HEADING_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCE_TYPE_HEADING))
 #define XFCE_HEADING_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_HEADING, XfceHeadingClass))
 
-struct _XfceHeadingClass
-{
-  /*< private >*/
-  GtkWidgetClass __parent__;
-};
-
-struct _XfceHeading
-{
-  /*< private >*/
-  GtkWidget           __parent__;
-  XfceHeadingPrivate *priv;
-};
-
 GType      _xfce_heading_get_type      (void) G_GNUC_CONST;
 
-GtkWidget *_xfce_heading_new           (void) G_GNUC_MALLOC;
-
 void       _xfce_heading_set_icon      (XfceHeading *heading,
                                         GdkPixbuf   *icon);
 
diff --git a/libxfce4ui/xfce-titled-dialog.c b/libxfce4ui/xfce-titled-dialog.c
index 385afa1..bde9651 100644
--- a/libxfce4ui/xfce-titled-dialog.c
+++ b/libxfce4ui/xfce-titled-dialog.c
@@ -55,6 +55,7 @@ static void xfce_titled_dialog_set_property   (GObject                *object,
                                                guint                   prop_id,
                                                const GValue           *value,
                                                GParamSpec             *pspec);
+static void xfce_titled_dialog_realize        (GtkWidget              *widget);
 static void xfce_titled_dialog_close          (GtkDialog              *dialog);
 static void xfce_titled_dialog_update_heading (XfceTitledDialog       *titled_dialog);
 
@@ -78,6 +79,7 @@ xfce_titled_dialog_class_init (XfceTitledDialogClass *klass)
   GtkDialogClass *gtkdialog_class;
   GtkBindingSet  *binding_set;
   GObjectClass   *gobject_class;
+  GtkWidgetClass *gtkwidget_class;
 
   /* add our private data to the class */
   g_type_class_add_private (klass, sizeof (XfceTitledDialogPrivate));
@@ -87,6 +89,9 @@ xfce_titled_dialog_class_init (XfceTitledDialogClass *klass)
   gobject_class->get_property = xfce_titled_dialog_get_property;
   gobject_class->set_property = xfce_titled_dialog_set_property;
 
+  gtkwidget_class = GTK_WIDGET_CLASS (klass);
+  gtkwidget_class->realize = xfce_titled_dialog_realize;
+
   gtkdialog_class = GTK_DIALOG_CLASS (klass);
   gtkdialog_class->close = xfce_titled_dialog_close;
 
@@ -131,7 +136,7 @@ xfce_titled_dialog_init (XfceTitledDialog *titled_dialog)
   gtk_widget_show (vbox);
 
   /* add the heading to the window */
-  titled_dialog->priv->heading = _xfce_heading_new ();
+  titled_dialog->priv->heading = g_object_new (XFCE_TYPE_HEADING, NULL);
   gtk_box_pack_start (GTK_BOX (vbox), titled_dialog->priv->heading, FALSE, FALSE, 0);
   gtk_widget_show (titled_dialog->priv->heading);
 
@@ -143,14 +148,6 @@ xfce_titled_dialog_init (XfceTitledDialog *titled_dialog)
   /* add the main dialog box to the new vbox */
   gtk_box_pack_start (GTK_BOX (vbox), GTK_DIALOG (titled_dialog)->vbox, TRUE, TRUE, 0);
   g_object_unref (G_OBJECT (GTK_DIALOG (titled_dialog)->vbox));
-
-  /* make sure to update the heading whenever one of the relevant window properties changes */
-  g_signal_connect (G_OBJECT (titled_dialog), "notify::icon", G_CALLBACK (xfce_titled_dialog_update_heading), NULL);
-  g_signal_connect (G_OBJECT (titled_dialog), "notify::icon-name", G_CALLBACK (xfce_titled_dialog_update_heading), NULL);
-  g_signal_connect (G_OBJECT (titled_dialog), "notify::title", G_CALLBACK (xfce_titled_dialog_update_heading), NULL);
-
-  /* initially update the heading properties */
-  xfce_titled_dialog_update_heading (titled_dialog);
 }
 
 
@@ -214,6 +211,24 @@ xfce_titled_dialog_set_property (GObject      *object,
 
 
 static void
+xfce_titled_dialog_realize (GtkWidget *widget)
+{
+  XfceTitledDialog *titled_dialog = XFCE_TITLED_DIALOG (widget);
+
+  /* make sure to update the heading whenever one of the relevant window properties changes */
+  g_signal_connect (G_OBJECT (titled_dialog), "notify::icon", G_CALLBACK (xfce_titled_dialog_update_heading), NULL);
+  g_signal_connect (G_OBJECT (titled_dialog), "notify::icon-name", G_CALLBACK (xfce_titled_dialog_update_heading), NULL);
+  g_signal_connect (G_OBJECT (titled_dialog), "notify::title", G_CALLBACK (xfce_titled_dialog_update_heading), NULL);
+
+  /* initially update the heading properties */
+  xfce_titled_dialog_update_heading (titled_dialog);
+
+  (*GTK_WIDGET_CLASS (xfce_titled_dialog_parent_class)->realize) (widget);
+}
+
+
+
+static void
 xfce_titled_dialog_close (GtkDialog *dialog)
 {
   GdkEvent *event;



More information about the Xfce4-commits mailing list