Changeset 12856


Ignore:
Timestamp:
Sep 12, 2011, 6:11:04 AM (10 years ago)
Author:
jordan
Message:

(trunk gtk) #4470 "Search in torrent list is broken" -- fixed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/tr-window.c

    r12655 r12856  
    106106}
    107107
     108static gboolean
     109tree_view_search_equal_func( GtkTreeModel * model,
     110                             gint           column UNUSED,
     111                             const gchar  * key,
     112                             GtkTreeIter  * iter,
     113                             gpointer       search_data UNUSED )
     114{
     115    gboolean match;
     116    char * lower;
     117    const char * name = NULL;
     118
     119    lower = g_strstrip( g_utf8_strdown( key, -1 ) );
     120    gtk_tree_model_get( model, iter, MC_NAME_COLLATED, &name, -1 );
     121    match = strstr( name, lower ) != NULL;
     122    g_free( lower );
     123
     124    return !match;
     125}
     126
    108127static GtkWidget*
    109128makeview( PrivateData * p )
     
    113132    GtkTreeSelection *  sel;
    114133    GtkCellRenderer *   r;
     134    GtkTreeView * tree_view;
    115135
    116136    view = gtk_tree_view_new( );
    117     gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE );
    118     gtk_tree_view_set_fixed_height_mode( GTK_TREE_VIEW( view ), TRUE );
    119 
    120     p->selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) );
     137    tree_view = GTK_TREE_VIEW( view );
     138    gtk_tree_view_set_search_column( tree_view, MC_NAME_COLLATED );
     139    gtk_tree_view_set_search_equal_func( tree_view,
     140                                         tree_view_search_equal_func,
     141                                         NULL, NULL );
     142    gtk_tree_view_set_headers_visible( tree_view, FALSE );
     143    gtk_tree_view_set_fixed_height_mode( tree_view, TRUE );
     144
     145    p->selection = gtk_tree_view_get_selection( tree_view );
    121146
    122147    p->column = col = GTK_TREE_VIEW_COLUMN (g_object_new (GTK_TYPE_TREE_VIEW_COLUMN,
     
    132157    gtk_tree_view_column_add_attribute( col, r, "piece-download-speed", MC_SPEED_DOWN );
    133158
    134     gtk_tree_view_append_column( GTK_TREE_VIEW( view ), col );
     159    gtk_tree_view_append_column( tree_view, col );
    135160    g_object_set( r, "xpad", GUI_PAD_SMALL, "ypad", GUI_PAD_SMALL, NULL );
    136161
    137     gtk_tree_view_set_rules_hint( GTK_TREE_VIEW( view ), TRUE );
    138     sel = gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) );
     162    gtk_tree_view_set_rules_hint( tree_view, TRUE );
     163    sel = gtk_tree_view_get_selection( tree_view );
    139164    gtk_tree_selection_set_mode( GTK_TREE_SELECTION( sel ),
    140165                                 GTK_SELECTION_MULTIPLE );
     
    151176
    152177
    153     gtk_tree_view_set_model( GTK_TREE_VIEW( view ), p->filter_model );
     178    gtk_tree_view_set_model( tree_view, p->filter_model );
    154179    g_object_unref( p->filter_model );
    155180
Note: See TracChangeset for help on using the changeset viewer.