* dlg.c (add_widget): New, safer implementation. Don't rely on

the position of the first widget.  Disable insertion into
running dialogs - it's unused and cannot be tested.
This commit is contained in:
Pavel Roskin 2003-09-12 02:25:41 +00:00
parent ab761c64a6
commit 0464c5e94d
2 changed files with 31 additions and 49 deletions

View File

@ -1,5 +1,9 @@
2003-09-11 Pavel Roskin <proski@gnu.org> 2003-09-11 Pavel Roskin <proski@gnu.org>
* dlg.c (add_widget): New, safer implementation. Don't rely on
the position of the first widget. Disable insertion into
running dialogs - it's unused and cannot be tested.
* boxes.c (symlink_dialog): Add "OK" and "Cancel" buttons. * boxes.c (symlink_dialog): Add "OK" and "Cancel" buttons.
Don't translate strings, it's done in quick_dialog(). Don't translate strings, it's done in quick_dialog().
Reported by Ali Akcaagac <aliakc@web.de> Reported by Ali Akcaagac <aliakc@web.de>

View File

@ -229,63 +229,41 @@ set_idle_proc (Dlg_head *d, int enable)
d->flags &= ~DLG_WANT_IDLE; d->flags &= ~DLG_WANT_IDLE;
} }
/* add component to dialog buffer */ /*
int add_widget (Dlg_head *where, void *what) * Insert widget to dialog before current widget and make the new widget
* current. Return widget number.
*/
int
add_widget (Dlg_head *h, void *w)
{ {
Widget_Item *back; Widget_Item *new_item;
Widget *widget = (Widget *) what; Widget *widget = (Widget *) w;
/* Don't accept 0 widgets, this could be from widgets that could not */ /* Don't accept 0 widgets, and running dialogs */
/* initialize properly */ if (!widget || h->running)
if (!what) abort ();
return 0;
widget->x += where->x; widget->x += h->x;
widget->y += where->y; widget->y += h->y;
widget->parent = h;
if (where->running){ new_item = g_new (Widget_Item, 1);
Widget_Item *point = where->current; new_item->dlg_id = h->count++;
new_item->widget = widget;
where->current = g_new (Widget_Item, 1); if (h->current) {
new_item->next = h->current;
if (point){ new_item->prev = h->current->prev;
where->current->next = point->next; h->current->prev->next = new_item;
where->current->prev = point; h->current->prev = new_item;
point->next->prev = where->current;
point->next = where->current;
} else { } else {
where->current->next = where->current; new_item->prev = new_item;
where->first = where->current; new_item->next = new_item;
where->current->prev = where->first; h->first = new_item;
where->first->next = where->current;
}
} else {
back = where->current;
where->current = g_new (Widget_Item, 1);
if (back){
back->prev = where->current;
where->current->next = back;
} else {
where->current->next = where->current;
where->first = where->current;
} }
where->current->prev = where->first; h->current = new_item;
where->first->next = where->current; return new_item->dlg_id;
}
where->current->dlg_id = where->count;
where->current->widget = what;
where->current->widget->parent = where;
where->count++;
/* If the widget is inserted in a running dialog */
if (where->running) {
send_message (widget, WIDGET_INIT, 0);
send_message (widget, WIDGET_DRAW, 0);
}
return (where->count - 1);
} }
/* broadcast a message to all the widgets in a dialog that have /* broadcast a message to all the widgets in a dialog that have