comparison src/gtkimhtml.c @ 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 44945824ba60
comparison
equal deleted inserted replaced
5019:eb1d45bffe66 5020:29c87c6e75d9
1560 break; 1560 break;
1561 1561
1562 formats = formats->next; 1562 formats = formats->next;
1563 } 1563 }
1564 1564
1565 g_slist_free(formats);
1566 #else
1567 /* this is really ugly code, but I think it will work */
1568 char *basename = g_path_get_basename(filename);
1569 char *ext = strrchr(basename, '.');
1570
1571 if(ext) {
1572 ext++;
1573 if(!g_ascii_strcasecmp(ext, "jpeg") || !g_ascii_strcasecmp(ext, "jpg"))
1574 type = g_strdup("jpeg");
1575 else if(!g_ascii_strcasecmp(ext, "png"))
1576 type = g_strdup("png");
1577 }
1578
1579 g_free(basename);
1580 #endif
1581
1565 /* If I can't find a valid type, I will just tell the user about it and then assume 1582 /* If I can't find a valid type, I will just tell the user about it and then assume
1566 it's a png */ 1583 it's a png */
1567 if(!type){ 1584 if(!type){
1568 gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, 1585 gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
1569 _("Gaim was unable to guess the image type base on the file extension supplied. Defaulting to PNG.")); 1586 _("Gaim was unable to guess the image type base on the file extension supplied. Defaulting to PNG."));
1570 type = g_strdup("png"); 1587 type = g_strdup("png");
1571 } 1588 }
1572 g_slist_free(formats);
1573 #else
1574 type = g_strdup("png");
1575 #endif
1576 1589
1577 gdk_pixbuf_save(gtk_image_get_pixbuf(image->image), filename, type, &error, NULL); 1590 gdk_pixbuf_save(gtk_image_get_pixbuf(image->image), filename, type, &error, NULL);
1578 1591
1579 if(error){ 1592 if(error){
1580 gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, 1593 gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,