GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Fri Aug 22, 2014 9:38 pm

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: GtkTreeView filter function - C
PostPosted: Wed Mar 12, 2008 2:51 am 
Offline

Joined: Tue Mar 11, 2008 8:58 pm
Posts: 4
Code:
void filter_function (GtkTreeView *treeview)
{
   GtkTreeModel *initial_model;
   GtkTreeModel *filter_model;

   initial_model= gtk_tree_view_get_model(GTK_TREE_VIEW( treeview )));
   filter_model = gtk_tree_model_filter_new( initial_model, NULL );

   gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER ( filter_model ),(GtkTreeModelFilterVisibleFunc) filter_visible_func, NULL , NULL);

   /* Apply model */
   gtk_tree_view_set_model( GTK_TREE_VIEW( treeview ),filter_model);

   g_object_unref( filter_model );
   return;
}/* filter_function */

...

gboolean filter_visible_func (GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
{
   gchar *expression = "SOMETHING";
   gchar *data;
   gchar *comp1;

   /* Get value from column */
   gtk_tree_model_get( GTK_TREE_MODEL(model), iter, COLUMN_X, &data, -1 );
   comp1 = g_utf8_strup (data, -1);

   if (g_strrstr(comp1, expression))
   {
      g_free (comp1);
      return TRUE;
   }
        else
   {
      g_free (comp1);
      return FALSE;
   }
}/* filter_visible_func*/


Please correct me if I made a mistake


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot], newguy and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group