From: simon Date: Fri, 18 Apr 2003 09:14:54 +0000 (+0000) Subject: Removing items from a list box using gtk_container_remove is nasty, X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/commitdiff_plain/b4c61ce2c6c9c8e1cf02260ac993676013c12c73 Removing items from a list box using gtk_container_remove is nasty, because when the selected item is removed the selection moves on to another item. Thus, calling dlg_listbox_clear causes repeated selchanges in the list, which in turn cause repeated valchanges if the list is attached to a combo box. This has been completely scuppering the Translation panel. git-svn-id: svn://svn.tartarus.org/sgt/putty@3130 cda61777-01e9-0310-a592-d414129be87e --- diff --git a/unix/gtkdlg.c b/unix/gtkdlg.c index 63e51010..a961ba50 100644 --- a/unix/gtkdlg.c +++ b/unix/gtkdlg.c @@ -307,15 +307,18 @@ void dlg_listbox_clear(union control *ctrl, void *dlg) { struct dlgparam *dp = (struct dlgparam *)dlg; struct uctrl *uc = dlg_find_byctrl(dp, ctrl); - GtkContainer *cont; assert(uc->ctrl->generic.type == CTRL_EDITBOX || uc->ctrl->generic.type == CTRL_LISTBOX); assert(uc->menu != NULL || uc->list != NULL); - cont = (uc->menu ? GTK_CONTAINER(uc->menu) : GTK_CONTAINER(uc->list)); - - gtk_container_foreach(cont, container_remove_and_destroy, cont); + if (uc->menu) { + gtk_container_foreach(GTK_CONTAINER(uc->menu), + container_remove_and_destroy, + GTK_CONTAINER(uc->menu)); + } else { + gtk_list_clear_items(GTK_LIST(uc->list), 0, -1); + } } void dlg_listbox_del(union control *ctrl, void *dlg, int index)