Ignore:
Timestamp:
Apr 10, 2009, 5:44:17 PM (13 years ago)
Author:
charles
Message:

(1.5x gtk) minor backports:
(1) remove dead code
(2) minor improvements to the filterbar buttons
(3) various minor formatting changes to reduce the diffs between 1.52 and trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.5x/gtk/tr-window.c

    r7994 r8205  
    9393    filter_text_mode_t    filter_text_mode;
    9494    char *                filter_text;
     95    GtkToggleButton     * filter_toggles[FILTER_MODE_QTY];
    9596}
    9697PrivateData;
     
    9899#define PRIVATE_DATA_KEY "private-data"
    99100
    100 #define FILTER_MODE_KEY "tr-filter-mode"
    101101#define FILTER_TEXT_MODE_KEY "tr-filter-text-mode"
    102 #define FILTER_TOGGLES_KEY "tr-filter-toggles"
    103102
    104103static PrivateData*
     
    340339        {
    341340            const tr_stat * s = tr_torrentStatCached( tor );
    342             ret = s->peersSendingToUs > 0 || s->peersGettingFromUs > 0;
     341            ret = s->peersSendingToUs > 0
     342               || s->peersGettingFromUs > 0
     343               || tr_torrentGetActivity( tor ) == TR_STATUS_CHECK;
    343344            break;
    344345        }
     
    393394                   gpointer          vprivate )
    394395{
    395     PrivateData *       p = vprivate;
    396     GSList *            l;
    397     GSList *            toggles = g_object_get_data( G_OBJECT(
    398                                                          toggle ),
    399                                                      FILTER_TOGGLES_KEY );
    400     const gboolean      isActive = gtk_toggle_button_get_active( toggle );
    401     const filter_mode_t mode =
    402         GPOINTER_TO_UINT( g_object_get_data( G_OBJECT( toggle ),
    403                                              FILTER_MODE_KEY ) );
    404 
    405     /* update the filter */
    406     if( isActive )
    407     {
     396    int mode = -1;
     397    PrivateData * p = vprivate;
     398
     399    if( gtk_toggle_button_get_active( toggle ) )
     400    {
     401        int i;
     402        for( i=0; i<FILTER_MODE_QTY; ++i )
     403            if( p->filter_toggles[i] == toggle )
     404                mode = i;
     405            else
     406                gtk_toggle_button_set_active( p->filter_toggles[i], FALSE );
     407    }
     408
     409    if( mode >= 0 ) {
    408410        p->filter_mode = mode;
    409411        refilter( p );
    410412    }
    411 
    412     /* deactivate the other toggles */
    413     for( l = toggles; l != NULL; l = l->next )
    414     {
    415         GtkToggleButton * walk = GTK_TOGGLE_BUTTON( l->data );
    416         if( isActive && ( toggle != walk ) )
    417             gtk_toggle_button_set_active( walk, FALSE );
    418     }
    419 
    420     /* at least one button must always be set */
    421     if( !isActive && ( p->filter_mode == mode ) )
    422         gtk_toggle_button_set_active( toggle, TRUE );
    423413}
    424414
     
    515505    GtkWindow *   win;
    516506    GSList *      l;
    517     GSList *      toggles;
    518507
    519508    const char *  filter_names[FILTER_MODE_QTY] = {
     
    568557
    569558    /* filter */
    570     toggles = NULL;
    571559    h = filter = p->filter = gtk_hbox_new( FALSE, 0 );
    572560    gtk_container_set_border_width( GTK_CONTAINER( h ), GUI_PAD_SMALL );
     
    575563        const char * mnemonic = _( filter_names[i] );
    576564        w = gtk_toggle_button_new_with_mnemonic( mnemonic );
    577         g_object_set_data( G_OBJECT( w ), FILTER_MODE_KEY,
    578                           GINT_TO_POINTER( i ) );
    579565        gtk_button_set_relief( GTK_BUTTON( w ), GTK_RELIEF_NONE );
    580         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(
    581                                           w ), i == FILTER_MODE_ALL );
    582         toggles = g_slist_prepend( toggles, w );
     566        gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( w ), i == FILTER_MODE_ALL );
     567        p->filter_toggles[i] = GTK_TOGGLE_BUTTON( w );
    583568        g_signal_connect( w, "toggled", G_CALLBACK( filter_toggled_cb ), p );
    584569        gtk_box_pack_start( GTK_BOX( h ), w, FALSE, FALSE, 0 );
    585570    }
    586     for( l = toggles; l != NULL; l = l->next )
    587         g_object_set_data( G_OBJECT( l->data ), FILTER_TOGGLES_KEY, toggles );
    588571    s = sexy_icon_entry_new( );
    589572    sexy_icon_entry_add_clear_button( SEXY_ICON_ENTRY( s ) );
    590573    image = gtk_image_new_from_stock( GTK_STOCK_FIND, GTK_ICON_SIZE_MENU );
    591     sexy_icon_entry_set_icon( SEXY_ICON_ENTRY(
    592                                  s ), SEXY_ICON_ENTRY_PRIMARY,
    593                              GTK_IMAGE( image ) );
    594     sexy_icon_entry_set_icon_highlight( SEXY_ICON_ENTRY(
    595                                             s ), SEXY_ICON_ENTRY_PRIMARY,
    596                                         TRUE );
     574    sexy_icon_entry_set_icon( SEXY_ICON_ENTRY( s ), SEXY_ICON_ENTRY_PRIMARY, GTK_IMAGE( image ) );
     575    sexy_icon_entry_set_icon_highlight( SEXY_ICON_ENTRY( s ), SEXY_ICON_ENTRY_PRIMARY, TRUE );
    597576    gtk_box_pack_end( GTK_BOX( h ), s, FALSE, FALSE, 0 );
    598577    g_signal_connect( s, "changed", G_CALLBACK( filter_entry_changed ), p );
Note: See TracChangeset for help on using the changeset viewer.