Changeset 12317


Ignore:
Timestamp:
Apr 5, 2011, 3:59:41 PM (11 years ago)
Author:
jordan
Message:

(trunk gtk) use GQuarks instead of strings for keys in the filterbar's key/value pairs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/filter.c

    r12306 r12317  
    2525#include "util.h" /* gtr_idle_add() */
    2626
    27 #define DIRTY_KEY          "tr-filter-dirty-key"
    28 #define SESSION_KEY        "tr-session-key"
    29 #define TEXT_KEY           "tr-filter-text-key"
    30 #define TORRENT_MODEL_KEY  "tr-filter-torrent-model-key"
     27static GQuark DIRTY_KEY = 0;
     28static GQuark SESSION_KEY = 0;
     29static GQuark TEXT_KEY = 0;
     30static GQuark TORRENT_MODEL_KEY = 0;
    3131
    3232/***
     
    138138    GObject * o = G_OBJECT( store );
    139139    GtkTreeModel * tmodel = GTK_TREE_MODEL(
    140                                     g_object_get_data( o, TORRENT_MODEL_KEY ) );
    141 
    142     g_object_steal_data( o, DIRTY_KEY );
     140                                    g_object_get_qdata( o, TORRENT_MODEL_KEY ) );
     141
     142    g_object_steal_qdata( o, DIRTY_KEY );
    143143
    144144    /* Walk through all the torrents, tallying how many matches there are
     
    249249            GtkTreePath * path;
    250250            GtkTreeRowReference * reference;
    251             tr_session * session = g_object_get_data( G_OBJECT( store ), SESSION_KEY );
     251            tr_session * session = g_object_get_qdata( G_OBJECT( store ), SESSION_KEY );
    252252            const char * host = hosts->pdata[i];
    253253            char * name = get_name_from_host( host );
     
    356356        -1 );
    357357
    358     g_object_set_data( G_OBJECT( store ), TORRENT_MODEL_KEY, tmodel );
     358    g_object_set_qdata( G_OBJECT( store ), TORRENT_MODEL_KEY, tmodel );
    359359    category_filter_model_update( store );
    360360    return GTK_TREE_MODEL( store );
     
    373373{
    374374    GObject * o = G_OBJECT( category_model );
    375     const gboolean pending = g_object_get_data( o, DIRTY_KEY ) != NULL;
     375    const gboolean pending = g_object_get_qdata( o, DIRTY_KEY ) != NULL;
    376376    if( !pending )
    377377    {
    378378        GSourceFunc func = (GSourceFunc) category_filter_model_update;
    379         g_object_set_data( o, DIRTY_KEY, GINT_TO_POINTER(1) );
     379        g_object_set_qdata( o, DIRTY_KEY, GINT_TO_POINTER(1) );
    380380        gtr_idle_add( func, category_model );
    381381    }
     
    686686    GtkTreeModel * model = GTK_TREE_MODEL( store );
    687687    GObject * o = G_OBJECT( store );
    688     GtkTreeModel * tmodel = GTK_TREE_MODEL( g_object_get_data( o, TORRENT_MODEL_KEY ) );
    689 
    690     g_object_steal_data( o, DIRTY_KEY );
     688    GtkTreeModel * tmodel = GTK_TREE_MODEL( g_object_get_qdata( o, TORRENT_MODEL_KEY ) );
     689
     690    g_object_steal_qdata( o, DIRTY_KEY );
    691691
    692692    if( gtk_tree_model_get_iter_first( model, &iter )) do
     
    743743            -1 );
    744744
    745     g_object_set_data( G_OBJECT( store ), TORRENT_MODEL_KEY, tmodel );
     745    g_object_set_qdata( G_OBJECT( store ), TORRENT_MODEL_KEY, tmodel );
    746746    activity_filter_model_update( store );
    747747    return GTK_TREE_MODEL( store );
     
    774774{
    775775    GObject * o = G_OBJECT( activity_model );
    776     const gboolean pending = g_object_get_data( o, DIRTY_KEY ) != NULL;
     776    const gboolean pending = g_object_get_qdata( o, DIRTY_KEY ) != NULL;
    777777    if( !pending )
    778778    {
    779779        GSourceFunc func = (GSourceFunc) activity_filter_model_update;
    780         g_object_set_data( o, DIRTY_KEY, GINT_TO_POINTER(1) );
     780        g_object_set_qdata( o, DIRTY_KEY, GINT_TO_POINTER(1) );
    781781        gtr_idle_add( func, activity_model );
    782782    }
     
    894894    folded = g_utf8_casefold( pch, -1 );
    895895    g_strstrip( folded );
    896     g_object_set_data_full( filter_model, TEXT_KEY, folded, g_free );
     896    g_object_set_qdata_full( filter_model, TEXT_KEY, folded, g_free );
    897897    g_free( pch );
    898898
     
    924924    gtk_tree_model_get( model, iter, MC_TORRENT, &tor, -1 );
    925925
    926     text = (const char*) g_object_get_data( o, TEXT_KEY );
     926    text = (const char*) g_object_get_qdata( o, TEXT_KEY );
    927927
    928928    return ( tor != NULL ) && testCategory( data->category, tor )
     
    950950    struct filter_data * data;
    951951
     952    g_assert( DIRTY_KEY == 0 );
     953    TEXT_KEY = g_quark_from_static_string( "tr-filter-text-key" );
     954    DIRTY_KEY = g_quark_from_static_string( "tr-filter-dirty-key" );
     955    SESSION_KEY = g_quark_from_static_string( "tr-session-key" );
     956    TORRENT_MODEL_KEY = g_quark_from_static_string( "tr-filter-torrent-model-key" );
     957
    952958    data = g_new( struct filter_data, 1 );
    953959    data->activity = activity = activity_combo_box_new( tmodel );
     
    957963
    958964    g_object_set( G_OBJECT( data->category ), "width-request", 170, NULL );
    959     g_object_set_data( G_OBJECT( gtk_combo_box_get_model( GTK_COMBO_BOX( data->category ) ) ), SESSION_KEY, session );
     965    g_object_set_qdata( G_OBJECT( gtk_combo_box_get_model( GTK_COMBO_BOX( data->category ) ) ), SESSION_KEY, session );
    960966
    961967    gtk_tree_model_filter_set_visible_func(
Note: See TracChangeset for help on using the changeset viewer.