changeset 111:799b28f181f8

added UI for icon size.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Tue, 15 Jul 2008 17:45:06 +0900
parents 8b98a26f44ce
children cece12684fb7
files pidgin-twitter.c
diffstat 1 files changed, 37 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin-twitter.c	Tue Jul 15 15:07:23 2008 +0900
+++ b/pidgin-twitter.c	Tue Jul 15 17:45:06 2008 +0900
@@ -893,7 +893,10 @@
     GList *mark_list = NULL;
     GList *current;
 
-    if(data && data->request_list)
+    if(!data)
+        return;
+
+    if(data->request_list)
         mark_list = data->request_list;
 
     /* remove the marks in its GtkTextBuffers */
@@ -1981,6 +1984,37 @@
     }
 }
 
+static void
+invalidate_icon_data_func(gpointer key, gpointer value, gpointer user_data)
+{
+    icon_data *data = (icon_data *)value;
+
+    g_return_if_fail(data != NULL);
+    g_return_if_fail(data->icon_id >0);
+
+    /* img->data is managed by gdkpixbuf, so we should not free here. */
+#if 0
+    PurpleStoredImage *img = purple_imgstore_find_by_id(data->icon_id);
+    if(img)
+        purple_imgstore_unref_by_id(data->icon_id);
+#endif
+
+    data->icon_id = 0;
+}
+
+static void
+icon_size_prefs_cb(const char *name, PurplePrefType type,
+                   gconstpointer val, gpointer data)
+{
+    /* invalidate icon cache */
+    g_hash_table_foreach(icon_data_by_user,
+                         (GHFunc)invalidate_icon_data_func, NULL);
+    g_hash_table_foreach(icon_data_by_user2,
+                         (GHFunc)invalidate_icon_data_func, NULL);
+    g_hash_table_foreach(icon_data_by_user3,
+                         (GHFunc)invalidate_icon_data_func, NULL);
+}
+
 static PurplePluginPrefFrame *
 get_plugin_pref_frame(PurplePlugin *plugin)
 {
@@ -2044,7 +2078,6 @@
                                                       "Show icons in conversation");
     purple_plugin_pref_frame_add(frame, pref);
 
-#if 0
     /* icon size */
     pref = purple_plugin_pref_new_with_name_and_label(OPT_ICON_SIZE,
                                                       "Icon size in pixel");
@@ -2052,7 +2085,8 @@
     purple_plugin_pref_frame_add(frame, pref);
 
     /* XXX should invalidate pixbufs in memory --yaz */
-#endif
+    purple_prefs_connect_callback(plugin, OPT_ICON_SIZE,
+                                  icon_size_prefs_cb, NULL);
 
     /* show text counter  */
     pref = purple_plugin_pref_new_with_name_and_label(OPT_COUNTER,