GtkTreeModelFilter question



Hi all,

I'm having problems with GtkTreeModelFilter.

The following sample program simply builds a window with a tree view inside.
A tree model filter wraps the tree model of the tree view.
The filter uses a visible function that always returns FALSE. So no rows
should be shown...
But compile and run it, and you'll see the tree view showing the row!

Could anyone explain me where am I wrong?


--[ begin code ]--

#include <gtk/gtk.h>


gboolean func (GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
{
       return FALSE;
}


int main(int argc, char* *argv)
{
       GtkListStore *store;
       GtkTreeIter iter;
       GtkWidget *view, *window;
       GtkTreeViewColumn *column;
       GtkCellRenderer *cell;
       GtkTreeModel *filter;

       gtk_init(&argc, &argv);

       store = gtk_list_store_new(1, G_TYPE_STRING);
       gtk_list_store_append(store, &iter);
       gtk_list_store_set(store, &iter, 0, "You should not see me!", -1);

       filter = gtk_tree_model_filter_new(GTK_TREE_MODEL(store), NULL);

gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(filter),
         (GtkTreeModelFilterVisibleFunc)func, NULL, NULL);

       view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
       cell = gtk_cell_renderer_text_new();
       column = gtk_tree_view_column_new_with_attributes("Column", cell,
         "text", 0, NULL);
       gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);

       window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
       g_signal_connect(window, "destroy", gtk_main_quit, NULL);
       gtk_container_add(GTK_CONTAINER(window), view);
       gtk_widget_show_all(window);

       gtk_main();
}

--[ end code ]--


Thanks!


--
David Rosal i Ricart
<drosalri7 fis ub edu>
--






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