* 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>
|
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.
|
* widget.c (input_callback): Don't handle Enter.
|
||||||
Requested by Ali Akcaagac <aliakc@web.de>
|
Requested by Ali Akcaagac <aliakc@web.de>
|
||||||
|
|
||||||
|
23
src/dlg.c
23
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
|
* Insert widget to dialog before current widget. For dialogs populated
|
||||||
* current. Return widget number.
|
* from the bottom, make the widget current. Return widget number.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
add_widget (Dlg_head *h, void *w)
|
add_widget (Dlg_head *h, void *w)
|
||||||
@ -262,7 +262,9 @@ add_widget (Dlg_head *h, void *w)
|
|||||||
h->first = new_item;
|
h->first = new_item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(h->flags & DLG_BACKWARD) || !h->current)
|
||||||
h->current = new_item;
|
h->current = new_item;
|
||||||
|
|
||||||
return new_item->dlg_id;
|
return new_item->dlg_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,18 +325,14 @@ dlg_unfocus (Dlg_head *h)
|
|||||||
return 0;
|
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)
|
if (!h->current)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!down)
|
|
||||||
dir_forward = !dir_forward;
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (dir_forward)
|
if (down)
|
||||||
h->current = h->current->next;
|
h->current = h->current->next;
|
||||||
else
|
else
|
||||||
h->current = h->current->prev;
|
h->current = h->current->prev;
|
||||||
@ -683,13 +681,6 @@ void init_dlg (Dlg_head *h)
|
|||||||
push_refresh (dlg_refresh, h, refresh_mode);
|
push_refresh (dlg_refresh, h, refresh_mode);
|
||||||
h->refresh_pushed = 1;
|
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;
|
h->previous_dialog = current_dlg;
|
||||||
current_dlg = h;
|
current_dlg = h;
|
||||||
|
|
||||||
|
@ -87,7 +87,6 @@ typedef struct Dlg_head {
|
|||||||
int count; /* number of widgets */
|
int count; /* number of widgets */
|
||||||
struct Widget_Item *current, *first;
|
struct Widget_Item *current, *first;
|
||||||
dlg_cb_fn callback;
|
dlg_cb_fn callback;
|
||||||
struct Widget_Item *initfocus;
|
|
||||||
void *previous_dialog; /* Pointer to the previously running Dlg_head */
|
void *previous_dialog; /* Pointer to the previously running Dlg_head */
|
||||||
|
|
||||||
} 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;
|
va_list ap;
|
||||||
Dlg_head *query_dlg;
|
Dlg_head *query_dlg;
|
||||||
|
WButton *button;
|
||||||
|
WButton *defbutton = NULL;
|
||||||
int win_len = 0;
|
int win_len = 0;
|
||||||
int i;
|
int i;
|
||||||
int result = -1;
|
int result = -1;
|
||||||
@ -155,7 +157,6 @@ query_dialog (char *header, char *text, int flags, int count, ...)
|
|||||||
"[QueryBox]", header, DLG_BACKWARD);
|
"[QueryBox]", header, DLG_BACKWARD);
|
||||||
|
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
|
|
||||||
cols = (cols - win_len - 2) / 2 + 2;
|
cols = (cols - win_len - 2) / 2 + 2;
|
||||||
va_start (ap, count);
|
va_start (ap, count);
|
||||||
for (i = 0; i < count; i++) {
|
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;
|
xpos = strlen (cur_name) + 6;
|
||||||
if (strchr (cur_name, '&') != NULL)
|
if (strchr (cur_name, '&') != NULL)
|
||||||
xpos--;
|
xpos--;
|
||||||
add_widget (query_dlg,
|
|
||||||
button_new (lines - 3, cols, B_USER + i,
|
button =
|
||||||
NORMAL_BUTTON, cur_name, 0));
|
button_new (lines - 3, cols, B_USER + i, NORMAL_BUTTON,
|
||||||
|
cur_name, 0);
|
||||||
|
add_widget (query_dlg, button);
|
||||||
cols += xpos;
|
cols += xpos;
|
||||||
if (i == sel_pos)
|
if (i == sel_pos)
|
||||||
query_dlg->initfocus = query_dlg->current;
|
defbutton = button;
|
||||||
}
|
}
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
add_widget (query_dlg, label_new (2, 3, text));
|
add_widget (query_dlg, label_new (2, 3, text));
|
||||||
|
|
||||||
|
if (defbutton)
|
||||||
|
dlg_select_widget (query_dlg, defbutton);
|
||||||
|
|
||||||
/* run dialog and make result */
|
/* run dialog and make result */
|
||||||
run_dlg (query_dlg);
|
run_dlg (query_dlg);
|
||||||
switch (query_dlg->ret_value) {
|
switch (query_dlg->ret_value) {
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user