static void get_size_full( TorrentCellRenderer * cell, GtkWidget * widget, gint * width, gint * height ) { int w, h; GdkRectangle icon_area; GdkRectangle name_area; GdkRectangle stat_area; GdkRectangle prog_area; const char * name; char * status; char * progress; GdkPixbuf * icon; GtkCellRenderer * text_renderer; struct TorrentCellRendererPrivate * p = cell->priv; const tr_torrent * tor = p->tor; const tr_stat * st = tr_torrentStatCached( (tr_torrent*)tor ); const tr_info * inf = tr_torrentInfo( tor ); icon = get_icon( tor, FULL_ICON_SIZE, widget ); name = inf->name; status = getStatusString( tor, st, p->upload_speed, p->download_speed ); progress = getProgressString( tor, inf, st ); /* get the idealized cell dimensions */ g_object_set( p->icon_renderer, "pixbuf", icon, NULL ); gtk_cell_renderer_get_size( p->icon_renderer, widget, NULL, NULL, NULL, &w, &h ); icon_area.width = w; icon_area.height = h; text_renderer = get_text_renderer( st, cell ); g_object_set( text_renderer, "text", name, "weight", PANGO_WEIGHT_BOLD, "scale", 1.0, "ellipsize", PANGO_ELLIPSIZE_NONE, NULL ); gtk_cell_renderer_get_size( text_renderer, widget, NULL, NULL, NULL, &w, &h ); name_area.width = w; name_area.height = h; g_object_set( text_renderer, "text", progress, "weight", PANGO_WEIGHT_NORMAL, "scale", SMALL_SCALE, NULL ); gtk_cell_renderer_get_size( text_renderer, widget, NULL, NULL, NULL, &w, &h ); prog_area.width = w; prog_area.height = h; g_object_set( text_renderer, "text", status, NULL ); gtk_cell_renderer_get_size( text_renderer, widget, NULL, NULL, NULL, &w, &h ); stat_area.width = w; stat_area.height = h; /** *** LAYOUT **/ if( width != NULL ) *width = cell->parent.xpad * 2 + icon_area.width + GUI_PAD + MAX3( name_area.width, prog_area.width, stat_area.width ); if( height != NULL ) *height = cell->parent.ypad * 2 + name_area.height + prog_area.height + GUI_PAD_SMALL + p->bar_height + GUI_PAD_SMALL + stat_area.height; /* cleanup */ g_free( status ); g_free( progress ); g_object_unref( icon ); }
static void get_size_compact( TorrentCellRenderer * cell, GtkWidget * widget, gint * width, gint * height ) { int w, h; int xpad, ypad; GdkRectangle icon_area; GdkRectangle name_area; GdkRectangle stat_area; const char * name; char * status; GdkPixbuf * icon; GtkCellRenderer * text_renderer; struct TorrentCellRendererPrivate * p = cell->priv; const tr_torrent * tor = p->tor; const tr_stat * st = tr_torrentStatCached( (tr_torrent*)tor ); icon = get_icon( tor, COMPACT_ICON_SIZE, widget ); name = tr_torrentInfo( tor )->name; status = getShortStatusString( tor, st, p->upload_speed_KBps, p->download_speed_KBps ); gtr_cell_renderer_get_padding( GTK_CELL_RENDERER( cell ), &xpad, &ypad ); /* get the idealized cell dimensions */ g_object_set( p->icon_renderer, "pixbuf", icon, NULL ); gtk_cell_renderer_get_size( p->icon_renderer, widget, NULL, NULL, NULL, &w, &h ); icon_area.width = w; icon_area.height = h; text_renderer = get_text_renderer( st, cell ); g_object_set( text_renderer, "text", name, "ellipsize", PANGO_ELLIPSIZE_NONE, "scale", 1.0, NULL ); gtk_cell_renderer_get_size( text_renderer, widget, NULL, NULL, NULL, &w, &h ); name_area.width = w; name_area.height = h; g_object_set( text_renderer, "text", status, "scale", SMALL_SCALE, NULL ); gtk_cell_renderer_get_size( text_renderer, widget, NULL, NULL, NULL, &w, &h ); stat_area.width = w; stat_area.height = h; /** *** LAYOUT **/ #define BAR_WIDTH 50 if( width != NULL ) *width = xpad * 2 + icon_area.width + GUI_PAD + name_area.width + GUI_PAD + BAR_WIDTH + GUI_PAD + stat_area.width; if( height != NULL ) *height = ypad * 2 + MAX( name_area.height, p->bar_height ); /* cleanup */ g_free( status ); g_object_unref( icon ); }
icon = get_icon( tor, COMPACT_ICON_SIZE, widget ); name = tr_torrentInfo( tor )->name; status = getShortStatusString( tor, st, p->upload_speed_KBps, p->download_speed_KBps ); gtr_cell_renderer_get_padding( GTK_CELL_RENDERER( cell ), &xpad, &ypad ); fill_area = *background_area; fill_area.x += xpad; fill_area.y += ypad; fill_area.width -= xpad * 2; fill_area.height -= ypad * 2; icon_area = name_area = stat_area = prog_area = fill_area; g_object_set( p->icon_renderer, "pixbuf", icon, NULL ); gtk_cell_renderer_get_size( p->icon_renderer, widget, NULL, NULL, NULL, &icon_area.width, NULL ); text_renderer = get_text_renderer( st, cell ); g_object_set( text_renderer, "text", name, "ellipsize", PANGO_ELLIPSIZE_NONE, "scale", 1.0, NULL ); gtk_cell_renderer_get_size( text_renderer, widget, NULL, NULL, NULL, &name_area.width, NULL ); g_object_set( text_renderer, "text", status, "scale", SMALL_SCALE, NULL ); gtk_cell_renderer_get_size( text_renderer, widget, NULL, NULL, NULL, &stat_area.width, NULL ); icon_area.x = fill_area.x; prog_area.x = fill_area.x + fill_area.width - BAR_WIDTH; prog_area.width = BAR_WIDTH; stat_area.x = prog_area.x - GUI_PAD - stat_area.width; name_area.x = icon_area.x + icon_area.width + GUI_PAD; name_area.y = fill_area.y; name_area.width = stat_area.x - GUI_PAD - name_area.x; /** *** RENDER