#include "tracker-list.h"
#include "util.h"
-#define UPDATE_INTERVAL_MSEC 200
-
#define UI_KEY "ui"
#define ANNOUNCE_KEY "recent-announce-url"
gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( ui->
private_check ) ) );
- tag = g_timeout_add ( UPDATE_INTERVAL_MSEC, refresh_cb, ui );
+ tag = gtr_timeout_add_seconds( 1, refresh_cb, ui );
g_object_set_data_full ( G_OBJECT( d ), "tag", GUINT_TO_POINTER(
tag ), remove_tag );
g_message( "response: [%*.*s]", (int)response_len, (int)response_len, response );
#endif
g_byte_array_append( bytes, (const uint8_t*)response, response_len );
- g_idle_add( readResponseIdle, bytes );
+ gtr_idle_add( readResponseIdle, bytes );
}
static void
data->isDouble = isDouble;
g_object_set_data_full( o, IDLE_DATA, data, spin_idle_data_free );
g_object_ref( G_OBJECT( o ) );
- g_timeout_add( 100, spun_cb_idle, w );
+ gtr_timeout_add_seconds( 1, spun_cb_idle, w );
}
g_timer_start( data->last_change );
}
void * user_data )
{
if( ( completeness != TR_LEECH ) && ( tr_torrentStat( tor )->sizeWhenDone != 0 ) )
- g_idle_add( notifyInMainThread, user_data );
+ gtr_idle_add( notifyInMainThread, user_data );
}
static TrTorrent *
static void
onAltSpeedToggled( tr_session * s UNUSED, tr_bool isEnabled UNUSED, tr_bool byUser UNUSED, void * p )
{
- g_idle_add( onAltSpeedToggledIdle, p );
+ gtr_idle_add( onAltSpeedToggledIdle, p );
}
/***
****
***/
-guint
-gtr_timeout_add_seconds( guint seconds, GSourceFunc function, gpointer data )
-{
-#if GLIB_CHECK_VERSION( 2,14,0 )
- return g_timeout_add_seconds( seconds, function, data );
-#else
- return g_timeout_add( seconds*1000, function, data );
-#endif
-}
-
void
gtr_widget_set_tooltip_text( GtkWidget * w, const char * tip )
{
gtk_toolbar_set_orientation( toolbar, orientation );
#endif
}
+
+/***
+****
+***/
+
+#if !GTK_CHECK_VERSION( 2,12,0 )
+struct gtr_func_data
+{
+ GSourceFunc function;
+ gpointer data;
+};
+
+static gboolean
+gtr_thread_func( gpointer data )
+{
+ struct gtr_func_data * idle_data = data;
+ gboolean more;
+
+ gdk_threads_enter( );
+ more = idle_data->function( idle_data->data );
+ gdk_threads_leave( );
+
+ if( !more )
+ g_free( data );
+
+ return more;
+}
+#endif
+
+void
+gtr_idle_add( GSourceFunc function, gpointer data )
+{
+#if GTK_CHECK_VERSION( 2,12,0 )
+ gdk_threads_add_idle( func, data );
+#else
+ struct gtr_func_data * d = g_new( struct gtr_func_data, 1 );
+ d->function = function;
+ d->data = data;
+ g_idle_add( gtr_thread_func, d );
+#endif
+}
+
+guint
+gtr_timeout_add_seconds( guint seconds, GSourceFunc function, gpointer data )
+{
+#if GTK_CHECK_VERSION( 2,14,0 )
+ return gdk_threads_add_timeout_seconds( seconds, function, data );
+#elif GTK_CHECK_VERSION( 2,12,0 )
+ return gdk_threads_add_timeout( seconds*1000, function, data );
+#else
+ struct gtr_func_data * d = g_new( struct gtr_func_data, 1 );
+ d->function = function;
+ d->data = data;
+ return g_timeout_add( seconds*1000, gtr_thread_func, d );
+#endif
+}
#ifdef GTK_MAJOR_VERSION
+guint gtr_timeout_add_seconds( guint seconds,
+ GSourceFunc function,
+ gpointer data );
+
+void gtr_idle_add( GSourceFunc func,
+ gpointer data );
+
void gtr_toolbar_set_orientation( GtkToolbar * toolbar,
GtkOrientation orientation );
GtkWidget * gtr_button_new_from_stock( const char * stock,
const char * mnemonic );
-guint gtr_timeout_add_seconds( guint seconds,
- GSourceFunc function,
- gpointer data );
-
void addTorrentErrorDialog( GtkWidget * window_or_child,
int err,
const char * filename );