2
* This file Copyright (C) 2007-2008 Charles Kerr <charles@rebelbase.com>
2
* This file Copyright (C) 2007-2009 Charles Kerr <charles@transmissionbt.com>
4
4
* This file is licensed by the GPL version 2. Works owned by the
5
5
* Transmission project are granted a special exemption to clause 2(b)
6
* so that the bulk of its code can remain under the MIT license.
6
* so that the bulk of its code can remain under the MIT license.
7
7
* This exemption does not extend to derived works not owned by
8
8
* the Transmission project.
10
* $Id: tr-icon.c 5476 2008-04-01 02:36:41Z charles $
10
* $Id: tr-icon.c 7658 2009-01-10 23:09:07Z charles $
13
13
#include <glib/gi18n.h>
29
#define UPDATE_INTERVAL 2500
29
#define UPDATE_INTERVAL_SECONDS 2
32
activated ( GtkStatusIcon * self UNUSED,
33
gpointer user_data UNUSED )
32
activated( GtkStatusIcon * self UNUSED,
33
gpointer user_data UNUSED )
35
action_activate ("toggle-main-window");
35
action_activate ( "toggle-main-window" );
39
popup ( GtkStatusIcon * self,
42
gpointer data UNUSED )
39
popup( GtkStatusIcon * self,
42
gpointer data UNUSED )
44
44
GtkWidget * w = action_get_widget( "/icon-popup" );
45
gtk_menu_popup (GTK_MENU(w), NULL, NULL,
46
gtk_status_icon_position_menu,
51
core_destroyed( gpointer data, GObject * core UNUSED )
53
g_source_remove( GPOINTER_TO_UINT( data ) );
46
gtk_menu_popup ( GTK_MENU( w ), NULL, NULL,
47
gtk_status_icon_position_menu,
57
52
refresh_tooltip_cb( gpointer data )
59
GtkStatusIcon * icon = GTK_STATUS_ICON( data );
60
TrCore * core = g_object_get_data( G_OBJECT( icon ), "tr-core" );
54
GtkStatusIcon * icon = GTK_STATUS_ICON( data );
55
TrCore * core = g_object_get_data( G_OBJECT( icon ), "tr-core" );
61
56
struct core_stats stats;
62
char downStr[32], upStr[32];
57
char downStr[32], upStr[32];
65
60
tr_core_get_stats( core, &stats );
71
66
%2$'d is the number of torrents we're downloading,
72
67
%3$s is our download speed,
73
68
%4$s is our upload speed */
74
_( "%1$'d Seeding, %2$'d Downloading\nDown: %3$s, Up: %4$s" ),
69
_( "%1$'d Seeding, %2$'d Downloading\nDown: %3$s, Up: %4$s" ),
75
70
stats.seedingCount,
76
71
stats.downloadCount,
79
closeTag( gpointer tag )
81
g_source_remove( GPOINTER_TO_UINT( tag ) );
84
85
tr_icon_new( TrCore * core )
87
GtkStatusIcon * icon = gtk_status_icon_new_from_icon_name( "transmission" );
88
GtkStatusIcon * icon = gtk_status_icon_new_from_icon_name(
88
91
g_signal_connect( icon, "activate", G_CALLBACK( activated ), NULL );
89
92
g_signal_connect( icon, "popup-menu", G_CALLBACK( popup ), NULL );
90
id = g_timeout_add( UPDATE_INTERVAL, refresh_tooltip_cb, icon );
91
g_object_weak_ref( G_OBJECT( core ), core_destroyed, GUINT_TO_POINTER( id ) );
93
id = gtr_timeout_add_seconds( UPDATE_INTERVAL_SECONDS, refresh_tooltip_cb, icon );
92
94
g_object_set_data( G_OBJECT( icon ), "tr-core", core );
95
g_object_set_data_full( G_OBJECT(
96
icon ), "update-tag", GUINT_TO_POINTER(