[gtk+/wip/baedert/drawing: 392/396] statusbar: Inherit from GtkWidget



commit 7b29dd5422fa12ccf700dc6e4642f2de3adc1a06
Author: Timm Bäder <mail baedert org>
Date:   Mon Jul 17 13:21:21 2017 +0200

    statusbar: Inherit from GtkWidget

 gtk/gtkstatusbar.c     |   50 +++++++++++++++++++++++++++++++++++++++++++++++-
 gtk/gtkstatusbar.h     |    4 +-
 gtk/ui/gtkstatusbar.ui |    4 +--
 3 files changed, 52 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkstatusbar.c b/gtk/gtkstatusbar.c
index eed2bcc..9ffca74 100644
--- a/gtk/gtkstatusbar.c
+++ b/gtk/gtkstatusbar.c
@@ -114,13 +114,59 @@ static void     gtk_statusbar_destroy           (GtkWidget         *widget);
 
 static guint              statusbar_signals[SIGNAL_LAST] = { 0 };
 
-G_DEFINE_TYPE_WITH_PRIVATE (GtkStatusbar, gtk_statusbar, GTK_TYPE_BOX)
+G_DEFINE_TYPE_WITH_PRIVATE (GtkStatusbar, gtk_statusbar, GTK_TYPE_WIDGET)
+
+static void
+gtk_statusbar_dispose (GObject *object)
+{
+  GtkStatusbarPrivate *priv = gtk_statusbar_get_instance_private (GTK_STATUSBAR (object));
+
+  if (priv->frame)
+    {
+      gtk_widget_unparent (priv->frame);
+      priv->frame = NULL;
+    }
+
+  G_OBJECT_CLASS (gtk_statusbar_parent_class)->dispose (object);
+}
+
+static void
+gtk_statusbar_measure (GtkWidget      *widget,
+                       GtkOrientation  orientation,
+                       int             for_size,
+                       int            *minimum,
+                       int            *natural,
+                       int            *minimum_baseline,
+                       int            *natural_baseline)
+{
+  GtkStatusbarPrivate *priv = gtk_statusbar_get_instance_private (GTK_STATUSBAR (widget));
+
+  gtk_widget_measure (priv->frame, orientation, for_size,
+                      minimum, natural,
+                      minimum_baseline, natural_baseline);
+}
+
+static void
+gtk_statusbar_size_allocate (GtkWidget           *widget,
+                             const GtkAllocation *allocation,
+                             int                  baseline,
+                             GtkAllocation       *out_clip)
+{
+  GtkStatusbarPrivate *priv = gtk_statusbar_get_instance_private (GTK_STATUSBAR (widget));
+
+  gtk_widget_size_allocate (priv->frame, allocation, baseline, out_clip);
+}
 
 static void
 gtk_statusbar_class_init (GtkStatusbarClass *class)
 {
+  GObjectClass *object_class = G_OBJECT_CLASS (class);
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
 
+  object_class->dispose = gtk_statusbar_dispose;
+
+  widget_class->measure = gtk_statusbar_measure;
+  widget_class->size_allocate = gtk_statusbar_size_allocate;
   widget_class->destroy = gtk_statusbar_destroy;
 
   class->text_pushed = gtk_statusbar_update;
@@ -180,6 +226,8 @@ gtk_statusbar_init (GtkStatusbar *statusbar)
 {
   GtkStatusbarPrivate *priv;
 
+  gtk_widget_set_has_window (GTK_WIDGET (statusbar), FALSE);
+
   statusbar->priv = gtk_statusbar_get_instance_private (statusbar);
   priv = statusbar->priv;
 
diff --git a/gtk/gtkstatusbar.h b/gtk/gtkstatusbar.h
index f80e178..61ef5cd 100644
--- a/gtk/gtkstatusbar.h
+++ b/gtk/gtkstatusbar.h
@@ -48,7 +48,7 @@ typedef struct _GtkStatusbarClass         GtkStatusbarClass;
 
 struct _GtkStatusbar
 {
-  GtkBox parent_widget;
+  GtkWidget parent_instance;
 
   /*< private >*/
   GtkStatusbarPrivate *priv;
@@ -56,7 +56,7 @@ struct _GtkStatusbar
 
 struct _GtkStatusbarClass
 {
-  GtkBoxClass parent_class;
+  GtkWidgetClass parent_class;
 
   gpointer reserved;
 
diff --git a/gtk/ui/gtkstatusbar.ui b/gtk/ui/gtkstatusbar.ui
index bfa354b..b0191a3 100644
--- a/gtk/ui/gtkstatusbar.ui
+++ b/gtk/ui/gtkstatusbar.ui
@@ -1,8 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface domain="gtk30">
   <!-- interface-requires gtk+ 3.10 -->
-  <template class="GtkStatusbar" parent="GtkBox">
-    <property name="spacing">2</property>
+  <template class="GtkStatusbar" parent="GtkWidget">
     <property name="hexpand">0</property>
     <child>
       <object class="GtkFrame" id="frame">
@@ -11,7 +10,6 @@
         <child>
           <object class="GtkBox" id="message_area">
             <property name="spacing">4</property>
-            <property name="margin">4</property>
             <child>
               <object class="GtkLabel" id="label">
                 <property name="halign">start</property>


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