2007-02-07 07:35:33 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* $Id$
|
|
|
|
*
|
2008-01-01 17:20:20 +00:00
|
|
|
* Copyright (c) 2005-2008 Transmission authors and contributors
|
2007-02-07 07:35:33 +00:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <glib/gi18n.h>
|
|
|
|
|
2007-07-18 23:04:26 +00:00
|
|
|
#include <libtransmission/transmission.h>
|
2007-02-07 07:35:33 +00:00
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
#include "actions.h"
|
2007-12-19 19:16:36 +00:00
|
|
|
#include "conf.h"
|
2007-06-18 03:40:41 +00:00
|
|
|
#include "hig.h"
|
2007-12-24 00:14:39 +00:00
|
|
|
#include "sexy-icon-entry.h"
|
2007-12-19 02:46:30 +00:00
|
|
|
#include "torrent-cell-renderer.h"
|
2008-02-26 19:58:03 +00:00
|
|
|
#include "tr-prefs.h"
|
|
|
|
#include "tr-torrent.h"
|
|
|
|
#include "tr-window.h"
|
2007-02-07 07:35:33 +00:00
|
|
|
#include "util.h"
|
|
|
|
|
2007-12-19 20:04:38 +00:00
|
|
|
#if !GTK_CHECK_VERSION(2,8,0)
|
|
|
|
static void
|
|
|
|
gtk_tree_view_column_queue_resize( GtkTreeViewColumn * column ) /* yuck */
|
|
|
|
{
|
|
|
|
const int spacing = gtk_tree_view_column_get_spacing( column );
|
|
|
|
gtk_tree_view_column_set_spacing( column, spacing+1 );
|
|
|
|
gtk_tree_view_column_set_spacing( column, spacing );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-12-24 00:14:39 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
FILTER_TEXT_MODE_NAME,
|
|
|
|
FILTER_TEXT_MODE_FILES,
|
|
|
|
FILTER_TEXT_MODE_TRACKER,
|
|
|
|
FILTER_TEXT_MODE_QTY
|
|
|
|
}
|
|
|
|
filter_text_mode_t;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
FILTER_MODE_ALL,
|
|
|
|
FILTER_MODE_ACTIVE,
|
|
|
|
FILTER_MODE_DOWNLOADING,
|
|
|
|
FILTER_MODE_SEEDING,
|
|
|
|
FILTER_MODE_PAUSED,
|
|
|
|
FILTER_MODE_QTY
|
|
|
|
}
|
|
|
|
filter_mode_t;
|
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
typedef struct
|
2007-02-07 07:35:33 +00:00
|
|
|
{
|
2008-02-09 17:49:09 +00:00
|
|
|
GtkTooltips * tooltips;
|
2007-06-18 03:40:41 +00:00
|
|
|
GtkWidget * scroll;
|
|
|
|
GtkWidget * view;
|
2007-12-20 02:56:47 +00:00
|
|
|
GtkWidget * toolbar;
|
2007-12-24 00:14:39 +00:00
|
|
|
GtkWidget * filter;
|
2007-06-18 03:40:41 +00:00
|
|
|
GtkWidget * status;
|
2007-12-20 19:21:21 +00:00
|
|
|
GtkWidget * status_menu;
|
2007-07-08 05:51:55 +00:00
|
|
|
GtkWidget * ul_lb;
|
|
|
|
GtkWidget * dl_lb;
|
2007-12-20 02:56:47 +00:00
|
|
|
GtkWidget * stats_lb;
|
2007-12-24 17:25:52 +00:00
|
|
|
GtkWidget * gutter_lb;
|
2008-02-09 17:49:09 +00:00
|
|
|
GtkWidget * update_tracker_button;
|
2007-12-19 20:04:38 +00:00
|
|
|
GtkTreeSelection * selection;
|
|
|
|
GtkCellRenderer * renderer;
|
|
|
|
GtkTreeViewColumn * column;
|
2007-12-24 00:14:39 +00:00
|
|
|
GtkTreeModel * filter_model;
|
2007-12-19 19:16:36 +00:00
|
|
|
TrCore * core;
|
|
|
|
gulong pref_handler_id;
|
2007-12-24 00:14:39 +00:00
|
|
|
filter_mode_t filter_mode;
|
|
|
|
filter_text_mode_t filter_text_mode;
|
|
|
|
char * filter_text;
|
2007-02-07 07:35:33 +00:00
|
|
|
}
|
2007-06-18 03:40:41 +00:00
|
|
|
PrivateData;
|
2007-02-07 07:35:33 +00:00
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
#define PRIVATE_DATA_KEY "private-data"
|
2007-02-23 19:50:48 +00:00
|
|
|
|
2007-12-24 00:14:39 +00:00
|
|
|
#define FILTER_MODE_KEY "tr-filter-mode"
|
|
|
|
#define FILTER_TEXT_MODE_KEY "tr-filter-text-mode"
|
|
|
|
#define FILTER_TOGGLES_KEY "tr-filter-toggles"
|
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
PrivateData*
|
|
|
|
get_private_data( TrWindow * w )
|
2007-02-07 07:35:33 +00:00
|
|
|
{
|
2008-02-24 14:32:42 +00:00
|
|
|
return g_object_get_data (G_OBJECT(w), PRIVATE_DATA_KEY);
|
2007-02-07 07:35:33 +00:00
|
|
|
}
|
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
2007-02-07 07:35:33 +00:00
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
static void
|
|
|
|
on_popup_menu ( GtkWidget * self UNUSED, GdkEventButton * event )
|
2007-02-07 07:35:33 +00:00
|
|
|
{
|
2007-06-18 03:40:41 +00:00
|
|
|
GtkWidget * menu = action_get_widget ( "/main-window-popup" );
|
|
|
|
gtk_menu_popup (GTK_MENU(menu), NULL, NULL, NULL, NULL,
|
|
|
|
(event ? event->button : 0),
|
|
|
|
(event ? event->time : 0));
|
2007-02-07 07:35:33 +00:00
|
|
|
}
|
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
static void
|
|
|
|
view_row_activated ( GtkTreeView * tree_view UNUSED,
|
|
|
|
GtkTreePath * path UNUSED,
|
|
|
|
GtkTreeViewColumn * column UNUSED,
|
|
|
|
gpointer user_data UNUSED )
|
2007-02-07 07:35:33 +00:00
|
|
|
{
|
2007-10-10 18:52:08 +00:00
|
|
|
action_activate( "show-torrent-details" );
|
2007-02-07 07:35:33 +00:00
|
|
|
}
|
|
|
|
|
2007-12-24 00:14:39 +00:00
|
|
|
static gboolean is_row_visible( GtkTreeModel *, GtkTreeIter *, gpointer );
|
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
static GtkWidget*
|
2007-12-24 00:14:39 +00:00
|
|
|
makeview( PrivateData * p, TrCore * core )
|
2007-02-07 07:35:33 +00:00
|
|
|
{
|
2007-06-18 03:40:41 +00:00
|
|
|
GtkWidget * view;
|
|
|
|
GtkTreeViewColumn * col;
|
|
|
|
GtkTreeSelection * sel;
|
2007-12-19 02:46:30 +00:00
|
|
|
GtkCellRenderer * r;
|
2007-12-24 00:14:39 +00:00
|
|
|
GtkTreeModel * filter_model;
|
2007-02-07 07:35:33 +00:00
|
|
|
|
2007-10-17 18:31:12 +00:00
|
|
|
view = gtk_tree_view_new();
|
2007-12-19 02:46:30 +00:00
|
|
|
gtk_tree_view_set_headers_visible( GTK_TREE_VIEW(view), FALSE );
|
2007-02-07 07:35:33 +00:00
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
p->selection = gtk_tree_view_get_selection( GTK_TREE_VIEW(view) );
|
2007-02-07 07:35:33 +00:00
|
|
|
|
2007-12-19 18:42:33 +00:00
|
|
|
p->renderer = r = torrent_cell_renderer_new( );
|
2007-12-19 20:04:38 +00:00
|
|
|
p->column = col = gtk_tree_view_column_new_with_attributes(
|
|
|
|
_("Torrent"), r, "torrent", MC_TORRENT_RAW, NULL );
|
2007-12-19 20:30:53 +00:00
|
|
|
g_object_set( G_OBJECT(col), "resizable", TRUE,
|
|
|
|
"sizing", GTK_TREE_VIEW_COLUMN_FIXED,
|
|
|
|
NULL );
|
2007-06-18 03:40:41 +00:00
|
|
|
gtk_tree_view_append_column( GTK_TREE_VIEW( view ), col );
|
2007-12-19 02:46:30 +00:00
|
|
|
g_object_set( r, "xpad", GUI_PAD_SMALL, "ypad", GUI_PAD_SMALL, NULL );
|
2007-02-07 07:35:33 +00:00
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
gtk_tree_view_set_rules_hint( GTK_TREE_VIEW( view ), TRUE );
|
|
|
|
sel = gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) );
|
|
|
|
gtk_tree_selection_set_mode( GTK_TREE_SELECTION( sel ),
|
|
|
|
GTK_SELECTION_MULTIPLE );
|
2007-02-23 19:50:48 +00:00
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
g_signal_connect( view, "popup-menu",
|
|
|
|
G_CALLBACK(on_popup_menu), NULL );
|
|
|
|
g_signal_connect( view, "button-press-event",
|
2007-12-20 01:33:51 +00:00
|
|
|
G_CALLBACK(on_tree_view_button_pressed),
|
|
|
|
(void *) on_popup_menu);
|
2007-06-18 03:40:41 +00:00
|
|
|
g_signal_connect( view, "row-activated",
|
|
|
|
G_CALLBACK(view_row_activated), NULL);
|
2007-02-07 07:35:33 +00:00
|
|
|
|
2007-12-24 00:14:39 +00:00
|
|
|
|
|
|
|
filter_model = p->filter_model = gtk_tree_model_filter_new( tr_core_model( core ), NULL );
|
|
|
|
|
|
|
|
gtk_tree_model_filter_set_visible_func( GTK_TREE_MODEL_FILTER( filter_model ),
|
|
|
|
is_row_visible,
|
|
|
|
p, NULL );
|
|
|
|
|
|
|
|
gtk_tree_view_set_model( GTK_TREE_VIEW( view ), filter_model );
|
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
return view;
|
2007-02-07 07:35:33 +00:00
|
|
|
}
|
|
|
|
|
2007-12-19 19:16:36 +00:00
|
|
|
static void
|
|
|
|
prefsChanged( TrCore * core UNUSED, const char * key, gpointer wind )
|
|
|
|
{
|
2007-12-20 02:56:47 +00:00
|
|
|
PrivateData * p = get_private_data( GTK_WINDOW( wind ) );
|
|
|
|
|
2007-12-19 19:16:36 +00:00
|
|
|
if( !strcmp( key, PREF_KEY_MINIMAL_VIEW ) )
|
|
|
|
{
|
|
|
|
g_object_set( p->renderer, "minimal", pref_flag_get( key ), NULL );
|
2007-12-19 20:04:38 +00:00
|
|
|
gtk_tree_view_column_queue_resize( p->column );
|
2008-01-03 21:33:06 +00:00
|
|
|
gtk_widget_queue_draw( p->view );
|
2007-12-19 19:16:36 +00:00
|
|
|
}
|
2008-03-19 19:30:03 +00:00
|
|
|
else if( !strcmp( key, PREF_KEY_STATUSBAR ) )
|
2007-12-20 02:56:47 +00:00
|
|
|
{
|
|
|
|
const gboolean isEnabled = pref_flag_get( key );
|
|
|
|
g_object_set( p->status, "visible", isEnabled, NULL );
|
|
|
|
}
|
2008-03-19 19:30:03 +00:00
|
|
|
else if( !strcmp( key, PREF_KEY_FILTERBAR ) )
|
2007-12-24 00:14:39 +00:00
|
|
|
{
|
|
|
|
const gboolean isEnabled = pref_flag_get( key );
|
|
|
|
g_object_set( p->filter, "visible", isEnabled, NULL );
|
|
|
|
}
|
2007-12-20 02:56:47 +00:00
|
|
|
else if( !strcmp( key, PREF_KEY_TOOLBAR ) )
|
|
|
|
{
|
|
|
|
const gboolean isEnabled = pref_flag_get( key );
|
|
|
|
g_object_set( p->toolbar, "visible", isEnabled, NULL );
|
|
|
|
}
|
2008-03-19 19:30:03 +00:00
|
|
|
else if( !strcmp( key, PREF_KEY_STATUSBAR_STATS ) )
|
2007-12-20 19:21:21 +00:00
|
|
|
{
|
|
|
|
tr_window_update( (TrWindow*)wind );
|
|
|
|
}
|
2007-12-19 19:16:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
privateFree( gpointer vprivate )
|
|
|
|
{
|
2008-02-24 14:32:42 +00:00
|
|
|
PrivateData * p = vprivate;
|
2007-12-19 19:16:36 +00:00
|
|
|
g_signal_handler_disconnect( p->core, p->pref_handler_id );
|
2008-01-12 17:59:09 +00:00
|
|
|
g_free( p->filter_text );
|
2007-12-19 19:16:36 +00:00
|
|
|
g_free( p );
|
|
|
|
}
|
|
|
|
|
2007-12-20 19:21:21 +00:00
|
|
|
static void
|
|
|
|
onYinYangReleased( GtkWidget * w UNUSED, GdkEventButton * button UNUSED, gpointer vprivate )
|
|
|
|
{
|
2008-02-24 14:32:42 +00:00
|
|
|
PrivateData * p = vprivate;
|
2007-12-20 19:21:21 +00:00
|
|
|
gtk_menu_popup( GTK_MENU( p->status_menu ), 0, 0, 0, 0, 0, gtk_get_current_event_time( ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
#define STATS_MODE "stats-mode"
|
|
|
|
|
|
|
|
static struct {
|
|
|
|
const char *val, *i18n;
|
|
|
|
} stats_modes[] = {
|
|
|
|
{ "total-ratio", N_("Total Ratio") },
|
|
|
|
{ "session-ratio", N_("Session Ratio") },
|
|
|
|
{ "total-transfer", N_("Total Transfer") },
|
|
|
|
{ "session-transfer", N_("Session Transfer") }
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
status_menu_toggled_cb( GtkCheckMenuItem * menu_item,
|
|
|
|
gpointer vprivate )
|
|
|
|
{
|
|
|
|
if( gtk_check_menu_item_get_active( menu_item ) )
|
|
|
|
{
|
2008-02-24 14:32:42 +00:00
|
|
|
PrivateData * p = vprivate;
|
2007-12-20 19:21:21 +00:00
|
|
|
const char * val = g_object_get_data( G_OBJECT( menu_item ), STATS_MODE );
|
2008-03-19 19:30:03 +00:00
|
|
|
tr_core_set_pref( p->core, PREF_KEY_STATUSBAR_STATS, val );
|
2007-12-20 19:21:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-24 00:14:39 +00:00
|
|
|
/***
|
|
|
|
**** FILTER
|
|
|
|
***/
|
|
|
|
|
|
|
|
static int
|
|
|
|
checkFilterText( filter_text_mode_t filter_text_mode,
|
|
|
|
const tr_info * torInfo,
|
|
|
|
const char * text )
|
|
|
|
{
|
2008-03-22 18:10:59 +00:00
|
|
|
tr_file_index_t i;
|
2007-12-24 00:14:39 +00:00
|
|
|
int ret = 0;
|
|
|
|
char * pch;
|
|
|
|
|
|
|
|
switch( filter_text_mode )
|
|
|
|
{
|
|
|
|
case FILTER_TEXT_MODE_FILES:
|
|
|
|
for( i=0; i<torInfo->fileCount && !ret; ++i ) {
|
|
|
|
pch = g_ascii_strdown( torInfo->files[i].name, -1 );
|
|
|
|
ret = !text || strstr( pch, text ) != NULL;
|
|
|
|
g_free( pch );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FILTER_TEXT_MODE_TRACKER:
|
2008-04-24 01:42:53 +00:00
|
|
|
pch = g_ascii_strdown( torInfo->trackers[0].announce, -1 );
|
2007-12-24 00:14:39 +00:00
|
|
|
ret = !text || ( strstr( pch, text ) != NULL );
|
|
|
|
g_free( pch );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: /* NAME */
|
|
|
|
pch = g_ascii_strdown( torInfo->name, -1 );
|
|
|
|
ret = !text || ( strstr( pch, text ) != NULL );
|
|
|
|
g_free( pch );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
checkFilterMode( filter_mode_t filter_mode,
|
2008-04-01 11:53:50 +00:00
|
|
|
tr_torrent * tor )
|
2007-12-24 00:14:39 +00:00
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
switch( filter_mode )
|
|
|
|
{
|
|
|
|
case FILTER_MODE_DOWNLOADING:
|
2008-04-01 11:53:50 +00:00
|
|
|
ret = tr_torrentGetStatus( tor ) == TR_STATUS_DOWNLOAD;
|
2007-12-24 00:14:39 +00:00
|
|
|
break;
|
|
|
|
case FILTER_MODE_SEEDING:
|
2008-04-01 11:53:50 +00:00
|
|
|
ret = tr_torrentGetStatus( tor ) == TR_STATUS_SEED;
|
2007-12-24 00:14:39 +00:00
|
|
|
break;
|
|
|
|
case FILTER_MODE_PAUSED:
|
2008-04-01 11:53:50 +00:00
|
|
|
ret = tr_torrentGetStatus( tor ) == TR_STATUS_STOPPED;
|
|
|
|
break;
|
|
|
|
case FILTER_MODE_ACTIVE: {
|
|
|
|
const tr_stat * s = tr_torrentStatCached( tor );
|
|
|
|
ret = s->peersSendingToUs>0 || s->peersGettingFromUs>0;
|
2007-12-24 00:14:39 +00:00
|
|
|
break;
|
2008-04-01 11:53:50 +00:00
|
|
|
}
|
2007-12-24 00:14:39 +00:00
|
|
|
default: /* all */
|
|
|
|
ret = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
is_row_visible( GtkTreeModel * model,
|
|
|
|
GtkTreeIter * iter,
|
|
|
|
gpointer vprivate )
|
|
|
|
{
|
|
|
|
PrivateData * p = vprivate;
|
|
|
|
tr_torrent * tor;
|
|
|
|
gtk_tree_model_get( model, iter, MC_TORRENT_RAW, &tor, -1 );
|
|
|
|
|
2008-04-01 11:53:50 +00:00
|
|
|
return checkFilterMode( p->filter_mode, tor )
|
2007-12-24 00:14:39 +00:00
|
|
|
&& checkFilterText( p->filter_text_mode, tr_torrentInfo( tor ), p->filter_text );
|
|
|
|
}
|
|
|
|
|
2007-12-24 17:25:52 +00:00
|
|
|
static void updateTorrentCount( PrivateData * p );
|
|
|
|
|
2007-12-24 00:14:39 +00:00
|
|
|
static void
|
|
|
|
refilter( PrivateData * p )
|
|
|
|
{
|
|
|
|
gtk_tree_model_filter_refilter( GTK_TREE_MODEL_FILTER( p->filter_model ) );
|
2007-12-24 17:25:52 +00:00
|
|
|
|
|
|
|
updateTorrentCount( p );
|
2007-12-24 00:14:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
filter_text_toggled_cb( GtkCheckMenuItem * menu_item,
|
|
|
|
gpointer vprivate )
|
|
|
|
{
|
|
|
|
if( gtk_check_menu_item_get_active( menu_item ) )
|
|
|
|
{
|
2008-02-24 14:32:42 +00:00
|
|
|
PrivateData * p = vprivate;
|
2007-12-24 00:14:39 +00:00
|
|
|
p->filter_text_mode = GPOINTER_TO_UINT( g_object_get_data( G_OBJECT( menu_item ),
|
|
|
|
FILTER_TEXT_MODE_KEY ) );
|
|
|
|
refilter( p );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
filter_toggled_cb( GtkToggleButton * toggle, gpointer vprivate )
|
|
|
|
{
|
2008-02-24 14:32:42 +00:00
|
|
|
PrivateData * p = vprivate;
|
2007-12-24 00:14:39 +00:00
|
|
|
GSList * l;
|
|
|
|
GSList * toggles = g_object_get_data( G_OBJECT( toggle ), FILTER_TOGGLES_KEY );
|
|
|
|
const gboolean isActive = gtk_toggle_button_get_active( toggle );
|
|
|
|
const filter_mode_t mode = GPOINTER_TO_UINT( g_object_get_data( G_OBJECT( toggle ), FILTER_MODE_KEY ) );
|
|
|
|
|
|
|
|
/* update the filter */
|
|
|
|
if( isActive ) {
|
|
|
|
p->filter_mode = mode;
|
|
|
|
refilter( p );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* deactivate the other toggles */
|
|
|
|
for( l=toggles; l!=NULL; l=l->next ) {
|
|
|
|
GtkToggleButton * walk = GTK_TOGGLE_BUTTON( l->data );
|
|
|
|
if( isActive && ( toggle != walk ) )
|
|
|
|
gtk_toggle_button_set_active( walk, FALSE );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* at least one button must always be set */
|
|
|
|
if( !isActive && ( p->filter_mode == mode ) )
|
|
|
|
gtk_toggle_button_set_active( toggle, TRUE );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
filter_entry_changed( GtkEditable * e, gpointer vprivate )
|
|
|
|
{
|
|
|
|
char * pch;
|
2008-02-24 14:32:42 +00:00
|
|
|
PrivateData * p = vprivate;
|
2008-01-06 17:36:48 +00:00
|
|
|
|
2007-12-24 00:14:39 +00:00
|
|
|
pch = gtk_editable_get_chars( e, 0, -1 );
|
2008-01-06 17:36:48 +00:00
|
|
|
g_free( p->filter_text );
|
2007-12-24 00:14:39 +00:00
|
|
|
p->filter_text = g_ascii_strdown( pch, -1 );
|
|
|
|
refilter( p );
|
|
|
|
g_free( pch );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
entry_icon_released( SexyIconEntry * entry UNUSED,
|
|
|
|
SexyIconEntryPosition icon_pos,
|
|
|
|
int button UNUSED,
|
|
|
|
gpointer menu )
|
|
|
|
{
|
|
|
|
if ( icon_pos == SEXY_ICON_ENTRY_PRIMARY )
|
|
|
|
gtk_menu_popup ( GTK_MENU( menu ), 0, 0, 0, 0, 0, gtk_get_current_event_time( ) );
|
|
|
|
}
|
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
/***
|
|
|
|
**** PUBLIC
|
|
|
|
***/
|
|
|
|
|
|
|
|
GtkWidget *
|
2007-12-19 19:16:36 +00:00
|
|
|
tr_window_new( GtkUIManager * ui_manager, TrCore * core )
|
2007-02-07 07:35:33 +00:00
|
|
|
{
|
2007-12-20 19:21:21 +00:00
|
|
|
int i, n;
|
|
|
|
int status_stats_mode;
|
|
|
|
char * pch;
|
2008-02-09 17:49:09 +00:00
|
|
|
PrivateData * p;
|
2007-12-24 00:14:39 +00:00
|
|
|
GtkWidget *vbox, *w, *self, *h, *c, *s, *image, *menu;
|
2008-04-21 20:58:39 +00:00
|
|
|
GtkWindow *win;
|
2007-12-24 00:14:39 +00:00
|
|
|
GSList * l;
|
|
|
|
GSList * toggles;
|
|
|
|
const char * filter_names[FILTER_MODE_QTY] = {
|
2008-03-08 01:43:20 +00:00
|
|
|
/* show all torrents */
|
2008-03-07 21:20:45 +00:00
|
|
|
N_( "A_ll"),
|
2008-03-08 01:43:20 +00:00
|
|
|
/* show only torrents that have connected peers */
|
2008-03-07 21:20:45 +00:00
|
|
|
N_("_Active"),
|
2008-03-08 01:43:20 +00:00
|
|
|
/* show only torrents that are trying to download */
|
2008-03-07 21:20:45 +00:00
|
|
|
N_("_Downloading"),
|
2008-03-08 01:43:20 +00:00
|
|
|
/* show only torrents that are trying to upload */
|
2008-03-07 21:20:45 +00:00
|
|
|
N_("_Seeding"),
|
2008-03-08 01:43:20 +00:00
|
|
|
/* show only torrents that are paused */
|
2008-03-07 21:20:45 +00:00
|
|
|
N_("_Paused")
|
2007-12-24 00:14:39 +00:00
|
|
|
};
|
|
|
|
const char * filter_text_names[FILTER_TEXT_MODE_QTY] = {
|
|
|
|
N_("Name"), N_("Files"), N_("Tracker")
|
|
|
|
};
|
2007-02-07 07:35:33 +00:00
|
|
|
|
2008-02-09 17:49:09 +00:00
|
|
|
p = g_new0( PrivateData, 1 );
|
2007-12-24 17:25:52 +00:00
|
|
|
p->filter_mode = FILTER_MODE_ALL;
|
|
|
|
p->filter_text_mode = FILTER_TEXT_MODE_NAME;
|
|
|
|
p->filter_text = NULL;
|
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
/* make the window */
|
|
|
|
self = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
2007-12-19 19:16:36 +00:00
|
|
|
g_object_set_data_full(G_OBJECT(self), PRIVATE_DATA_KEY, p, privateFree );
|
2008-04-21 20:58:39 +00:00
|
|
|
win = GTK_WINDOW( self );
|
|
|
|
gtk_window_set_title( win, g_get_application_name());
|
|
|
|
gtk_window_set_role( win, "tr-main" );
|
|
|
|
gtk_window_set_default_size( win, pref_int_get( PREF_KEY_MAIN_WINDOW_WIDTH ),
|
|
|
|
pref_int_get( PREF_KEY_MAIN_WINDOW_HEIGHT ) );
|
|
|
|
gtk_window_move( win, pref_int_get( PREF_KEY_MAIN_WINDOW_X ),
|
|
|
|
pref_int_get( PREF_KEY_MAIN_WINDOW_Y ) );
|
|
|
|
gtk_window_add_accel_group( win, gtk_ui_manager_get_accel_group( ui_manager ) );
|
2007-06-18 03:40:41 +00:00
|
|
|
|
|
|
|
/* window's main container */
|
|
|
|
vbox = gtk_vbox_new (FALSE, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER(self), vbox);
|
|
|
|
|
|
|
|
/* main menu */
|
|
|
|
w = action_get_widget( "/main-window-menu" );
|
|
|
|
gtk_box_pack_start( GTK_BOX(vbox), w, FALSE, FALSE, 0 );
|
2008-02-09 17:49:09 +00:00
|
|
|
w = action_get_widget( "/main-window-menu/torrent-menu/update-tracker" );
|
|
|
|
p->update_tracker_button = w;
|
2007-06-18 03:40:41 +00:00
|
|
|
|
|
|
|
/* toolbar */
|
2007-12-20 02:56:47 +00:00
|
|
|
w = p->toolbar = action_get_widget( "/main-window-toolbar" );
|
2007-06-18 03:40:41 +00:00
|
|
|
gtk_box_pack_start( GTK_BOX(vbox), w, FALSE, FALSE, 0 );
|
|
|
|
|
2008-01-17 18:03:45 +00:00
|
|
|
/* filter */
|
|
|
|
toggles = NULL;
|
|
|
|
h = p->filter = gtk_hbox_new( FALSE, 0 );
|
|
|
|
gtk_container_set_border_width( GTK_CONTAINER( h ), GUI_PAD_SMALL );
|
|
|
|
for( i=0; i<FILTER_MODE_QTY; ++i ) {
|
|
|
|
const char * mnemonic = _( filter_names[i] );
|
|
|
|
w = gtk_toggle_button_new_with_mnemonic( mnemonic );
|
|
|
|
g_object_set_data( G_OBJECT( w ), FILTER_MODE_KEY, GINT_TO_POINTER( i ) );
|
|
|
|
gtk_button_set_relief( GTK_BUTTON( w ), GTK_RELIEF_NONE );
|
|
|
|
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( w ), i==FILTER_MODE_ALL );
|
|
|
|
toggles = g_slist_prepend( toggles, w );
|
|
|
|
g_signal_connect( w, "toggled", G_CALLBACK(filter_toggled_cb), p );
|
|
|
|
gtk_box_pack_start( GTK_BOX( h ), w, FALSE, FALSE, 0 );
|
|
|
|
}
|
|
|
|
for( l=toggles; l!=NULL; l=l->next )
|
|
|
|
g_object_set_data( G_OBJECT( l->data ), FILTER_TOGGLES_KEY, toggles );
|
|
|
|
s = sexy_icon_entry_new( );
|
|
|
|
sexy_icon_entry_add_clear_button( SEXY_ICON_ENTRY(s) );
|
|
|
|
image = gtk_image_new_from_stock( GTK_STOCK_FIND, GTK_ICON_SIZE_MENU );
|
|
|
|
sexy_icon_entry_set_icon( SEXY_ICON_ENTRY(s), SEXY_ICON_ENTRY_PRIMARY, GTK_IMAGE(image) );
|
|
|
|
sexy_icon_entry_set_icon_highlight( SEXY_ICON_ENTRY(s), SEXY_ICON_ENTRY_PRIMARY, TRUE );
|
|
|
|
gtk_box_pack_end( GTK_BOX( h ), s, FALSE, FALSE, 0 );
|
|
|
|
gtk_box_pack_start( GTK_BOX(vbox), h, FALSE, FALSE, 0 );
|
|
|
|
g_signal_connect( s, "changed", G_CALLBACK( filter_entry_changed ), p );
|
|
|
|
|
|
|
|
w = gtk_hseparator_new( );
|
|
|
|
gtk_box_pack_start( GTK_BOX(vbox), w, FALSE, FALSE, 0 );
|
|
|
|
|
2007-12-20 19:21:21 +00:00
|
|
|
/* status menu */
|
2007-12-24 00:14:39 +00:00
|
|
|
menu = p->status_menu = gtk_menu_new( );
|
2007-12-20 19:21:21 +00:00
|
|
|
status_stats_mode = 0;
|
2007-12-24 00:14:39 +00:00
|
|
|
l = NULL;
|
2008-03-19 19:30:03 +00:00
|
|
|
pch = pref_string_get( PREF_KEY_STATUSBAR_STATS );
|
2007-12-20 19:21:21 +00:00
|
|
|
for( i=0, n=G_N_ELEMENTS(stats_modes); i<n; ++i )
|
|
|
|
{
|
|
|
|
const char * val = stats_modes[i].val;
|
|
|
|
w = gtk_radio_menu_item_new_with_label( l, _( stats_modes[i].i18n ) );
|
|
|
|
l = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(w) );
|
|
|
|
gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(w), !strcmp( val, pch ) );
|
|
|
|
g_object_set_data( G_OBJECT(w), STATS_MODE, (gpointer)stats_modes[i].val );
|
|
|
|
g_signal_connect( w, "toggled", G_CALLBACK(status_menu_toggled_cb), p );
|
|
|
|
gtk_menu_shell_append( GTK_MENU_SHELL(menu), w );
|
|
|
|
gtk_widget_show( w );
|
|
|
|
}
|
|
|
|
g_free( pch );
|
|
|
|
|
2008-01-17 18:03:45 +00:00
|
|
|
/* status */
|
2007-12-20 02:56:47 +00:00
|
|
|
h = p->status = gtk_hbox_new( FALSE, GUI_PAD );
|
2008-01-17 18:03:45 +00:00
|
|
|
gtk_container_set_border_width( GTK_CONTAINER( h ), GUI_PAD );
|
2008-03-07 20:48:36 +00:00
|
|
|
w = p->gutter_lb = gtk_label_new( "N Torrents" );
|
2008-01-17 18:03:45 +00:00
|
|
|
gtk_box_pack_start( GTK_BOX(h), w, 0, 0, 0 );
|
2007-12-20 02:56:47 +00:00
|
|
|
w = p->ul_lb = gtk_label_new( NULL );
|
|
|
|
gtk_box_pack_end( GTK_BOX(h), w, FALSE, FALSE, 0 );
|
2008-01-20 01:18:11 +00:00
|
|
|
w = gtk_image_new_from_stock( GTK_STOCK_GO_UP, GTK_ICON_SIZE_MENU );
|
2007-12-20 02:56:47 +00:00
|
|
|
gtk_box_pack_end( GTK_BOX(h), w, FALSE, FALSE, 0 );
|
|
|
|
w = gtk_alignment_new( 0.0f, 0.0f, 0.0f, 0.0f );
|
2008-01-27 18:50:37 +00:00
|
|
|
gtk_widget_set_size_request( w, GUI_PAD, 0u );
|
2007-12-20 02:56:47 +00:00
|
|
|
gtk_box_pack_end( GTK_BOX(h), w, FALSE, FALSE, 0 );
|
|
|
|
w = p->dl_lb = gtk_label_new( NULL );
|
|
|
|
gtk_box_pack_end( GTK_BOX(h), w, FALSE, FALSE, 0 );
|
2008-01-20 01:18:11 +00:00
|
|
|
w = gtk_image_new_from_stock( GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_MENU );
|
2007-12-20 02:56:47 +00:00
|
|
|
gtk_box_pack_end( GTK_BOX(h), w, FALSE, FALSE, 0 );
|
2008-01-17 18:03:45 +00:00
|
|
|
w = gtk_alignment_new( 0.0f, 0.0f, 0.0f, 0.0f );
|
2008-01-27 18:50:37 +00:00
|
|
|
gtk_widget_set_size_request( w, GUI_PAD, 0u );
|
2008-01-17 18:03:45 +00:00
|
|
|
gtk_box_pack_end( GTK_BOX(h), w, FALSE, FALSE, 0 );
|
|
|
|
w = p->stats_lb = gtk_label_new( NULL );
|
|
|
|
gtk_box_pack_end( GTK_BOX(h), w, FALSE, FALSE, 0 );
|
2008-01-20 01:18:11 +00:00
|
|
|
w = gtk_image_new_from_stock( GTK_STOCK_REFRESH, GTK_ICON_SIZE_MENU );
|
2007-12-20 19:21:21 +00:00
|
|
|
c = gtk_event_box_new( );
|
|
|
|
gtk_container_add( GTK_CONTAINER(c), w );
|
|
|
|
w = c;
|
2008-01-17 18:03:45 +00:00
|
|
|
gtk_box_pack_end( GTK_BOX(h), w, FALSE, FALSE, 0 );
|
2007-12-20 19:21:21 +00:00
|
|
|
g_signal_connect( w, "button-release-event", G_CALLBACK(onYinYangReleased), p );
|
2007-12-20 02:56:47 +00:00
|
|
|
gtk_box_pack_start( GTK_BOX(vbox), h, FALSE, FALSE, 0 );
|
|
|
|
|
2007-12-24 00:14:39 +00:00
|
|
|
menu = gtk_menu_new( );
|
|
|
|
l = NULL;
|
|
|
|
for( i=0; i<FILTER_TEXT_MODE_QTY; ++i )
|
|
|
|
{
|
|
|
|
const char * name = _( filter_text_names[i] );
|
|
|
|
GtkWidget * w = gtk_radio_menu_item_new_with_label ( l, name );
|
|
|
|
l = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM( w ) );
|
|
|
|
g_object_set_data( G_OBJECT( w ), FILTER_TEXT_MODE_KEY, GINT_TO_POINTER( i ) );
|
|
|
|
g_signal_connect( w, "toggled", G_CALLBACK( filter_text_toggled_cb ), p );
|
|
|
|
gtk_menu_shell_append( GTK_MENU_SHELL( menu ), w );
|
|
|
|
gtk_widget_show( w );
|
|
|
|
}
|
|
|
|
g_signal_connect( s, "icon-released", G_CALLBACK(entry_icon_released), menu );
|
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
/* workarea */
|
2007-12-24 00:14:39 +00:00
|
|
|
p->view = makeview( p, core );
|
2007-06-18 03:40:41 +00:00
|
|
|
w = p->scroll = gtk_scrolled_window_new( NULL, NULL );
|
2008-04-21 20:58:39 +00:00
|
|
|
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(w), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC );
|
2007-06-18 03:40:41 +00:00
|
|
|
gtk_container_add( GTK_CONTAINER(w), p->view );
|
|
|
|
gtk_box_pack_start_defaults( GTK_BOX(vbox), w );
|
|
|
|
gtk_container_set_focus_child( GTK_CONTAINER( vbox ), w );
|
|
|
|
|
|
|
|
/* show all but the window */
|
|
|
|
gtk_widget_show_all( vbox );
|
2007-02-07 07:35:33 +00:00
|
|
|
|
2007-12-19 19:16:36 +00:00
|
|
|
/* listen for prefs changes that affect the window */
|
2007-12-22 16:34:47 +00:00
|
|
|
p->core = core;
|
2007-12-19 19:16:36 +00:00
|
|
|
prefsChanged( core, PREF_KEY_MINIMAL_VIEW, self );
|
2008-03-19 19:30:03 +00:00
|
|
|
prefsChanged( core, PREF_KEY_FILTERBAR, self );
|
|
|
|
prefsChanged( core, PREF_KEY_STATUSBAR, self );
|
|
|
|
prefsChanged( core, PREF_KEY_STATUSBAR_STATS, self );
|
2007-12-20 02:56:47 +00:00
|
|
|
prefsChanged( core, PREF_KEY_TOOLBAR, self );
|
2007-12-20 01:33:51 +00:00
|
|
|
p->pref_handler_id = g_signal_connect( core, "prefs-changed",
|
|
|
|
G_CALLBACK(prefsChanged), self );
|
2007-12-19 19:16:36 +00:00
|
|
|
|
2008-01-06 17:36:48 +00:00
|
|
|
filter_entry_changed( GTK_EDITABLE( s ), p );
|
2007-06-18 03:40:41 +00:00
|
|
|
return self;
|
2007-02-07 07:35:33 +00:00
|
|
|
}
|
|
|
|
|
2007-12-24 17:25:52 +00:00
|
|
|
static void
|
|
|
|
updateTorrentCount( PrivateData * p )
|
|
|
|
{
|
|
|
|
if( p && p->core )
|
|
|
|
{
|
|
|
|
char buf[128];
|
|
|
|
const int torrentCount = gtk_tree_model_iter_n_children( tr_core_model( p->core ), NULL );
|
|
|
|
const int visibleCount = gtk_tree_model_iter_n_children( p->filter_model, NULL );
|
|
|
|
|
|
|
|
if( torrentCount != visibleCount )
|
2008-03-19 20:07:27 +00:00
|
|
|
g_snprintf( buf, sizeof( buf ), ngettext( "%1$'d of %2$'d Torrent",
|
|
|
|
"%1$'d of %2$'d Torrents",
|
2007-12-24 17:25:52 +00:00
|
|
|
torrentCount ),
|
|
|
|
visibleCount, torrentCount );
|
|
|
|
else
|
2008-03-19 20:07:27 +00:00
|
|
|
g_snprintf( buf, sizeof( buf ), ngettext( "%'d Torrent",
|
|
|
|
"%'d Torrents",
|
2007-12-24 17:25:52 +00:00
|
|
|
torrentCount ),
|
|
|
|
torrentCount );
|
|
|
|
gtk_label_set_text( GTK_LABEL( p->gutter_lb ), buf );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-24 19:12:52 +00:00
|
|
|
static void
|
|
|
|
updateStats( PrivateData * p )
|
|
|
|
{
|
|
|
|
char * pch;
|
2008-01-04 18:52:39 +00:00
|
|
|
char up[32], down[32], ratio[32], buf[128];
|
2007-12-24 19:12:52 +00:00
|
|
|
struct tr_session_stats stats;
|
|
|
|
tr_handle * handle = tr_core_handle( p->core );
|
|
|
|
|
|
|
|
/* update the stats */
|
2008-03-19 19:30:03 +00:00
|
|
|
pch = pref_string_get( PREF_KEY_STATUSBAR_STATS );
|
2007-12-24 19:12:52 +00:00
|
|
|
if( !strcmp( pch, "session-ratio" ) ) {
|
|
|
|
tr_getSessionStats( handle, &stats );
|
2008-01-04 18:52:39 +00:00
|
|
|
tr_strlratio( ratio, stats.ratio, sizeof( ratio ) );
|
|
|
|
g_snprintf( buf, sizeof(buf), _("Ratio: %s"), ratio );
|
2007-12-24 19:12:52 +00:00
|
|
|
} else if( !strcmp( pch, "session-transfer" ) ) {
|
|
|
|
tr_getSessionStats( handle, &stats );
|
|
|
|
tr_strlsize( up, stats.uploadedBytes, sizeof( up ) );
|
|
|
|
tr_strlsize( down, stats.downloadedBytes, sizeof( down ) );
|
2008-03-08 01:43:20 +00:00
|
|
|
/* Translators: do not translate the "size|" disambiguation prefix.
|
2008-03-08 04:53:11 +00:00
|
|
|
%1$s is the size of the data we've downloaded
|
|
|
|
%2$s is the size of the data we've uploaded */
|
2008-03-08 01:43:20 +00:00
|
|
|
g_snprintf( buf, sizeof( buf ), Q_( "size|Down: %1$s, Up: %2$s" ), down, up );
|
2007-12-24 19:12:52 +00:00
|
|
|
} else if( !strcmp( pch, "total-transfer" ) ) {
|
|
|
|
tr_getCumulativeSessionStats( handle, &stats );
|
|
|
|
tr_strlsize( up, stats.uploadedBytes, sizeof( up ) );
|
|
|
|
tr_strlsize( down, stats.downloadedBytes, sizeof( down ) );
|
2008-03-08 01:43:20 +00:00
|
|
|
/* Translators: do not translate the "size|" disambiguation prefix.
|
2008-03-08 04:53:11 +00:00
|
|
|
%1$s is the size of the data we've downloaded
|
|
|
|
%2$s is the size of the data we've uploaded */
|
2008-03-08 01:43:20 +00:00
|
|
|
g_snprintf( buf, sizeof( buf ), Q_( "size|Down: %1$s, Up: %2$s" ), down, up );
|
2007-12-24 19:12:52 +00:00
|
|
|
} else { /* default is total-ratio */
|
|
|
|
tr_getCumulativeSessionStats( handle, &stats );
|
2008-01-04 18:52:39 +00:00
|
|
|
tr_strlratio( ratio, stats.ratio, sizeof( ratio ) );
|
|
|
|
g_snprintf( buf, sizeof(buf), _("Ratio: %s"), ratio );
|
2007-12-24 19:12:52 +00:00
|
|
|
}
|
|
|
|
g_free( pch );
|
|
|
|
gtk_label_set_text( GTK_LABEL( p->stats_lb ), buf );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
updateSpeeds( PrivateData * p )
|
|
|
|
{
|
|
|
|
char buf[128];
|
|
|
|
float u, d;
|
|
|
|
tr_handle * handle = tr_core_handle( p->core );
|
|
|
|
|
|
|
|
tr_torrentRates( handle, &d, &u );
|
|
|
|
tr_strlspeed( buf, d, sizeof( buf ) );
|
|
|
|
gtk_label_set_text( GTK_LABEL( p->dl_lb ), buf );
|
|
|
|
tr_strlspeed( buf, u, sizeof( buf ) );
|
|
|
|
gtk_label_set_text( GTK_LABEL( p->ul_lb ), buf );
|
|
|
|
}
|
|
|
|
|
2008-02-09 17:49:09 +00:00
|
|
|
static void
|
|
|
|
findMaxAnnounceTime( GtkTreeModel * model,
|
|
|
|
GtkTreePath * path UNUSED,
|
|
|
|
GtkTreeIter * iter,
|
|
|
|
gpointer gmaxTime )
|
|
|
|
{
|
|
|
|
tr_torrent * tor;
|
|
|
|
const tr_stat * torStat;
|
|
|
|
time_t * maxTime = gmaxTime;
|
|
|
|
|
|
|
|
gtk_tree_model_get( model, iter, MC_TORRENT_RAW, &tor, -1 );
|
|
|
|
torStat = tr_torrentStatCached( tor );
|
|
|
|
*maxTime = MAX( *maxTime, torStat->manualAnnounceTime );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
updateAskForPeers( PrivateData * p )
|
|
|
|
{
|
|
|
|
char buf[128];
|
|
|
|
time_t maxTime = 0;
|
|
|
|
const time_t now = time( NULL );
|
|
|
|
|
|
|
|
gtk_tree_selection_selected_foreach( p->selection,
|
|
|
|
findMaxAnnounceTime,
|
|
|
|
&maxTime );
|
|
|
|
|
|
|
|
if( maxTime <= now )
|
|
|
|
*buf = '\0';
|
|
|
|
else {
|
|
|
|
char secbuf[32];
|
|
|
|
const int seconds = maxTime - time( NULL );
|
|
|
|
tr_strltime( secbuf, seconds, sizeof( secbuf ) );
|
|
|
|
g_snprintf( buf, sizeof( buf ), _( "Tracker will allow requests in %s" ), secbuf );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !p->tooltips )
|
|
|
|
p->tooltips = gtk_tooltips_new( );
|
|
|
|
gtk_tooltips_set_tip( p->tooltips, p->update_tracker_button, buf, NULL );
|
|
|
|
}
|
2007-12-24 17:25:52 +00:00
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
void
|
2007-12-20 19:21:21 +00:00
|
|
|
tr_window_update( TrWindow * self )
|
2007-02-07 07:35:33 +00:00
|
|
|
{
|
2007-06-18 03:40:41 +00:00
|
|
|
PrivateData * p = get_private_data( self );
|
2007-12-24 19:12:52 +00:00
|
|
|
if( p && p->core && tr_core_handle(p->core) )
|
2007-12-20 19:21:21 +00:00
|
|
|
{
|
2007-12-24 19:12:52 +00:00
|
|
|
updateSpeeds( p );
|
2007-12-24 17:25:52 +00:00
|
|
|
updateTorrentCount( p );
|
2007-12-24 19:12:52 +00:00
|
|
|
updateStats( p );
|
2008-02-09 17:49:09 +00:00
|
|
|
updateAskForPeers( p );
|
2007-12-24 19:12:52 +00:00
|
|
|
refilter( p );
|
2007-12-20 19:21:21 +00:00
|
|
|
}
|
2007-02-07 07:35:33 +00:00
|
|
|
}
|
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
GtkTreeSelection*
|
|
|
|
tr_window_get_selection ( TrWindow * w )
|
2007-02-07 07:35:33 +00:00
|
|
|
{
|
2007-06-18 03:40:41 +00:00
|
|
|
return get_private_data(w)->selection;
|
2007-02-07 07:35:33 +00:00
|
|
|
}
|