changeset 5020:29c87c6e75d9

[gaim-migrate @ 5356] ugly code warning, but this should at least let people using gtk 2.0.x save jpegs if they want to. committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Sat, 05 Apr 2003 03:06:55 +0000
parents eb1d45bffe66
children 00b6af528964
files src/gtkimhtml.c
diffstat 1 files changed, 17 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkimhtml.c	Sat Apr 05 03:02:12 2003 +0000
+++ b/src/gtkimhtml.c	Sat Apr 05 03:06:55 2003 +0000
@@ -1562,6 +1562,23 @@
 		formats = formats->next;
 	}
 
+	g_slist_free(formats);
+#else
+	/* this is really ugly code, but I think it will work */
+	char *basename = g_path_get_basename(filename);
+	char *ext = strrchr(basename, '.');
+
+	if(ext) {
+		ext++;
+		if(!g_ascii_strcasecmp(ext, "jpeg") || !g_ascii_strcasecmp(ext, "jpg"))
+			type = g_strdup("jpeg");
+		else if(!g_ascii_strcasecmp(ext, "png"))
+			type = g_strdup("png");
+	}
+
+	g_free(basename);
+#endif
+
 	/* If I can't find a valid type, I will just tell the user about it and then assume
 	   it's a png */
 	if(!type){
@@ -1569,10 +1586,6 @@
 						_("Gaim was unable to guess the image type base on the file extension supplied.  Defaulting to PNG."));
 		type = g_strdup("png");
 	}
-	g_slist_free(formats);
-#else
-	type = g_strdup("png");
-#endif
 
 	gdk_pixbuf_save(gtk_image_get_pixbuf(image->image), filename, type, &error, NULL);