diff --git a/lib/widget/dialog.c b/lib/widget/dialog.c index 2b062880b..d2ae51877 100644 --- a/lib/widget/dialog.c +++ b/lib/widget/dialog.c @@ -1065,7 +1065,7 @@ dlg_select_by_id (const Dlg_head * h, unsigned long id) } /* --------------------------------------------------------------------------------------------- */ -/* +/** * 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); } +/* --------------------------------------------------------------------------------------------- */ + +/** + * 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 */ diff --git a/lib/widget/dialog.h b/lib/widget/dialog.h index b13ed8eb7..db2cdf353 100644 --- a/lib/widget/dialog.h +++ b/lib/widget/dialog.h @@ -201,7 +201,8 @@ void dlg_erase (Dlg_head * h); void dlg_stop (Dlg_head * h); /* 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_down (Dlg_head * h); gboolean dlg_focus (Dlg_head * h);