GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

GtkTreeView filter function - C

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Example Code
Author Message
guillermohurta



Joined: 11 Mar 2008
Posts: 4

PostPosted: Wed Mar 12, 2008 2:51 am    Post subject: GtkTreeView filter function - C Reply with quote

Code: (Plaintext)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

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
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Example Code All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP