Changeset 11067


Ignore:
Timestamp:
Jul 30, 2010, 10:19:20 PM (12 years ago)
Author:
charles
Message:

(trunk gtk) simplify the collation process for sorting torrents by name

File:
1 edited

Legend:

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

    r10937 r11067  
    364364    gtk_tree_model_get( model, b, MC_NAME_COLLATED, &cb, -1 );
    365365    ret = strcmp( ca, cb );
     366
    366367    g_free( cb );
    367368    g_free( ca );
     
    877878}
    878879
    879 static char*
    880 doCollate( const char * in )
    881 {
    882     char * ret;
    883     char * casefold;
    884     const char * end = in ? in + strlen( in ) : NULL;
    885 
    886     while( in < end )
    887     {
    888         const gunichar ch = g_utf8_get_char( in );
    889         if( !g_unichar_isalnum ( ch ) ) /* eat everything before the first alnum
    890                                           */
    891             in += g_unichar_to_utf8( ch, NULL );
    892         else
    893             break;
    894     }
    895 
    896     if( in == end )
    897         return g_strdup ( "" );
    898 
    899     casefold = g_utf8_casefold( in, end - in );
    900     ret = g_utf8_collate_key( casefold, -1 );
    901     g_free( casefold );
    902 
    903     return ret;
    904 }
    905 
    906880void
    907881tr_core_add_torrent( TrCore     * self,
     
    912886    const tr_stat * st = tr_torrent_stat( gtor );
    913887    tr_torrent *    tor = tr_torrent_handle( gtor );
    914     char *          collated = doCollate( inf->name );
     888    char *          collated = g_utf8_strdown( inf->name, -1 );
    915889    GtkListStore *  store = GTK_LIST_STORE( tr_core_model( self ) );
    916890    GtkTreeIter     unused;
Note: See TracChangeset for help on using the changeset viewer.