From: <sa...@us...> - 2006-08-22 17:02:27
|
Revision: 16982 Author: sadrul Date: 2006-08-22 10:02:20 -0700 (Tue, 22 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16982&view=rev Log Message: ----------- Make sure new windows fit in the screen. Modified Paths: -------------- trunk/console/libgnt/gntmain.c trunk/console/libgnt/gntwidget.c trunk/console/libgnt/test/multiwin.c Modified: trunk/console/libgnt/gntmain.c =================================================================== --- trunk/console/libgnt/gntmain.c 2006-08-22 16:43:19 UTC (rev 16981) +++ trunk/console/libgnt/gntmain.c 2006-08-22 17:02:20 UTC (rev 16982) @@ -846,6 +846,8 @@ g_hash_table_replace(nodes, widget, node); + refresh_node(widget, node, NULL); + if (window_list.window) { if ((GNT_IS_BOX(widget) && GNT_BOX(widget)->title) && window_list.window != widget Modified: trunk/console/libgnt/gntwidget.c =================================================================== --- trunk/console/libgnt/gntwidget.c 2006-08-22 16:43:19 UTC (rev 16981) +++ trunk/console/libgnt/gntwidget.c 2006-08-22 17:02:20 UTC (rev 16982) @@ -331,6 +331,30 @@ widget->window = newwin(widget->priv.height + shadow, widget->priv.width + shadow, widget->priv.y, widget->priv.x); + if (widget->window == NULL) /* The size is probably too large for the screen */ + { + int x = widget->priv.x, y = widget->priv.y; + int w = widget->priv.width + shadow, h = widget->priv.height + shadow; + int maxx, maxy; /* Max-X is cool */ + + getmaxyx(stdscr, maxy, maxx); + + if (x + w >= maxx) + x = MAX(0, maxx - w); + if (y + h >= maxy) + y = MAX(0, maxy - h); + + w = MIN(w, maxx); + h = MIN(h, maxy); + + widget->priv.x = x; + widget->priv.y = y; + widget->priv.width = w - shadow; + widget->priv.height = h - shadow; + + widget->window = newwin(widget->priv.height + shadow, widget->priv.width + shadow, + widget->priv.y, widget->priv.x); + } init_widget(widget); } Modified: trunk/console/libgnt/test/multiwin.c =================================================================== --- trunk/console/libgnt/test/multiwin.c 2006-08-22 16:43:19 UTC (rev 16981) +++ trunk/console/libgnt/test/multiwin.c 2006-08-22 17:02:20 UTC (rev 16982) @@ -43,7 +43,7 @@ gnt_box_add_widget(GNT_BOX(box2), gnt_entry_new(NULL)); gnt_widget_show(hbox); - gnt_widget_set_position(box2, 35, 15); + gnt_widget_set_position(box2, 80, 40); gnt_widget_show(box2); gnt_tree_add_row_after(GNT_TREE(tree), "a", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |