Mercurial > pidgin-twitter
changeset 156:e65f81211340
now interval setting from UI takes effect immediately.
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Sat, 26 Jul 2008 00:41:23 +0900 |
parents | 0921655b4ae1 |
children | fbe526b20885 |
files | pidgin-twitter.c |
diffstat | 1 files changed, 29 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/pidgin-twitter.c Fri Jul 25 21:23:18 2008 +0900 +++ b/pidgin-twitter.c Sat Jul 26 00:41:23 2008 +0900 @@ -35,6 +35,10 @@ static gchar *wassr_post = NULL; static gchar *identica_post = NULL; +static struct _source { + guint id; + PurpleConversation *conv; +} source; /*************/ /* functions */ @@ -1416,12 +1420,12 @@ /* only attach to twitter conversation window */ switch(service) { case twitter_service: - /* api based retrieve */ /* xxx should configurable */ if(purple_prefs_get_bool(OPT_API_BASE_POST)) { get_status_with_api((gpointer)conv); - g_timeout_add_seconds( + source.id = g_timeout_add_seconds( purple_prefs_get_int(OPT_API_BASE_GET_INTERVAL), get_status_with_api, (gpointer)conv); + source.conv = conv; } attach_to_conv(conv, NULL); break; @@ -1450,8 +1454,11 @@ /* only attach to twitter conversation window */ switch(service) { case twitter_service: - if(purple_prefs_get_bool(OPT_API_BASE_POST)) + if(purple_prefs_get_bool(OPT_API_BASE_POST)) { g_source_remove_by_user_data((gpointer)conv); + source.id = 0; + source.conv = NULL; + } hash = icon_hash[twitter_service]; break; case wassr_service: @@ -2468,12 +2475,10 @@ { gboolean enabled = purple_prefs_get_bool(OPT_COUNTER); - if(enabled) { + if(enabled) attach_to_window(); - } - else { + else detach_from_window(); - } } static void @@ -2508,6 +2513,21 @@ } static void +interval_prefs_cb(const char *name, PurplePrefType type, + gconstpointer val, gpointer data) +{ + /* remove idle func */ + g_source_remove_by_user_data((gpointer)(source.conv)); + + /* add idle func */ + if(purple_prefs_get_bool(OPT_API_BASE_POST)) { + source.id = g_timeout_add_seconds( + purple_prefs_get_int(OPT_API_BASE_GET_INTERVAL), + get_status_with_api, (gpointer)(source.conv)); + } +} + +static void text_changed_cb(gpointer *data) { const gchar *text; @@ -2659,6 +2679,8 @@ gtk_spin_button_set_value(GTK_SPIN_BUTTON(e), (gdouble)value); g_signal_connect(e, "value-changed", G_CALLBACK(spin_changed_cb), &e); + purple_prefs_connect_callback(plugin, OPT_API_BASE_GET_INTERVAL, + interval_prefs_cb, NULL);