# HG changeset patch # User Mark Doliner # Date 1181512725 0 # Node ID 43961a41237a5063b6f317673776a7a981888c69 # Parent 329ca72df5fa71dda17e5ec0feb6cc2fb4c04383 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 diff -r 329ca72df5fa -r 43961a41237a pidgin/gtkimhtml.c --- 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, _("Unrecognized file type\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 */