Changeset 6829
- Timestamp:
- Oct 2, 2008, 2:13:26 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gtk/tr-window.c
r6807 r6829 74 74 typedef struct 75 75 { 76 GtkTooltips * tooltips;77 76 GtkWidget * scroll; 78 77 GtkWidget * view; … … 85 84 GtkWidget * stats_lb; 86 85 GtkWidget * gutter_lb; 87 GtkWidget * update_tracker_button;88 86 GtkTreeSelection * selection; 89 87 GtkCellRenderer * renderer; … … 444 442 gtk_get_current_event_time( ) ); 445 443 } 444 445 #if GTK_CHECK_VERSION( 2, 12, 0 ) 446 447 static void 448 findMaxAnnounceTime( GtkTreeModel * model, 449 GtkTreePath * path UNUSED, 450 GtkTreeIter * iter, 451 gpointer gmaxTime ) 452 { 453 tr_torrent * tor; 454 const tr_stat * torStat; 455 time_t * maxTime = gmaxTime; 456 457 gtk_tree_model_get( model, iter, MC_TORRENT_RAW, &tor, -1 ); 458 torStat = tr_torrentStatCached( tor ); 459 *maxTime = MAX( *maxTime, torStat->manualAnnounceTime ); 460 } 461 462 static gboolean 463 onAskTrackerQueryTooltip( GtkWidget * widget UNUSED, 464 gint x UNUSED, 465 gint y UNUSED, 466 gboolean keyboard_tip UNUSED, 467 GtkTooltip * tooltip, 468 gpointer gdata ) 469 { 470 const time_t now = time( NULL ); 471 time_t maxTime = 0; 472 PrivateData * p = gdata; 473 474 gtk_tree_selection_selected_foreach( p->selection, 475 findMaxAnnounceTime, 476 &maxTime ); 477 if( maxTime <= now ) 478 { 479 return FALSE; 480 } 481 else 482 { 483 char buf[128]; 484 char timebuf[64]; 485 const int seconds = maxTime - now; 486 487 tr_strltime( timebuf, seconds, sizeof( timebuf ) ); 488 g_snprintf( buf, sizeof( buf ), 489 _( "Tracker will allow requests in %s" ), timebuf ); 490 gtk_tooltip_set_text( tooltip, buf ); 491 return TRUE; 492 } 493 } 494 495 #endif 446 496 447 497 /*** … … 504 554 gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 ); 505 555 w = action_get_widget( "/main-window-menu/torrent-menu/update-tracker" ); 506 p->update_tracker_button = w; 556 #if GTK_CHECK_VERSION( 2, 12, 0 ) 557 g_signal_connect( w, "query-tooltip", 558 G_CALLBACK( onAskTrackerQueryTooltip ), p ); 559 #endif 507 560 508 561 /* toolbar */ … … 728 781 } 729 782 730 static void731 findMaxAnnounceTime( GtkTreeModel * model,732 GtkTreePath * path UNUSED,733 GtkTreeIter * iter,734 gpointer gmaxTime )735 {736 tr_torrent * tor;737 const tr_stat * torStat;738 time_t * maxTime = gmaxTime;739 740 gtk_tree_model_get( model, iter, MC_TORRENT_RAW, &tor, -1 );741 torStat = tr_torrentStatCached( tor );742 *maxTime = MAX( *maxTime, torStat->manualAnnounceTime );743 }744 745 static void746 updateAskForPeers( PrivateData * p )747 {748 char buf[128];749 time_t maxTime = 0;750 const time_t now = time( NULL );751 752 gtk_tree_selection_selected_foreach( p->selection,753 findMaxAnnounceTime,754 &maxTime );755 756 if( maxTime <= now )757 *buf = '\0';758 else759 {760 char secbuf[32];761 const int seconds = maxTime - time( NULL );762 tr_strltime( secbuf, seconds, sizeof( secbuf ) );763 g_snprintf( buf, sizeof( buf ),764 _( "Tracker will allow requests in %s" ), secbuf );765 }766 767 if( !p->tooltips )768 p->tooltips = gtk_tooltips_new( );769 gtk_tooltips_set_tip( p->tooltips, p->update_tracker_button, buf, NULL );770 }771 772 783 void 773 784 tr_window_update( TrWindow * self ) … … 780 791 updateTorrentCount( p ); 781 792 updateStats( p ); 782 updateAskForPeers( p );783 793 refilter( p ); 784 794 }
Note: See TracChangeset
for help on using the changeset viewer.