Re: Multiple File Selection Widgetet?
- From: Sven Neumann <sven gimp org>
- To: Roland Roberts <roland astrofoto org>
- Cc: gtk-list gnome org
- Subject: Re: Multiple File Selection Widgetet?
- Date: 30 Mar 2001 09:43:04 +0200
Hi,
Roland Roberts <roland astrofoto org> writes:
> I've been playing with what I have to do to get a file selection
> widget to allow multiple files to be selected. It's not pretty. The
> basic problem is easy: change the file_list child widget to
> GTK_SELECTION_EXTENDED and add a couple of callbacks to keep track of
> select-row and unsetect-row events. The ugly part is that the
> directory information is kept in internal structs which are only
> accessible to the class because they are declared inside gtkfilesel.c
> (of course, for my testing, that didn't keep me from copying them into
> my code...).
>
> I'm thinking of hacking together a variant of GtkFileSelection (maybe
> GtkExtFileSelection) that will provide a a function to return a GList
> of the selected files. Given that I've never messed with GTK until a
> couple of weeks ago, I'm wondering if anyone knows of a widget that
> will already allow multiple file selection or if there are plans to do
> this in GTK+ 2.0 (I didn't see anything in the API documentation to
> make me think so).
I don't think you need to extend the GtkFileSelection API. While I must
admit that it should be easier, it's certainly possible to get the list
of selected files through the current API. Here's how The Gimp does it:
list = clist_to_slist (GTK_CLIST (GTK_FILE_SELECTION (fs)->file_list));
static GSList *
clist_to_slist (GtkCList *file_list)
{
GSList *list = NULL;
GList *row;
gint rownum;
gchar *temp;
for (row = file_list->row_list, rownum = 0;
row;
row = g_list_next (row), rownum++)
{
if (GTK_CLIST_ROW (row)->state == GTK_STATE_SELECTED)
{
if (gtk_clist_get_cell_type (file_list, rownum, 0) == GTK_CELL_TEXT)
{
gtk_clist_get_text (file_list, rownum, 0, &temp);
list = g_slist_prepend (list, g_strdup (temp));
}
}
}
return list;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]