(trunk gtk) #2587: speed display isn't the same in the main window and in the system tray icon's tooltip
This commit is contained in:
parent
7f16bbaa02
commit
84f8fb5258
|
@ -1151,11 +1151,15 @@ updatemodel( gpointer gdata )
|
||||||
tr_core_update( data->core );
|
tr_core_update( data->core );
|
||||||
|
|
||||||
/* update the main window's statusbar and toolbar buttons */
|
/* update the main window's statusbar and toolbar buttons */
|
||||||
if( data->wind )
|
if( data->wind != NULL )
|
||||||
tr_window_update( data->wind );
|
tr_window_update( data->wind );
|
||||||
|
|
||||||
/* update the actions */
|
/* update the actions */
|
||||||
refreshActions( data );
|
refreshActions( data );
|
||||||
|
|
||||||
|
/* update the status tray icon */
|
||||||
|
if( data->icon != NULL )
|
||||||
|
tr_icon_refresh( data->icon );
|
||||||
}
|
}
|
||||||
|
|
||||||
return !done;
|
return !done;
|
||||||
|
|
|
@ -24,9 +24,12 @@ tr_icon_new( TrCore * core )
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
void
|
||||||
|
tr_icon_refresh( gpointer vicon UNUSED )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
#define UPDATE_INTERVAL_SECONDS 2
|
#else
|
||||||
|
|
||||||
static void
|
static void
|
||||||
activated( GtkStatusIcon * self UNUSED,
|
activated( GtkStatusIcon * self UNUSED,
|
||||||
|
@ -48,8 +51,8 @@ popup( GtkStatusIcon * self,
|
||||||
self, button, when );
|
self, button, when );
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
void
|
||||||
refresh_tooltip_cb( gpointer data )
|
tr_icon_refresh( gpointer vicon )
|
||||||
{
|
{
|
||||||
double d;
|
double d;
|
||||||
int limit;
|
int limit;
|
||||||
|
@ -59,7 +62,7 @@ refresh_tooltip_cb( gpointer data )
|
||||||
char downLimit[64];
|
char downLimit[64];
|
||||||
char tip[1024];
|
char tip[1024];
|
||||||
const char * idle = _( "Idle" );
|
const char * idle = _( "Idle" );
|
||||||
GtkStatusIcon * icon = GTK_STATUS_ICON( data );
|
GtkStatusIcon * icon = GTK_STATUS_ICON( vicon );
|
||||||
tr_session * session = tr_core_session( g_object_get_data( G_OBJECT( icon ), "tr-core" ) );
|
tr_session * session = tr_core_session( g_object_get_data( G_OBJECT( icon ), "tr-core" ) );
|
||||||
|
|
||||||
/* up */
|
/* up */
|
||||||
|
@ -103,30 +106,17 @@ refresh_tooltip_cb( gpointer data )
|
||||||
#else
|
#else
|
||||||
gtk_status_icon_set_tooltip( GTK_STATUS_ICON( icon ), tip );
|
gtk_status_icon_set_tooltip( GTK_STATUS_ICON( icon ), tip );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
closeTag( gpointer tag )
|
|
||||||
{
|
|
||||||
g_source_remove( GPOINTER_TO_UINT( tag ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gpointer
|
gpointer
|
||||||
tr_icon_new( TrCore * core )
|
tr_icon_new( TrCore * core )
|
||||||
{
|
{
|
||||||
guint id;
|
|
||||||
GtkStatusIcon * icon = gtk_status_icon_new_from_icon_name(
|
GtkStatusIcon * icon = gtk_status_icon_new_from_icon_name(
|
||||||
"transmission" );
|
"transmission" );
|
||||||
|
|
||||||
g_signal_connect( icon, "activate", G_CALLBACK( activated ), NULL );
|
g_signal_connect( icon, "activate", G_CALLBACK( activated ), NULL );
|
||||||
g_signal_connect( icon, "popup-menu", G_CALLBACK( popup ), NULL );
|
g_signal_connect( icon, "popup-menu", G_CALLBACK( popup ), NULL );
|
||||||
id = gtr_timeout_add_seconds( UPDATE_INTERVAL_SECONDS, refresh_tooltip_cb, icon );
|
|
||||||
g_object_set_data( G_OBJECT( icon ), "tr-core", core );
|
g_object_set_data( G_OBJECT( icon ), "tr-core", core );
|
||||||
g_object_set_data_full( G_OBJECT(
|
|
||||||
icon ), "update-tag", GUINT_TO_POINTER(
|
|
||||||
id ), closeTag );
|
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,4 +22,6 @@
|
||||||
|
|
||||||
gpointer tr_icon_new( TrCore * core );
|
gpointer tr_icon_new( TrCore * core );
|
||||||
|
|
||||||
|
void tr_icon_refresh( gpointer );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue