clist and GList



I have two clists side by side -- available items on the left,
selected items on the right -- with Add and Remove buttons to add
elements from the left list to the right list and remove elements
from the right list respectively.

It's working mostly, but something's wrong with my removal code.  My
Remove button is hooked up to "remove_from_right_callback" below
("selector" is a wrapper struct):

static void remove_right_var (gint i, selector *sr)
{
    gtk_clist_remove(GTK_CLIST(sr->rightvars), i);
}

static void remove_from_right_callback (GtkWidget *w, selector *sr)
{
    GList *mylist = GTK_CLIST(sr->rightvars)->selection;

    if (mylist != NULL) {
        g_list_foreach(mylist, (GFunc) remove_right_var, sr);
    }
}

The trouble is that more variables are being removed than are
(visibly) selected.  E.g. I highlight item 2 on the right, press
Remove, and items 2 and 0 both disappear.

What's the right way to do this?  Thanks.

-- 
Allin Cottrell
Department of Economics
Wake Forest University, NC




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]