Changeset 11738


Ignore:
Timestamp:
Jan 21, 2011, 4:32:27 PM (11 years ago)
Author:
jordan
Message:

(trunk gtk) make "gtr_label_set_text" public and use it everywhere instead of gtk_label_set_text()

Some of the refresh events to the main window's torrent list are caused by main window relayout caused by the toolbar's GtkLabels? recalculating their size after being updated once per second. To prevent relayout in some trivial cases, I'm replacing the gtk_label_set_text() calls with gtr_label_set_text() because the latter doesn't update the label widget if the old and new text strings are the same.

There are other changes that can handle more important cases -- I'll test those out next.

Location:
trunk/gtk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/details.c

    r11711 r11738  
    573573
    574574    return "";
    575 }
    576 
    577 /* Only call gtk_label_set_text() if the new text differs from the old.
    578  * This way if the user has text selected, refreshing won't deselect it */
    579 static void
    580 gtr_label_set_text( GtkLabel * lb, const char * newstr )
    581 {
    582     const char * oldstr = gtk_label_get_text( lb );
    583 
    584     if( ( oldstr == NULL ) || strcmp( oldstr, newstr ) )
    585         gtk_label_set_text( lb, newstr );
    586575}
    587576
  • trunk/gtk/makemeta-ui.c

    r11709 r11738  
    9191
    9292    if( str != NULL ) {
    93         gtk_label_set_text( GTK_LABEL( ui->progress_label ), str );
     93        gtr_label_set_text( GTK_LABEL( ui->progress_label ), str );
    9494        g_free( str );
    9595    }
  • trunk/gtk/stats.c

    r11709 r11738  
    4141          const char * str )
    4242{
    43     gtk_label_set_text( GTK_LABEL( w ), str );
     43    gtr_label_set_text( GTK_LABEL( w ), str );
    4444}
    4545
  • trunk/gtk/tr-prefs.c

    r11709 r11738  
    11051105        struct network_page_data * data = gdata;
    11061106        gdk_threads_enter();
    1107         gtk_label_set_text( GTK_LABEL( data->portLabel ), _( "Status unknown" ) );
     1107        gtr_label_set_text( GTK_LABEL( data->portLabel ), _( "Status unknown" ) );
    11081108        gtk_widget_set_sensitive( data->portButton, TRUE );
    11091109        gtk_widget_set_sensitive( data->portSpin, TRUE );
  • trunk/gtk/tr-window.c

    r11720 r11738  
    537537    w = p->speedlimit_on_item[TR_DOWN];
    538538    tr_formatter_speed_KBps( buf1, gtr_pref_int_get( TR_PREFS_KEY_DSPEED_KBps ), sizeof( buf1 ) );
    539     gtk_label_set_text( GTK_LABEL( gtk_bin_get_child( GTK_BIN( w ) ) ), buf1 );
     539    gtr_label_set_text( GTK_LABEL( gtk_bin_get_child( GTK_BIN( w ) ) ), buf1 );
    540540
    541541    b = gtr_pref_flag_get( TR_PREFS_KEY_DSPEED_ENABLED );
     
    545545    w = p->speedlimit_on_item[TR_UP];
    546546    tr_formatter_speed_KBps( buf1, gtr_pref_int_get( TR_PREFS_KEY_USPEED_KBps ), sizeof( buf1 ) );
    547     gtk_label_set_text( GTK_LABEL( gtk_bin_get_child( GTK_BIN( w ) ) ), buf1 );
     547    gtr_label_set_text( GTK_LABEL( gtk_bin_get_child( GTK_BIN( w ) ) ), buf1 );
    548548
    549549    b = gtr_pref_flag_get( TR_PREFS_KEY_USPEED_ENABLED );
     
    553553    tr_strlratio( buf1, gtr_pref_double_get( TR_PREFS_KEY_RATIO ), sizeof( buf1 ) );
    554554    g_snprintf( buf2, sizeof( buf2 ), _( "Stop at Ratio (%s)" ), buf1 );
    555     gtk_label_set_text( GTK_LABEL( gtk_bin_get_child( GTK_BIN( p->ratio_on_item ) ) ), buf2 );
     555    gtr_label_set_text( GTK_LABEL( gtk_bin_get_child( GTK_BIN( p->ratio_on_item ) ) ), buf2 );
    556556
    557557    b = gtr_pref_flag_get( TR_PREFS_KEY_RATIO_ENABLED );
     
    760760                        gtr_ngettext( "%'d Torrent", "%'d Torrents", torrentCount ),
    761761                        torrentCount );
    762         gtk_label_set_text( GTK_LABEL( p->gutter_lb ), buf );
     762        gtr_label_set_text( GTK_LABEL( p->gutter_lb ), buf );
    763763    }
    764764}
     
    808808        g_snprintf( buf, sizeof( buf ), _( "Ratio: %s" ), ratio );
    809809    }
    810     gtk_label_set_text( GTK_LABEL( p->stats_lb ), buf );
     810    gtr_label_set_text( GTK_LABEL( p->stats_lb ), buf );
    811811}
    812812
     
    835835
    836836        tr_formatter_speed_KBps( buf, down, sizeof( buf ) );
    837         gtk_label_set_text( GTK_LABEL( p->dl_lb ), buf );
     837        gtr_label_set_text( GTK_LABEL( p->dl_lb ), buf );
    838838
    839839        tr_formatter_speed_KBps( buf, up, sizeof( buf ) );
    840         gtk_label_set_text( GTK_LABEL( p->ul_lb ), buf );
     840        gtr_label_set_text( GTK_LABEL( p->ul_lb ), buf );
    841841    }
    842842}
  • trunk/gtk/util.c

    r11709 r11738  
    941941}
    942942
     943/***
     944****
     945***/
     946
     947void
     948gtr_label_set_text( GtkLabel * lb, const char * newstr )
     949{
     950    const char * oldstr = gtk_label_get_text( lb );
     951
     952    if( ( oldstr == NULL ) || strcmp( oldstr, newstr ) )
     953        gtk_label_set_text( lb, newstr );
     954}
  • trunk/gtk/util.h

    r11709 r11738  
    201201void gtr_paste_clipboard_url_into_entry( GtkWidget * entry );
    202202
     203/* Only call gtk_label_set_text() if the new text differs from the old.
     204 * This prevents the label from having to recalculate its size
     205 * and prevents selected text in the label from being deselected */
     206void gtr_label_set_text( GtkLabel * lb, const char * text );
    203207
    204208#endif /* GTR_UTIL_H */
Note: See TracChangeset for help on using the changeset viewer.