gtk_tree_model_filter_set_modify_func()
- From: Russell Shaw <rjshaw netspace net au>
- To: gtk-app-devel-list gnome org
- Subject: gtk_tree_model_filter_set_modify_func()
- Date: Tue, 29 Jun 2004 19:55:22 +1000
Hi,
In the following code, i can only get printed: n:0 val:(null)
I should get: n:0 val:abc
If i comment out the gtk_tree_model_filter_set_modify_func(), then
it works. Gtk 2.4.3
#include <stdlib.h>
#include <stdio.h>
#include <gtk/gtk.h>
#include <gtk/gtksignal.h>
#include "xmalloc.h"
#include <string.h>
static
gboolean delete( GtkWidget *widget, GtkWidget *event, gpointer data)
{
gtk_main_quit ();
}
void filtermodifyfunc(GtkTreeModel *model, GtkTreeIter *iter, GValue *value,
gint column, gpointer data)
{
return;
}
gint main(gint argc, gchar *argv[])
{
gtk_init (&argc, &argv);
GtkWidget *window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT(window),"delete_event",G_CALLBACK(delete),NULL);
GtkListStore *store=gtk_list_store_new(2,G_TYPE_UINT,G_TYPE_STRING);
GtkTreeIter iter;
gtk_list_store_append(store,&iter);
gtk_list_store_set(store,&iter,0,0,1,"abc",-1);
gtk_list_store_append(store,&iter);
gtk_list_store_set(store,&iter,0,1,1,"def",-1);
gtk_list_store_append(store,&iter);
gtk_list_store_set(store,&iter,0,2,1,"ghi",-1);
GtkTreeModel *modelfilter=
gtk_tree_model_filter_new(GTK_TREE_MODEL(store),NULL);
GType types[]={G_TYPE_UINT,G_TYPE_STRING};
gtk_tree_model_filter_set_modify_func(
GTK_TREE_MODEL_FILTER(modelfilter),
2,
types,
filtermodifyfunc,
NULL,NULL);
gtk_tree_model_get_iter_first(GTK_TREE_MODEL(modelfilter),&iter);
guint n;
gchar *str1;
gtk_tree_model_get(GTK_TREE_MODEL(modelfilter),&iter,0,&n,1,&str1,-1);
g_printf("n:%d val:%s\n",n,str1);
gtk_widget_show_all(window);
gtk_main();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]