Changeset 8763 for trunk/gtk/tr-icon.c
- Timestamp:
- Jun 30, 2009, 6:08:50 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gtk/tr-icon.c
r8724 r8763 52 52 refresh_tooltip_cb( gpointer data ) 53 53 { 54 GtkStatusIcon * icon = GTK_STATUS_ICON( data ); 55 TrCore * core = g_object_get_data( G_OBJECT( icon ), "tr-core" ); 56 struct core_stats stats; 57 char downStr[32], upStr[32]; 58 char tip[256]; 54 double d; 55 int limit; 56 char up[64]; 57 char upLimit[64]; 58 char down[64]; 59 char downLimit[64]; 60 char tip[1024]; 61 const char * idle = _( "Idle" ); 62 GtkStatusIcon * icon = GTK_STATUS_ICON( data ); 63 tr_session * session = tr_core_session( g_object_get_data( G_OBJECT( icon ), "tr-core" ) ); 59 64 60 tr_core_get_stats( core, &stats ); 65 /* up */ 66 if(((d = tr_sessionGetRawSpeed( session, TR_UP ))) < 0.1 ) 67 g_strlcpy( up, idle, sizeof( up ) ); 68 else 69 tr_strlspeed( up, d, sizeof( up ) ); 61 70 62 tr_strlspeed( downStr, stats.clientDownloadSpeed, sizeof( downStr ) ); 63 tr_strlspeed( upStr, stats.clientUploadSpeed, sizeof( upStr ) ); 64 g_snprintf( tip, sizeof( tip ), 65 /* %1$'d is the number of torrents we're seeding, 66 %2$'d is the number of torrents we're downloading, 67 %3$s is our download speed, 68 %4$s is our upload speed */ 69 _( "%1$'d Seeding, %2$'d Downloading\nDown: %3$s, Up: %4$s" ), 70 stats.seedingCount, 71 stats.downloadCount, 72 downStr, upStr ); 71 /* up limit */ 72 if( !tr_sessionGetActiveSpeedLimit( session, TR_UP, &limit ) ) 73 *upLimit = '\0'; 74 else { 75 char buf[64]; 76 tr_strlspeed( buf, limit, sizeof( buf ) ); 77 g_snprintf( upLimit, sizeof( upLimit ), _( "(Limit: %s)" ), buf ); 78 } 79 80 /* down */ 81 if(((d = tr_sessionGetRawSpeed( session, TR_DOWN ))) < 0.1 ) 82 g_strlcpy( down, idle, sizeof( down ) ); 83 else 84 tr_strlspeed( down, d, sizeof( down ) ); 85 86 /* down limit */ 87 if( !tr_sessionGetActiveSpeedLimit( session, TR_DOWN, &limit ) ) 88 *downLimit = '\0'; 89 else { 90 char buf[64]; 91 tr_strlspeed( buf, limit, sizeof( buf ) ); 92 g_snprintf( downLimit, sizeof( downLimit ), _( "(Limit: %s)" ), buf ); 93 } 94 95 /* %1$s: current upload speed 96 * %2$s: current upload limit, if any 97 * %3$s: current download speed 98 * %4$s: current download limit, if any */ 99 g_snprintf( tip, sizeof( tip ), _( "Transmission\nUp: %1$s %2$s\nDown: %3$s %4$s" ), up, upLimit, down, downLimit ); 100 73 101 #if GTK_CHECK_VERSION( 2,16,0 ) 74 102 gtk_status_icon_set_tooltip_text( GTK_STATUS_ICON( icon ), tip );
Note: See TracChangeset
for help on using the changeset viewer.