summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4ef05ef)
raw | patch | inline | side by side (parent: 4ef05ef)
author | joncruz <joncruz@users.sourceforge.net> | |
Sat, 3 Mar 2007 09:10:49 +0000 (09:10 +0000) | ||
committer | joncruz <joncruz@users.sourceforge.net> | |
Sat, 3 Mar 2007 09:10:49 +0000 (09:10 +0000) |
src/ui/dialog/filedialog.cpp | patch | blob | history |
index 26f20b9e630af306e5b5d2dc49a1fcb78e320147..894129795fc885e40b72de19b79bff1c8e29df44 100644 (file)
#include <unistd.h>
#include <sys/stat.h>
+#include <set>
#include <glibmm/i18n.h>
#include <gtkmm/box.h>
#include <gtkmm/colorbutton.h>
* Filename that was given
*/
Glib::ustring myFilename;
+
+ /**
+ * List of known file extensions.
+ */
+ std::set<Glib::ustring> knownExtensions;
};
}
Inkscape::Extension::Output* newOut = extension ? dynamic_cast<Inkscape::Extension::Output*>(extension) : 0;
+ bool appendExtension = true;
if ( newOut ) {
- size_t pos = myFilename.rfind('.');
- if ( pos != Glib::ustring::npos ) {
- Glib::ustring trail = myFilename.substr( pos );
- try {
- Glib::ustring trailUtf8 = Glib::filename_to_utf8( trail );
- if ( trailUtf8.casefold() != Glib::ustring( newOut->get_extension() ).casefold() ) {
- myFilename = myFilename.erase( pos ) + newOut->get_extension();
- change_path(myFilename);
+ try {
+ Glib::ustring utf8Name = Glib::filename_to_utf8( myFilename );
+ size_t pos = utf8Name.rfind('.');
+ if ( pos != Glib::ustring::npos ) {
+ Glib::ustring trail = utf8Name.substr( pos );
+ Glib::ustring foldedTrail = trail.casefold();
+ if ( (trail == ".")
+ | (foldedTrail != Glib::ustring( newOut->get_extension() ).casefold()
+ && ( knownExtensions.find(foldedTrail) != knownExtensions.end() ) ) ) {
+ utf8Name = utf8Name.erase( pos );
+ } else {
+ appendExtension = false;
}
- } catch ( Glib::ConvertError& e ) {
- // ignore
}
- } else {
- myFilename = myFilename + newOut->get_extension();
- change_path(myFilename);
+
+ if (appendExtension) {
+ utf8Name = utf8Name + newOut->get_extension();
+ myFilename = Glib::filename_from_utf8( utf8Name );
+ change_path(myFilename);
+ }
+ } catch ( Glib::ConvertError& e ) {
+ // ignore
}
}
}
{
Inkscape::Extension::DB::OutputList extension_list;
Inkscape::Extension::db.get_output_list(extension_list);
+ knownExtensions.clear();
for (Inkscape::Extension::DB::OutputList::iterator current_item = extension_list.begin();
current_item != extension_list.end(); current_item++)
type.name = (_(omod->get_filetypename()));
type.pattern = "*";
Glib::ustring extension = omod->get_extension();
+ knownExtensions.insert( extension.casefold() );
fileDialogExtensionToPattern (type.pattern, extension);
type.extension= omod;
fileTypeComboBox.append_text(type.name);