Changeset 7271


Ignore:
Timestamp:
Dec 4, 2008, 5:02:37 PM (12 years ago)
Author:
charles
Message:

(gtk) #1560: tr_strlsize() type conflict

Location:
trunk/gtk
Files:
2 edited

Legend:

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

    r7261 r7271  
    8484    GtkWidget *           stats_lb;
    8585    GtkWidget *           gutter_lb;
     86    GSList *              toggles;
    8687    GtkTreeSelection *    selection;
    8788    GtkCellRenderer *     renderer;
     
    257258};
    258259
     260const char *  filter_names[FILTER_MODE_QTY] = {
     261    /* show all torrents */
     262    N_( "A_ll" ),
     263    /* show only torrents that have connected peers */
     264    N_( "_Active" ),
     265    /* show only torrents that are trying to download */
     266    N_( "_Downloading" ),
     267    /* show only torrents that are trying to upload */
     268    N_( "_Seeding" ),
     269    /* show only torrents that are paused */
     270    N_( "_Paused" )
     271};
     272
    259273static void
    260274status_menu_toggled_cb( GtkCheckMenuItem * menu_item,
     
    380394        refilter( p );
    381395    }
     396}
     397
     398static void
     399update_toggle( GtkToggleButton * toggle,
     400                   gpointer          vprivate )
     401{
     402    PrivateData *       p = vprivate;
     403    GtkWidget * l;
     404    const filter_mode_t mode =
     405            GPOINTER_TO_UINT( g_object_get_data( G_OBJECT( toggle ),
     406                                         FILTER_MODE_KEY ) );
     407    const char * mnemonic  = (char *) g_object_get_data( G_OBJECT( toggle ), "title");
     408
     409    char buf[128];
     410    int filtercount = 0;
     411
     412    tr_session * session = tr_core_session(p->core);
     413    tr_torrent * torrent = tr_torrentNext(session, 0);
     414
     415    while (torrent) {
     416        if (checkFilterMode(mode, torrent))
     417            filtercount++;
     418        torrent = tr_torrentNext(session, torrent);
     419    }
     420
     421    l = gtk_bin_get_child( GTK_BIN( toggle ) );
     422    if( filtercount )
     423        g_snprintf( buf, sizeof( buf ), "%s (%d)", mnemonic, filtercount );
     424    else
     425        g_snprintf( buf, sizeof( buf ), "%s", mnemonic );
     426    gtk_label_set_markup_with_mnemonic( GTK_LABEL( l ), buf );
     427
     428//ccc
     429  //  gtk_button_set_label( GTK_BUTTON( toggle ), buf);
    382430}
    383431
     
    395443        GPOINTER_TO_UINT( g_object_get_data( G_OBJECT( toggle ),
    396444                                             FILTER_MODE_KEY ) );
    397 
     445   
    398446    /* update the filter */
    399447    if( isActive )
     
    407455    {
    408456        GtkToggleButton * walk = GTK_TOGGLE_BUTTON( l->data );
     457        update_toggle(walk, vprivate);
    409458        if( isActive && ( toggle != walk ) )
    410459            gtk_toggle_button_set_active( walk, FALSE );
     
    509558    GSList *      l;
    510559    GSList *      toggles;
    511     const char *  filter_names[FILTER_MODE_QTY] = {
    512         /* show all torrents */
    513         N_( "A_ll" ),
    514         /* show only torrents that have connected peers */
    515         N_( "_Active" ),
    516         /* show only torrents that are trying to download */
    517         N_( "_Downloading" ),
    518         /* show only torrents that are trying to upload */
    519         N_( "_Seeding" ),
    520         /* show only torrents that are paused */
    521         N_( "_Paused" )
    522     };
     560
    523561    const char *  filter_text_names[FILTER_TEXT_MODE_QTY] = {
    524562        N_( "Name" ), N_( "Files" ), N_( "Tracker" )
     
    564602    /* filter */
    565603    toggles = NULL;
    566     h = p->filter = gtk_hbox_new( FALSE, 0 );
     604    h = p->filter = gtk_hbox_new( FALSE, GUI_PAD );
    567605    gtk_container_set_border_width( GTK_CONTAINER( h ), GUI_PAD_SMALL );
    568606    for( i = 0; i < FILTER_MODE_QTY; ++i )
    569607    {
    570608        const char * mnemonic = _( filter_names[i] );
    571         w = gtk_toggle_button_new_with_mnemonic( mnemonic );
    572         g_object_set_data( G_OBJECT( w ), FILTER_MODE_KEY,
    573                           GINT_TO_POINTER( i ) );
     609        GtkWidget * label;
     610        w = gtk_toggle_button_new( );
     611        label = gtk_label_new_with_mnemonic( mnemonic );
     612        gtk_container_add( GTK_CONTAINER( w ), label );
     613        g_object_set_data( G_OBJECT( w ), FILTER_MODE_KEY, GINT_TO_POINTER( i ) );
    574614        gtk_button_set_relief( GTK_BUTTON( w ), GTK_RELIEF_NONE );
    575         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(
    576                                           w ), i == FILTER_MODE_ALL );
     615        gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( w ), i == FILTER_MODE_ALL );
    577616        toggles = g_slist_prepend( toggles, w );
    578617        g_signal_connect( w, "toggled", G_CALLBACK( filter_toggled_cb ), p );
    579618        gtk_box_pack_start( GTK_BOX( h ), w, FALSE, FALSE, 0 );
     619        g_object_set_data( G_OBJECT( w ), "title", mnemonic);
    580620    }
    581621    for( l = toggles; l != NULL; l = l->next )
    582622        g_object_set_data( G_OBJECT( l->data ), FILTER_TOGGLES_KEY, toggles );
     623    p->toggles = toggles;
    583624    s = sexy_icon_entry_new( );
    584625    sexy_icon_entry_add_clear_button( SEXY_ICON_ENTRY( s ) );
     
    687728
    688729    filter_entry_changed( GTK_EDITABLE( s ), p );
     730   
     731    for( l = toggles; l != NULL; l = l->next ) {
     732        update_toggle(GTK_TOGGLE_BUTTON( l->data ), p);
     733    }
    689734    return self;
    690735}
     
    787832{
    788833    PrivateData * p = get_private_data( self );
     834    GSList *      l;   
    789835
    790836    if( p && p->core && tr_core_session( p->core ) )
     
    794840        updateStats( p );
    795841        refilter( p );
     842        for( l = p->toggles; l != NULL; l = l->next ) {
     843            update_toggle(GTK_TOGGLE_BUTTON( l->data ), p);
     844        }
    796845    }
    797846}
  • trunk/gtk/util.h

    r6807 r7271  
    4242/* return a human-readable string for the size given in bytes. */
    4343char*       tr_strlsize( char *   buf,
    44                          uint64_t size,
     44                         guint64 size,
    4545                         size_t   buflen );
    4646
Note: See TracChangeset for help on using the changeset viewer.