comparison finch/libgnt/gntbox.c @ 15945:92fa7d6e75b0

A few more fixes for resizing.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Tue, 27 Mar 2007 03:50:04 +0000
parents 0e3a8505ebbe
children 8410511f4dbb 05d7fe2320a9
comparison
equal deleted inserted replaced
15944:1071320641b9 15945:92fa7d6e75b0
350 { 350 {
351 GList *iter; 351 GList *iter;
352 GntBox *box = GNT_BOX(widget); 352 GntBox *box = GNT_BOX(widget);
353 int wchange, hchange; 353 int wchange, hchange;
354 354
355 if (widget->priv.width != width && !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_GROW_X))
356 return FALSE;
357 if (widget->priv.height != height && !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_GROW_Y))
358 return FALSE;
359
360 if (!box->list) 355 if (!box->list)
361 return TRUE; 356 return TRUE;
362 357
363 wchange = widget->priv.width - width; 358 wchange = widget->priv.width - width;
364 hchange = widget->priv.height - height; 359 hchange = widget->priv.height - height;
385 int tw, th; 380 int tw, th;
386 if (i == iter) continue; 381 if (i == iter) continue;
387 gnt_widget_get_size(GNT_WIDGET(i->data), &tw, &th); 382 gnt_widget_get_size(GNT_WIDGET(i->data), &tw, &th);
388 if (box->vertical) 383 if (box->vertical)
389 { 384 {
390 if (!gnt_widget_confirm_size(i->data, tw - wchange, th)) 385 if (!gnt_widget_confirm_size(i->data, tw - wchange, th)) {
391 return FALSE; 386 /* If we are decreasing the size and the widget is going
387 * to be too large to fit into the box, then do not allow
388 * resizing. */
389 if (wchange > 0 && tw >= widget->priv.width)
390 return FALSE;
391 }
392 } 392 }
393 else 393 else
394 { 394 {
395 if (!gnt_widget_confirm_size(i->data, tw, th - hchange)) 395 if (!gnt_widget_confirm_size(i->data, tw, th - hchange)) {
396 if (hchange > 0 && th >= widget->priv.height)
397 return FALSE;
396 return FALSE; 398 return FALSE;
399 }
397 } 400 }
398 } 401 }
399 #if 0 402 #if 0
400 gnt_widget_set_size(wid, w - wchange, h - hchange); 403 gnt_widget_set_size(wid, w - wchange, h - hchange);
401 if (box->vertical) 404 if (box->vertical)
560 563
561 void gnt_box_add_widget(GntBox *b, GntWidget *widget) 564 void gnt_box_add_widget(GntBox *b, GntWidget *widget)
562 { 565 {
563 b->list = g_list_append(b->list, widget); 566 b->list = g_list_append(b->list, widget);
564 widget->parent = GNT_WIDGET(b); 567 widget->parent = GNT_WIDGET(b);
565
566 if (b->vertical)
567 {
568 if (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_GROW_X))
569 GNT_WIDGET_UNSET_FLAGS(GNT_WIDGET(b), GNT_WIDGET_GROW_X);
570 }
571 else
572 {
573 if (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_GROW_Y))
574 GNT_WIDGET_UNSET_FLAGS(GNT_WIDGET(b), GNT_WIDGET_GROW_Y);
575 }
576 } 568 }
577 569
578 void gnt_box_set_title(GntBox *b, const char *title) 570 void gnt_box_set_title(GntBox *b, const char *title)
579 { 571 {
580 char *prev = b->title; 572 char *prev = b->title;