Displaying contents of a folder in gtk_tree_view
- From: Tom <haifischhathunger web de>
- To: gtk-app-devel-list gnome org
- Subject: Displaying contents of a folder in gtk_tree_view
- Date: Thu, 19 Apr 2007 18:34:30 +0200
Hi!
I'm writing a program which uses "gtk_tree_view" to display the contents
of a folder. This folder is selected by the user through a
"gtk_file_chooser_dialog". Now while I can get my app to display the
files of any folder I want when I tell it which folder to scan by
'hardcoding' in the path, I can't figure out how to call the appropriate
functions when 'user-selecting' this path. To clarify:
static GtkTreeModel *create_and_fill_model (void)
{
GtkListStore *store;
...
scanFiles(folder);
printf("Files found: %d\n",count);
for (cnt = 0; cnt < count; ++cnt)
{
file = files[cnt]->d_name;
printf ("%s\n",file);
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,COL_TYPE,
"none",COL_NAME, file,-1);
}
return GTK_TREE_MODEL (store);
}
static GtkWidget *create_view_and_model (void)
{
GtkWidget *view;
GtkTreeModel *model;
...
model = create_and_fill_model ();
...
return view;
}
static void openDialog( GtkWidget *widget,GtkWidget *window)
{
GtkWidget *dialogOPEN;
...
folder = gtk_file_chooser_get_current_folder(...)
create_view_and_model();
...
}
}
int main( int argc,char *argv[] )
{
GtkWidget *list;
GtkWidget *buttonOPEN;
...
list = create_view_and_model();
buttonOPEN = gtk_button_new_from_stock (GTK_STOCK_OPEN);
g_signal_connect (G_OBJECT
(buttonOPEN),"clicked",G_CALLBACK (openDialog),(gpointer) window);
...
}
This is the basic structure of my program. I'm guessing that because I
am 'recalling' "create_view_and_model" from within "openDIALOG" the list
is not getting drawn inside the widget. I know that the
'data'(filenames) is getting to my function, as I can dump them with
printf();
How do I solve this?
Sorry for the long post...
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]