[evolution-patches] fix for bug #43917



Fix the memory corruption in bug #43917 and also fix a few other UI
niggles I discovered while testing this:

1. don't escape _'s in the GtkOptionMenu version - otherwise we get
Shift__JIS rather than Shift_JIS which looks funny.

2. For use with the Mail-Display code where we just say the charset name
is "Default", don't make the menu label look like "Unknown (Default)",
just make it say "Default". Looks a little better, tho possibly still
confusing to suers (but hopefully less so?)

If someone has ideas for what it should say instead of Default, I can
make it say that... but whatever. What it is supposed to mean is:

"We are displaying each MIME part in whatever charset it claims to be
in, nothing is being over-ridden"

obviously, we can't always just select a charset in the menu (although
this would be nicer, if we could do it) that has the same name as the
charset the message has, since the message could be 5 text parts, each
with a different charset.

Jeff

-- 
Jeffrey Stedfast
Evolution Hacker - Ximian, Inc.
fejj ximian com  - www.ximian.com
? 43917.patch
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/widgets/misc/ChangeLog,v
retrieving revision 1.226
diff -u -r1.226 ChangeLog
--- ChangeLog	13 Jun 2003 15:44:33 -0000	1.226
+++ ChangeLog	17 Jun 2003 20:37:57 -0000
@@ -1,3 +1,14 @@
+2003-06-17  Jeffrey Stedfast  <fejj ximian com>
+
+	* e-charset-picker.c (e_charset_picker_bonobo_ui_populate): Don't
+	use the charset class in the menu label if it is 'Unknown'.
+	(e_charset_picker_bonobo_ui_populate): For user-defined charsets,
+	just use the name of the charset rather than "Unknown".
+	(add_charset): Don't escape _'s anymore, this seems to not be
+	needed int gtk2.
+	(add_other_charset): g_strdup() the charset name. Fixes bug
+	#43917.
+
 2003-06-11  Larry Ewing  <lewing ximian com>
 
 	* e-search-bar.c (impl_get_property): take ownership of the duped
Index: e-charset-picker.c
===================================================================
RCS file: /cvs/gnome/evolution/widgets/misc/e-charset-picker.c,v
retrieving revision 1.15
diff -u -r1.15 e-charset-picker.c
--- e-charset-picker.c	19 May 2003 13:54:21 -0000	1.15
+++ e-charset-picker.c	17 Jun 2003 20:37:57 -0000
@@ -123,40 +123,20 @@
 static GtkWidget *
 add_charset (GtkWidget *menu, ECharset *charset, gboolean free_name)
 {
-	char *charset_name, *label, *u;
 	GtkWidget *item;
-	
-	/* escape _'s in the charset name so that it doesn't become an underline in a GtkLabel */
-	if ((u = strchr (charset->name, '_'))) {
-		int extra = 1;
-		char *s, *d;
-		
-		while ((u = strchr (u + 1, '_')))
-			extra++;
-		
-		d = charset_name = g_alloca (strlen (charset->name) + extra + 1);
-		s = charset->name;
-		while (*s != '\0') {
-			if (*s == '_')
-				*d++ = '_';
-			*d++ = *s++;
-		}
-		*d = '\0';
-	} else {
-		charset_name = charset->name;
-	}
+	char *label;
 	
 	if (charset->subclass) {
 		label = g_strdup_printf ("%s, %s (%s)",
 					 _(classnames[charset->class]),
 					 _(charset->subclass),
-					 charset_name);
+					 charset->name);
 	} else if (charset->class) {
 		label = g_strdup_printf ("%s (%s)",
 					 _(classnames[charset->class]),
-					 charset_name);
+					 charset->name);
 	} else {
-		label = g_strdup (charset_name);
+		label = g_strdup (charset->name);
 	}
 	
 	item = gtk_menu_item_new_with_label (label);
@@ -172,7 +152,7 @@
 }
 
 static gboolean
-add_other_charset (GtkWidget *menu, GtkWidget *other, char *new_charset) 
+add_other_charset (GtkWidget *menu, GtkWidget *other, const char *new_charset) 
 {
 	ECharset charset = { NULL, E_CHARSET_UNKNOWN, NULL };
 	GtkWidget *item;
@@ -192,7 +172,7 @@
 	gtk_container_remove (GTK_CONTAINER (menu), other);
 	
 	/* Create new menu item */
-	charset.name = new_charset;
+	charset.name = g_strdup (new_charset);
 	item = add_charset (menu, &charset, TRUE);
 	
 	/* And re-add "Other..." */
@@ -246,7 +226,7 @@
 		gtk_entry_set_text (GTK_ENTRY (entry), old_charset);
 	g_signal_connect (entry, "activate",
 			  G_CALLBACK (activate_entry), dialog);
-			  
+	
 	gtk_container_set_border_width (GTK_CONTAINER (dialog->vbox), 6);
 	gtk_box_pack_start (GTK_BOX (dialog->vbox), label, FALSE, FALSE, 6);
 	gtk_box_pack_start (GTK_BOX (dialog->vbox), entry, FALSE, FALSE, 6);
@@ -493,10 +473,12 @@
 						 _(classnames[charsets[i].class]),
 						 _(charsets[i].subclass),
 						 charset_name);
-		} else {
+		} else if (charsets[i].class) {
 			label = g_strdup_printf ("%s (%s)",
 						 _(classnames[charsets[i].class]),
 						 charset_name);
+		} else {
+			label = g_strdup (charset_name);
 		}
 		
 		encoded_label = bonobo_ui_util_encode_str (label);
@@ -543,7 +525,7 @@
 			charset_name = (char *) default_charset;
 		}
 		
-		label = g_strdup_printf ("%s (%s)", _("Unknown"), charset_name);
+		label = g_strdup (charset_name);
 		encoded_label = bonobo_ui_util_encode_str (label);
 		g_free (label);
 		


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]