Changeset 11747


Ignore:
Timestamp:
Jan 22, 2011, 1:26:44 PM (11 years ago)
Author:
jordan
Message:

(trunk gtk) #3887: "CPU spikes to 100% on scrolling" -- workaround committed.

The patch avoids use of GtkCellRendererText?'s "sensitive" property, and instead renders paused torrents' text using the widget's style's color for insensitive text. This approach honors the theme's "insensitive" color setting and uses it to draw insensitive text with no etching or shadowing.

The better option is still for Murrine to fix its text shadow issue... but until then, here is a workaround.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/torrent-cell-renderer.c

    r11709 r11747  
    326326    tr_torrent       * tor;
    327327    GtkCellRenderer  * text_renderer;
    328     GtkCellRenderer  * text_renderer_err;
    329328    GtkCellRenderer  * progress_renderer;
    330329    GtkCellRenderer  * icon_renderer;
     
    365364}
    366365
    367 static GtkCellRenderer*
    368 get_text_renderer( const tr_stat * st, TorrentCellRenderer * r )
    369 {
    370     return st->error ? r->priv->text_renderer_err : r->priv->text_renderer;
    371 }
    372 
    373366/***
    374367****
     
    389382    char * status;
    390383    GdkPixbuf * icon;
    391     GtkCellRenderer * text_renderer;
    392384
    393385    struct TorrentCellRendererPrivate * p = cell->priv;
     
    405397    icon_area.width = w;
    406398    icon_area.height = h;
    407     text_renderer = get_text_renderer( st, cell );
    408     g_object_set( text_renderer, "text", name, "ellipsize", PANGO_ELLIPSIZE_NONE,  "scale", 1.0, NULL );
    409     gtk_cell_renderer_get_size( text_renderer, widget, NULL, NULL, NULL, &w, &h );
     399    g_object_set( p->text_renderer, "text", name, "ellipsize", PANGO_ELLIPSIZE_NONE,  "scale", 1.0, NULL );
     400    gtk_cell_renderer_get_size( p->text_renderer, widget, NULL, NULL, NULL, &w, &h );
    410401    name_area.width = w;
    411402    name_area.height = h;
    412     g_object_set( text_renderer, "text", status, "scale", SMALL_SCALE, NULL );
    413     gtk_cell_renderer_get_size( text_renderer, widget, NULL, NULL, NULL, &w, &h );
     403    g_object_set( p->text_renderer, "text", status, "scale", SMALL_SCALE, NULL );
     404    gtk_cell_renderer_get_size( p->text_renderer, widget, NULL, NULL, NULL, &w, &h );
    414405    stat_area.width = w;
    415406    stat_area.height = h;
     
    448439    char * progress;
    449440    GdkPixbuf * icon;
    450     GtkCellRenderer * text_renderer;
    451441
    452442    struct TorrentCellRendererPrivate * p = cell->priv;
     
    466456    icon_area.width = w;
    467457    icon_area.height = h;
    468     text_renderer = get_text_renderer( st, cell );
    469     g_object_set( text_renderer, "text", name, "weight", PANGO_WEIGHT_BOLD, "scale", 1.0, "ellipsize", PANGO_ELLIPSIZE_NONE, NULL );
    470     gtk_cell_renderer_get_size( text_renderer, widget, NULL, NULL, NULL, &w, &h );
     458    g_object_set( p->text_renderer, "text", name, "weight", PANGO_WEIGHT_BOLD, "scale", 1.0, "ellipsize", PANGO_ELLIPSIZE_NONE, NULL );
     459    gtk_cell_renderer_get_size( p->text_renderer, widget, NULL, NULL, NULL, &w, &h );
    471460    name_area.width = w;
    472461    name_area.height = h;
    473     g_object_set( text_renderer, "text", progress, "weight", PANGO_WEIGHT_NORMAL, "scale", SMALL_SCALE, NULL );
    474     gtk_cell_renderer_get_size( text_renderer, widget, NULL, NULL, NULL, &w, &h );
     462    g_object_set( p->text_renderer, "text", progress, "weight", PANGO_WEIGHT_NORMAL, "scale", SMALL_SCALE, NULL );
     463    gtk_cell_renderer_get_size( p->text_renderer, widget, NULL, NULL, NULL, &w, &h );
    475464    prog_area.width = w;
    476465    prog_area.height = h;
    477     g_object_set( text_renderer, "text", status, NULL );
    478     gtk_cell_renderer_get_size( text_renderer, widget, NULL, NULL, NULL, &w, &h );
     466    g_object_set( p->text_renderer, "text", status, NULL );
     467    gtk_cell_renderer_get_size( p->text_renderer, widget, NULL, NULL, NULL, &w, &h );
    479468    stat_area.width = w;
    480469    stat_area.height = h;
     
    532521        }
    533522    }
     523}
     524
     525static void
     526get_text_color( GtkWidget * w, const tr_stat * st, GdkColor * setme )
     527{
     528    static const GdkColor red = { 0, 65535, 0, 0 };
     529
     530    if( st->error )
     531        *setme = red;
     532    else if( st->activity == TR_STATUS_STOPPED )
     533        *setme = gtk_widget_get_style(w)->text[GTK_STATE_INSENSITIVE];
     534    else
     535        *setme = gtk_widget_get_style(w)->text[GTK_STATE_NORMAL];
    534536}
    535537
     
    552554    char * status;
    553555    GdkPixbuf * icon;
    554     GtkCellRenderer * text_renderer;
     556    GdkColor text_color;
    555557
    556558    struct TorrentCellRendererPrivate * p = cell->priv;
     
    565567    status = getShortStatusString( tor, st, p->upload_speed_KBps, p->download_speed_KBps );
    566568    gtr_cell_renderer_get_padding( GTK_CELL_RENDERER( cell ), &xpad, &ypad );
     569    get_text_color( widget, st, &text_color );
    567570
    568571    fill_area = *background_area;
     
    575578    g_object_set( p->icon_renderer, "pixbuf", icon, NULL );
    576579    gtk_cell_renderer_get_size( p->icon_renderer, widget, NULL, NULL, NULL, &icon_area.width, NULL );
    577     text_renderer = get_text_renderer( st, cell );
    578     g_object_set( text_renderer, "text", name, "ellipsize", PANGO_ELLIPSIZE_NONE, "scale", 1.0, NULL );
    579     gtk_cell_renderer_get_size( text_renderer, widget, NULL, NULL, NULL, &name_area.width, NULL );
    580     g_object_set( text_renderer, "text", status, "scale", SMALL_SCALE, NULL );
    581     gtk_cell_renderer_get_size( text_renderer, widget, NULL, NULL, NULL, &stat_area.width, NULL );
     580    g_object_set( p->text_renderer, "text", name, "ellipsize", PANGO_ELLIPSIZE_NONE, "scale", 1.0, NULL );
     581    gtk_cell_renderer_get_size( p->text_renderer, widget, NULL, NULL, NULL, &name_area.width, NULL );
     582    g_object_set( p->text_renderer, "text", status, "scale", SMALL_SCALE, NULL );
     583    gtk_cell_renderer_get_size( p->text_renderer, widget, NULL, NULL, NULL, &stat_area.width, NULL );
    582584
    583585    icon_area.x = fill_area.x;
     
    597599    g_object_set( p->progress_renderer, "value", (int)(percentDone*100.0), "text", NULL, "sensitive", sensitive, NULL );
    598600    gtk_cell_renderer_render( p->progress_renderer, window, widget, &prog_area, &prog_area, &prog_area, flags );
    599     g_object_set( text_renderer, "text", status, "scale", SMALL_SCALE, "sensitive", sensitive, "ellipsize", PANGO_ELLIPSIZE_END, NULL );
    600     gtk_cell_renderer_render( text_renderer, window, widget, &stat_area, &stat_area, &stat_area, flags );
    601     g_object_set( text_renderer, "text", name, "scale", 1.0, NULL );
    602     gtk_cell_renderer_render( text_renderer, window, widget, &name_area, &name_area, &name_area, flags );
     601    g_object_set( p->text_renderer, "text", status, "scale", SMALL_SCALE, "ellipsize", PANGO_ELLIPSIZE_END, "foreground-gdk", &text_color, NULL );
     602    gtk_cell_renderer_render( p->text_renderer, window, widget, &stat_area, &stat_area, &stat_area, flags );
     603    g_object_set( p->text_renderer, "text", name, "scale", 1.0, NULL );
     604    gtk_cell_renderer_render( p->text_renderer, window, widget, &name_area, &name_area, &name_area, flags );
    603605
    604606    /* cleanup */
     
    628630    char * progress;
    629631    GdkPixbuf * icon;
    630     GtkCellRenderer * text_renderer;
     632    GdkColor text_color;
    631633
    632634    struct TorrentCellRendererPrivate * p = cell->priv;
     
    643645    progress = getProgressString( tor, inf, st );
    644646    gtr_cell_renderer_get_padding( GTK_CELL_RENDERER( cell ), &xpad, &ypad );
     647    get_text_color( widget, st, &text_color );
    645648
    646649    /* get the idealized cell dimensions */
     
    649652    icon_area.width = w;
    650653    icon_area.height = h;
    651     text_renderer = get_text_renderer( st, cell );
    652     g_object_set( text_renderer, "text", name, "weight", PANGO_WEIGHT_BOLD, "ellipsize", PANGO_ELLIPSIZE_NONE, "scale", 1.0, NULL );
    653     gtk_cell_renderer_get_size( text_renderer, widget, NULL, NULL, NULL, &w, &h );
     654    g_object_set( p->text_renderer, "text", name, "weight", PANGO_WEIGHT_BOLD, "ellipsize", PANGO_ELLIPSIZE_NONE, "scale", 1.0, NULL );
     655    gtk_cell_renderer_get_size( p->text_renderer, widget, NULL, NULL, NULL, &w, &h );
    654656    name_area.width = w;
    655657    name_area.height = h;
    656     g_object_set( text_renderer, "text", progress, "weight", PANGO_WEIGHT_NORMAL, "scale", SMALL_SCALE, NULL );
    657     gtk_cell_renderer_get_size( text_renderer, widget, NULL, NULL, NULL, &w, &h );
     658    g_object_set( p->text_renderer, "text", progress, "weight", PANGO_WEIGHT_NORMAL, "scale", SMALL_SCALE, NULL );
     659    gtk_cell_renderer_get_size( p->text_renderer, widget, NULL, NULL, NULL, &w, &h );
    658660    prog_area.width = w;
    659661    prog_area.height = h;
    660     g_object_set( text_renderer, "text", status, NULL );
    661     gtk_cell_renderer_get_size( text_renderer, widget, NULL, NULL, NULL, &w, &h );
     662    g_object_set( p->text_renderer, "text", status, NULL );
     663    gtk_cell_renderer_get_size( p->text_renderer, widget, NULL, NULL, NULL, &w, &h );
    662664    stat_area.width = w;
    663665    stat_area.height = h;
     
    704706    g_object_set( p->icon_renderer, "pixbuf", icon, "sensitive", sensitive, NULL );
    705707    gtk_cell_renderer_render( p->icon_renderer, window, widget, &icon_area, &icon_area, &icon_area, flags );
    706     g_object_set( text_renderer, "text", name, "scale", 1.0, "sensitive", sensitive, "ellipsize", PANGO_ELLIPSIZE_END, "weight", PANGO_WEIGHT_BOLD, NULL );
    707     gtk_cell_renderer_render( text_renderer, window, widget, &name_area, &name_area, &name_area, flags );
    708     g_object_set( text_renderer, "text", progress, "scale", SMALL_SCALE, "weight", PANGO_WEIGHT_NORMAL, NULL );
    709     gtk_cell_renderer_render( text_renderer, window, widget, &prog_area, &prog_area, &prog_area, flags );
     708    g_object_set( p->text_renderer, "text", name, "scale", 1.0, "foreground-gdk", &text_color, "ellipsize", PANGO_ELLIPSIZE_END, "weight", PANGO_WEIGHT_BOLD, NULL );
     709    gtk_cell_renderer_render( p->text_renderer, window, widget, &name_area, &name_area, &name_area, flags );
     710    g_object_set( p->text_renderer, "text", progress, "scale", SMALL_SCALE, "weight", PANGO_WEIGHT_NORMAL, NULL );
     711    gtk_cell_renderer_render( p->text_renderer, window, widget, &prog_area, &prog_area, &prog_area, flags );
    710712    g_object_set( p->progress_renderer, "value", (int)(percentDone*100.0), "text", "", "sensitive", sensitive, NULL );
    711713    gtk_cell_renderer_render( p->progress_renderer, window, widget, &prct_area, &prct_area, &prct_area, flags );
    712     g_object_set( text_renderer, "text", status, NULL );
    713     gtk_cell_renderer_render( text_renderer, window, widget, &stat_area, &stat_area, &stat_area, flags );
     714    g_object_set( p->text_renderer, "text", status, NULL );
     715    gtk_cell_renderer_render( p->text_renderer, window, widget, &stat_area, &stat_area, &stat_area, flags );
    714716
    715717    /* cleanup */
     
    798800    {
    799801        g_object_unref( G_OBJECT( r->priv->text_renderer ) );
    800         g_object_unref( G_OBJECT( r->priv->text_renderer_err ) );
    801802        g_object_unref( G_OBJECT( r->priv->progress_renderer ) );
    802803        g_object_unref( G_OBJECT( r->priv->icon_renderer ) );
     
    873874    p->text_renderer = gtk_cell_renderer_text_new( );
    874875    g_object_set( p->text_renderer, "xpad", 0, "ypad", 0, NULL );
    875     p->text_renderer_err = gtk_cell_renderer_text_new(  );
    876     g_object_set( p->text_renderer_err, "xpad", 0, "ypad", 0, NULL );
    877876    p->progress_renderer = gtk_cell_renderer_progress_new(  );
    878877    p->icon_renderer = gtk_cell_renderer_pixbuf_new(  );
    879     g_object_set( p->text_renderer_err, "foreground", "red", NULL );
    880878    gtr_object_ref_sink( p->text_renderer );
    881     gtr_object_ref_sink( p->text_renderer_err );
    882879    gtr_object_ref_sink( p->progress_renderer );
    883880    gtr_object_ref_sink( p->icon_renderer );
Note: See TracChangeset for help on using the changeset viewer.