* dlg.c: DLG_BACKWARD now affects how the dialog is populated by
widgets, not the runtime behavior. (init_dlg): Don't change current widget. This allows using dlg_select_widget() before the dialog is run. * dlg.h: Remove initfocus field. * wtools.c (query_dialog): Use dlg_select_widget(), not initfocus to set the initial widget.
Этот коммит содержится в:
родитель
7c143915b4
Коммит
997a8ddd8b
@ -1,5 +1,13 @@
|
||||
2003-09-12 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* dlg.c: DLG_BACKWARD now affects how the dialog is populated by
|
||||
widgets, not the runtime behavior.
|
||||
(init_dlg): Don't change current widget. This allows using
|
||||
dlg_select_widget() before the dialog is run.
|
||||
* dlg.h: Remove initfocus field.
|
||||
* wtools.c (query_dialog): Use dlg_select_widget(), not
|
||||
initfocus to set the initial widget.
|
||||
|
||||
* widget.c (input_callback): Don't handle Enter.
|
||||
Requested by Ali Akcaagac <aliakc@web.de>
|
||||
|
||||
|
27
src/dlg.c
27
src/dlg.c
@ -230,8 +230,8 @@ set_idle_proc (Dlg_head *d, int enable)
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert widget to dialog before current widget and make the new widget
|
||||
* current. Return widget number.
|
||||
* Insert widget to dialog before current widget. For dialogs populated
|
||||
* from the bottom, make the widget current. Return widget number.
|
||||
*/
|
||||
int
|
||||
add_widget (Dlg_head *h, void *w)
|
||||
@ -262,7 +262,9 @@ add_widget (Dlg_head *h, void *w)
|
||||
h->first = new_item;
|
||||
}
|
||||
|
||||
h->current = new_item;
|
||||
if (!(h->flags & DLG_BACKWARD) || !h->current)
|
||||
h->current = new_item;
|
||||
|
||||
return new_item->dlg_id;
|
||||
}
|
||||
|
||||
@ -323,18 +325,14 @@ dlg_unfocus (Dlg_head *h)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void select_a_widget (Dlg_head *h, int down)
|
||||
static void
|
||||
select_a_widget (Dlg_head *h, int down)
|
||||
{
|
||||
int dir_forward = !(h->flags & DLG_BACKWARD);
|
||||
|
||||
if (!h->current)
|
||||
return;
|
||||
|
||||
if (!down)
|
||||
dir_forward = !dir_forward;
|
||||
return;
|
||||
|
||||
do {
|
||||
if (dir_forward)
|
||||
if (down)
|
||||
h->current = h->current->next;
|
||||
else
|
||||
h->current = h->current->prev;
|
||||
@ -683,13 +681,6 @@ void init_dlg (Dlg_head *h)
|
||||
push_refresh (dlg_refresh, h, refresh_mode);
|
||||
h->refresh_pushed = 1;
|
||||
|
||||
/* Initialize direction */
|
||||
if (h->flags & DLG_BACKWARD)
|
||||
h->current = h->first;
|
||||
|
||||
if (h->initfocus != NULL)
|
||||
h->current = h->initfocus;
|
||||
|
||||
h->previous_dialog = current_dlg;
|
||||
current_dlg = h;
|
||||
|
||||
|
@ -87,7 +87,6 @@ typedef struct Dlg_head {
|
||||
int count; /* number of widgets */
|
||||
struct Widget_Item *current, *first;
|
||||
dlg_cb_fn callback;
|
||||
struct Widget_Item *initfocus;
|
||||
void *previous_dialog; /* Pointer to the previously running Dlg_head */
|
||||
|
||||
} Dlg_head;
|
||||
|
16
src/wtools.c
16
src/wtools.c
@ -115,6 +115,8 @@ query_dialog (char *header, char *text, int flags, int count, ...)
|
||||
{
|
||||
va_list ap;
|
||||
Dlg_head *query_dlg;
|
||||
WButton *button;
|
||||
WButton *defbutton = NULL;
|
||||
int win_len = 0;
|
||||
int i;
|
||||
int result = -1;
|
||||
@ -155,7 +157,6 @@ query_dialog (char *header, char *text, int flags, int count, ...)
|
||||
"[QueryBox]", header, DLG_BACKWARD);
|
||||
|
||||
if (count > 0) {
|
||||
|
||||
cols = (cols - win_len - 2) / 2 + 2;
|
||||
va_start (ap, count);
|
||||
for (i = 0; i < count; i++) {
|
||||
@ -163,17 +164,22 @@ query_dialog (char *header, char *text, int flags, int count, ...)
|
||||
xpos = strlen (cur_name) + 6;
|
||||
if (strchr (cur_name, '&') != NULL)
|
||||
xpos--;
|
||||
add_widget (query_dlg,
|
||||
button_new (lines - 3, cols, B_USER + i,
|
||||
NORMAL_BUTTON, cur_name, 0));
|
||||
|
||||
button =
|
||||
button_new (lines - 3, cols, B_USER + i, NORMAL_BUTTON,
|
||||
cur_name, 0);
|
||||
add_widget (query_dlg, button);
|
||||
cols += xpos;
|
||||
if (i == sel_pos)
|
||||
query_dlg->initfocus = query_dlg->current;
|
||||
defbutton = button;
|
||||
}
|
||||
va_end (ap);
|
||||
|
||||
add_widget (query_dlg, label_new (2, 3, text));
|
||||
|
||||
if (defbutton)
|
||||
dlg_select_widget (query_dlg, defbutton);
|
||||
|
||||
/* run dialog and make result */
|
||||
run_dlg (query_dlg);
|
||||
switch (query_dlg->ret_value) {
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user