[gtk+/wip/baedert/widget-templates: 3/9] infobar: Inherit from GtkWidget
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/baedert/widget-templates: 3/9] infobar: Inherit from GtkWidget
- Date: Sat, 25 Mar 2017 20:18:29 +0000 (UTC)
commit 755dd7ddaafa7398a3f3040c5415c3dd4e1eeb73
Author: Timm Bäder <mail baedert org>
Date: Sat Mar 25 17:18:48 2017 +0100
infobar: Inherit from GtkWidget
gtk/gtkinfobar.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++-
gtk/gtkinfobar.h | 4 +-
gtk/ui/gtkinfobar.ui | 2 +-
3 files changed, 62 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkinfobar.c b/gtk/gtkinfobar.c
index fbd6640..661f95f 100644
--- a/gtk/gtkinfobar.c
+++ b/gtk/gtkinfobar.c
@@ -190,7 +190,7 @@ static void gtk_info_bar_buildable_custom_finished (GtkBuildable *build
gpointer user_data);
-G_DEFINE_TYPE_WITH_CODE (GtkInfoBar, gtk_info_bar, GTK_TYPE_BOX,
+G_DEFINE_TYPE_WITH_CODE (GtkInfoBar, gtk_info_bar, GTK_TYPE_WIDGET,
G_ADD_PRIVATE (GtkInfoBar)
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
gtk_info_bar_buildable_interface_init))
@@ -308,6 +308,58 @@ gtk_info_bar_close (GtkInfoBar *info_bar)
}
static void
+gtk_info_bar_measure (GtkWidget *widget,
+ GtkOrientation orientation,
+ int for_size,
+ int *minimum,
+ int *natural,
+ int *minimum_baseline,
+ int *natural_baseline)
+{
+ GtkInfoBar *self = GTK_INFO_BAR (widget);
+ GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (self);
+
+ gtk_widget_measure (priv->revealer, orientation, for_size,
+ minimum, natural,
+ minimum_baseline, natural_baseline);
+}
+
+static void
+gtk_info_bar_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ GtkInfoBar *self = GTK_INFO_BAR (widget);
+ GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (self);
+
+ gtk_widget_size_allocate (priv->revealer, allocation);
+}
+
+static void
+gtk_info_bar_snapshot (GtkWidget *widget,
+ GtkSnapshot *snapshot)
+{
+ GtkInfoBar *self = GTK_INFO_BAR (widget);
+ GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (self);
+
+ gtk_widget_snapshot_child (widget, priv->revealer, snapshot);
+}
+
+static void
+gtk_info_bar_dispose (GObject *object)
+{
+ GtkInfoBar *self = GTK_INFO_BAR (object);
+ GtkInfoBarPrivate *priv = gtk_info_bar_get_instance_private (self);
+
+ if (priv->revealer)
+ {
+ gtk_widget_unparent (priv->revealer);
+ priv->revealer = NULL;
+ }
+
+ G_OBJECT_CLASS (gtk_info_bar_parent_class)->dispose (object);
+}
+
+static void
gtk_info_bar_class_init (GtkInfoBarClass *klass)
{
GtkWidgetClass *widget_class;
@@ -319,6 +371,11 @@ gtk_info_bar_class_init (GtkInfoBarClass *klass)
object_class->get_property = gtk_info_bar_get_property;
object_class->set_property = gtk_info_bar_set_property;
+ object_class->dispose = gtk_info_bar_dispose;
+
+ widget_class->measure = gtk_info_bar_measure;
+ widget_class->size_allocate = gtk_info_bar_size_allocate;
+ widget_class->snapshot = gtk_info_bar_snapshot;
klass->close = gtk_info_bar_close;
@@ -433,7 +490,7 @@ gtk_info_bar_init (GtkInfoBar *info_bar)
priv = info_bar->priv = gtk_info_bar_get_instance_private (info_bar);
- gtk_widget_set_redraw_on_allocate (widget, TRUE);
+ gtk_widget_set_has_window (GTK_WIDGET (info_bar), FALSE);
/* message-type is a CONSTRUCT property, so we init to a value
* different from its default to trigger its property setter
diff --git a/gtk/gtkinfobar.h b/gtk/gtkinfobar.h
index b4674f9..ca57f4d 100644
--- a/gtk/gtkinfobar.h
+++ b/gtk/gtkinfobar.h
@@ -56,7 +56,7 @@ typedef struct _GtkInfoBar GtkInfoBar;
struct _GtkInfoBar
{
- GtkBox parent;
+ GtkWidget parent_instance;
/*< private > */
GtkInfoBarPrivate *priv;
@@ -65,7 +65,7 @@ struct _GtkInfoBar
struct _GtkInfoBarClass
{
- GtkBoxClass parent_class;
+ GtkWidgetClass parent_class;
/* Signals */
void (* response) (GtkInfoBar *info_bar, gint response_id);
diff --git a/gtk/ui/gtkinfobar.ui b/gtk/ui/gtkinfobar.ui
index 1644442..48633dc 100644
--- a/gtk/ui/gtkinfobar.ui
+++ b/gtk/ui/gtkinfobar.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface domain="gtk30">
<!-- interface-requires gtk+ 3.10 -->
- <template class="GtkInfoBar" parent="GtkBox">
+ <template class="GtkInfoBar" parent="GtkWidget">
<child>
<object class="GtkRevealer" id="revealer">
<property name="visible">1</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]