First let me say thank you for your reply! :)
However, I don't think that the type of button that calls the file_chooser_dialog makes any difference regarding my problem.
This is the function 'my' button calls when clicked:
Code:
char *folder;
static void openDialog( GtkWidget *widget,GtkWidget *window)
{
GtkWidget *dialogOPEN;
dialogOPEN = gtk_file_chooser_dialog_new ("Select a folder", GTK_WINDOW (window),
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
NULL);
if (gtk_dialog_run (GTK_DIALOG (dialogOPEN)) == GTK_RESPONSE_ACCEPT)
{
folder = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER (dialogOPEN));
create_view_and_model();
g_free (folder);
}
gtk_widget_destroy (dialogOPEN);
}
This pops up the file_choose_dialog and the user can select what he wants.
On 'clicking' OK, "folder" is mapped to the selected path, and "create_view_and_model" is called. Now as far as I can work out, the TreeView-model is getting populated with the correct data, but it is not (re-)connected to the actual view.
(When "folder" is mapped at start-up, the "model" is populated and the view 'shows' its data accordingly)
This is the function that gets called from the file_chooser:
Code:
static GtkWidget *create_view_and_model (void)
{
GtkCellRenderer *renderer;
GtkTreeModel *model;
GtkWidget *view;
view = gtk_tree_view_new ();
renderer = gtk_cell_renderer_text_new ();
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view),0,"Type",renderer,"text", COL_TYPE,NULL);
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view),1,"Name",renderer,"text", COL_NAME,NULL);
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (view),TRUE);
gtk_tree_view_set_headers_clickable (GTK_TREE_VIEW (view),FALSE);
gtk_tree_view_set_enable_search(GTK_TREE_VIEW(view),FALSE);
gtk_tree_view_columns_autosize (GTK_TREE_VIEW (view));
model = create_and_fill_model ();
gtk_tree_view_set_model (GTK_TREE_VIEW (view), model);
g_object_unref (model);
return view;
}
What am I doing wrong?