2007-02-07 07:35:33 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (c) 2005-2007 Transmission authors and contributors
|
|
|
|
*
|
|
|
|
* 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-19 02:46:30 +00:00
|
|
|
#include "torrent-cell-renderer.h"
|
2007-12-19 19:16:36 +00:00
|
|
|
#include "tr_prefs.h"
|
2007-02-07 07:35:33 +00:00
|
|
|
#include "tr_torrent.h"
|
|
|
|
#include "tr_window.h"
|
|
|
|
#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-06-18 03:40:41 +00:00
|
|
|
typedef struct
|
2007-02-07 07:35:33 +00:00
|
|
|
{
|
2007-06-18 03:40:41 +00:00
|
|
|
GtkWidget * scroll;
|
|
|
|
GtkWidget * view;
|
2007-12-20 02:56:47 +00:00
|
|
|
GtkWidget * toolbar;
|
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-19 20:04:38 +00:00
|
|
|
GtkTreeSelection * selection;
|
|
|
|
GtkCellRenderer * renderer;
|
|
|
|
GtkTreeViewColumn * column;
|
2007-12-19 19:16:36 +00:00
|
|
|
TrCore * core;
|
|
|
|
gulong pref_handler_id;
|
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-06-18 03:40:41 +00:00
|
|
|
PrivateData*
|
|
|
|
get_private_data( TrWindow * w )
|
2007-02-07 07:35:33 +00:00
|
|
|
{
|
2007-06-18 03:40:41 +00:00
|
|
|
return (PrivateData*) 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-06-18 03:40:41 +00:00
|
|
|
static GtkWidget*
|
|
|
|
makeview( PrivateData * p )
|
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-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-06-18 03:40:41 +00:00
|
|
|
return view;
|
2007-02-07 07:35:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-06-18 03:40:41 +00:00
|
|
|
realized_cb ( GtkWidget * wind, gpointer unused UNUSED )
|
2007-02-07 07:35:33 +00:00
|
|
|
{
|
2007-06-18 03:40:41 +00:00
|
|
|
PrivateData * p = get_private_data( GTK_WINDOW( wind ) );
|
2007-12-19 20:04:38 +00:00
|
|
|
sizingmagic( GTK_WINDOW(wind),
|
|
|
|
GTK_SCROLLED_WINDOW( p->scroll ),
|
|
|
|
GTK_POLICY_NEVER,
|
|
|
|
GTK_POLICY_ALWAYS );
|
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 );
|
2007-12-19 19:16:36 +00:00
|
|
|
}
|
2007-12-20 02:56:47 +00:00
|
|
|
else if( !strcmp( key, PREF_KEY_STATUS_BAR ) )
|
|
|
|
{
|
|
|
|
const gboolean isEnabled = pref_flag_get( key );
|
|
|
|
g_object_set( p->status, "visible", isEnabled, NULL );
|
|
|
|
}
|
|
|
|
else if( !strcmp( key, PREF_KEY_TOOLBAR ) )
|
|
|
|
{
|
|
|
|
const gboolean isEnabled = pref_flag_get( key );
|
|
|
|
g_object_set( p->toolbar, "visible", isEnabled, NULL );
|
|
|
|
}
|
2007-12-20 19:21:21 +00:00
|
|
|
else if( !strcmp( key, PREF_KEY_STATUS_BAR_STATS ) )
|
|
|
|
{
|
|
|
|
tr_window_update( (TrWindow*)wind );
|
|
|
|
}
|
2007-12-19 19:16:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
privateFree( gpointer vprivate )
|
|
|
|
{
|
2007-12-20 19:21:21 +00:00
|
|
|
PrivateData * p = ( PrivateData * ) vprivate;
|
2007-12-19 19:16:36 +00:00
|
|
|
g_signal_handler_disconnect( p->core, p->pref_handler_id );
|
|
|
|
g_free( p );
|
|
|
|
}
|
|
|
|
|
2007-12-20 19:21:21 +00:00
|
|
|
static void
|
|
|
|
onYinYangReleased( GtkWidget * w UNUSED, GdkEventButton * button UNUSED, gpointer vprivate )
|
|
|
|
{
|
|
|
|
PrivateData * p = ( PrivateData * ) vprivate;
|
|
|
|
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 ) )
|
|
|
|
{
|
|
|
|
PrivateData * p = (PrivateData*) vprivate;
|
|
|
|
const char * val = g_object_get_data( G_OBJECT( menu_item ), STATS_MODE );
|
|
|
|
tr_core_set_pref( p->core, PREF_KEY_STATUS_BAR_STATS, val );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
2007-06-18 03:40:41 +00:00
|
|
|
PrivateData * p = g_new( PrivateData, 1 );
|
2007-12-20 19:21:21 +00:00
|
|
|
GtkWidget *vbox, *w, *self, *h, *c;
|
2007-02-07 07:35:33 +00:00
|
|
|
|
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 );
|
2007-06-18 03:40:41 +00:00
|
|
|
gtk_window_set_title( GTK_WINDOW( self ), g_get_application_name());
|
|
|
|
gtk_window_set_role( GTK_WINDOW( self ), "tr-main" );
|
|
|
|
gtk_window_add_accel_group (GTK_WINDOW(self),
|
|
|
|
gtk_ui_manager_get_accel_group (ui_manager));
|
|
|
|
g_signal_connect( self, "realize", G_CALLBACK(realized_cb), NULL);
|
|
|
|
|
|
|
|
/* 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 );
|
|
|
|
|
|
|
|
/* 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 );
|
|
|
|
|
2007-12-20 19:21:21 +00:00
|
|
|
/* status menu */
|
|
|
|
GtkWidget * menu = p->status_menu = gtk_menu_new( );
|
|
|
|
status_stats_mode = 0;
|
|
|
|
GSList * l = NULL;
|
|
|
|
pch = pref_string_get( PREF_KEY_STATUS_BAR_STATS );
|
|
|
|
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 );
|
|
|
|
|
2007-12-20 02:56:47 +00:00
|
|
|
/* statusbar */
|
|
|
|
h = p->status = gtk_hbox_new( FALSE, GUI_PAD );
|
|
|
|
gtk_container_set_border_width( GTK_CONTAINER(h), GUI_PAD );
|
|
|
|
|
|
|
|
w = p->ul_lb = gtk_label_new( NULL );
|
|
|
|
gtk_box_pack_end( GTK_BOX(h), w, FALSE, FALSE, 0 );
|
|
|
|
w = gtk_image_new_from_stock( "tr-arrow-up", (GtkIconSize)-1 );
|
|
|
|
gtk_box_pack_end( GTK_BOX(h), w, FALSE, FALSE, 0 );
|
|
|
|
w = gtk_alignment_new( 0.0f, 0.0f, 0.0f, 0.0f );
|
|
|
|
gtk_widget_set_usize( w, GUI_PAD, 0u );
|
|
|
|
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 );
|
|
|
|
w = gtk_image_new_from_stock( "tr-arrow-down", (GtkIconSize)-1 );
|
|
|
|
gtk_box_pack_end( GTK_BOX(h), w, FALSE, FALSE, 0 );
|
|
|
|
|
|
|
|
w = gtk_image_new_from_stock( "tr-yin-yang", (GtkIconSize)-1 );
|
2007-12-20 19:21:21 +00:00
|
|
|
c = gtk_event_box_new( );
|
|
|
|
gtk_container_add( GTK_CONTAINER(c), w );
|
|
|
|
w = c;
|
|
|
|
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(h), w, FALSE, FALSE, 0 );
|
|
|
|
w = p->stats_lb = gtk_label_new( NULL );
|
|
|
|
gtk_box_pack_start( GTK_BOX(h), w, FALSE, FALSE, 0 );
|
|
|
|
|
|
|
|
gtk_box_pack_start( GTK_BOX(vbox), h, FALSE, FALSE, 0 );
|
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
/* workarea */
|
|
|
|
p->view = makeview( p );
|
|
|
|
w = p->scroll = gtk_scrolled_window_new( NULL, NULL );
|
|
|
|
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 );
|
|
|
|
|
2007-07-08 05:51:55 +00:00
|
|
|
/* spacer */
|
|
|
|
w = gtk_alignment_new (0.0f, 0.0f, 0.0f, 0.0f);
|
|
|
|
gtk_widget_set_usize (w, 0u, 6u);
|
|
|
|
gtk_box_pack_start( GTK_BOX(vbox), w, FALSE, FALSE, 0 );
|
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
/* 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 */
|
|
|
|
prefsChanged( core, PREF_KEY_MINIMAL_VIEW, self );
|
2007-12-20 02:56:47 +00:00
|
|
|
prefsChanged( core, PREF_KEY_STATUS_BAR, self );
|
2007-12-20 19:21:21 +00:00
|
|
|
prefsChanged( core, PREF_KEY_STATUS_BAR_STATS, self );
|
2007-12-20 02:56:47 +00:00
|
|
|
prefsChanged( core, PREF_KEY_TOOLBAR, self );
|
2007-12-19 19:16:36 +00:00
|
|
|
p->core = core;
|
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
|
|
|
|
2007-06-18 03:40:41 +00:00
|
|
|
return self;
|
2007-02-07 07:35:33 +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-20 19:21:21 +00:00
|
|
|
tr_handle * handle = NULL;
|
2007-12-19 02:46:30 +00:00
|
|
|
|
2007-12-20 19:21:21 +00:00
|
|
|
if( p && p->core )
|
|
|
|
handle = tr_core_handle( p->core );
|
2007-12-19 02:46:30 +00:00
|
|
|
|
2007-12-20 19:21:21 +00:00
|
|
|
if( handle )
|
|
|
|
{
|
|
|
|
char * pch;
|
|
|
|
float u, d;
|
|
|
|
char up[32], down[32], buf[64];
|
|
|
|
struct tr_session_stats stats;
|
|
|
|
|
|
|
|
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 );
|
|
|
|
|
|
|
|
pch = pref_string_get( PREF_KEY_STATUS_BAR_STATS );
|
|
|
|
if( !strcmp( pch, "session-ratio" ) ) {
|
|
|
|
tr_getSessionStats( handle, &stats );
|
|
|
|
g_snprintf( buf, sizeof(buf), _("Ratio: %.1f"), stats.ratio );
|
|
|
|
} else if( !strcmp( pch, "session-transfer" ) ) {
|
|
|
|
tr_getSessionStats( handle, &stats );
|
|
|
|
tr_strlsize( up, stats.uploadedBytes, sizeof( up ) );
|
|
|
|
tr_strlsize( down, stats.downloadedBytes, sizeof( down ) );
|
|
|
|
g_snprintf( buf, sizeof( buf ), _( "Down: %s Up: %s" ), down, up );
|
|
|
|
} else if( !strcmp( pch, "total-transfer" ) ) {
|
|
|
|
tr_getCumulativeSessionStats( handle, &stats );
|
|
|
|
tr_strlsize( up, stats.uploadedBytes, sizeof( up ) );
|
|
|
|
tr_strlsize( down, stats.downloadedBytes, sizeof( down ) );
|
|
|
|
g_snprintf( buf, sizeof( buf ), _( "Down: %s Up: %s" ), down, up );
|
|
|
|
} else { /* default is total-ratio */
|
|
|
|
tr_getCumulativeSessionStats( handle, &stats );
|
|
|
|
g_snprintf( buf, sizeof(buf), _("Ratio: %.1f"), stats.ratio );
|
|
|
|
}
|
|
|
|
g_free( pch );
|
|
|
|
gtk_label_set_text( GTK_LABEL( p->stats_lb ), buf );
|
|
|
|
}
|
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
|
|
|
}
|