diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2007-01-04 21:47:38 +0000 |
|---|---|---|
| committer | johanengelen <johanengelen@users.sourceforge.net> | 2007-01-04 21:47:38 +0000 |
| commit | a42358634e8c7aff95a160ed78dd926bea5fb1d5 (patch) | |
| tree | 7afdb440427166372aa15bd9581d8b8788fce79d /src/dialogs/export.cpp | |
| parent | update (diff) | |
| download | inkscape-a42358634e8c7aff95a160ed78dd926bea5fb1d5.tar.gz inkscape-a42358634e8c7aff95a160ed78dd926bea5fb1d5.zip | |
Fixed [ 1628085 ] PNG file not created/not recognized by WINXP, where the actual problem was that Windows defaults to not displaying extensions ><
(bzr r2129)
Diffstat (limited to 'src/dialogs/export.cpp')
| -rw-r--r-- | src/dialogs/export.cpp | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp index 387474485..80aaf9c91 100644 --- a/src/dialogs/export.cpp +++ b/src/dialogs/export.cpp @@ -8,8 +8,9 @@ * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * bulia byak <buliabyak@users.sf.net> + * Johan Engelen <j.b.c.engelen@ewi.utwente.nl> * - * Copyright (C) 1999-2005 Authors + * Copyright (C) 1999-2007 Authors * Copyright (C) 2001-2002 Ximian, Inc. * * Released under GNU GPL, read the file 'COPYING' for more information @@ -1124,6 +1125,31 @@ sp_export_export_clicked (GtkButton *button, GtkObject *base) return; } // end of sp_export_export_clicked() + +// FIXME: Some lib function should be available to do this ... +static gchar * +filename_add_extension (const gchar *filename, const gchar *extension) +{ + gchar *dot; + + dot = strrchr (filename, '.'); + if ( !dot ) + return g_strconcat (filename, ".", extension, NULL); + { + if (dot[1] == '\0') + return g_strconcat (filename, extension, NULL); + else + { + if (g_strncasecmp (dot + 1, extension,-1) == 0) + return g_strdup (filename); + else + { + return g_strconcat (filename, ".", extension, NULL); + } + } + } +} + /// Called when Browse button is clicked static void sp_export_browse_clicked (GtkButton *button, gpointer userdata) @@ -1157,11 +1183,16 @@ sp_export_browse_clicked (GtkButton *button, gpointer userdata) gchar *file; file = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fs)); - gchar * utf8file = g_filename_to_utf8( file, -1, NULL, NULL, NULL ); + // make sure that .png is the extension of the file: + gchar * file_ext = filename_add_extension(file, "png"); + + gchar * utf8file = g_filename_to_utf8( file_ext, -1, NULL, NULL, NULL ); gtk_entry_set_text (GTK_ENTRY (fe), utf8file); - g_free(utf8file); g_object_set_data (G_OBJECT (dlg), "filename", fe); + + g_free(file_ext); + g_free(utf8file); g_free(file); } |
