clist EXTENDED selection & keyboard



Hi, 

I'm currently experimenting with GTK by building a small file manager.
I've created a clist with EXTENDED selection mode. When I start the
application, the clist grabs the focus, and  I can move around the files
in the list using the arrow (cursor) keys. I've set up a key_press
handler on the clist, which, amongst other functions, shows the
currently selected files. My code for getting the selection is:

void panel_showselected (panel *p) {
    char *filename;
    GList *cur;

    cur = GTK_CLIST(p->list)->selection;
    while (cur) {
        gtk_clist_get_text (
                GTK_CLIST(p->list),
                GPOINTER_TO_INT(cur->data),
                0,
                &filename);
        printf ("%s\n",filename);
        cur = cur->next;
    }
}

This works, but only for 1 selected file. If I create a selection of
multiple files with the keyboard (using shift + arrow) and I call the
panel_showselected() function, cur oddly enough is NULL. After the call
to panel_showselected() the arrow keys also stop working. When I use the
mouse to click somewhere in the list (for the first time), the arrow
keys work again, and after this, selections made with shift+arrows DO
work (as in, cur is a pointer to the GList of selected files) and keep
working.

Could somebody explain to me what I'm doing wrong or what I forgot? It
would seem this is a focus problem, but if that's the case, how come I
can use the arrow keys to move around the list?

Thanks in advance,

Ferry Boender





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