[gtk+] Implement gtk_statusbar_get_message_area and "message_area" child



commit 0bc668056449e5a3502eef9d3cfdc3b6e5f201b9
Author: Christian Dywan <christian twotoasts de>
Date:   Thu Nov 12 18:57:37 2009 +0100

    Implement gtk_statusbar_get_message_area and "message_area" child
    
    Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=594535

 gtk/gtk.symbols    |    1 +
 gtk/gtkstatusbar.c |   56 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 gtk/gtkstatusbar.h |    2 +
 3 files changed, 57 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index 1582eaf..ba109d9 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -3841,6 +3841,7 @@ gtk_spinner_stop
 #if IN_FILE(__GTK_STATUSBAR_C__)
 gtk_statusbar_get_context_id
 gtk_statusbar_get_has_resize_grip
+gtk_statusbar_get_message_area
 gtk_statusbar_get_type G_GNUC_CONST
 gtk_statusbar_new
 gtk_statusbar_pop
diff --git a/gtk/gtkstatusbar.c b/gtk/gtkstatusbar.c
index 0a494c9..eda9caa 100644
--- a/gtk/gtkstatusbar.c
+++ b/gtk/gtkstatusbar.c
@@ -33,6 +33,7 @@
 #include "gtkwindow.h"
 #include "gtkprivate.h"
 #include "gtkintl.h"
+#include "gtkbuildable.h"
 #include "gtkalias.h"
 
 typedef struct _GtkStatusbarMsg GtkStatusbarMsg;
@@ -57,6 +58,10 @@ enum
   PROP_HAS_RESIZE_GRIP
 };
 
+static void     gtk_statusbar_buildable_interface_init    (GtkBuildableIface *iface);
+static GObject *gtk_statusbar_buildable_get_internal_child (GtkBuildable *buildable,
+                                                            GtkBuilder   *builder,
+                                                            const gchar  *childname);
 static void     gtk_statusbar_destroy           (GtkObject         *object);
 static void     gtk_statusbar_update            (GtkStatusbar      *statusbar,
 						 guint              context_id,
@@ -96,7 +101,9 @@ static void     label_selectable_changed        (GtkWidget         *label,
 
 static guint              statusbar_signals[SIGNAL_LAST] = { 0 };
 
-G_DEFINE_TYPE (GtkStatusbar, gtk_statusbar, GTK_TYPE_HBOX)
+G_DEFINE_TYPE_WITH_CODE (GtkStatusbar, gtk_statusbar, GTK_TYPE_HBOX,
+                         G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
+                                                gtk_statusbar_buildable_interface_init));
 
 static void
 gtk_statusbar_class_init (GtkStatusbarClass *class)
@@ -194,6 +201,7 @@ static void
 gtk_statusbar_init (GtkStatusbar *statusbar)
 {
   GtkBox *box;
+  GtkWidget *message_area;
   GtkShadowType shadow_type;
   
   box = GTK_BOX (statusbar);
@@ -212,13 +220,17 @@ gtk_statusbar_init (GtkStatusbar *statusbar)
   gtk_box_pack_start (box, statusbar->frame, TRUE, TRUE, 0);
   gtk_widget_show (statusbar->frame);
 
+  message_area = gtk_hbox_new (FALSE, 4);
+  gtk_container_add (GTK_CONTAINER (statusbar->frame), message_area);
+  gtk_widget_show (message_area);
+
   statusbar->label = gtk_label_new ("");
   gtk_label_set_single_line_mode (GTK_LABEL (statusbar->label), TRUE);
   gtk_misc_set_alignment (GTK_MISC (statusbar->label), 0.0, 0.5);
   g_signal_connect (statusbar->label, "notify::selectable",
 		    G_CALLBACK (label_selectable_changed), statusbar);
   gtk_label_set_ellipsize (GTK_LABEL (statusbar->label), PANGO_ELLIPSIZE_END);
-  gtk_container_add (GTK_CONTAINER (statusbar->frame), statusbar->label);
+  gtk_container_add (GTK_CONTAINER (message_area), statusbar->label);
   gtk_widget_show (statusbar->label);
 
   statusbar->seq_context_id = 1;
@@ -227,6 +239,28 @@ gtk_statusbar_init (GtkStatusbar *statusbar)
   statusbar->keys = NULL;
 }
 
+static GtkBuildableIface *parent_buildable_iface;
+
+static void
+gtk_statusbar_buildable_interface_init (GtkBuildableIface *iface)
+{
+  parent_buildable_iface = g_type_interface_peek_parent (iface);
+  iface->get_internal_child = gtk_statusbar_buildable_get_internal_child;
+}
+
+static GObject *
+gtk_statusbar_buildable_get_internal_child (GtkBuildable *buildable,
+                                            GtkBuilder   *builder,
+                                            const gchar  *childname)
+{
+    if (strcmp (childname, "message_area") == 0)
+      return G_OBJECT (gtk_bin_get_child (GTK_BIN (GTK_STATUSBAR (buildable)->frame)));
+
+    return parent_buildable_iface->get_internal_child (buildable,
+                                                       builder,
+                                                       childname);
+}
+
 /**
  * gtk_statusbar_new:
  *
@@ -482,6 +516,24 @@ gtk_statusbar_get_has_resize_grip (GtkStatusbar *statusbar)
   return statusbar->has_resize_grip;
 }
 
+/**
+ * gtk_statusbar_get_message_area:
+ * @statusbar: a #GtkStatusBar
+ *
+ * Retrieves the box containing the label widget.
+ *
+ * Returns: a #GtkBox
+ *
+ * Since: 2.20
+ */
+GtkWidget*
+gtk_statusbar_get_message_area (GtkStatusbar *statusbar)
+{
+  g_return_val_if_fail (GTK_IS_STATUSBAR (statusbar), NULL);
+
+  return gtk_bin_get_child (GTK_BIN (statusbar->frame));
+}
+
 static void
 gtk_statusbar_destroy (GtkObject *object)
 {
diff --git a/gtk/gtkstatusbar.h b/gtk/gtkstatusbar.h
index 3ca102b..ff05976 100644
--- a/gtk/gtkstatusbar.h
+++ b/gtk/gtkstatusbar.h
@@ -107,6 +107,8 @@ void     gtk_statusbar_set_has_resize_grip (GtkStatusbar *statusbar,
 					    gboolean      setting);
 gboolean gtk_statusbar_get_has_resize_grip (GtkStatusbar *statusbar);
 
+GtkWidget* gtk_statusbar_get_message_area  (GtkStatusbar *statusbar);
+
 G_END_DECLS
 
 #endif /* __GTK_STATUSBAR_H__ */



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