]> git.draconx.ca Git - aspectbin.git/commitdiff
Add fill property.
authorNick Bowler <nbowler@draconx.ca>
Sun, 15 Mar 2009 04:49:14 +0000 (00:49 -0400)
committerNick Bowler <nbowler@draconx.ca>
Sun, 15 Mar 2009 04:49:14 +0000 (00:49 -0400)
aspectbin.c
aspectbin.h

index 8ab752c7b4d055e02255ec0635523ac71ea8b66f..c75fe3c549ae188305c91f4aa86e65e108c63177 100644 (file)
@@ -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;
index 5def388aa70997e0cd5c125f1a294913dba0c73a..65113f7182e05e24024ab5a1902a7fea36753125 100644 (file)
@@ -22,6 +22,7 @@ struct AspectBin {
 
        gfloat     align;
        gboolean   constrain;
+       gboolean   fill;
 };
 
 struct AspectBinClass {