(trunk gtk) #1585: use g_timeout_add_seconds() where appropriate to group timers together for fewer scheduled wakeups

This commit is contained in:
Charles Kerr 2008-12-22 05:39:03 +00:00
parent d142a075c4
commit e44239fc4e
11 changed files with 29 additions and 13 deletions

View File

@ -28,7 +28,7 @@
#include "hig.h"
#include "util.h"
#define UPDATE_INTERVAL_MSEC 2000
#define UPDATE_INTERVAL_SECONDS 2
/****
***** PIECES VIEW
@ -1529,7 +1529,7 @@ torrent_inspector_new( GtkWindow * parent,
gtk_box_pack_start( GTK_BOX( GTK_DIALOG( d )->vbox ), n, TRUE, TRUE, 0 );
tag = g_timeout_add ( UPDATE_INTERVAL_MSEC, periodic_refresh, d );
tag = gtr_timeout_add_seconds( UPDATE_INTERVAL_SECONDS, periodic_refresh, d );
g_object_set_data_full ( G_OBJECT( d ), "tag",
GUINT_TO_POINTER( tag ), remove_tag );

View File

@ -483,7 +483,7 @@ file_list_set_torrent( GtkWidget * w,
refresh( data );
data->timeout_tag = g_timeout_add( 2500, refreshModel, data );
data->timeout_tag = gtr_timeout_add_seconds( 2, refreshModel, data );
}
gtk_tree_view_set_model( GTK_TREE_VIEW( data->view ),

View File

@ -612,8 +612,7 @@ appsetup( TrWindow * wind,
/* start scheduled rate timer */
updateScheduledLimits ( tr_core_session( cbdata->core ) );
g_timeout_add( 60 * 1000, updateScheduledLimits,
tr_core_session( cbdata->core ) );
gtr_timeout_add_seconds( 60, updateScheduledLimits, tr_core_session( cbdata->core ) );
/* either show the window or iconify it */
if( !isIconified )

View File

@ -543,7 +543,7 @@ msgwin_new( TrCore * core )
gtk_box_pack_start( GTK_BOX( vbox ), w, TRUE, TRUE, 0 );
gtk_container_add( GTK_CONTAINER( win ), vbox );
data->refresh_tag = g_timeout_add( 1666, onRefresh, data );
data->refresh_tag = gtr_timeout_add_seconds( 2, onRefresh, data );
g_object_weak_ref( G_OBJECT( win ), onWindowDestroyed, data );
gtk_widget_show_all( win );

View File

@ -169,7 +169,7 @@ stats_dialog_create( GtkWindow * parent,
updateStats( ui );
g_object_set_data_full( G_OBJECT( d ), "data", ui, g_free );
g_signal_connect( d, "response", G_CALLBACK( dialogResponse ), ui );
i = g_timeout_add( 1000, updateStats, ui );
i = gtr_timeout_add_seconds( 1, updateStats, ui );
g_object_weak_ref( G_OBJECT( d ), dialogDestroyed, GUINT_TO_POINTER( i ) );
return d;
}

View File

@ -498,8 +498,7 @@ maybeAddTorrent( TrCore * core,
p->monitor_files =
g_slist_append( p->monitor_files, g_strdup( filename ) );
if( !p->monitor_idle_tag )
p->monitor_idle_tag = g_timeout_add( 1000, watchFolderIdle,
core );
p->monitor_idle_tag = gtr_timeout_add_seconds( 1, watchFolderIdle, core );
}
}

View File

@ -26,7 +26,7 @@ tr_icon_new( TrCore * core )
#else
#define UPDATE_INTERVAL 2500
#define UPDATE_INTERVAL_SECONDS 2
static void
activated( GtkStatusIcon * self UNUSED,
@ -90,7 +90,7 @@ tr_icon_new( TrCore * core )
g_signal_connect( icon, "activate", G_CALLBACK( activated ), NULL );
g_signal_connect( icon, "popup-menu", G_CALLBACK( popup ), NULL );
id = g_timeout_add( UPDATE_INTERVAL, refresh_tooltip_cb, icon );
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_full( G_OBJECT(
icon ), "update-tag", GUINT_TO_POINTER(

View File

@ -1242,7 +1242,7 @@ onCorePrefsChanged( TrCore * core UNUSED,
data = g_new0( struct test_port_data, 1 );
data->label = ndata->label;
data->alive = ndata->alive;
g_timeout_add( 3000, testing_port_begin, data );
gtr_timeout_add_seconds( 3, testing_port_begin, data );
}
}

View File

@ -28,7 +28,6 @@
#include "hig.h"
#include "util.h"
#define UPDATE_INTERVAL_MSEC 2000
#define PAGE_KEY "page"
struct tracker_page

View File

@ -641,3 +641,18 @@ gtr_button_new_from_stock( const char * stock,
return button;
}
/***
****
***/
guint
gtr_timeout_add_seconds( guint interval,
GSourceFunc function,
gpointer data )
{
#if GLIB_CHECK_VERSION( 2,14,0 )
return g_timeout_add_seconds( interval, function, data );
#else
return g_timeout_add( interval*1000, function, data );
#endif
}

View File

@ -95,6 +95,10 @@ char* gtr_get_help_url( void );
GtkWidget * gtr_button_new_from_stock( const char * stock,
const char * mnemonic );
guint gtr_timeout_add_seconds( guint interval,
GSourceFunc function,
gpointer data );
void addTorrentErrorDialog( GtkWidget * window_or_child,
int err,
const char * filename );