Mercurial > pidgin.yaz
diff console/libgnt/gntbox.c @ 13855:5b288502a382
[gaim-migrate @ 16314]
New widget GntEntry. It's mostly functional.
Some minor improvements to the box-packing code.
Minor improvements to the skeleton code for gnt, and completely change the name from my initial choice of GN (Glib and Ncurses) to GNT (Gaim Ncurses Toolkit).
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Fri, 23 Jun 2006 06:24:25 +0000 |
parents | a4c30c1d9de8 |
children | c1e3f7c75c3f |
line wrap: on
line diff
--- a/console/libgnt/gntbox.c Fri Jun 23 00:57:30 2006 +0000 +++ b/console/libgnt/gntbox.c Fri Jun 23 06:24:25 2006 +0000 @@ -53,15 +53,13 @@ w = h = 0; max = -1; - curx = widget->priv.x + 1; - cury = widget->priv.y + 1; + curx = widget->priv.x; + cury = widget->priv.y; if (!(GNT_WIDGET_FLAGS(widget) & GNT_WIDGET_NO_BORDER)) { has_border = TRUE; - curx += box->pad; - cury += box->pad; - if (!box->vertical) - curx++; + curx += 1; + cury += 1; } for (iter = box->list; iter; iter = iter->next) @@ -84,7 +82,7 @@ if (has_border) { - curx += 2; + curx += 1; cury += 1; max += 2; } @@ -146,16 +144,44 @@ DEBUG; } +/* Ensures that the current widget can take focus */ +static void +ensure_active(GntBox *box) +{ + int investigated = 0; + int total; + + if (box->active == NULL) + box->active = box->list; + + total = g_list_length(box->list); + + while (box->active && !GNT_WIDGET_IS_FLAG_SET(box->active->data, GNT_WIDGET_CAN_TAKE_FOCUS)) + { + box->active = box->active->next; + investigated++; + } + + /* Rotate if necessary */ + if (!box->active && investigated < total) + { + box->active = box->list; + while (investigated < total && !GNT_WIDGET_IS_FLAG_SET(box->active->data, GNT_WIDGET_CAN_TAKE_FOCUS)) + { + box->active = box->active->next; + investigated++; + } + } +} + static gboolean gnt_box_key_pressed(GntWidget *widget, const char *text) { GntBox *box = GNT_BOX(widget); - /*if (box->list == NULL)*/ - /*return FALSE;*/ - + ensure_active(box); if (box->active == NULL) - box->active = box->list; + return FALSE; if (gnt_widget_key_pressed(box->active->data, text)) return TRUE;