Changeset 10231


Ignore:
Timestamp:
Feb 19, 2010, 2:49:03 PM (11 years ago)
Author:
charles
Message:

(trunk gtk) #2932 "The 'comment' field in the Torrent Properties dialog loses selection" -- fixed in trunk for 1.91

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/details.c

    r10099 r10231  
    546546}
    547547
     548/* Only call gtk_label_set_text() if the new text differs from the old.
     549 * This way if the user has text selected, refreshing won't deselect it */
    548550static void
    549551gtr_label_set_text( GtkLabel * lb, const char * newstr )
     
    553555    if( ( oldstr == NULL ) || strcmp( oldstr, newstr ) )
    554556        gtk_label_set_text( lb, newstr );
     557}
     558
     559/* Only call gtk_text_buffer_set_text() if the new text differs from the old.
     560 * This way if the user has text selected, refreshing won't deselect it */
     561static void
     562gtr_text_buffer_set_text( GtkTextBuffer * b, const char * str )
     563{
     564    char * old_str;
     565    GtkTextIter start, end;
     566
     567    if( str == NULL )
     568        str = "";
     569
     570    gtk_text_buffer_get_bounds( b, &start, &end );
     571    old_str = gtk_text_buffer_get_text( b, &start, &end, FALSE );
     572
     573    if( ( old_str == NULL ) || strcmp( old_str, str ) )
     574        gtk_text_buffer_set_text( b, str, -1 );
     575
     576    g_free( old_str );
    555577}
    556578
     
    632654            str = mixed;
    633655    }
    634     gtk_text_buffer_set_text( di->comment_buffer, str, -1 );
     656    gtr_text_buffer_set_text( di->comment_buffer, str );
    635657
    636658    /* destination_lb */
Note: See TracChangeset for help on using the changeset viewer.