1
1

* wtools.h: Eliminate the_widget filed in QuickWidget.

* wtools.c (quick_callback): Allocate widget table dynamically.
Этот коммит содержится в:
Pavel Roskin 2002-11-13 00:20:15 +00:00
родитель 0106eebda6
Коммит 11913b36a2
3 изменённых файлов: 63 добавлений и 40 удалений

Просмотреть файл

@ -1,5 +1,8 @@
2002-11-12 Pavel Roskin <proski@gnu.org>
* wtools.h: Eliminate the_widget filed in QuickWidget.
* wtools.c (quick_callback): Allocate widget table dynamically.
* dlg.c (widget_redraw): Remove.
* widget.c (find_buttonbar): Use find_widget_type(). Make
global.

Просмотреть файл

@ -250,7 +250,8 @@ static int quick_callback (struct Dlg_head *h, int id, int Msg)
#define I18N(x) (do_int && *x ? (x = _(x)): x)
int quick_dialog_skip (QuickDialog *qd, int nskip)
int
quick_dialog_skip (QuickDialog *qd, int nskip)
{
Dlg_head *dd;
void *widget;
@ -261,6 +262,9 @@ int quick_dialog_skip (QuickDialog *qd, int nskip)
WInput *input;
QuickWidget *qw;
int do_int;
int count = 0; /* number of quick widgets */
int curr_widget; /* number of the current quick widget */
Widget **widgets; /* table of corresponding widgets */
if (!qd->i18n) {
qd->i18n = 1;
@ -271,34 +275,48 @@ int quick_dialog_skip (QuickDialog *qd, int nskip)
do_int = 0;
if (qd->xpos == -1)
dd = create_dlg (0, 0, qd->ylen, qd->xlen, dialog_colors, quick_callback,
qd->help, qd->title, DLG_CENTER | DLG_TRYUP);
dd = create_dlg (0, 0, qd->ylen, qd->xlen, dialog_colors,
quick_callback, qd->help, qd->title,
DLG_CENTER | DLG_TRYUP);
else
dd = create_dlg (qd->ypos, qd->xpos, qd->ylen, qd->xlen, dialog_colors,
quick_callback,
qd->help, qd->title, DLG_NONE);
dd = create_dlg (qd->ypos, qd->xpos, qd->ylen, qd->xlen,
dialog_colors, quick_callback, qd->help,
qd->title, DLG_NONE);
/* We pass this to the callback */
dd->cols = qd->xlen;
dd->lines = qd->ylen;
/* Count widgets */
for (qw = qd->widgets; qw->widget_type; qw++) {
count++;
}
widgets = (Widget **) g_new (Widget *, count);
for (curr_widget = 0, qw = qd->widgets; qw->widget_type; qw++) {
xpos = (qd->xlen * qw->relative_x) / qw->x_divisions;
ypos = (qd->ylen * qw->relative_y) / qw->y_divisions;
switch (qw->widget_type) {
case quick_checkbox:
widget = check_new (ypos, xpos, *qw->result, I18N (qw->text), qw->tkname);
widget =
check_new (ypos, xpos, *qw->result, I18N (qw->text),
qw->tkname);
break;
case quick_radio:
r = radio_new (ypos, xpos, qw->hotkey_pos, qw->str_result, 1, qw->tkname);
r = radio_new (ypos, xpos, qw->hotkey_pos, qw->str_result, 1,
qw->tkname);
r->pos = r->sel = qw->value;
widget = r;
break;
case quick_button:
widget = button_new (ypos, xpos, qw->value, (qw->value==B_ENTER) ? DEFPUSH_BUTTON : NORMAL_BUTTON,
widget =
button_new (ypos, xpos, qw->value,
(qw->value ==
B_ENTER) ? DEFPUSH_BUTTON : NORMAL_BUTTON,
I18N (qw->text), 0, 0, qw->tkname);
break;
@ -322,7 +340,7 @@ int quick_dialog_skip (QuickDialog *qd, int nskip)
fprintf (stderr, "QuickWidget: unknown widget type\n");
break;
}
qw->the_widget = widget;
widgets[curr_widget++] = widget;
add_widget (dd, widget);
}
@ -333,24 +351,27 @@ int quick_dialog_skip (QuickDialog *qd, int nskip)
/* Get the data if we found something interesting */
if (dd->ret_value != B_CANCEL) {
for (qw = qd->widgets; qw->widget_type; qw++){
for (curr_widget = 0, qw = qd->widgets; qw->widget_type; qw++) {
Widget *w = widgets[curr_widget++];
switch (qw->widget_type) {
case quick_checkbox:
*qw->result = ((WCheck *) qw->the_widget)->state & C_BOOL;
*qw->result = ((WCheck *) w)->state & C_BOOL;
break;
case quick_radio:
*qw->result = ((WRadio *) qw->the_widget)->sel;
*qw->result = ((WRadio *) w)->sel;
break;
case quick_input:
*qw->str_result = g_strdup (((WInput *) qw->the_widget)->buffer);
*qw->str_result = g_strdup (((WInput *) w)->buffer);
break;
}
}
}
return_val = dd->ret_value;
destroy_dlg (dd);
g_free (widgets);
return return_val;
}

Просмотреть файл

@ -40,7 +40,6 @@ typedef struct {
int *result; /* Checkbutton: where to store result */
char **str_result; /* Input lines: destination */
char *tkname; /* Name of the widget used for Tk only */
void *the_widget; /* For the quick quick dialog manager */
} QuickWidget;
typedef struct {