From 02883c61ed395cbbf25e66e40b8238e1a1b31cc6 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Sun, 3 May 2009 17:01:03 +0000 Subject: [PATCH] Use the sublime CLAMP() macro git-svn-id: http://lassie.dyndns-server.com/svn/gargoyle-gtk@44 ddfedd41-794f-dd11-ae45-00112f111e67 --- src/chimara-glk.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/chimara-glk.c b/src/chimara-glk.c index ad50b0f..73c1287 100644 --- a/src/chimara-glk.c +++ b/src/chimara-glk.c @@ -263,24 +263,16 @@ allocate_recurse(winid_t win, GtkAllocation *allocation, guint spacing) switch(win->split_method & winmethod_DirMask) { case winmethod_Left: - child1.width = win->constraint_size * win->key_window->unit_width; - if(child1.width > allocation->width - spacing) - child1.width = allocation->width - spacing; + child1.width = CLAMP(win->constraint_size * win->key_window->unit_width, 0, allocation->width - spacing); break; case winmethod_Right: - child2.width = win->constraint_size * win->key_window->unit_width; - if(child2.width > allocation->width - spacing) - child2.width = allocation->width - spacing; + child2.width = CLAMP(win->constraint_size * win->key_window->unit_width, 0, allocation->width - spacing); break; case winmethod_Above: - child1.height = win->constraint_size * win->key_window->unit_height; - if(child1.height > allocation->height - spacing) - child1.height = allocation->height - spacing; + child1.height = CLAMP(win->constraint_size * win->key_window->unit_height, 0, allocation->height - spacing); break; case winmethod_Below: - child2.height = win->constraint_size * win->key_window->unit_height; - if(child2.height > allocation->height - spacing) - child2.height = allocation->height - spacing; + child2.height = CLAMP(win->constraint_size * win->key_window->unit_height, 0, allocation->height - spacing); break; } } @@ -359,12 +351,8 @@ chimara_glk_size_allocate(GtkWidget *widget, GtkAllocation *allocation) GtkAllocation child; child.x = allocation->x + GTK_CONTAINER(widget)->border_width; child.y = allocation->y + GTK_CONTAINER(widget)->border_width; - child.width = allocation->width - 2 * GTK_CONTAINER(widget)->border_width; - child.height = allocation->height - 2 * GTK_CONTAINER(widget)->border_width; - if(child.width < 0) - child.width = 0; - if(child.height < 0) - child.height = 0; + child.width = CLAMP(allocation->width - 2 * GTK_CONTAINER(widget)->border_width, 0, allocation->width); + child.height = CLAMP(allocation->height - 2 * GTK_CONTAINER(widget)->border_width, 0, allocation->height); allocate_recurse(priv->root_window->data, &child, priv->spacing); } } -- 2.30.2