From: Nick Bowler Date: Sun, 15 Mar 2009 04:49:14 +0000 (-0400) Subject: Add fill property. X-Git-Url: https://git.draconx.ca/gitweb/aspectbin.git/commitdiff_plain/33ab452e00592c8ea9d51fe6be30b8401567b0f7 Add fill property. --- diff --git a/aspectbin.c b/aspectbin.c index 8ab752c..c75fe3c 100644 --- a/aspectbin.c +++ b/aspectbin.c @@ -4,6 +4,7 @@ enum { PROP_0, PROP_CONSTRAIN, + PROP_FILL, }; static void aspect_bin_size_request(GtkWidget *, GtkRequisition *); @@ -28,6 +29,7 @@ static void aspect_bin_init(AspectBin *abin) abin->ratio = 1; abin->align = 0; abin->constrain = FALSE; + abin->fill = TRUE; } static void aspect_bin_class_init(AspectBinClass *class) @@ -47,11 +49,18 @@ static void aspect_bin_class_init(AspectBinClass *class) object_class->set_property = aspect_bin_set_property; object_class->get_property = aspect_bin_get_property; - g_object_class_install_property(object_class, PROP_CONSTRAIN, + g_object_class_install_property(object_class, + PROP_FILL, + g_param_spec_boolean("fill", + "Fill", + "Allocate all remaining space to the side.", + TRUE, + G_PARAM_READWRITE)); + g_object_class_install_property(object_class, + PROP_CONSTRAIN, g_param_spec_boolean("constrain", "Constrain", - "TRUE if side child should expand only as much as the" - " body", + "Only expand the side to be as large as the body.", FALSE, G_PARAM_READWRITE)); } @@ -73,6 +82,10 @@ static void aspect_bin_set_property(GObject *object, abin->constrain = g_value_get_boolean(value); gtk_widget_queue_resize(GTK_WIDGET(abin)); break; + case PROP_FILL: + abin->fill = g_value_get_boolean(value); + gtk_widget_queue_resize(GTK_WIDGET(abin)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); } @@ -89,6 +102,9 @@ static void aspect_bin_get_property(GObject *object, case PROP_CONSTRAIN: g_value_set_boolean(value, abin->constrain); break; + case PROP_FILL: + g_value_set_boolean(value, abin->fill); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); } @@ -196,11 +212,15 @@ aspect_bin_size_allocate(GtkWidget *widget, GtkAllocation *allocation) } csize.width = allocation->width - asize.width; - csize.height = MIN(allocation->height, creq.height); - if (abin->constrain) { - csize.height = MAX(csize.height, asize.height); - } csize.x = asize.width; + + if (abin->fill && abin->constrain) { + csize.height = asize.height; + } else if (abin->fill) { + csize.height = allocation->height; + } else { + csize.height = creq.height; + } } csize.y = (allocation->height - csize.height) * abin->align + 0.5; diff --git a/aspectbin.h b/aspectbin.h index 5def388..65113f7 100644 --- a/aspectbin.h +++ b/aspectbin.h @@ -22,6 +22,7 @@ struct AspectBin { gfloat align; gboolean constrain; + gboolean fill; }; struct AspectBinClass {