[Commits] [SCM] claws branch, master, updated. 3.9.3-33-gb6c5639

mones at claws-mail.org mones at claws-mail.org
Tue Mar 11 21:36:33 CET 2014


The branch master of project "claws" (Claws Mail) has been updated
       via  b6c563983a8cea0c13859f3b9bcd80cd8ec011ed (commit)
      from  7593136257a76ae5618fdcaeacd435475deee5e8 (commit)


- Log -----------------------------------------------------------------
commit b6c563983a8cea0c13859f3b9bcd80cd8ec011ed
Author: Ricardo Mones <ricardo at mones.org>
Date:   Tue Mar 11 21:34:26 2014 +0100

    Fix a couple of bugs
    
     • Incorrect initialization of radiobuttons on prefs (remember
       not to use the same variable for two purposes...)
     • Empty missing cache when changing to generated-avatar missing
       icon modes, otherwise they're still served as missing

diff --git a/src/plugins/libravatar/libravatar.c b/src/plugins/libravatar/libravatar.c
index 9f40a95..843ffb4 100644
--- a/src/plugins/libravatar/libravatar.c
+++ b/src/plugins/libravatar/libravatar.c
@@ -50,7 +50,6 @@ static const char *def_mode[] = {
 static guint update_hook_id;
 static guint render_hook_id;
 static gchar *cache_dir = NULL; /* dir-separator terminated */
-static GHashTable *misses;
 
 static gboolean libravatar_header_update_hook(gpointer source, gpointer data)
 {
@@ -170,7 +169,7 @@ static GtkWidget *image_widget_from_url(const gchar *url, const gchar *md5)
 		}
 
 		if (filesize == 0)
-			missing_add_md5(misses, md5);
+			missing_add_md5(libravatarmisses, md5);
 	} else {
 		g_warning("could not open '%s' for writting\n", filename);
 	}
@@ -245,7 +244,7 @@ static gboolean libravatar_image_render_hook(gpointer source, gpointer data)
 
 		md5_hex_digest(md5sum, a);
 		/* try missing cache */
-		if (is_missing_md5(misses, md5sum)) {
+		if (is_missing_md5(libravatarmisses, md5sum)) {
 			return FALSE;
 		}
 		/* try disk cache */
@@ -315,10 +314,10 @@ static gint missing_cache_init()
 	                                LIBRAVATAR_CACHE_DIR, G_DIR_SEPARATOR_S,
 					LIBRAVATAR_MISSING_FILE, NULL);
 
-	misses = missing_load_from_file(cache_file);
+	libravatarmisses = missing_load_from_file(cache_file);
 	g_free(cache_file);
 
-	if (misses == NULL)
+	if (libravatarmisses == NULL)
 		return -1;
 
 	return 0;
@@ -328,13 +327,13 @@ static void missing_cache_done()
 {
 	gchar *cache_file;
 
-	if (misses != NULL) {
+	if (libravatarmisses != NULL) {
 		cache_file = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
 					LIBRAVATAR_CACHE_DIR, G_DIR_SEPARATOR_S,
 					LIBRAVATAR_MISSING_FILE, NULL);
-		missing_save_to_file(misses, cache_file);
+		missing_save_to_file(libravatarmisses, cache_file);
 		g_free(cache_file);
-		g_hash_table_destroy(misses);
+		g_hash_table_destroy(libravatarmisses);
 	}
 }
 
diff --git a/src/plugins/libravatar/libravatar_prefs.c b/src/plugins/libravatar/libravatar_prefs.c
index c14948d..735168c 100644
--- a/src/plugins/libravatar/libravatar_prefs.c
+++ b/src/plugins/libravatar/libravatar_prefs.c
@@ -42,6 +42,7 @@
 #define INTERVAL_MAX_H 720.0
 
 LibravatarPrefs libravatarprefs;
+GHashTable *libravatarmisses;
 
 struct LibravatarPrefsPage
 {
@@ -134,18 +135,28 @@ static GtkWidget *p_create_frame_cache(struct LibravatarPrefsPage *page)
 
 static void default_mode_radio_button_cb(GtkToggleButton *button, gpointer data)
 {
+	guint mode;
 	gboolean is_url;
 
-	if (gtk_toggle_button_get_active(button) == TRUE) {
-		is_url = (*((guint *)data) == DEF_MODE_URL)? TRUE: FALSE;
-		gtk_widget_set_sensitive(libravatarprefs_page.defm_url_text, is_url);
-		if (is_url) /* custom URL requires following redirects */
-			gtk_toggle_button_set_active(
-				GTK_TOGGLE_BUTTON(libravatarprefs_page.allow_redirects_check),
-				TRUE);
+	if (gtk_toggle_button_get_active(button) != TRUE)
+		return;
+
+	mode = *((guint *)data);
+	is_url = (mode == DEF_MODE_URL)? TRUE: FALSE;
+
+	gtk_widget_set_sensitive(libravatarprefs_page.defm_url_text, is_url);
+	if (is_url) /* custom URL requires following redirects */
+		gtk_toggle_button_set_active(
+			GTK_TOGGLE_BUTTON(libravatarprefs_page.allow_redirects_check),
+			TRUE);
+
+	if (mode == DEF_MODE_NONE) {
+		prefs_common.enable_avatars = AVATARS_ENABLE_BOTH;
+	} else {
 		/* don't waste time with headers that won't be displayed */
-		prefs_common.enable_avatars = (*((guint *)data) == DEF_MODE_NONE)
-						? AVATARS_ENABLE_BOTH: AVATARS_DISABLE;
+		prefs_common.enable_avatars = AVATARS_DISABLE;
+		/* empty missing cache when switching to generated */
+		g_hash_table_remove_all(libravatarmisses);
 	}
 }
 
@@ -163,7 +174,7 @@ static GtkWidget *p_create_frame_missing(struct LibravatarPrefsPage *page)
 {
 	GtkWidget *vbox, *radio[NUM_DEF_BUTTONS], *hbox, *label, *entry;
 	gboolean enable = FALSE;
-	int i;
+	int i, e;
 	gchar *radio_label[] = {
 		_("None"),
 		_("Mystery man"),
@@ -186,7 +197,8 @@ static GtkWidget *p_create_frame_missing(struct LibravatarPrefsPage *page)
 	vbox =  gtk_vbox_new(FALSE, 6);
 
 	for (i = 0; i < NUM_DEF_BUTTONS; ++i) {
-		enable = (!enable && libravatarprefs.default_mode == radio_value[i])? TRUE: FALSE;
+		enable = (libravatarprefs.default_mode == radio_value[i])? TRUE: FALSE;
+		e += enable? 1: 0;
 		radio[i] = gtk_radio_button_new_with_label_from_widget(
 				(i > 0)? GTK_RADIO_BUTTON(radio[i - 1]): NULL, radio_label[i]);
 		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio[i]), enable);
@@ -198,7 +210,7 @@ static GtkWidget *p_create_frame_missing(struct LibravatarPrefsPage *page)
 		gtk_widget_show(radio[i]);
 		page->defm_radio[i] = radio[i];
 	}
-	if (!enable) { /* unknown value, go default */
+	if (e == 0) { /* unknown value, go default */
 		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio[0]), TRUE);
 		libravatarprefs.default_mode = DEF_MODE_NONE;
 	}
diff --git a/src/plugins/libravatar/libravatar_prefs.h b/src/plugins/libravatar/libravatar_prefs.h
index fe8ed6a..791c440 100644
--- a/src/plugins/libravatar/libravatar_prefs.h
+++ b/src/plugins/libravatar/libravatar_prefs.h
@@ -48,6 +48,7 @@ struct _LibravatarPrefs
 };
 
 extern LibravatarPrefs libravatarprefs;
+extern GHashTable *libravatarmisses;
 
 void libravatar_prefs_init(void);
 void libravatar_prefs_done(void);

-----------------------------------------------------------------------

Summary of changes:
 src/plugins/libravatar/libravatar.c       |   15 ++++++------
 src/plugins/libravatar/libravatar_prefs.c |   36 +++++++++++++++++++----------
 src/plugins/libravatar/libravatar_prefs.h |    1 +
 3 files changed, 32 insertions(+), 20 deletions(-)


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list