From 5ae44bc4ae0f4410fd2830e7e42d4a7629d68e69 Mon Sep 17 00:00:00 2001 From: dooglus Date: Fri, 8 Feb 2008 09:36:32 +0000 Subject: [PATCH] Allow saving .sif files in a format that can be read by versions 0.61.07 and older. git-svn-id: http://svn.voria.com/code@1624 1f10aa63-cdf2-0310-b900-c93c546f37ac --- synfig-core/trunk/src/synfig/savecanvas.cpp | 14 ++++++++++++++ synfig-core/trunk/src/synfig/savecanvas.h | 9 +++++++++ .../trunk/src/synfig/valuenode_composite.cpp | 4 ++++ .../trunk/src/synfig/valuenode_radialcomposite.cpp | 4 ++++ synfig-studio/trunk/src/gtkmm/app.cpp | 22 ++++++++++++++++++++++ 5 files changed, 53 insertions(+) diff --git a/synfig-core/trunk/src/synfig/savecanvas.cpp b/synfig-core/trunk/src/synfig/savecanvas.cpp index d381c78..1c2f4c6 100644 --- a/synfig-core/trunk/src/synfig/savecanvas.cpp +++ b/synfig-core/trunk/src/synfig/savecanvas.cpp @@ -79,6 +79,8 @@ using namespace synfig; /* === G L O B A L S ======================================================= */ +FileVersion save_canvas_version; + /* === P R O C E D U R E S ================================================= */ xmlpp::Element* encode_canvas(xmlpp::Element* root,Canvas::ConstHandle canvas); @@ -773,3 +775,15 @@ synfig::canvas_to_string(Canvas::ConstHandle canvas) return document.write_to_string_formatted(); } + +void +synfig::set_file_version(FileVersion version) +{ + save_canvas_version = version; +} + +FileVersion +synfig::get_file_version() +{ + return save_canvas_version; +} diff --git a/synfig-core/trunk/src/synfig/savecanvas.h b/synfig-core/trunk/src/synfig/savecanvas.h index aa35480..6319c7b 100644 --- a/synfig-core/trunk/src/synfig/savecanvas.h +++ b/synfig-core/trunk/src/synfig/savecanvas.h @@ -40,6 +40,12 @@ namespace synfig { /* === E X T E R N S ======================================================= */ +typedef enum +{ + FILE_VERSION_0_61_08, + FILE_VERSION_0_61_07, +} FileVersion; + //! Saves a canvas to \a filename /*! \return \c true on success, \c false on error. */ bool save_canvas(const String &filename, Canvas::ConstHandle canvas); @@ -47,6 +53,9 @@ bool save_canvas(const String &filename, Canvas::ConstHandle canvas); //! Stores a Canvas in a string in XML format String canvas_to_string(Canvas::ConstHandle canvas); +void set_file_version(FileVersion version); +FileVersion get_file_version(); + }; // END of namespace synfig /* === E N D =============================================================== */ diff --git a/synfig-core/trunk/src/synfig/valuenode_composite.cpp b/synfig-core/trunk/src/synfig/valuenode_composite.cpp index 8d7428b..102690a 100644 --- a/synfig-core/trunk/src/synfig/valuenode_composite.cpp +++ b/synfig-core/trunk/src/synfig/valuenode_composite.cpp @@ -37,6 +37,7 @@ #include "vector.h" #include "color.h" #include "segment.h" +#include "savecanvas.h" #endif @@ -309,6 +310,9 @@ ValueNode_Composite::link_name(int i)const { assert(i>=0 && i #include "general.h" #include "color.h" +#include "savecanvas.h" #endif /* === U S I N G =========================================================== */ @@ -226,6 +227,9 @@ ValueNode_RadialComposite::link_name(int i)const { assert(i>=0 && i #include +#include #include "app.h" #include "about.h" @@ -85,6 +86,7 @@ #include "devicetracker.h" #include "dialog_tooloptions.h" +#include "widget_enum.h" #include "autorecover.h" @@ -1750,6 +1752,24 @@ App::dialog_save_file(const std::string &title, std::string &filename, std::stri dialog->add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); dialog->add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT); + Widget_Enum *file_type_enum; + if (preference == ANIMATION_DIR_PREFERENCE) + { + file_type_enum = manage(new Widget_Enum()); + file_type_enum->set_param_desc(ParamDesc("filetype") + .set_hint("enum") + .add_enum_value(synfig::FILE_VERSION_0_61_08, "0.61.08", "0.61.08") + .add_enum_value(synfig::FILE_VERSION_0_61_07, "0.61.07", "0.61.07")); + file_type_enum->set_value(0); + + Gtk::HBox *hbox = manage(new Gtk::HBox); + hbox->pack_start(*manage(new Gtk::Label(_("File Type: "))),Gtk::PACK_SHRINK,0); + hbox->pack_start(*file_type_enum,Gtk::PACK_EXPAND_WIDGET,0); + hbox->show_all(); + + dialog->set_extra_widget(*hbox); + } + if (filename.empty()) dialog->set_filename(prev_path); else @@ -1770,6 +1790,8 @@ App::dialog_save_file(const std::string &title, std::string &filename, std::stri } if(dialog->run() == GTK_RESPONSE_ACCEPT) { + if (preference == ANIMATION_DIR_PREFERENCE) + set_file_version(synfig::FileVersion(file_type_enum->get_value())); filename = dialog->get_filename(); info("Saving preference %s = '%s' in App::dialog_save_file()", preference.c_str(), dirname(filename).c_str()); _preferences.set_value(preference, dirname(filename)); -- 2.7.4