Changeset 10653


Ignore:
Timestamp:
May 18, 2010, 2:14:17 PM (11 years ago)
Author:
charles
Message:

(trunk gtk) add stock icons to some of the filter states

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/filter.c

    r10648 r10653  
    602602    ACTIVITY_FILTER_COL_COUNT,
    603603    ACTIVITY_FILTER_COL_TYPE,
     604    ACTIVITY_FILTER_COL_STOCK_ID,
    604605    ACTIVITY_FILTER_N_COLS
    605606};
     
    713714        int type;
    714715        const char * name;
     716        const char * stock_id;
    715717    } types[] = {
    716         { ACTIVITY_FILTER_ALL, N_( "All" ) },
    717         { ACTIVITY_FILTER_SEPARATOR, NULL },
    718         { ACTIVITY_FILTER_DOWNLOADING, N_( "Downloading" ) },
    719         { ACTIVITY_FILTER_SEEDING, N_( "Seeding" ) },
    720         { ACTIVITY_FILTER_ACTIVE, N_( "Active" ) },
    721         { ACTIVITY_FILTER_PAUSED, N_( "Paused" ) },
    722         { ACTIVITY_FILTER_QUEUED, N_( "Queued" ) },
    723         { ACTIVITY_FILTER_VERIFYING, N_( "Verifying" ) },
    724         { ACTIVITY_FILTER_ERROR, N_( "Error" ) }
     718        { ACTIVITY_FILTER_ALL, N_( "All" ), NULL },
     719        { ACTIVITY_FILTER_SEPARATOR, NULL, NULL },
     720        { ACTIVITY_FILTER_ACTIVE, N_( "Active" ), GTK_STOCK_EXECUTE },
     721        { ACTIVITY_FILTER_DOWNLOADING, N_( "Downloading" ), GTK_STOCK_GO_DOWN },
     722        { ACTIVITY_FILTER_SEEDING, N_( "Seeding" ), GTK_STOCK_GO_UP },
     723        { ACTIVITY_FILTER_PAUSED, N_( "Paused" ), GTK_STOCK_MEDIA_PAUSE },
     724        { ACTIVITY_FILTER_QUEUED, N_( "Queued" ), NULL },
     725        { ACTIVITY_FILTER_VERIFYING, N_( "Verifying" ), GTK_STOCK_REFRESH },
     726        { ACTIVITY_FILTER_ERROR, N_( "Error" ), GTK_STOCK_DIALOG_ERROR }
    725727    };
    726     GtkListStore * store;
    727 
    728     store = gtk_list_store_new( ACTIVITY_FILTER_N_COLS,
    729                                 G_TYPE_STRING,
    730                                 G_TYPE_INT,
    731                                 G_TYPE_INT );
     728    GtkListStore * store = gtk_list_store_new( ACTIVITY_FILTER_N_COLS,
     729                                               G_TYPE_STRING,
     730                                               G_TYPE_INT,
     731                                               G_TYPE_INT,
     732                                               G_TYPE_STRING );
    732733    for( i=0, n=G_N_ELEMENTS(types); i<n; ++i )
    733734        gtk_list_store_insert_with_values( store, NULL, -1,
    734735            ACTIVITY_FILTER_COL_NAME, _( types[i].name ),
    735736            ACTIVITY_FILTER_COL_TYPE, types[i].type,
     737            ACTIVITY_FILTER_COL_STOCK_ID, types[i].stock_id,
    736738            -1 );
    737739
     
    739741    activity_filter_model_update( store );
    740742    return GTK_TREE_MODEL( store );
     743}
     744
     745static void
     746render_activity_pixbuf_func( GtkCellLayout    * cell_layout UNUSED,
     747                             GtkCellRenderer  * cell_renderer,
     748                             GtkTreeModel     * tree_model,
     749                             GtkTreeIter      * iter,
     750                             gpointer           data UNUSED )
     751{
     752    int type;
     753    int width;
     754    int ypad;
     755    const gboolean leaf = !gtk_tree_model_iter_has_child( tree_model, iter );
     756
     757    gtk_tree_model_get( tree_model, iter, ACTIVITY_FILTER_COL_TYPE, &type, -1 );
     758    width = type == ACTIVITY_FILTER_ALL ? 0 : 20;
     759    ypad = type == ACTIVITY_FILTER_ALL ? 0 : 5;
     760
     761    g_object_set( cell_renderer, "width", width,
     762                                 "sensitive", leaf,
     763                                 "ypad", ypad,
     764                                 NULL );
    741765}
    742766
     
    783807                                       activity_is_it_a_separator, NULL, NULL );
    784808    gtk_combo_box_set_active( GTK_COMBO_BOX( c ), 0 );
     809
     810    r = gtk_cell_renderer_pixbuf_new( );
     811    gtk_cell_layout_pack_start( GTK_CELL_LAYOUT( c ), r, FALSE );
     812    gtk_cell_layout_set_attributes( GTK_CELL_LAYOUT( c ), r,
     813                                    "stock-id", ACTIVITY_FILTER_COL_STOCK_ID,
     814                                    NULL );
     815    gtk_cell_layout_set_cell_data_func( GTK_CELL_LAYOUT( c ), r,
     816                                        render_activity_pixbuf_func, NULL, NULL );
    785817
    786818    r = gtk_cell_renderer_text_new( );
Note: See TracChangeset for help on using the changeset viewer.