2008-02-10 22:25:42 +00:00
|
|
|
/*
|
2009-01-10 23:09:07 +00:00
|
|
|
* This file Copyright (C) 2007-2009 Charles Kerr <charles@transmissionbt.com>
|
2007-06-06 00:30:13 +00:00
|
|
|
*
|
2008-02-10 22:25:42 +00:00
|
|
|
* This file is licensed by the GPL version 2. Works owned by the
|
|
|
|
* Transmission project are granted a special exemption to clause 2(b)
|
2008-09-23 19:11:04 +00:00
|
|
|
* so that the bulk of its code can remain under the MIT license.
|
2008-02-10 22:25:42 +00:00
|
|
|
* This exemption does not extend to derived works not owned by
|
|
|
|
* the Transmission project.
|
2008-09-23 19:11:04 +00:00
|
|
|
*
|
2008-02-10 22:25:42 +00:00
|
|
|
* $Id$
|
|
|
|
*/
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2008-06-01 01:40:32 +00:00
|
|
|
#include <errno.h>
|
2009-01-12 19:30:34 +00:00
|
|
|
#include <math.h> /* ceil() */
|
2007-06-06 00:30:13 +00:00
|
|
|
#include <stddef.h>
|
2007-07-19 03:55:00 +00:00
|
|
|
#include <stdio.h>
|
2007-06-06 00:30:13 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <glib/gi18n.h>
|
|
|
|
#include <gtk/gtk.h>
|
2007-06-18 03:40:41 +00:00
|
|
|
|
2007-07-18 23:04:26 +00:00
|
|
|
#include <libtransmission/transmission.h>
|
2008-06-01 01:40:32 +00:00
|
|
|
#include <libtransmission/utils.h> /* tr_httpIsValidURL */
|
2007-06-18 03:40:41 +00:00
|
|
|
|
|
|
|
#include "actions.h"
|
2008-02-19 03:57:03 +00:00
|
|
|
#include "details.h"
|
2008-02-10 22:25:42 +00:00
|
|
|
#include "file-list.h"
|
2008-02-26 19:58:03 +00:00
|
|
|
#include "tr-torrent.h"
|
2008-06-01 05:36:23 +00:00
|
|
|
#include "tracker-list.h"
|
2007-06-06 00:30:13 +00:00
|
|
|
#include "hig.h"
|
|
|
|
#include "util.h"
|
|
|
|
|
2008-12-22 05:39:03 +00:00
|
|
|
#define UPDATE_INTERVAL_SECONDS 2
|
2009-03-05 17:18:36 +00:00
|
|
|
|
|
|
|
struct ResponseData
|
2009-02-13 18:23:56 +00:00
|
|
|
{
|
|
|
|
gpointer gtor;
|
|
|
|
TrCore * core;
|
|
|
|
guint handler;
|
2009-03-05 17:18:36 +00:00
|
|
|
};
|
2007-06-06 00:30:13 +00:00
|
|
|
|
|
|
|
/****
|
|
|
|
***** PEERS TAB
|
|
|
|
****/
|
|
|
|
|
2008-06-10 02:36:52 +00:00
|
|
|
enum
|
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
WEBSEED_COL_URL,
|
|
|
|
WEBSEED_COL_DOWNLOAD_RATE,
|
|
|
|
N_WEBSEED_COLS
|
2008-06-10 02:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const char * webseed_column_names[N_WEBSEED_COLS] =
|
|
|
|
{
|
|
|
|
N_( "Web Seeds" ),
|
|
|
|
/* 'download speed' column header. terse to keep the column narrow. */
|
|
|
|
N_( "Down" )
|
|
|
|
};
|
|
|
|
|
|
|
|
static GtkTreeModel*
|
|
|
|
webseed_model_new( const tr_torrent * tor )
|
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
int i;
|
2008-06-10 02:36:52 +00:00
|
|
|
const tr_info * inf = tr_torrentInfo( tor );
|
2008-09-23 19:11:04 +00:00
|
|
|
float * speeds = tr_torrentWebSpeeds( tor );
|
|
|
|
GtkListStore * store = gtk_list_store_new( N_WEBSEED_COLS,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_FLOAT );
|
|
|
|
|
|
|
|
for( i = 0; i < inf->webseedCount; ++i )
|
2008-06-10 02:36:52 +00:00
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
gtk_list_store_append( store, &iter );
|
2009-02-26 17:53:55 +00:00
|
|
|
gtk_list_store_set( store, &iter,
|
|
|
|
WEBSEED_COL_URL, inf->webseeds[i],
|
2008-09-23 19:11:04 +00:00
|
|
|
WEBSEED_COL_DOWNLOAD_RATE, speeds[i],
|
|
|
|
-1 );
|
2008-06-10 02:36:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tr_free( speeds );
|
|
|
|
return GTK_TREE_MODEL( store );
|
|
|
|
}
|
|
|
|
|
2007-06-06 00:30:13 +00:00
|
|
|
enum
|
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
PEER_COL_ADDRESS,
|
|
|
|
PEER_COL_DOWNLOAD_RATE,
|
|
|
|
PEER_COL_UPLOAD_RATE,
|
|
|
|
PEER_COL_CLIENT,
|
|
|
|
PEER_COL_PROGRESS,
|
|
|
|
PEER_COL_IS_ENCRYPTED,
|
|
|
|
PEER_COL_STATUS,
|
|
|
|
N_PEER_COLS
|
2007-06-06 00:30:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const char* peer_column_names[N_PEER_COLS] =
|
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
N_( "Address" ),
|
|
|
|
/* 'download speed' column header. terse to keep the column narrow. */
|
|
|
|
N_( "Down" ),
|
|
|
|
/* 'upload speed' column header. terse to keep the column narrow. */
|
|
|
|
N_( "Up" ),
|
|
|
|
N_( "Client" ),
|
|
|
|
/* 'percent done' column header. terse to keep the column narrow. */
|
|
|
|
N_( "%" ),
|
|
|
|
" ",
|
|
|
|
N_( "Status" )
|
2007-06-06 00:30:13 +00:00
|
|
|
};
|
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
static int
|
2008-11-23 17:10:40 +00:00
|
|
|
compare_peers( const void * a, const void * b )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
const tr_peer_stat * pa = a;
|
|
|
|
const tr_peer_stat * pb = b;
|
|
|
|
|
2008-11-23 17:10:40 +00:00
|
|
|
return strcmp( pa->addr, pb->addr );
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
2008-09-23 19:11:04 +00:00
|
|
|
|
|
|
|
static int
|
2008-11-23 17:10:40 +00:00
|
|
|
compare_addr_to_peer( const void * addr, const void * b )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
const tr_peer_stat * peer = b;
|
|
|
|
|
2008-11-23 17:10:40 +00:00
|
|
|
return strcmp( addr, peer->addr );
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-11-23 17:10:40 +00:00
|
|
|
peer_row_set( GtkListStore * store,
|
|
|
|
GtkTreeIter * iter,
|
|
|
|
const tr_peer_stat * peer )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
const char * client = peer->client;
|
|
|
|
|
|
|
|
if( !client || !strcmp( client, "Unknown Client" ) )
|
|
|
|
client = " ";
|
|
|
|
|
|
|
|
gtk_list_store_set( store, iter,
|
|
|
|
PEER_COL_ADDRESS, peer->addr,
|
|
|
|
PEER_COL_CLIENT, client,
|
|
|
|
PEER_COL_IS_ENCRYPTED, peer->isEncrypted,
|
|
|
|
PEER_COL_PROGRESS, (int)( 100.0 * peer->progress ),
|
|
|
|
PEER_COL_DOWNLOAD_RATE, peer->rateToClient,
|
|
|
|
PEER_COL_UPLOAD_RATE, peer->rateToPeer,
|
|
|
|
PEER_COL_STATUS, peer->flagStr,
|
|
|
|
-1 );
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-09-23 19:11:04 +00:00
|
|
|
append_peers_to_model( GtkListStore * store,
|
|
|
|
const tr_peer_stat * peers,
|
|
|
|
int n_peers )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for( i = 0; i < n_peers; ++i )
|
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
gtk_list_store_append( store, &iter );
|
2009-03-05 17:18:36 +00:00
|
|
|
peer_row_set( store, &iter, &peers[i] );
|
2008-09-23 19:11:04 +00:00
|
|
|
}
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GtkTreeModel*
|
2008-09-23 19:11:04 +00:00
|
|
|
peer_model_new( tr_torrent * tor )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2009-03-05 17:18:36 +00:00
|
|
|
GtkListStore * m = gtk_list_store_new( N_PEER_COLS,
|
|
|
|
G_TYPE_STRING, /* addr */
|
|
|
|
G_TYPE_FLOAT, /* downloadFromRate */
|
|
|
|
G_TYPE_FLOAT, /* uploadToRate */
|
|
|
|
G_TYPE_STRING, /* client */
|
|
|
|
G_TYPE_INT, /* progress [0..100] */
|
|
|
|
G_TYPE_BOOLEAN, /* isEncrypted */
|
|
|
|
G_TYPE_STRING ); /* flagString */
|
2008-09-23 19:11:04 +00:00
|
|
|
|
|
|
|
int n_peers = 0;
|
2009-03-05 17:18:36 +00:00
|
|
|
tr_peer_stat * peers = tr_torrentPeers( tor, &n_peers );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
qsort( peers, n_peers, sizeof( tr_peer_stat ), compare_peers );
|
|
|
|
append_peers_to_model( m, peers, n_peers );
|
2008-09-23 19:11:04 +00:00
|
|
|
tr_torrentPeersFree( peers, 0 );
|
2009-03-05 17:18:36 +00:00
|
|
|
return GTK_TREE_MODEL( m );
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
static void
|
2008-09-23 19:11:04 +00:00
|
|
|
render_encrypted( GtkTreeViewColumn * column UNUSED,
|
|
|
|
GtkCellRenderer * renderer,
|
|
|
|
GtkTreeModel * tree_model,
|
|
|
|
GtkTreeIter * iter,
|
|
|
|
gpointer data UNUSED )
|
2007-09-20 16:32:01 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
gboolean is_encrypted = FALSE;
|
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
gtk_tree_model_get( tree_model, iter, PEER_COL_IS_ENCRYPTED, &is_encrypted, -1 );
|
|
|
|
g_object_set( renderer, "xalign", (gfloat)0.0,
|
|
|
|
"yalign", (gfloat)0.5,
|
|
|
|
"stock-id", ( is_encrypted ? "transmission-lock" : NULL ),
|
|
|
|
NULL );
|
2007-09-20 16:32:01 +00:00
|
|
|
}
|
|
|
|
|
2007-06-06 00:30:13 +00:00
|
|
|
static void
|
2009-03-05 17:18:36 +00:00
|
|
|
render_speed( GtkCellRenderer * renderer,
|
|
|
|
GtkTreeModel * tree_model,
|
|
|
|
GtkTreeIter * iter,
|
|
|
|
int col )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
float rate = 0.0;
|
2009-03-05 17:18:36 +00:00
|
|
|
char str[64];
|
|
|
|
gtk_tree_model_get( tree_model, iter, col, &rate, -1 );
|
2008-09-23 19:11:04 +00:00
|
|
|
if( rate < 0.01 )
|
2009-03-05 17:18:36 +00:00
|
|
|
*str = '\0';
|
2008-09-23 19:11:04 +00:00
|
|
|
else
|
2009-03-05 17:18:36 +00:00
|
|
|
tr_strlspeed( str, rate, sizeof( str ) );
|
|
|
|
g_object_set( renderer, "text", str, NULL );
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-03-05 17:18:36 +00:00
|
|
|
render_ul_rate( GtkTreeViewColumn * column UNUSED,
|
|
|
|
GtkCellRenderer * renderer,
|
|
|
|
GtkTreeModel * tree_model,
|
|
|
|
GtkTreeIter * iter,
|
2008-09-23 19:11:04 +00:00
|
|
|
gpointer data UNUSED )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2009-03-05 17:18:36 +00:00
|
|
|
render_speed( renderer, tree_model, iter, PEER_COL_UPLOAD_RATE );
|
|
|
|
}
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
static void
|
|
|
|
render_dl_rate( GtkTreeViewColumn * column UNUSED,
|
|
|
|
GtkCellRenderer * renderer,
|
|
|
|
GtkTreeModel * tree_model,
|
|
|
|
GtkTreeIter * iter,
|
|
|
|
gpointer data UNUSED )
|
|
|
|
{
|
|
|
|
render_speed( renderer, tree_model, iter, PEER_COL_DOWNLOAD_RATE );
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-09-23 19:11:04 +00:00
|
|
|
render_client( GtkTreeViewColumn * column UNUSED,
|
|
|
|
GtkCellRenderer * renderer,
|
|
|
|
GtkTreeModel * tree_model,
|
|
|
|
GtkTreeIter * iter,
|
|
|
|
gpointer data UNUSED )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
char * client = NULL;
|
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
gtk_tree_model_get( tree_model, iter, PEER_COL_CLIENT, &client, -1 );
|
|
|
|
g_object_set( renderer, "text", ( client ? client : "" ), NULL );
|
|
|
|
g_free( client );
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
TrTorrent * gtor;
|
|
|
|
GtkTreeModel * model; /* same object as store, but recast */
|
|
|
|
GtkListStore * store; /* same object as model, but recast */
|
|
|
|
GtkListStore * webseeds;
|
|
|
|
GtkWidget * completeness;
|
|
|
|
GtkWidget * seeders_lb;
|
|
|
|
GtkWidget * leechers_lb;
|
|
|
|
GtkWidget * completed_lb;
|
2008-11-23 17:10:40 +00:00
|
|
|
GtkWidget * peer_tree_view;
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
PeerData;
|
|
|
|
|
|
|
|
static void
|
2008-09-23 19:11:04 +00:00
|
|
|
fmtpeercount( GtkWidget * l,
|
|
|
|
int count )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
if( 0 > count )
|
|
|
|
{
|
|
|
|
gtk_label_set_text( GTK_LABEL( l ), "?" );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char str[16];
|
|
|
|
g_snprintf( str, sizeof str, "%'d", count );
|
|
|
|
gtk_label_set_text( GTK_LABEL( l ), str );
|
|
|
|
}
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-09-23 19:11:04 +00:00
|
|
|
refresh_peers( GtkWidget * top )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
int i;
|
|
|
|
int n_peers;
|
|
|
|
GtkTreeIter iter;
|
2009-03-05 17:18:36 +00:00
|
|
|
PeerData * p = (PeerData*) g_object_get_data( G_OBJECT( top ), "peer-data" );
|
|
|
|
tr_torrent * tor = tr_torrent_handle( p->gtor );
|
2008-09-23 19:11:04 +00:00
|
|
|
GtkTreeModel * model = p->model;
|
|
|
|
GtkListStore * store = p->store;
|
|
|
|
tr_peer_stat * peers;
|
|
|
|
const tr_stat * stat = tr_torrent_stat( p->gtor );
|
|
|
|
const tr_info * inf = tr_torrent_info( p->gtor );
|
|
|
|
|
|
|
|
if( inf->webseedCount )
|
2008-06-10 02:36:52 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
float * speeds = tr_torrentWebSpeeds( tor );
|
|
|
|
for( i = 0; i < inf->webseedCount; ++i )
|
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
2009-03-05 17:18:36 +00:00
|
|
|
gtk_tree_model_iter_nth_child( GTK_TREE_MODEL( p->webseeds ), &iter, NULL, i );
|
|
|
|
gtk_list_store_set( p->webseeds, &iter, WEBSEED_COL_DOWNLOAD_RATE, speeds[i], -1 );
|
2008-09-23 19:11:04 +00:00
|
|
|
}
|
|
|
|
tr_free( speeds );
|
2008-06-10 02:36:52 +00:00
|
|
|
}
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
/**
|
|
|
|
*** merge the peer diffs into the tree model.
|
|
|
|
***
|
|
|
|
*** this is more complicated than creating a new model,
|
|
|
|
*** but is also (a) more efficient and (b) doesn't undo
|
|
|
|
*** the view's visible area and sorting on every refresh.
|
|
|
|
**/
|
|
|
|
|
|
|
|
n_peers = 0;
|
2009-03-05 17:18:36 +00:00
|
|
|
peers = tr_torrentPeers( tor, &n_peers );
|
|
|
|
qsort( peers, n_peers, sizeof( tr_peer_stat ), compare_peers );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
if( gtk_tree_model_get_iter_first( model, &iter ) ) do
|
2008-09-23 19:11:04 +00:00
|
|
|
{
|
|
|
|
char * addr = NULL;
|
|
|
|
tr_peer_stat * peer = NULL;
|
2009-03-05 17:18:36 +00:00
|
|
|
gtk_tree_model_get( model, &iter, PEER_COL_ADDRESS, &addr, -1 );
|
|
|
|
peer = bsearch( addr, peers, n_peers, sizeof( tr_peer_stat ),
|
|
|
|
compare_addr_to_peer );
|
|
|
|
g_free( addr );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
|
|
|
if( peer ) /* update a pre-existing row */
|
|
|
|
{
|
|
|
|
const int pos = peer - peers;
|
|
|
|
const int n_rhs = n_peers - ( pos + 1 );
|
2009-03-05 17:18:36 +00:00
|
|
|
g_assert( n_rhs >= 0 );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
peer_row_set( store, &iter, peer );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
|
|
|
/* remove it from the tr_peer_stat list */
|
2009-03-05 17:18:36 +00:00
|
|
|
g_memmove( peer, peer + 1, sizeof( tr_peer_stat ) * n_rhs );
|
2008-09-23 19:11:04 +00:00
|
|
|
--n_peers;
|
|
|
|
}
|
2009-03-05 17:18:36 +00:00
|
|
|
else if( !gtk_list_store_remove( store, &iter ) )
|
2008-09-23 19:11:04 +00:00
|
|
|
break; /* we removed the model's last item */
|
|
|
|
}
|
2009-03-05 17:18:36 +00:00
|
|
|
while( gtk_tree_model_iter_next( model, &iter ) );
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
append_peers_to_model( store, peers, n_peers ); /* all these are new */
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
fmtpeercount( p->seeders_lb, stat->seeders );
|
|
|
|
fmtpeercount( p->leechers_lb, stat->leechers );
|
|
|
|
fmtpeercount( p->completed_lb, stat->timesCompleted );
|
2007-06-07 17:53:54 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
free( peers );
|
2008-11-23 17:10:40 +00:00
|
|
|
|
|
|
|
gtk_widget_queue_draw( p->peer_tree_view );
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
#if GTK_CHECK_VERSION( 2, 12, 0 )
|
2008-04-12 01:36:31 +00:00
|
|
|
static gboolean
|
2008-09-23 19:11:04 +00:00
|
|
|
onPeerViewQueryTooltip( GtkWidget * widget,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gboolean keyboard_tip,
|
|
|
|
GtkTooltip * tooltip,
|
2008-04-12 01:36:31 +00:00
|
|
|
gpointer user_data UNUSED )
|
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
gboolean show_tip = FALSE;
|
2008-04-12 01:36:31 +00:00
|
|
|
GtkTreeModel * model;
|
2008-09-23 19:11:04 +00:00
|
|
|
GtkTreeIter iter;
|
2008-04-12 01:36:31 +00:00
|
|
|
|
|
|
|
if( gtk_tree_view_get_tooltip_context( GTK_TREE_VIEW( widget ),
|
|
|
|
&x, &y, keyboard_tip,
|
|
|
|
&model, NULL, &iter ) )
|
|
|
|
{
|
|
|
|
const char * pch;
|
2008-09-23 19:11:04 +00:00
|
|
|
char * str = NULL;
|
|
|
|
GString * gstr = g_string_new( NULL );
|
2008-04-12 01:36:31 +00:00
|
|
|
gtk_tree_model_get( model, &iter, PEER_COL_STATUS, &str, -1 );
|
2008-09-23 19:11:04 +00:00
|
|
|
for( pch = str; pch && *pch; ++pch )
|
|
|
|
{
|
2008-04-12 01:36:31 +00:00
|
|
|
const char * txt = NULL;
|
2008-09-23 19:11:04 +00:00
|
|
|
switch( *pch )
|
|
|
|
{
|
2009-03-05 17:18:36 +00:00
|
|
|
case 'O': txt = _( "Optimistic unchoke" ); break;
|
|
|
|
case 'D': txt = _( "Downloading from this peer" ); break;
|
|
|
|
case 'd': txt = _( "We would download from this peer if they would let us" ); break;
|
|
|
|
case 'U': txt = _( "Uploading to peer" ); break;
|
|
|
|
case 'u': txt = _( "We would upload to this peer if they asked" ); break;
|
|
|
|
case 'K': txt = _( "Peer has unchoked us, but we're not interested" ); break;
|
|
|
|
case '?': txt = _( "We unchoked this peer, but they're not interested" ); break;
|
|
|
|
case 'E': txt = _( "Encrypted connection" ); break;
|
|
|
|
case 'X': txt = _( "Peer was discovered through Peer Exchange (PEX)" ); break;
|
|
|
|
case 'I': txt = _( "Peer is an incoming connection" ); break;
|
2008-04-12 01:36:31 +00:00
|
|
|
}
|
|
|
|
if( txt )
|
|
|
|
g_string_append_printf( gstr, "%c: %s\n", *pch, txt );
|
|
|
|
}
|
|
|
|
if( gstr->len ) /* remove the last linefeed */
|
2008-09-23 19:11:04 +00:00
|
|
|
g_string_set_size( gstr, gstr->len - 1 );
|
2008-04-12 01:36:31 +00:00
|
|
|
gtk_tooltip_set_text( tooltip, gstr->str );
|
|
|
|
g_string_free( gstr, TRUE );
|
|
|
|
g_free( str );
|
|
|
|
show_tip = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return show_tip;
|
|
|
|
}
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-04-12 01:36:31 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
static GtkWidget*
|
2008-09-23 19:11:04 +00:00
|
|
|
peer_page_new( TrTorrent * gtor )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
guint i;
|
|
|
|
GtkTreeModel * m;
|
|
|
|
GtkWidget * v, *w, *ret, *sw, *l, *vbox, *hbox;
|
|
|
|
GtkWidget * webtree = NULL;
|
2009-03-05 17:18:36 +00:00
|
|
|
tr_torrent * tor = tr_torrent_handle( gtor );
|
|
|
|
PeerData * p = g_new( PeerData, 1 );
|
2008-09-23 19:11:04 +00:00
|
|
|
const tr_info * inf = tr_torrent_info( gtor );
|
|
|
|
|
|
|
|
/* TODO: make this configurable? */
|
2008-11-09 15:29:43 +00:00
|
|
|
int view_columns[] = { PEER_COL_IS_ENCRYPTED,
|
|
|
|
PEER_COL_UPLOAD_RATE,
|
|
|
|
PEER_COL_DOWNLOAD_RATE,
|
|
|
|
PEER_COL_PROGRESS,
|
|
|
|
PEER_COL_STATUS,
|
|
|
|
PEER_COL_ADDRESS,
|
|
|
|
PEER_COL_CLIENT };
|
2008-09-23 19:11:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
if( inf->webseedCount )
|
|
|
|
{
|
|
|
|
GtkTreeViewColumn * c;
|
|
|
|
GtkCellRenderer * r;
|
|
|
|
const char * t;
|
2009-02-26 17:53:55 +00:00
|
|
|
GtkWidget * w;
|
|
|
|
GtkWidget * v;
|
2008-09-23 19:11:04 +00:00
|
|
|
|
|
|
|
m = webseed_model_new( tr_torrent_handle( gtor ) );
|
2009-02-26 17:53:55 +00:00
|
|
|
v = gtk_tree_view_new_with_model( m );
|
|
|
|
g_signal_connect( v, "button-release-event", G_CALLBACK( on_tree_view_button_released ), NULL );
|
|
|
|
gtk_tree_view_set_rules_hint( GTK_TREE_VIEW( v ), TRUE );
|
2008-09-23 19:11:04 +00:00
|
|
|
p->webseeds = GTK_LIST_STORE( m );
|
|
|
|
g_object_unref( G_OBJECT( m ) );
|
|
|
|
|
|
|
|
t = _( webseed_column_names[WEBSEED_COL_URL] );
|
2009-03-05 17:18:36 +00:00
|
|
|
r = gtk_cell_renderer_text_new( );
|
2008-09-23 19:11:04 +00:00
|
|
|
g_object_set( G_OBJECT( r ), "ellipsize", PANGO_ELLIPSIZE_END, NULL );
|
2009-02-26 17:53:55 +00:00
|
|
|
c = gtk_tree_view_column_new_with_attributes( t, r, "text", WEBSEED_COL_URL, NULL );
|
2008-09-23 19:11:04 +00:00
|
|
|
g_object_set( G_OBJECT( c ), "expand", TRUE, NULL );
|
|
|
|
gtk_tree_view_column_set_sort_column_id( c, WEBSEED_COL_URL );
|
2009-02-26 17:53:55 +00:00
|
|
|
gtk_tree_view_append_column( GTK_TREE_VIEW( v ), c );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
|
|
|
t = _( webseed_column_names[WEBSEED_COL_DOWNLOAD_RATE] );
|
2009-03-05 17:18:36 +00:00
|
|
|
r = gtk_cell_renderer_text_new( );
|
|
|
|
c = gtk_tree_view_column_new_with_attributes( t, r, "text", WEBSEED_COL_DOWNLOAD_RATE, NULL );
|
|
|
|
gtk_tree_view_column_set_cell_data_func( c, r, render_dl_rate, NULL, NULL );
|
2009-02-26 17:53:55 +00:00
|
|
|
gtk_tree_view_column_set_sort_column_id( c, WEBSEED_COL_DOWNLOAD_RATE );
|
|
|
|
gtk_tree_view_append_column( GTK_TREE_VIEW( v ), c );
|
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
w = gtk_scrolled_window_new( NULL, NULL );
|
|
|
|
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( w ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
|
|
|
|
gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( w ), GTK_SHADOW_IN );
|
|
|
|
gtk_container_add( GTK_CONTAINER( w ), v );
|
2009-02-26 17:53:55 +00:00
|
|
|
|
|
|
|
webtree = w;
|
2008-09-23 19:11:04 +00:00
|
|
|
}
|
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
m = peer_model_new( tor );
|
2008-09-23 19:11:04 +00:00
|
|
|
v = GTK_WIDGET( g_object_new( GTK_TYPE_TREE_VIEW,
|
2008-11-23 17:10:40 +00:00
|
|
|
"model", gtk_tree_model_sort_new_with_model( m ),
|
2008-09-23 19:11:04 +00:00
|
|
|
"rules-hint", TRUE,
|
|
|
|
#if GTK_CHECK_VERSION( 2, 12, 0 )
|
|
|
|
"has-tooltip", TRUE,
|
2008-04-12 01:36:31 +00:00
|
|
|
#endif
|
2008-09-23 19:11:04 +00:00
|
|
|
NULL ) );
|
2008-11-23 17:10:40 +00:00
|
|
|
p->peer_tree_view = v;
|
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
#if GTK_CHECK_VERSION( 2, 12, 0 )
|
|
|
|
g_signal_connect( v, "query-tooltip",
|
|
|
|
G_CALLBACK( onPeerViewQueryTooltip ), NULL );
|
2008-04-12 01:36:31 +00:00
|
|
|
#endif
|
2008-09-23 19:11:04 +00:00
|
|
|
gtk_widget_set_size_request( v, 550, 0 );
|
2009-03-05 17:18:36 +00:00
|
|
|
g_object_unref( G_OBJECT( m ) );
|
2008-09-27 18:01:31 +00:00
|
|
|
g_signal_connect( v, "button-release-event",
|
|
|
|
G_CALLBACK( on_tree_view_button_released ), NULL );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
|
|
|
for( i = 0; i < G_N_ELEMENTS( view_columns ); ++i )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
const int col = view_columns[i];
|
|
|
|
const char * t = _( peer_column_names[col] );
|
|
|
|
GtkTreeViewColumn * c;
|
|
|
|
GtkCellRenderer * r;
|
|
|
|
|
|
|
|
switch( col )
|
|
|
|
{
|
|
|
|
case PEER_COL_ADDRESS:
|
2009-03-05 17:18:36 +00:00
|
|
|
r = gtk_cell_renderer_text_new( );
|
|
|
|
c = gtk_tree_view_column_new_with_attributes( t, r, "text", col, NULL );
|
2008-09-23 19:11:04 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PEER_COL_CLIENT:
|
2009-03-05 17:18:36 +00:00
|
|
|
r = gtk_cell_renderer_text_new( );
|
|
|
|
c = gtk_tree_view_column_new_with_attributes( t, r, "text", col, NULL );
|
|
|
|
gtk_tree_view_column_set_cell_data_func( c, r, render_client, NULL, NULL );
|
2008-09-23 19:11:04 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PEER_COL_PROGRESS:
|
2009-03-05 17:18:36 +00:00
|
|
|
r = gtk_cell_renderer_progress_new( );
|
|
|
|
c = gtk_tree_view_column_new_with_attributes( t, r, "value", PEER_COL_PROGRESS, NULL );
|
2008-09-23 19:11:04 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PEER_COL_IS_ENCRYPTED:
|
2009-03-05 17:18:36 +00:00
|
|
|
r = gtk_cell_renderer_pixbuf_new( );
|
|
|
|
c = gtk_tree_view_column_new_with_attributes( t, r, NULL );
|
|
|
|
gtk_tree_view_column_set_sizing( c, GTK_TREE_VIEW_COLUMN_FIXED );
|
|
|
|
gtk_tree_view_column_set_fixed_width( c, 20 );
|
|
|
|
gtk_tree_view_column_set_cell_data_func( c, r, render_encrypted, NULL, NULL );
|
2008-09-23 19:11:04 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PEER_COL_DOWNLOAD_RATE:
|
2009-03-05 17:18:36 +00:00
|
|
|
r = gtk_cell_renderer_text_new( );
|
|
|
|
c = gtk_tree_view_column_new_with_attributes( t, r, "text", col, NULL );
|
|
|
|
gtk_tree_view_column_set_cell_data_func( c, r, render_dl_rate, NULL, NULL );
|
2008-09-23 19:11:04 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PEER_COL_UPLOAD_RATE:
|
2009-03-05 17:18:36 +00:00
|
|
|
r = gtk_cell_renderer_text_new( );
|
|
|
|
c = gtk_tree_view_column_new_with_attributes( t, r, "text", col, NULL );
|
|
|
|
gtk_tree_view_column_set_cell_data_func( c, r, render_ul_rate, NULL, NULL );
|
2008-09-23 19:11:04 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PEER_COL_STATUS:
|
|
|
|
r = gtk_cell_renderer_text_new( );
|
2009-03-05 17:18:36 +00:00
|
|
|
c = gtk_tree_view_column_new_with_attributes( t, r, "text", col, NULL );
|
2008-09-23 19:11:04 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2009-03-05 17:18:36 +00:00
|
|
|
abort( );
|
2008-09-23 19:11:04 +00:00
|
|
|
}
|
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
gtk_tree_view_column_set_resizable( c, FALSE );
|
|
|
|
gtk_tree_view_column_set_sort_column_id( c, col );
|
|
|
|
gtk_tree_view_append_column( GTK_TREE_VIEW( v ), c );
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
/* the 'expander' column has a 10-pixel margin on the left
|
|
|
|
that doesn't look quite correct in any of these columns...
|
|
|
|
so create a non-visible column and assign it as the
|
|
|
|
'expander column. */
|
|
|
|
{
|
2009-03-05 17:18:36 +00:00
|
|
|
GtkTreeViewColumn *c = gtk_tree_view_column_new( );
|
|
|
|
gtk_tree_view_column_set_visible( c, FALSE );
|
|
|
|
gtk_tree_view_append_column( GTK_TREE_VIEW( v ), c );
|
|
|
|
gtk_tree_view_set_expander_column( GTK_TREE_VIEW( v ), c );
|
2008-09-23 19:11:04 +00:00
|
|
|
}
|
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
w = sw = gtk_scrolled_window_new( NULL, NULL );
|
|
|
|
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( w ),
|
|
|
|
GTK_POLICY_AUTOMATIC,
|
|
|
|
GTK_POLICY_AUTOMATIC );
|
|
|
|
gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( w ),
|
|
|
|
GTK_SHADOW_IN );
|
|
|
|
gtk_container_add( GTK_CONTAINER( w ), v );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
vbox = gtk_vbox_new( FALSE, GUI_PAD );
|
|
|
|
gtk_container_set_border_width( GTK_CONTAINER( vbox ), GUI_PAD_BIG );
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2009-02-26 17:53:55 +00:00
|
|
|
if( webtree == NULL )
|
|
|
|
gtk_box_pack_start( GTK_BOX( vbox ), sw, TRUE, TRUE, 0 );
|
|
|
|
else {
|
|
|
|
GtkWidget * vpaned = gtk_vpaned_new( );
|
|
|
|
gtk_paned_pack1( GTK_PANED( vpaned ), webtree, FALSE, TRUE );
|
|
|
|
gtk_paned_pack2( GTK_PANED( vpaned ), sw, TRUE, TRUE );
|
|
|
|
gtk_box_pack_start( GTK_BOX( vbox ), vpaned, TRUE, TRUE, 0 );
|
|
|
|
}
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
hbox = gtk_hbox_new( FALSE, GUI_PAD );
|
|
|
|
l = gtk_label_new( NULL );
|
|
|
|
gtk_label_set_markup( GTK_LABEL( l ), _( "<b>Seeders:</b>" ) );
|
|
|
|
gtk_box_pack_start( GTK_BOX( hbox ), l, FALSE, FALSE, 0 );
|
|
|
|
l = p->seeders_lb = gtk_label_new( NULL );
|
|
|
|
gtk_box_pack_start( GTK_BOX( hbox ), l, FALSE, FALSE, 0 );
|
|
|
|
gtk_box_pack_start( GTK_BOX( hbox ), gtk_alignment_new( 0.0f, 0.0f, 0.0f, 0.0f ), TRUE, TRUE, 0 );
|
|
|
|
l = gtk_label_new( NULL );
|
|
|
|
gtk_label_set_markup( GTK_LABEL( l ), _( "<b>Leechers:</b>" ) );
|
|
|
|
gtk_box_pack_start( GTK_BOX( hbox ), l, FALSE, FALSE, 0 );
|
|
|
|
l = p->leechers_lb = gtk_label_new( NULL );
|
|
|
|
gtk_box_pack_start( GTK_BOX( hbox ), l, FALSE, FALSE, 0 );
|
|
|
|
gtk_box_pack_start( GTK_BOX( hbox ), gtk_alignment_new( 0.0f, 0.0f, 0.0f, 0.0f ), TRUE, TRUE, 0 );
|
|
|
|
l = gtk_label_new( NULL );
|
|
|
|
gtk_label_set_markup( GTK_LABEL( l ), _( "<b>Times Completed:</b>" ) );
|
|
|
|
gtk_box_pack_start( GTK_BOX( hbox ), l, FALSE, FALSE, 0 );
|
|
|
|
l = p->completed_lb = gtk_label_new( NULL );
|
|
|
|
gtk_box_pack_start( GTK_BOX( hbox ), l, FALSE, FALSE, 0 );
|
|
|
|
gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
|
|
|
ret = vbox;
|
|
|
|
p->gtor = gtor;
|
|
|
|
p->model = m;
|
|
|
|
p->store = GTK_LIST_STORE( m );
|
2009-03-05 17:18:36 +00:00
|
|
|
g_object_set_data_full( G_OBJECT( ret ), "peer-data", p, g_free );
|
2008-09-23 19:11:04 +00:00
|
|
|
return ret;
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/****
|
|
|
|
***** INFO TAB
|
|
|
|
****/
|
|
|
|
|
2008-05-23 20:04:41 +00:00
|
|
|
static void
|
2008-09-23 19:11:04 +00:00
|
|
|
refresh_time_lb( GtkWidget * l,
|
|
|
|
time_t t )
|
2008-05-23 20:04:41 +00:00
|
|
|
{
|
|
|
|
const char * never = _( "Never" );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-05-23 20:04:41 +00:00
|
|
|
if( !t )
|
|
|
|
gtk_label_set_text( GTK_LABEL( l ), never );
|
2008-09-23 19:11:04 +00:00
|
|
|
else
|
|
|
|
{
|
2008-07-25 14:56:28 +00:00
|
|
|
char * str = gtr_localtime( t );
|
2008-05-23 20:04:41 +00:00
|
|
|
gtk_label_set_text( GTK_LABEL( l ), str );
|
|
|
|
g_free( str );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-06 21:59:00 +00:00
|
|
|
static GtkWidget*
|
2008-09-23 19:11:04 +00:00
|
|
|
info_page_new( tr_torrent * tor )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
int row = 0;
|
2009-03-05 17:18:36 +00:00
|
|
|
GtkWidget * t = hig_workarea_create( );
|
2008-09-23 19:11:04 +00:00
|
|
|
GtkWidget * l, *w, *fr;
|
|
|
|
char * pch;
|
|
|
|
char sizeStr[128];
|
|
|
|
char countStr[128];
|
|
|
|
char buf[256];
|
|
|
|
GtkTextBuffer * b;
|
|
|
|
const tr_info * info = tr_torrentInfo( tor );
|
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
hig_workarea_add_section_title( t, &row, _( "Details" ) );
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2008-06-03 20:13:22 +00:00
|
|
|
g_snprintf( countStr, sizeof( countStr ),
|
2008-07-11 17:09:53 +00:00
|
|
|
ngettext( "%'d Piece", "%'d Pieces", info->pieceCount ),
|
2008-06-03 20:13:22 +00:00
|
|
|
info->pieceCount );
|
2008-09-23 19:11:04 +00:00
|
|
|
tr_strlsize( sizeStr, info->pieceSize, sizeof( sizeStr ) );
|
2008-03-08 02:00:47 +00:00
|
|
|
g_snprintf( buf, sizeof( buf ),
|
2008-06-03 20:13:22 +00:00
|
|
|
/* %1$s is number of pieces;
|
2008-03-19 20:07:27 +00:00
|
|
|
%2$s is how big each piece is */
|
2008-06-03 20:13:22 +00:00
|
|
|
_( "%1$s @ %2$s" ),
|
2008-09-23 19:11:04 +00:00
|
|
|
countStr, sizeStr );
|
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
l = gtk_label_new( buf );
|
|
|
|
hig_workarea_add_row( t, &row, _( "Pieces:" ), l, NULL );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
l = g_object_new( GTK_TYPE_LABEL, "label", info->hashString,
|
|
|
|
"selectable", TRUE,
|
2008-09-23 19:11:04 +00:00
|
|
|
"ellipsize", PANGO_ELLIPSIZE_END,
|
|
|
|
NULL );
|
2009-03-05 17:18:36 +00:00
|
|
|
hig_workarea_add_row( t, &row, _( "Hash:" ), l, NULL );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
|
|
|
pch = ( info->isPrivate )
|
|
|
|
? _( "Private to this tracker -- PEX disabled" )
|
|
|
|
: _( "Public torrent" );
|
2009-03-05 17:18:36 +00:00
|
|
|
l = gtk_label_new( pch );
|
|
|
|
hig_workarea_add_row( t, &row, _( "Privacy:" ), l, NULL );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
b = gtk_text_buffer_new( NULL );
|
2008-02-14 17:18:00 +00:00
|
|
|
if( info->comment )
|
2009-03-05 17:18:36 +00:00
|
|
|
gtk_text_buffer_set_text( b, info->comment, -1 );
|
|
|
|
w = gtk_text_view_new_with_buffer( b );
|
|
|
|
gtk_widget_set_size_request( w, 0u, 100u );
|
|
|
|
gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( w ), GTK_WRAP_WORD );
|
|
|
|
gtk_text_view_set_editable( GTK_TEXT_VIEW( w ), FALSE );
|
|
|
|
fr = gtk_frame_new( NULL );
|
|
|
|
gtk_frame_set_shadow_type( GTK_FRAME( fr ), GTK_SHADOW_IN );
|
|
|
|
gtk_container_add( GTK_CONTAINER( fr ), w );
|
|
|
|
w = hig_workarea_add_row( t, &row, _( "Comment:" ), fr, NULL );
|
|
|
|
gtk_misc_set_alignment( GTK_MISC( w ), 0.0f, 0.0f );
|
|
|
|
|
|
|
|
hig_workarea_add_section_divider( t, &row );
|
|
|
|
hig_workarea_add_section_title( t, &row, _( "Origins" ) );
|
|
|
|
|
|
|
|
l = gtk_label_new( *info->creator ? info->creator : _( "Unknown" ) );
|
2008-08-13 03:05:51 +00:00
|
|
|
gtk_label_set_ellipsize( GTK_LABEL( l ), PANGO_ELLIPSIZE_END );
|
2009-03-05 17:18:36 +00:00
|
|
|
hig_workarea_add_row( t, &row, _( "Creator:" ), l, NULL );
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2008-05-23 20:04:41 +00:00
|
|
|
l = gtk_label_new( NULL );
|
|
|
|
refresh_time_lb( l, info->dateCreated );
|
2009-03-05 17:18:36 +00:00
|
|
|
hig_workarea_add_row( t, &row, _( "Date:" ), l, NULL );
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
hig_workarea_add_section_divider( t, &row );
|
|
|
|
hig_workarea_add_section_title( t, &row, _( "Location" ) );
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
l = g_object_new( GTK_TYPE_LABEL, "label", tr_torrentGetDownloadDir( tor ),
|
|
|
|
"selectable", TRUE,
|
|
|
|
"ellipsize", PANGO_ELLIPSIZE_END,
|
|
|
|
NULL );
|
|
|
|
hig_workarea_add_row( t, &row, _( "Destination folder:" ), l, NULL );
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
l = g_object_new( GTK_TYPE_LABEL, "label", info->torrent,
|
|
|
|
"selectable", TRUE,
|
|
|
|
"ellipsize", PANGO_ELLIPSIZE_END,
|
|
|
|
NULL );
|
|
|
|
hig_workarea_add_row( t, &row, _( "Torrent file:" ), l, NULL );
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
hig_workarea_finish( t, &row );
|
2008-09-23 19:11:04 +00:00
|
|
|
return t;
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/****
|
|
|
|
***** ACTIVITY TAB
|
|
|
|
****/
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2009-03-05 17:18:36 +00:00
|
|
|
GtkWidget * state_lb;
|
|
|
|
GtkWidget * progress_lb;
|
|
|
|
GtkWidget * have_lb;
|
|
|
|
GtkWidget * dl_lb;
|
|
|
|
GtkWidget * ul_lb;
|
|
|
|
GtkWidget * failed_lb;
|
|
|
|
GtkWidget * ratio_lb;
|
|
|
|
GtkWidget * err_lb;
|
|
|
|
GtkWidget * swarm_lb;
|
|
|
|
GtkWidget * date_added_lb;
|
|
|
|
GtkWidget * last_activity_lb;
|
|
|
|
GtkWidget * availability_da;
|
|
|
|
TrTorrent * gtor;
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
Activity;
|
|
|
|
|
|
|
|
static void
|
2008-09-23 19:11:04 +00:00
|
|
|
refresh_activity( GtkWidget * top )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2009-03-02 17:45:08 +00:00
|
|
|
int i;
|
|
|
|
char * pch;
|
|
|
|
char buf1[128];
|
|
|
|
char buf2[128];
|
2009-03-05 17:18:36 +00:00
|
|
|
Activity * a = g_object_get_data( G_OBJECT( top ), "activity-data" );
|
2008-09-23 19:11:04 +00:00
|
|
|
const tr_stat * stat = tr_torrent_stat( a->gtor );
|
2009-01-12 19:30:34 +00:00
|
|
|
const tr_info * info = tr_torrent_info( a->gtor );
|
2009-03-02 17:45:08 +00:00
|
|
|
const double complete = stat->percentComplete * 100.0;
|
|
|
|
const double done = stat->percentDone * 100.0;
|
|
|
|
const double verifiedPieceCount = (double)stat->haveValid / info->pieceSize;
|
2008-09-23 19:11:04 +00:00
|
|
|
|
|
|
|
pch = tr_torrent_status_str( a->gtor );
|
2009-03-05 17:18:36 +00:00
|
|
|
gtk_label_set_text( GTK_LABEL( a->state_lb ), pch );
|
|
|
|
g_free( pch );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
|
|
|
if( (int)complete == (int)done )
|
|
|
|
pch = g_strdup_printf( _( "%.1f%%" ), complete );
|
|
|
|
else
|
|
|
|
/* %1$.1f is percent of how much of what we want's been downloaded,
|
2009-03-02 17:45:08 +00:00
|
|
|
* %2$.1f is percent of how much of the whole torrent we've downloaded */
|
|
|
|
pch = g_strdup_printf( _( "%1$.1f%% (%2$.1f%% selected)" ),
|
2008-09-23 19:11:04 +00:00
|
|
|
complete, done );
|
2009-03-05 17:18:36 +00:00
|
|
|
gtk_label_set_text( GTK_LABEL( a->progress_lb ), pch );
|
|
|
|
g_free( pch );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2009-03-02 17:45:08 +00:00
|
|
|
i = (int) ceil( verifiedPieceCount );
|
|
|
|
tr_strlsize( buf1, stat->haveValid + stat->haveUnchecked, sizeof( buf1 ) );
|
|
|
|
tr_strlsize( buf2, stat->haveValid, sizeof( buf2 ) );
|
2008-09-23 19:11:04 +00:00
|
|
|
/* %1$s is total size of what we've saved to disk
|
2009-03-02 17:45:08 +00:00
|
|
|
* %2$s is how much of it's passed the checksum test
|
|
|
|
* %3$s is how many pieces are verified */
|
2009-03-05 17:18:36 +00:00
|
|
|
if( !i )
|
|
|
|
pch = tr_strdup( buf1 );
|
|
|
|
else
|
|
|
|
pch = g_strdup_printf( ngettext( "%1$s (%2$s verified in %3$d piece)",
|
|
|
|
"%1$s (%2$s verified in %3$d pieces)", i ),
|
|
|
|
buf1, buf2, i );
|
2009-03-02 17:45:08 +00:00
|
|
|
gtk_label_set_text( GTK_LABEL( a->have_lb ), pch );
|
|
|
|
g_free( pch );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2009-03-02 17:45:08 +00:00
|
|
|
tr_strlsize( buf1, stat->downloadedEver, sizeof( buf1 ) );
|
|
|
|
gtk_label_set_text( GTK_LABEL( a->dl_lb ), buf1 );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2009-03-02 17:45:08 +00:00
|
|
|
tr_strlsize( buf1, stat->uploadedEver, sizeof( buf1 ) );
|
|
|
|
gtk_label_set_text( GTK_LABEL( a->ul_lb ), buf1 );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2009-03-02 17:45:08 +00:00
|
|
|
tr_strlsize( buf1, stat->corruptEver, sizeof( buf1 ) );
|
|
|
|
gtk_label_set_text( GTK_LABEL( a->failed_lb ), buf1 );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2009-03-02 17:45:08 +00:00
|
|
|
tr_strlratio( buf1, stat->ratio, sizeof( buf1 ) );
|
|
|
|
gtk_label_set_text( GTK_LABEL( a->ratio_lb ), buf1 );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2009-03-02 17:45:08 +00:00
|
|
|
tr_strlspeed( buf1, stat->swarmSpeed, sizeof( buf1 ) );
|
2009-03-05 17:18:36 +00:00
|
|
|
gtk_label_set_text( GTK_LABEL( a->swarm_lb ), buf1 );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
gtk_label_set_text( GTK_LABEL( a->err_lb ),
|
2008-09-23 19:11:04 +00:00
|
|
|
*stat->errorString ? stat->errorString : _( "None" ) );
|
|
|
|
|
|
|
|
refresh_time_lb( a->date_added_lb, stat->addedDate );
|
|
|
|
|
|
|
|
refresh_time_lb( a->last_activity_lb, stat->activityDate );
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GtkWidget*
|
2008-09-23 19:11:04 +00:00
|
|
|
activity_page_new( TrTorrent * gtor )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2009-03-05 17:18:36 +00:00
|
|
|
Activity * a = g_new( Activity, 1 );
|
2008-09-23 19:11:04 +00:00
|
|
|
int row = 0;
|
2009-03-05 17:18:36 +00:00
|
|
|
GtkWidget *t = hig_workarea_create( );
|
2008-09-23 19:11:04 +00:00
|
|
|
GtkWidget *l;
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
a->gtor = gtor;
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
hig_workarea_add_section_title( t, &row, _( "Transfer" ) );
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
l = a->state_lb = gtk_label_new( NULL );
|
|
|
|
hig_workarea_add_row( t, &row, _( "State:" ), l, NULL );
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
l = a->progress_lb = gtk_label_new( NULL );
|
|
|
|
hig_workarea_add_row( t, &row, _( "Progress:" ), l, NULL );
|
2007-09-26 01:55:04 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
l = a->have_lb = gtk_label_new( NULL );
|
2008-03-08 01:43:20 +00:00
|
|
|
/* "Have" refers to how much of the torrent we have */
|
2009-03-05 17:18:36 +00:00
|
|
|
hig_workarea_add_row( t, &row, _( "Have:" ), l, NULL );
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
l = a->dl_lb = gtk_label_new( NULL );
|
|
|
|
hig_workarea_add_row( t, &row, _( "Downloaded:" ), l, NULL );
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
l = a->ul_lb = gtk_label_new( NULL );
|
|
|
|
hig_workarea_add_row( t, &row, _( "Uploaded:" ), l, NULL );
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2008-03-08 01:43:20 +00:00
|
|
|
/* how much downloaded data was corrupt */
|
2009-03-05 17:18:36 +00:00
|
|
|
l = a->failed_lb = gtk_label_new( NULL );
|
|
|
|
hig_workarea_add_row( t, &row, _( "Failed DL:" ), l, NULL );
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
l = a->ratio_lb = gtk_label_new( NULL );
|
|
|
|
hig_workarea_add_row( t, &row, _( "Ratio:" ), l, NULL );
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
l = a->swarm_lb = gtk_label_new( NULL );
|
|
|
|
hig_workarea_add_row( t, &row, _( "Swarm rate:" ), l, NULL );
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
l = a->err_lb = gtk_label_new( NULL );
|
|
|
|
hig_workarea_add_row( t, &row, _( "Error:" ), l, NULL );
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
hig_workarea_add_section_divider( t, &row );
|
|
|
|
hig_workarea_add_section_title( t, &row, _( "Dates" ) );
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
l = a->date_added_lb = gtk_label_new( NULL );
|
|
|
|
hig_workarea_add_row( t, &row, _( "Started at:" ), l, NULL );
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
l = a->last_activity_lb = gtk_label_new( NULL );
|
|
|
|
hig_workarea_add_row( t, &row, _( "Last activity at:" ), l, NULL );
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
hig_workarea_add_section_divider( t, &row );
|
|
|
|
hig_workarea_finish( t, &row );
|
|
|
|
g_object_set_data_full( G_OBJECT( t ), "activity-data", a, g_free );
|
2008-09-23 19:11:04 +00:00
|
|
|
return t;
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/****
|
|
|
|
***** OPTIONS
|
|
|
|
****/
|
|
|
|
|
2007-07-20 03:24:04 +00:00
|
|
|
static void
|
2009-03-04 19:52:57 +00:00
|
|
|
up_speed_toggled_cb( GtkToggleButton *tb,
|
|
|
|
gpointer gtor )
|
2007-07-20 03:24:04 +00:00
|
|
|
{
|
2009-03-05 17:18:36 +00:00
|
|
|
tr_torrent * tor = tr_torrent_handle( gtor );
|
2009-03-04 19:52:57 +00:00
|
|
|
const gboolean b = gtk_toggle_button_get_active( tb );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2009-03-04 19:52:57 +00:00
|
|
|
tr_torrentUseSpeedLimit( tor, TR_UP, b );
|
2007-07-20 03:24:04 +00:00
|
|
|
}
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2007-06-06 00:30:13 +00:00
|
|
|
static void
|
2009-03-04 19:52:57 +00:00
|
|
|
down_speed_toggled_cb( GtkToggleButton *tb,
|
|
|
|
gpointer gtor )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2009-03-05 17:18:36 +00:00
|
|
|
tr_torrent * tor = tr_torrent_handle( gtor );
|
2009-03-04 19:52:57 +00:00
|
|
|
const gboolean b = gtk_toggle_button_get_active( tb );
|
|
|
|
|
|
|
|
tr_torrentUseSpeedLimit( tor, TR_DOWN, b );
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2007-06-06 00:30:13 +00:00
|
|
|
static void
|
2009-03-04 19:52:57 +00:00
|
|
|
global_speed_toggled_cb( GtkToggleButton * tb, gpointer gtor )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2009-03-05 17:18:36 +00:00
|
|
|
tr_torrent * tor = tr_torrent_handle( gtor );
|
2009-03-04 19:52:57 +00:00
|
|
|
const gboolean b = gtk_toggle_button_get_active( tb );
|
|
|
|
|
2009-03-28 16:47:01 +00:00
|
|
|
tr_torrentUseSessionLimits( tor, b );
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
2009-02-13 18:23:56 +00:00
|
|
|
#define RATIO_MODE_KEY "ratio-mode"
|
|
|
|
|
|
|
|
static void
|
|
|
|
ratio_mode_changed_cb( GtkToggleButton * tb, gpointer gtor )
|
|
|
|
{
|
|
|
|
if( gtk_toggle_button_get_active( tb ) )
|
|
|
|
{
|
|
|
|
tr_torrent * tor = tr_torrent_handle( gtor );
|
|
|
|
const int mode = GPOINTER_TO_INT( g_object_get_data( G_OBJECT( tb ), RATIO_MODE_KEY ) );
|
|
|
|
tr_torrentSetRatioMode( tor, mode );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-06 00:30:13 +00:00
|
|
|
static void
|
2009-03-04 19:52:57 +00:00
|
|
|
sensitize_from_check_cb( GtkToggleButton * toggle, gpointer w )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2009-03-05 17:18:36 +00:00
|
|
|
gtk_widget_set_sensitive( GTK_WIDGET( w ),
|
|
|
|
gtk_toggle_button_get_active( toggle ) );
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
2007-07-20 03:24:04 +00:00
|
|
|
static void
|
2009-03-04 19:52:57 +00:00
|
|
|
setSpeedLimit( GtkSpinButton* spin, gpointer gtor, int up_or_down )
|
2007-07-20 03:24:04 +00:00
|
|
|
{
|
2009-03-05 17:18:36 +00:00
|
|
|
tr_torrent * tor = tr_torrent_handle( gtor );
|
|
|
|
const int kb_sec = gtk_spin_button_get_value_as_int( spin );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
|
|
|
tr_torrentSetSpeedLimit( tor, up_or_down, kb_sec );
|
2007-07-20 03:24:04 +00:00
|
|
|
}
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2007-06-06 00:30:13 +00:00
|
|
|
static void
|
2009-03-04 19:52:57 +00:00
|
|
|
up_speed_spun_cb( GtkSpinButton * spin, gpointer gtor )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
setSpeedLimit( spin, gtor, TR_UP );
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2007-06-06 00:30:13 +00:00
|
|
|
static void
|
2009-03-04 19:52:57 +00:00
|
|
|
down_speed_spun_cb( GtkSpinButton * spin, gpointer gtor )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
setSpeedLimit( spin, gtor, TR_DOWN );
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
2009-02-13 18:23:56 +00:00
|
|
|
static void
|
2009-03-04 19:52:57 +00:00
|
|
|
ratio_spun_cb( GtkSpinButton * spin, gpointer gtor )
|
2009-02-13 18:23:56 +00:00
|
|
|
{
|
2009-03-05 17:18:36 +00:00
|
|
|
tr_torrent * tor = tr_torrent_handle( gtor );
|
|
|
|
float ratio = gtk_spin_button_get_value( spin );
|
2009-02-13 18:23:56 +00:00
|
|
|
|
|
|
|
tr_torrentSetRatioLimit( tor, ratio );
|
|
|
|
}
|
|
|
|
|
2007-12-22 00:06:38 +00:00
|
|
|
static void
|
2009-03-04 19:52:57 +00:00
|
|
|
max_peers_spun_cb( GtkSpinButton * spin, gpointer gtor )
|
2007-12-22 00:06:38 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
const uint16_t n = gtk_spin_button_get_value( spin );
|
|
|
|
|
|
|
|
tr_torrentSetPeerLimit( tr_torrent_handle( gtor ), n );
|
2007-12-22 00:06:38 +00:00
|
|
|
}
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2009-02-13 18:23:56 +00:00
|
|
|
static char*
|
|
|
|
get_global_ratio_radiobutton_string( void )
|
|
|
|
{
|
|
|
|
char * s;
|
|
|
|
const gboolean b = pref_flag_get( TR_PREFS_KEY_RATIO_ENABLED );
|
|
|
|
const double d = pref_double_get( TR_PREFS_KEY_RATIO );
|
|
|
|
|
|
|
|
if( b )
|
|
|
|
s = g_strdup_printf( _( "Use _Global setting (currently: stop seeding when a torrent's ratio reaches %.2f)" ), d );
|
|
|
|
else
|
|
|
|
s = g_strdup( _( "Use _Global setting (currently: seed regardless of ratio)" ) );
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
prefsChanged( TrCore * core UNUSED, const char * key, gpointer rb )
|
|
|
|
{
|
|
|
|
if( !strcmp( key, TR_PREFS_KEY_RATIO_ENABLED ) || !strcmp( key, TR_PREFS_KEY_RATIO ) )
|
|
|
|
{
|
|
|
|
char * s = get_global_ratio_radiobutton_string( );
|
|
|
|
gtk_button_set_label( GTK_BUTTON( rb ), s );
|
|
|
|
g_free( s );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-03 21:41:15 +00:00
|
|
|
static GtkWidget*
|
2009-03-05 17:18:36 +00:00
|
|
|
options_page_new( struct ResponseData * data )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
uint16_t maxConnectedPeers;
|
|
|
|
int i, row;
|
2009-02-13 18:23:56 +00:00
|
|
|
double d;
|
2008-09-23 19:11:04 +00:00
|
|
|
gboolean b;
|
2009-02-13 18:23:56 +00:00
|
|
|
char * s;
|
|
|
|
GSList * group;
|
|
|
|
GtkWidget * t, *w, *tb, *h;
|
|
|
|
tr_ratiolimit mode;
|
|
|
|
TrCore * core = data->core;
|
|
|
|
TrTorrent * gtor = data->gtor;
|
2009-03-05 17:18:36 +00:00
|
|
|
tr_torrent * tor = tr_torrent_handle( gtor );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
|
|
|
row = 0;
|
2009-03-05 17:18:36 +00:00
|
|
|
t = hig_workarea_create( );
|
|
|
|
hig_workarea_add_section_title( t, &row, _( "Speed Limits" ) );
|
2009-03-04 19:52:57 +00:00
|
|
|
|
2009-03-28 16:47:01 +00:00
|
|
|
b = tr_torrentUsesSessionLimits( tor );
|
2009-03-04 19:52:57 +00:00
|
|
|
tb = hig_workarea_add_wide_checkbutton( t, &row, _( "Honor global _limits" ), b );
|
|
|
|
g_signal_connect( tb, "toggled", G_CALLBACK( global_speed_toggled_cb ), gtor );
|
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
tb = gtk_check_button_new_with_mnemonic( _( "Limit _download speed (KB/s):" ) );
|
2009-03-28 16:47:01 +00:00
|
|
|
b = tr_torrentUsesSpeedLimit( tor, TR_DOWN );
|
2009-03-05 17:18:36 +00:00
|
|
|
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( tb ), b );
|
|
|
|
g_signal_connect( tb, "toggled", G_CALLBACK( down_speed_toggled_cb ), gtor );
|
2009-03-04 19:52:57 +00:00
|
|
|
|
|
|
|
i = tr_torrentGetSpeedLimit( tor, TR_DOWN );
|
|
|
|
w = gtk_spin_button_new_with_range( 1, INT_MAX, 5 );
|
|
|
|
gtk_spin_button_set_value( GTK_SPIN_BUTTON( w ), i );
|
2009-03-05 17:18:36 +00:00
|
|
|
g_signal_connect( w, "value-changed", G_CALLBACK( down_speed_spun_cb ), gtor );
|
|
|
|
g_signal_connect( tb, "toggled", G_CALLBACK( sensitize_from_check_cb ), w );
|
|
|
|
sensitize_from_check_cb( GTK_TOGGLE_BUTTON( tb ), w );
|
|
|
|
hig_workarea_add_row_w( t, &row, tb, w, NULL );
|
2009-03-04 19:52:57 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
tb = gtk_check_button_new_with_mnemonic( _( "Limit _upload speed (KB/s):" ) );
|
2009-03-28 16:47:01 +00:00
|
|
|
b = tr_torrentUsesSpeedLimit( tor, TR_UP );
|
2009-03-05 17:18:36 +00:00
|
|
|
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( tb ), b );
|
|
|
|
g_signal_connect( tb, "toggled", G_CALLBACK( up_speed_toggled_cb ), gtor );
|
2009-03-04 19:52:57 +00:00
|
|
|
|
|
|
|
i = tr_torrentGetSpeedLimit( tor, TR_UP );
|
|
|
|
w = gtk_spin_button_new_with_range( 1, INT_MAX, 5 );
|
|
|
|
gtk_spin_button_set_value( GTK_SPIN_BUTTON( w ), i );
|
2009-03-05 17:18:36 +00:00
|
|
|
g_signal_connect( w, "value-changed", G_CALLBACK( up_speed_spun_cb ), gtor );
|
|
|
|
g_signal_connect( tb, "toggled", G_CALLBACK( sensitize_from_check_cb ), w );
|
|
|
|
sensitize_from_check_cb( GTK_TOGGLE_BUTTON( tb ), w );
|
|
|
|
hig_workarea_add_row_w( t, &row, tb, w, NULL );
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
hig_workarea_add_section_divider( t, &row );
|
|
|
|
hig_workarea_add_section_title( t, &row, _( "Seed-Until Ratio" ) );
|
2009-02-13 18:23:56 +00:00
|
|
|
|
|
|
|
group = NULL;
|
|
|
|
mode = tr_torrentGetRatioMode( tor );
|
|
|
|
s = get_global_ratio_radiobutton_string( );
|
|
|
|
w = gtk_radio_button_new_with_mnemonic( group, s );
|
|
|
|
data->handler = g_signal_connect( core, "prefs-changed", G_CALLBACK( prefsChanged ), w );
|
|
|
|
group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( w ) );
|
2009-03-05 17:18:36 +00:00
|
|
|
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( w ), mode == TR_RATIOLIMIT_GLOBAL);
|
2009-02-13 18:23:56 +00:00
|
|
|
hig_workarea_add_wide_control( t, &row, w );
|
|
|
|
g_free( s );
|
|
|
|
g_object_set_data( G_OBJECT( w ), RATIO_MODE_KEY, GINT_TO_POINTER( TR_RATIOLIMIT_GLOBAL ) );
|
|
|
|
g_signal_connect( w, "toggled", G_CALLBACK( ratio_mode_changed_cb ), gtor );
|
|
|
|
|
|
|
|
w = gtk_radio_button_new_with_mnemonic( group, _( "Seed _regardless of ratio" ) );
|
|
|
|
group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( w ) );
|
2009-03-05 17:18:36 +00:00
|
|
|
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( w ), mode == TR_RATIOLIMIT_UNLIMITED);
|
2009-02-13 18:23:56 +00:00
|
|
|
hig_workarea_add_wide_control( t, &row, w );
|
|
|
|
g_object_set_data( G_OBJECT( w ), RATIO_MODE_KEY, GINT_TO_POINTER( TR_RATIOLIMIT_UNLIMITED ) );
|
|
|
|
g_signal_connect( w, "toggled", G_CALLBACK( ratio_mode_changed_cb ), gtor );
|
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
h = gtk_hbox_new( FALSE, GUI_PAD );
|
2009-02-13 18:23:56 +00:00
|
|
|
w = gtk_radio_button_new_with_mnemonic( group, _( "_Stop seeding when a torrent's ratio reaches" ) );
|
|
|
|
g_object_set_data( G_OBJECT( w ), RATIO_MODE_KEY, GINT_TO_POINTER( TR_RATIOLIMIT_SINGLE ) );
|
2009-03-05 17:18:36 +00:00
|
|
|
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( w ), mode == TR_RATIOLIMIT_SINGLE);
|
2009-02-13 18:23:56 +00:00
|
|
|
g_signal_connect( w, "toggled", G_CALLBACK( ratio_mode_changed_cb ), gtor );
|
|
|
|
group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( w ) );
|
2009-03-05 17:18:36 +00:00
|
|
|
gtk_box_pack_start( GTK_BOX( h ), w, FALSE, FALSE, 0 );
|
2009-02-13 18:23:56 +00:00
|
|
|
d = tr_torrentGetRatioLimit( tor );
|
|
|
|
w = gtk_spin_button_new_with_range( 0.5, INT_MAX, .05 );
|
|
|
|
gtk_spin_button_set_digits( GTK_SPIN_BUTTON( w ), 2 );
|
|
|
|
gtk_spin_button_set_value( GTK_SPIN_BUTTON( w ), d );
|
2009-03-05 17:18:36 +00:00
|
|
|
g_signal_connect( w, "value-changed", G_CALLBACK( ratio_spun_cb ), gtor );
|
|
|
|
gtk_box_pack_start( GTK_BOX( h ), w, FALSE, FALSE, 0 );
|
2009-02-13 18:23:56 +00:00
|
|
|
hig_workarea_add_wide_control( t, &row, h );
|
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
hig_workarea_add_section_divider( t, &row );
|
|
|
|
hig_workarea_add_section_title( t, &row, _( "Peer Connections" ) );
|
2007-06-06 00:30:13 +00:00
|
|
|
|
2008-05-12 16:33:17 +00:00
|
|
|
maxConnectedPeers = tr_torrentGetPeerLimit( tor );
|
2007-12-22 00:06:38 +00:00
|
|
|
w = gtk_spin_button_new_with_range( 1, 3000, 5 );
|
|
|
|
gtk_spin_button_set_value( GTK_SPIN_BUTTON( w ), maxConnectedPeers );
|
2008-03-19 01:49:07 +00:00
|
|
|
hig_workarea_add_row( t, &row, _( "_Maximum peers:" ), w, w );
|
2008-09-23 19:11:04 +00:00
|
|
|
g_signal_connect( w, "value-changed", G_CALLBACK(
|
|
|
|
max_peers_spun_cb ), gtor );
|
2007-12-22 00:06:38 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
hig_workarea_finish( t, &row );
|
2008-09-23 19:11:04 +00:00
|
|
|
return t;
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
2008-02-21 07:29:39 +00:00
|
|
|
/****
|
|
|
|
***** TRACKER
|
|
|
|
****/
|
|
|
|
|
|
|
|
#define TRACKER_PAGE "tracker-page"
|
|
|
|
|
|
|
|
struct tracker_page
|
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
TrTorrent * gtor;
|
2008-02-21 07:29:39 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
GtkTreeView * view;
|
|
|
|
GtkListStore * store;
|
|
|
|
GtkTreeSelection * sel;
|
2008-06-01 01:40:32 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
GtkWidget * add_button;
|
|
|
|
GtkWidget * remove_button;
|
|
|
|
GtkWidget * save_button;
|
|
|
|
GtkWidget * revert_button;
|
2008-06-01 01:40:32 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
GtkWidget * last_scrape_time_lb;
|
|
|
|
GtkWidget * last_scrape_response_lb;
|
|
|
|
GtkWidget * next_scrape_countdown_lb;
|
2008-02-21 07:29:39 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
GtkWidget * last_announce_time_lb;
|
|
|
|
GtkWidget * last_announce_response_lb;
|
|
|
|
GtkWidget * next_announce_countdown_lb;
|
|
|
|
GtkWidget * manual_announce_countdown_lb;
|
2008-02-21 07:29:39 +00:00
|
|
|
};
|
|
|
|
|
2008-08-11 19:05:02 +00:00
|
|
|
static GtkWidget*
|
2008-02-21 07:29:39 +00:00
|
|
|
tracker_page_new( TrTorrent * gtor )
|
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
GtkWidget * t;
|
|
|
|
GtkWidget * l;
|
|
|
|
GtkWidget * w;
|
|
|
|
int row = 0;
|
|
|
|
const char * s;
|
2008-02-21 07:29:39 +00:00
|
|
|
struct tracker_page * page = g_new0( struct tracker_page, 1 );
|
2009-03-05 17:18:36 +00:00
|
|
|
const tr_info * info = tr_torrent_info( gtor );
|
2008-02-21 07:29:39 +00:00
|
|
|
|
|
|
|
page->gtor = gtor;
|
|
|
|
|
|
|
|
t = hig_workarea_create( );
|
2008-06-01 01:40:32 +00:00
|
|
|
hig_workarea_add_section_title( t, &row, _( "Trackers" ) );
|
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
w = tracker_list_new( gtor );
|
|
|
|
hig_workarea_add_wide_control( t, &row, w );
|
2008-06-01 01:40:32 +00:00
|
|
|
|
|
|
|
hig_workarea_add_section_divider( t, &row );
|
2008-02-21 07:29:39 +00:00
|
|
|
hig_workarea_add_section_title( t, &row, _( "Scrape" ) );
|
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
s = _( "Last scrape at:" );
|
|
|
|
l = gtk_label_new( NULL );
|
|
|
|
page->last_scrape_time_lb = l;
|
|
|
|
hig_workarea_add_row( t, &row, s, l, NULL );
|
2008-02-21 07:29:39 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
s = _( "Tracker responded:" );
|
|
|
|
l = gtk_label_new( NULL );
|
|
|
|
page->last_scrape_response_lb = l;
|
|
|
|
hig_workarea_add_row( t, &row, s, l, NULL );
|
2008-02-21 07:29:39 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
s = _( "Next scrape in:" );
|
|
|
|
l = gtk_label_new( NULL );
|
|
|
|
page->next_scrape_countdown_lb = l;
|
|
|
|
hig_workarea_add_row( t, &row, s, l, NULL );
|
2008-02-21 07:29:39 +00:00
|
|
|
|
|
|
|
hig_workarea_add_section_divider( t, &row );
|
|
|
|
hig_workarea_add_section_title( t, &row, _( "Announce" ) );
|
2008-03-08 02:00:47 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
l = gtk_label_new( info->trackers[0].announce );
|
|
|
|
gtk_label_set_ellipsize( GTK_LABEL( l ), PANGO_ELLIPSIZE_END );
|
2009-03-05 17:18:36 +00:00
|
|
|
hig_workarea_add_row( t, &row, _( "Tracker:" ), l, NULL );
|
2008-02-21 07:29:39 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
s = _( "Last announce at:" );
|
|
|
|
l = gtk_label_new( NULL );
|
|
|
|
page->last_announce_time_lb = l;
|
|
|
|
hig_workarea_add_row( t, &row, s, l, NULL );
|
2008-02-21 07:29:39 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
s = _( "Tracker responded:" );
|
|
|
|
l = gtk_label_new( NULL );
|
|
|
|
page->last_announce_response_lb = l;
|
|
|
|
hig_workarea_add_row( t, &row, s, l, NULL );
|
2008-02-21 07:29:39 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
s = _( "Next announce in:" );
|
|
|
|
l = gtk_label_new( NULL );
|
|
|
|
page->next_announce_countdown_lb = l;
|
|
|
|
hig_workarea_add_row( t, &row, s, l, NULL );
|
2008-02-21 07:29:39 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
/* how long until the tracker will honor user
|
|
|
|
* pressing the "ask for more peers" button */
|
|
|
|
s = _( "Manual announce allowed in:" );
|
|
|
|
l = gtk_label_new( NULL );
|
|
|
|
page->manual_announce_countdown_lb = l;
|
|
|
|
hig_workarea_add_row( t, &row, s, l, NULL );
|
2008-02-21 07:29:39 +00:00
|
|
|
|
|
|
|
hig_workarea_finish( t, &row );
|
2008-06-01 01:40:32 +00:00
|
|
|
g_object_set_data_full( G_OBJECT( t ), TRACKER_PAGE, page, g_free );
|
2008-02-21 07:29:39 +00:00
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-09-23 19:11:04 +00:00
|
|
|
refresh_countdown_lb( GtkWidget * w,
|
|
|
|
time_t t,
|
2008-06-19 13:11:25 +00:00
|
|
|
const char * countdown_done )
|
2008-02-21 07:29:39 +00:00
|
|
|
{
|
|
|
|
const time_t now = time( NULL );
|
2008-09-23 19:11:04 +00:00
|
|
|
GtkLabel * l = GTK_LABEL( w );
|
2008-02-21 07:29:39 +00:00
|
|
|
|
2008-07-11 11:51:15 +00:00
|
|
|
if( t == 1 )
|
|
|
|
gtk_label_set_text( l, _( "In progress" ) );
|
|
|
|
else if( t < now )
|
|
|
|
gtk_label_set_text( l, countdown_done );
|
2009-03-05 17:18:36 +00:00
|
|
|
else {
|
|
|
|
char buf[512];
|
2008-02-21 07:29:39 +00:00
|
|
|
const int seconds = t - now;
|
|
|
|
tr_strltime( buf, seconds, sizeof( buf ) );
|
2008-07-11 11:51:15 +00:00
|
|
|
gtk_label_set_text( l, buf );
|
2008-02-21 07:29:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
refresh_tracker( GtkWidget * w )
|
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
GtkWidget * l;
|
|
|
|
time_t t;
|
|
|
|
struct tracker_page * page = g_object_get_data( G_OBJECT(
|
|
|
|
w ), TRACKER_PAGE );
|
|
|
|
const tr_stat * torStat = tr_torrent_stat( page->gtor );
|
2008-02-21 07:29:39 +00:00
|
|
|
|
|
|
|
l = page->last_scrape_time_lb;
|
2008-05-22 23:11:21 +00:00
|
|
|
t = torStat->lastScrapeTime;
|
2008-02-21 07:29:39 +00:00
|
|
|
refresh_time_lb( l, t );
|
|
|
|
|
|
|
|
l = page->last_scrape_response_lb;
|
2008-05-22 23:11:21 +00:00
|
|
|
gtk_label_set_text( GTK_LABEL( l ), torStat->scrapeResponse );
|
2008-02-21 07:29:39 +00:00
|
|
|
|
|
|
|
l = page->next_scrape_countdown_lb;
|
2008-05-22 23:11:21 +00:00
|
|
|
t = torStat->nextScrapeTime;
|
2008-06-19 13:11:25 +00:00
|
|
|
refresh_countdown_lb( l, t, _( "Never" ) );
|
2008-02-21 07:29:39 +00:00
|
|
|
|
|
|
|
l = page->last_announce_time_lb;
|
2008-05-22 23:11:21 +00:00
|
|
|
t = torStat->lastAnnounceTime;
|
2008-02-21 07:29:39 +00:00
|
|
|
refresh_time_lb( l, t );
|
|
|
|
|
|
|
|
l = page->last_announce_response_lb;
|
2008-05-22 23:11:21 +00:00
|
|
|
gtk_label_set_text( GTK_LABEL( l ), torStat->announceResponse );
|
2008-02-21 07:29:39 +00:00
|
|
|
|
|
|
|
l = page->next_announce_countdown_lb;
|
2008-05-22 23:11:21 +00:00
|
|
|
t = torStat->nextAnnounceTime;
|
2008-06-19 13:11:25 +00:00
|
|
|
refresh_countdown_lb( l, t, _( "Never" ) );
|
2008-02-21 07:29:39 +00:00
|
|
|
|
|
|
|
l = page->manual_announce_countdown_lb;
|
2008-05-22 23:11:21 +00:00
|
|
|
t = torStat->manualAnnounceTime;
|
2008-06-19 13:11:25 +00:00
|
|
|
refresh_countdown_lb( l, t, _( "Now" ) );
|
2008-02-21 07:29:39 +00:00
|
|
|
}
|
|
|
|
|
2007-06-06 00:30:13 +00:00
|
|
|
/****
|
|
|
|
***** DIALOG
|
|
|
|
****/
|
|
|
|
|
|
|
|
static void
|
2009-03-05 17:18:36 +00:00
|
|
|
torrent_destroyed( gpointer dialog, GObject * dead_torrent UNUSED )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2009-03-05 17:18:36 +00:00
|
|
|
gtk_widget_destroy( GTK_WIDGET( dialog ) );
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-09-23 19:11:04 +00:00
|
|
|
remove_tag( gpointer tag )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2009-03-05 17:18:36 +00:00
|
|
|
g_source_remove( GPOINTER_TO_UINT( tag ) ); /* stop the periodic refresh */
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-09-23 19:11:04 +00:00
|
|
|
response_cb( GtkDialog * dialog,
|
|
|
|
int response UNUSED,
|
2009-02-13 18:23:56 +00:00
|
|
|
gpointer data )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2009-03-05 17:18:36 +00:00
|
|
|
struct ResponseData *rd = data;
|
2009-02-13 18:23:56 +00:00
|
|
|
TrCore * core = rd->core;
|
|
|
|
gulong handler = rd-> handler;
|
|
|
|
|
|
|
|
g_signal_handler_disconnect( core, handler );
|
2009-03-05 17:18:36 +00:00
|
|
|
g_object_weak_unref( G_OBJECT( rd->gtor ), torrent_destroyed, dialog );
|
|
|
|
gtk_widget_destroy( GTK_WIDGET( dialog ) );
|
2009-02-13 18:23:56 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
g_free( rd );
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2008-09-23 19:11:04 +00:00
|
|
|
periodic_refresh( gpointer data )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2009-03-05 17:18:36 +00:00
|
|
|
refresh_tracker ( g_object_get_data( G_OBJECT( data ), "tracker-top" ) );
|
|
|
|
refresh_peers ( g_object_get_data( G_OBJECT( data ), "peers-top" ) );
|
|
|
|
refresh_activity ( g_object_get_data( G_OBJECT( data ), "activity-top" ) );
|
2008-09-23 19:11:04 +00:00
|
|
|
return TRUE;
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget*
|
2008-09-23 19:11:04 +00:00
|
|
|
torrent_inspector_new( GtkWindow * parent,
|
2009-02-13 18:23:56 +00:00
|
|
|
TrCore * core,
|
2008-09-23 19:11:04 +00:00
|
|
|
TrTorrent * gtor )
|
2007-06-06 00:30:13 +00:00
|
|
|
{
|
2008-09-23 19:11:04 +00:00
|
|
|
guint tag;
|
2009-03-05 17:18:36 +00:00
|
|
|
GtkWidget * d, *n, *w, *lb;
|
2008-09-23 19:11:04 +00:00
|
|
|
char title[512];
|
2009-03-05 17:18:36 +00:00
|
|
|
struct ResponseData * rd;
|
|
|
|
tr_torrent * tor = tr_torrent_handle( gtor );
|
|
|
|
const tr_info * info = tr_torrent_info( gtor );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
|
|
|
/* create the dialog */
|
2009-03-05 17:18:36 +00:00
|
|
|
rd = g_new0(struct ResponseData, 1);
|
2009-02-13 18:23:56 +00:00
|
|
|
rd->gtor = gtor;
|
|
|
|
rd->core = core;
|
2008-11-13 04:10:04 +00:00
|
|
|
g_snprintf( title, sizeof( title ), _( "%s Properties" ), info->name );
|
2009-03-05 17:18:36 +00:00
|
|
|
d = gtk_dialog_new_with_buttons( title, parent, 0,
|
|
|
|
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
|
|
|
|
NULL );
|
|
|
|
gtk_window_set_role( GTK_WINDOW( d ), "tr-info" );
|
|
|
|
g_signal_connect( d, "response", G_CALLBACK( response_cb ), rd );
|
2008-09-23 19:11:04 +00:00
|
|
|
gtk_dialog_set_has_separator( GTK_DIALOG( d ), FALSE );
|
|
|
|
gtk_container_set_border_width( GTK_CONTAINER( d ), GUI_PAD );
|
2009-03-05 17:18:36 +00:00
|
|
|
g_object_weak_ref( G_OBJECT( gtor ), torrent_destroyed, d );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* add the notebook */
|
2009-03-05 17:18:36 +00:00
|
|
|
n = gtk_notebook_new( );
|
|
|
|
gtk_container_set_border_width( GTK_CONTAINER( n ), GUI_PAD );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
w = activity_page_new( gtor );
|
|
|
|
lb = gtk_label_new( _( "Activity" ) );
|
|
|
|
gtk_notebook_append_page( GTK_NOTEBOOK( n ), w, lb );
|
|
|
|
g_object_set_data( G_OBJECT( d ), "activity-top", w );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
w = peer_page_new( gtor );
|
|
|
|
lb = gtk_label_new( _( "Peers" ) );
|
|
|
|
gtk_notebook_append_page( GTK_NOTEBOOK( n ), w, lb );
|
|
|
|
g_object_set_data( G_OBJECT( d ), "peers-top", w );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
|
|
|
w = tracker_page_new( gtor );
|
2009-03-05 17:18:36 +00:00
|
|
|
lb = gtk_label_new( _( "Tracker" ) );
|
|
|
|
gtk_notebook_append_page( GTK_NOTEBOOK( n ), w, lb );
|
2008-09-23 19:11:04 +00:00
|
|
|
g_object_set_data( G_OBJECT( d ), "tracker-top", w );
|
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
w = info_page_new( tor );
|
|
|
|
lb = gtk_label_new( _( "Information" ) );
|
|
|
|
gtk_notebook_append_page( GTK_NOTEBOOK( n ), w, lb );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
|
|
|
w = file_list_new( gtor );
|
|
|
|
gtk_container_set_border_width( GTK_CONTAINER( w ), GUI_PAD_BIG );
|
2009-03-05 17:18:36 +00:00
|
|
|
lb = gtk_label_new( _( "Files" ) );
|
|
|
|
gtk_notebook_append_page( GTK_NOTEBOOK( n ), w, lb );
|
|
|
|
g_object_set_data( G_OBJECT( d ), "files-top", w );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2009-03-05 17:18:36 +00:00
|
|
|
w = options_page_new( rd );
|
|
|
|
lb = gtk_label_new( _( "Options" ) );
|
|
|
|
gtk_notebook_append_page( GTK_NOTEBOOK( n ), w, lb );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-10-31 18:25:21 +00:00
|
|
|
gtk_box_pack_start( GTK_BOX( GTK_DIALOG( d )->vbox ), n, TRUE, TRUE, 0 );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-12-22 05:39:03 +00:00
|
|
|
tag = gtr_timeout_add_seconds( UPDATE_INTERVAL_SECONDS, periodic_refresh, d );
|
2009-03-05 17:18:36 +00:00
|
|
|
g_object_set_data_full( G_OBJECT( d ), "tag", GUINT_TO_POINTER( tag ), remove_tag );
|
|
|
|
periodic_refresh( d );
|
|
|
|
gtk_widget_show_all( GTK_DIALOG( d )->vbox );
|
2008-09-23 19:11:04 +00:00
|
|
|
return d;
|
2007-06-06 00:30:13 +00:00
|
|
|
}
|
2008-09-23 19:11:04 +00:00
|
|
|
|