statusbar: Inherit from GtkWidget

This commit is contained in:
Timm Bäder 2017-07-17 13:21:21 +02:00 committed by Matthias Clasen
parent 4a4c7131fd
commit 9bf5def6b7
3 changed files with 52 additions and 6 deletions

View File

@ -114,13 +114,59 @@ static void gtk_statusbar_destroy (GtkWidget *widget);
static guint statusbar_signals[SIGNAL_LAST] = { 0 }; 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 static void
gtk_statusbar_class_init (GtkStatusbarClass *class) gtk_statusbar_class_init (GtkStatusbarClass *class)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_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; widget_class->destroy = gtk_statusbar_destroy;
class->text_pushed = gtk_statusbar_update; class->text_pushed = gtk_statusbar_update;
@ -180,6 +226,8 @@ gtk_statusbar_init (GtkStatusbar *statusbar)
{ {
GtkStatusbarPrivate *priv; GtkStatusbarPrivate *priv;
gtk_widget_set_has_window (GTK_WIDGET (statusbar), FALSE);
statusbar->priv = gtk_statusbar_get_instance_private (statusbar); statusbar->priv = gtk_statusbar_get_instance_private (statusbar);
priv = statusbar->priv; priv = statusbar->priv;

View File

@ -48,7 +48,7 @@ typedef struct _GtkStatusbarClass GtkStatusbarClass;
struct _GtkStatusbar struct _GtkStatusbar
{ {
GtkBox parent_widget; GtkWidget parent_instance;
/*< private >*/ /*< private >*/
GtkStatusbarPrivate *priv; GtkStatusbarPrivate *priv;
@ -56,7 +56,7 @@ struct _GtkStatusbar
struct _GtkStatusbarClass struct _GtkStatusbarClass
{ {
GtkBoxClass parent_class; GtkWidgetClass parent_class;
gpointer reserved; gpointer reserved;

View File

@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<interface domain="gtk30"> <interface domain="gtk30">
<!-- interface-requires gtk+ 3.10 --> <!-- interface-requires gtk+ 3.10 -->
<template class="GtkStatusbar" parent="GtkBox"> <template class="GtkStatusbar" parent="GtkWidget">
<property name="spacing">2</property>
<property name="hexpand">0</property> <property name="hexpand">0</property>
<child> <child>
<object class="GtkFrame" id="frame"> <object class="GtkFrame" id="frame">
@ -11,7 +10,6 @@
<child> <child>
<object class="GtkBox" id="message_area"> <object class="GtkBox" id="message_area">
<property name="spacing">4</property> <property name="spacing">4</property>
<property name="margin">4</property>
<child> <child>
<object class="GtkLabel" id="label"> <object class="GtkLabel" id="label">
<property name="halign">start</property> <property name="halign">start</property>