Mercurial > pidgin.yaz
changeset 17827:43961a41237a
When right-clicking on an image in a GtkIMHtml to save it, if the file
extension is not recognized then make sure we strip off the
user-entered file format and tack on a ".png"
Fixes bug #914
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 10 Jun 2007 21:58:45 +0000 |
parents | 329ca72df5fa |
children | abc4dcd25c50 |
files | pidgin/gtkimhtml.c |
diffstat | 1 files changed, 19 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/pidgin/gtkimhtml.c Sun Jun 10 21:07:02 2007 +0000 +++ b/pidgin/gtkimhtml.c Sun Jun 10 21:58:45 2007 +0000 @@ -3173,6 +3173,7 @@ char *basename = g_path_get_basename(filename); char *ext = strrchr(basename, '.'); #endif + char *newfilename; gtk_widget_destroy(image->filesel); image->filesel = NULL; @@ -3220,6 +3221,7 @@ /* 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){ + char *basename, *tmp; #if GTK_CHECK_VERSION(2,4,0) GtkWidget *dialog = gtk_message_dialog_new_with_markup(NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("<span size='larger' weight='bold'>Unrecognized file type</span>\n\nDefaulting to PNG.")); @@ -3230,10 +3232,26 @@ g_signal_connect_swapped(dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog); gtk_widget_show(dialog); + type = g_strdup("png"); + basename = g_path_get_basename(filename); + tmp = strrchr(basename, '.'); + if (tmp != NULL) + tmp[0] = '\0'; + newfilename = g_strdup_printf("%s.png", basename); + g_free(basename); + } else { + /* + * We're able to save the file in it's original format, so we + * can use the original file name. + */ + newfilename = g_strdup(filename); } - gdk_pixbuf_save(image->pixbuf, filename, type, &error, NULL); + gdk_pixbuf_save(image->pixbuf, newfilename, type, &error, NULL); + + g_free(newfilename); + g_free(type); if (error){ #if GTK_CHECK_VERSION(2,4,0) @@ -3247,8 +3265,6 @@ gtk_widget_show(dialog); g_error_free(error); } - - g_free(type); } #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */