Added dlg_set_top_widget() function

...to move widget to the top of widget list and make it current.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2011-04-23 16:51:53 +04:00
parent 6ad4b2466b
commit fe34f89a19
2 changed files with 33 additions and 2 deletions

View File

@ -1065,7 +1065,7 @@ dlg_select_by_id (const Dlg_head * h, unsigned long id)
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
/* /**
* Try to select widget in the dialog. * Try to select widget in the dialog.
*/ */
@ -1078,6 +1078,36 @@ dlg_select_widget (void *w)
do_select_widget (h, g_list_find (h->widgets, widget), SELECT_EXACT); do_select_widget (h, g_list_find (h->widgets, widget), SELECT_EXACT);
} }
/* --------------------------------------------------------------------------------------------- */
/**
* Set widget at top of widget list and make it current.
*/
void
dlg_set_top_widget (void *w)
{
Widget *widget = (Widget *) w;
Dlg_head *h = widget->owner;
GList *l;
l = g_list_find (h->widgets, w);
if (l == NULL)
abort (); /* widget is not in dialog, this should not happen */
/* unfocus prevoius widget and focus current one before widget reordering */
if (h->state == DLG_ACTIVE)
do_select_widget (h, l, SELECT_EXACT);
/* widget reordering */
h->widgets = g_list_remove_link (h->widgets, l);
if ((h->flags & DLG_REVERSE) != 0)
h->widgets = g_list_concat (l, h->widgets);
else
h->widgets = g_list_concat (h->widgets, l);
h->current = l;
}
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
/** Try to select previous widget in the tab order */ /** Try to select previous widget in the tab order */

View File

@ -201,7 +201,8 @@ void dlg_erase (Dlg_head * h);
void dlg_stop (Dlg_head * h); void dlg_stop (Dlg_head * h);
/* Widget selection */ /* Widget selection */
void dlg_select_widget (void *widget); void dlg_select_widget (void *w);
void dlg_set_top_widget (void *w);
void dlg_one_up (Dlg_head * h); void dlg_one_up (Dlg_head * h);
void dlg_one_down (Dlg_head * h); void dlg_one_down (Dlg_head * h);
gboolean dlg_focus (Dlg_head * h); gboolean dlg_focus (Dlg_head * h);