diff --git a/lib/widget/dialog.c b/lib/widget/dialog.c index b5e73bf83..097b79a33 100644 --- a/lib/widget/dialog.c +++ b/lib/widget/dialog.c @@ -514,8 +514,7 @@ dlg_init (WDialog * h) } /* Select the first widget that takes focus */ - while (g->current != NULL && !widget_get_options (WIDGET (g->current->data), WOP_SELECTABLE) - && !widget_get_state (WIDGET (g->current->data), WST_DISABLED)) + while (g->current != NULL && !widget_is_focusable (g->current->data)) group_set_current_widget_next (g); widget_set_state (wh, WST_ACTIVE, TRUE); diff --git a/lib/widget/group.c b/lib/widget/group.c index b0dace41c..7bad74081 100644 --- a/lib/widget/group.c +++ b/lib/widget/group.c @@ -113,15 +113,12 @@ group_select_next_or_prev (WGroup * g, gboolean next) if (g->widgets != NULL && g->current != NULL) { GList *l = g->current; - Widget *w; do { l = group_get_next_or_prev_of (l, next); - w = WIDGET (l->data); } - while ((widget_get_state (w, WST_DISABLED) || !widget_get_options (w, WOP_SELECTABLE)) - && l != g->current); + while (!widget_is_focusable (l->data) && l != g->current); widget_select (l->data); } diff --git a/lib/widget/widget-common.c b/lib/widget/widget-common.c index 7abd59c64..6802ebf43 100644 --- a/lib/widget/widget-common.c +++ b/lib/widget/widget-common.c @@ -567,8 +567,7 @@ widget_replace (Widget * old_w, Widget * new_w) GList *l; for (l = group_get_widget_next_of (holder); - !widget_get_options (WIDGET (l->data), WOP_SELECTABLE) - && !widget_get_state (WIDGET (l->data), WST_DISABLED); + widget_is_focusable (WIDGET (l->data); l = group_get_widget_next_of (l)) ; @@ -589,6 +588,14 @@ widget_replace (Widget * old_w, Widget * new_w) widget_draw (new_w); } +/* --------------------------------------------------------------------------------------------- */ + +gboolean +widget_is_focusable (const Widget * w) +{ + return (widget_get_options (w, WOP_SELECTABLE) && !widget_get_state (w, WST_DISABLED)); +} + /* --------------------------------------------------------------------------------------------- */ /** * Select specified widget in it's owner. diff --git a/lib/widget/widget-common.h b/lib/widget/widget-common.h index a20bcd671..63ec55908 100644 --- a/lib/widget/widget-common.h +++ b/lib/widget/widget-common.h @@ -213,6 +213,7 @@ void widget_erase (Widget * w); gboolean widget_is_active (const void *w); gboolean widget_overlapped (const Widget * a, const Widget * b); void widget_replace (Widget * old, Widget * new); +gboolean widget_is_focusable (const Widget * w); void widget_select (Widget * w); void widget_set_bottom (Widget * w);