Changeset 7275
- Timestamp:
- Dec 5, 2008, 3:28:02 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3x/gtk/tr-window.c
r6751 r7275 72 72 typedef struct 73 73 { 74 GtkTooltips * tooltips;75 74 GtkWidget * scroll; 76 75 GtkWidget * view; … … 83 82 GtkWidget * stats_lb; 84 83 GtkWidget * gutter_lb; 85 GtkWidget * update_tracker_button;86 84 GtkTreeSelection * selection; 87 85 GtkCellRenderer * renderer; … … 227 225 gtk_menu_popup( GTK_MENU( p->status_menu ), NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time( ) ); 228 226 } 227 228 #if GTK_CHECK_VERSION(2,12,0 ) 229 230 static void 231 findMaxAnnounceTime( GtkTreeModel * model, 232 GtkTreePath * path UNUSED, 233 GtkTreeIter * iter, 234 gpointer gmaxTime ) 235 { 236 tr_torrent * tor; 237 const tr_stat * torStat; 238 time_t * maxTime = gmaxTime; 239 240 gtk_tree_model_get( model, iter, MC_TORRENT_RAW, &tor, -1 ); 241 torStat = tr_torrentStatCached( tor ); 242 *maxTime = MAX( *maxTime, torStat->manualAnnounceTime ); 243 } 244 245 static gboolean 246 onAskTrackerQueryTooltip( GtkWidget * widget UNUSED, 247 gint x UNUSED, 248 gint y UNUSED, 249 gboolean keyboard_tip UNUSED, 250 GtkTooltip * tooltip, 251 gpointer gdata ) 252 { 253 const time_t now = time( NULL ); 254 time_t maxTime = 0; 255 PrivateData * p = gdata; 256 257 gtk_tree_selection_selected_foreach( p->selection, 258 findMaxAnnounceTime, 259 &maxTime ); 260 if( maxTime <= now ) 261 { 262 return FALSE; 263 } 264 else 265 { 266 char buf[128]; 267 char timebuf[64]; 268 const int seconds = maxTime - now; 269 270 tr_strltime( timebuf, seconds, sizeof( timebuf ) ); 271 g_snprintf( buf, sizeof( buf ), 272 _( "Tracker will allow requests in %s" ), timebuf ); 273 gtk_tooltip_set_text( tooltip, buf ); 274 return TRUE; 275 } 276 } 277 278 #endif 229 279 230 280 #define STATS_MODE "stats-mode" … … 460 510 gtk_box_pack_start( GTK_BOX(vbox), w, FALSE, FALSE, 0 ); 461 511 w = action_get_widget( "/main-window-menu/torrent-menu/update-tracker" ); 462 p->update_tracker_button = w; 512 #if GTK_CHECK_VERSION( 2, 12, 0 ) 513 g_signal_connect( w, "query-tooltip", 514 G_CALLBACK( onAskTrackerQueryTooltip ), p ); 515 #endif 463 516 464 517 /* toolbar */ … … 654 707 } 655 708 656 static void657 findMaxAnnounceTime( GtkTreeModel * model,658 GtkTreePath * path UNUSED,659 GtkTreeIter * iter,660 gpointer gmaxTime )661 {662 tr_torrent * tor;663 const tr_stat * torStat;664 time_t * maxTime = gmaxTime;665 666 gtk_tree_model_get( model, iter, MC_TORRENT_RAW, &tor, -1 );667 torStat = tr_torrentStatCached( tor );668 *maxTime = MAX( *maxTime, torStat->manualAnnounceTime );669 }670 671 static void672 updateAskForPeers( PrivateData * p )673 {674 char buf[128];675 time_t maxTime = 0;676 const time_t now = time( NULL );677 678 gtk_tree_selection_selected_foreach( p->selection,679 findMaxAnnounceTime,680 &maxTime );681 682 if( maxTime <= now )683 *buf = '\0';684 else {685 char secbuf[32];686 const int seconds = maxTime - time( NULL );687 tr_strltime( secbuf, seconds, sizeof( secbuf ) );688 g_snprintf( buf, sizeof( buf ), _( "Tracker will allow requests in %s" ), secbuf );689 }690 691 if( !p->tooltips )692 p->tooltips = gtk_tooltips_new( );693 gtk_tooltips_set_tip( p->tooltips, p->update_tracker_button, buf, NULL );694 }695 696 709 void 697 710 tr_window_update( TrWindow * self ) … … 703 716 updateTorrentCount( p ); 704 717 updateStats( p ); 705 updateAskForPeers( p );706 718 refilter( p ); 707 719 }
Note: See TracChangeset
for help on using the changeset viewer.