diff options
author | Timm Bäder <mail@baedert.org> | 2017-07-17 13:21:21 +0200 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2017-07-19 21:27:16 -0400 |
commit | 9bf5def6b729f5ff4d587e6b7525ba05e713cfc9 (patch) | |
tree | b08c560ca71b916ee9d55b09f56d7bbb1c722181 | |
parent | 4a4c7131fd5760daafefe7b87dd2792a23692817 (diff) | |
download | gtk+-9bf5def6b729f5ff4d587e6b7525ba05e713cfc9.tar.gz |
statusbar: Inherit from GtkWidget
-rw-r--r-- | gtk/gtkstatusbar.c | 50 | ||||
-rw-r--r-- | gtk/gtkstatusbar.h | 4 | ||||
-rw-r--r-- | gtk/ui/gtkstatusbar.ui | 4 |
3 files changed, 52 insertions, 6 deletions
diff --git a/gtk/gtkstatusbar.c b/gtk/gtkstatusbar.c index eed2bcc90b..9ffca74435 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 f80e178b22..61ef5cdd4b 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 bfa354b880..b0191a300e 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> |