From c0a89b1bd11864c8535d064fbdf648a7e69e628e Mon Sep 17 00:00:00 2001 From: tchernobog Date: Sat, 2 Sep 2006 13:35:14 +0000 Subject: [PATCH] - Add standard file extension when needed (note: this doesn't behaves exactly like the design says, since it doesn't allow for Serializer::get_filename_extension() to return a *list* of space-separated extensions; rather, it assumes that a Serializer will return just *one* extension) git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@999 3ecf2c5c-341e-0410-92b4-d18e462d057c --- src/gui_builder.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gui_builder.cc b/src/gui_builder.cc index 12304b3..f9bcb94 100644 --- a/src/gui_builder.cc +++ b/src/gui_builder.cc @@ -225,8 +225,15 @@ GuiBuilder::on_file_saveas_activate() int result = dialog.run(); if(result==Gtk::RESPONSE_OK) { - serializer.save_snapshot(dialog.get_filename(), history); _filename = dialog.get_filename(); + + // Append standard extension if none (or a different one) is provided + std::string ext = std::string(".") + serializer.get_filename_extension(); + if(_filename.size() < ext.size() || _filename.substr(_filename.size() - ext.size()) != ext) + _filename += ext; + + serializer.save_snapshot(_filename, history); + msg = "File: " + _filename + " saved."; } // end - if(result==Gtk::RESPONSE_OK)