diff options
author | Benjamin Otte <otte@redhat.com> | 2013-01-08 14:56:02 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2013-01-08 14:56:02 +0100 |
commit | b495ce5446a0bbf2ed63b5880537779e4b123515 (patch) | |
tree | 311c7542e4adb79d02042102fed07c0ccc958ee0 | |
parent | 9be7e3e2d82396167dd606a77794c412deca4180 (diff) | |
download | gtk+-b495ce5446a0bbf2ed63b5880537779e4b123515.tar.gz |
widget: Give some meaning to "visible"
GtkWidget::visible is required for the widget to:
- have a preferred size other than 0/0
- have a size allocated
- return other values than { -1, -1, 1, 1 } from get_allocation()
This is an experimental patch aiming to make concepts and behaviors
inside GTK more concreate. GtkWidget::visible is now essentially what
CSS does for "display: none".
Note that if you want the effect of CSS's "visibility: hidden", you'll
have to use a GtkNotebook with an empty page as the concept of reserving
space but not drawing anything isn't supported natively in GTK.
-rw-r--r-- | gtk/gtkwidget.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 53f5048dc9..35fa755a71 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -4817,6 +4817,12 @@ gtk_widget_size_allocate (GtkWidget *widget, g_return_if_fail (GTK_IS_WIDGET (widget)); + if (!priv->visible) + { + g_print ("woot, invisible widget allocated!\n"); + return; + } + gtk_widget_push_verify_invariants (widget); #ifdef G_ENABLE_DEBUG @@ -7494,7 +7500,17 @@ void _gtk_widget_set_visible_flag (GtkWidget *widget, gboolean visible) { - widget->priv->visible = visible; + GtkWidgetPrivate *priv = widget->priv; + + priv->visible = visible; + + if (!visible) + { + priv->allocation.x = -1; + priv->allocation.y = -1; + priv->allocation.width = 1; + priv->allocation.height = 1; + } } /** @@ -13513,6 +13529,7 @@ gtk_widget_set_allocation (GtkWidget *widget, GtkWidgetPrivate *priv; g_return_if_fail (GTK_IS_WIDGET (widget)); + g_return_if_fail (gtk_widget_get_visible (widget)); g_return_if_fail (allocation != NULL); priv = widget->priv; |