Removing items from a list box using gtk_container_remove is nasty,
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Fri, 18 Apr 2003 09:14:54 +0000 (09:14 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Fri, 18 Apr 2003 09:14:54 +0000 (09:14 +0000)
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

unix/gtkdlg.c

index 63e5101..a961ba5 100644 (file)
@@ -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)