Mercurial > pidgin
changeset 14292:c111a7e718d0
[gaim-migrate @ 16982]
Make sure new windows fit in the screen.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Tue, 22 Aug 2006 17:02:20 +0000 |
parents | bfe84e01626f |
children | 82373bb6a47a |
files | console/libgnt/gntmain.c console/libgnt/gntwidget.c console/libgnt/test/multiwin.c |
diffstat | 3 files changed, 27 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/console/libgnt/gntmain.c Tue Aug 22 16:43:19 2006 +0000 +++ b/console/libgnt/gntmain.c Tue Aug 22 17:02:20 2006 +0000 @@ -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
--- a/console/libgnt/gntwidget.c Tue Aug 22 16:43:19 2006 +0000 +++ b/console/libgnt/gntwidget.c Tue Aug 22 17:02:20 2006 +0000 @@ -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); }
--- a/console/libgnt/test/multiwin.c Tue Aug 22 16:43:19 2006 +0000 +++ b/console/libgnt/test/multiwin.c Tue Aug 22 17:02:20 2006 +0000 @@ -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",