comparison pidgin-twitter.c @ 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
comparison
equal deleted inserted replaced
155:0921655b4ae1 156:e65f81211340
33 static GList *postedlist = NULL; 33 static GList *postedlist = NULL;
34 34
35 static gchar *wassr_post = NULL; 35 static gchar *wassr_post = NULL;
36 static gchar *identica_post = NULL; 36 static gchar *identica_post = NULL;
37 37
38 static struct _source {
39 guint id;
40 PurpleConversation *conv;
41 } source;
38 42
39 /*************/ 43 /*************/
40 /* functions */ 44 /* functions */
41 /*************/ 45 /*************/
42 46
1414 1418
1415 gint service = get_service_type(conv); 1419 gint service = get_service_type(conv);
1416 /* only attach to twitter conversation window */ 1420 /* only attach to twitter conversation window */
1417 switch(service) { 1421 switch(service) {
1418 case twitter_service: 1422 case twitter_service:
1419 /* api based retrieve */ /* xxx should configurable */
1420 if(purple_prefs_get_bool(OPT_API_BASE_POST)) { 1423 if(purple_prefs_get_bool(OPT_API_BASE_POST)) {
1421 get_status_with_api((gpointer)conv); 1424 get_status_with_api((gpointer)conv);
1422 g_timeout_add_seconds( 1425 source.id = g_timeout_add_seconds(
1423 purple_prefs_get_int(OPT_API_BASE_GET_INTERVAL), 1426 purple_prefs_get_int(OPT_API_BASE_GET_INTERVAL),
1424 get_status_with_api, (gpointer)conv); 1427 get_status_with_api, (gpointer)conv);
1428 source.conv = conv;
1425 } 1429 }
1426 attach_to_conv(conv, NULL); 1430 attach_to_conv(conv, NULL);
1427 break; 1431 break;
1428 case wassr_service: 1432 case wassr_service:
1429 case identica_service: 1433 case identica_service:
1448 GHashTable *hash = NULL; 1452 GHashTable *hash = NULL;
1449 1453
1450 /* only attach to twitter conversation window */ 1454 /* only attach to twitter conversation window */
1451 switch(service) { 1455 switch(service) {
1452 case twitter_service: 1456 case twitter_service:
1453 if(purple_prefs_get_bool(OPT_API_BASE_POST)) 1457 if(purple_prefs_get_bool(OPT_API_BASE_POST)) {
1454 g_source_remove_by_user_data((gpointer)conv); 1458 g_source_remove_by_user_data((gpointer)conv);
1459 source.id = 0;
1460 source.conv = NULL;
1461 }
1455 hash = icon_hash[twitter_service]; 1462 hash = icon_hash[twitter_service];
1456 break; 1463 break;
1457 case wassr_service: 1464 case wassr_service:
1458 hash = icon_hash[wassr_service]; 1465 hash = icon_hash[wassr_service];
1459 break; 1466 break;
2466 counter_prefs_cb(const char *name, PurplePrefType type, 2473 counter_prefs_cb(const char *name, PurplePrefType type,
2467 gconstpointer val, gpointer data) 2474 gconstpointer val, gpointer data)
2468 { 2475 {
2469 gboolean enabled = purple_prefs_get_bool(OPT_COUNTER); 2476 gboolean enabled = purple_prefs_get_bool(OPT_COUNTER);
2470 2477
2471 if(enabled) { 2478 if(enabled)
2472 attach_to_window(); 2479 attach_to_window();
2473 } 2480 else
2474 else {
2475 detach_from_window(); 2481 detach_from_window();
2476 }
2477 } 2482 }
2478 2483
2479 static void 2484 static void
2480 invalidate_icon_data_func(gpointer key, gpointer value, gpointer user_data) 2485 invalidate_icon_data_func(gpointer key, gpointer value, gpointer user_data)
2481 { 2486 {
2502 2507
2503 /* invalidate icon cache */ 2508 /* invalidate icon cache */
2504 for(i = twitter_service; i <= identica_service; i++) { 2509 for(i = twitter_service; i <= identica_service; i++) {
2505 g_hash_table_foreach(icon_hash[i], 2510 g_hash_table_foreach(icon_hash[i],
2506 (GHFunc)invalidate_icon_data_func, NULL); 2511 (GHFunc)invalidate_icon_data_func, NULL);
2512 }
2513 }
2514
2515 static void
2516 interval_prefs_cb(const char *name, PurplePrefType type,
2517 gconstpointer val, gpointer data)
2518 {
2519 /* remove idle func */
2520 g_source_remove_by_user_data((gpointer)(source.conv));
2521
2522 /* add idle func */
2523 if(purple_prefs_get_bool(OPT_API_BASE_POST)) {
2524 source.id = g_timeout_add_seconds(
2525 purple_prefs_get_int(OPT_API_BASE_GET_INTERVAL),
2526 get_status_with_api, (gpointer)(source.conv));
2507 } 2527 }
2508 } 2528 }
2509 2529
2510 static void 2530 static void
2511 text_changed_cb(gpointer *data) 2531 text_changed_cb(gpointer *data)
2657 purple_prefs_set_int(OPT_API_BASE_GET_INTERVAL, value); 2677 purple_prefs_set_int(OPT_API_BASE_GET_INTERVAL, value);
2658 } 2678 }
2659 gtk_spin_button_set_value(GTK_SPIN_BUTTON(e), (gdouble)value); 2679 gtk_spin_button_set_value(GTK_SPIN_BUTTON(e), (gdouble)value);
2660 g_signal_connect(e, "value-changed", 2680 g_signal_connect(e, "value-changed",
2661 G_CALLBACK(spin_changed_cb), &e); 2681 G_CALLBACK(spin_changed_cb), &e);
2682 purple_prefs_connect_callback(plugin, OPT_API_BASE_GET_INTERVAL,
2683 interval_prefs_cb, NULL);
2662 2684
2663 2685
2664 2686
2665 /*********************/ 2687 /*********************/
2666 /* translation page */ 2688 /* translation page */