From 2f3580a8d7b743811e1bc78487e56210d564e4aa Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 24 Feb 2007 21:24:36 +0000 Subject: Fixed save/save as dialog behavior. git-svn-id: http://svn.drobilla.net/lad/machina@337 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/MachinaGUI.cpp | 43 ++++++++++++++++++------------------------- src/gui/MachinaGUI.hpp | 2 ++ 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/src/gui/MachinaGUI.cpp b/src/gui/MachinaGUI.cpp index 59c035e..77dcbc5 100644 --- a/src/gui/MachinaGUI.cpp +++ b/src/gui/MachinaGUI.cpp @@ -359,31 +359,29 @@ MachinaGUI::menu_file_open() void MachinaGUI::menu_file_save() { - cerr << "save\n"; - + if (_save_filename == "") { + menu_file_save_as(); + } else { + Raul::RDFWriter writer; + writer.start_to_filename(_save_filename); + machine()->write_state(writer); + writer.finish(); + } +} + + +void +MachinaGUI::menu_file_save_as() +{ Gtk::FileChooserDialog dialog(*_main_window, "Save Machine", Gtk::FILE_CHOOSER_ACTION_SAVE); - /*Gtk::VBox* box = dialog.get_vbox(); - Gtk::Label warning("Warning: Recursively saving will overwrite any subpatch files \ - without confirmation."); - box->pack_start(warning, false, false, 2); - Gtk::CheckButton recursive_checkbutton("Recursively save all subpatches"); - box->pack_start(recursive_checkbutton, false, false, 0); - recursive_checkbutton.show(); - */ dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK); - // Set current folder to most sensible default - /*const string& current_filename = _patch->filename(); - if (current_filename.length() > 0) - dialog.set_filename(current_filename); - else if (App::instance().configuration()->patch_folder().length() > 0) - dialog.set_current_folder(App::instance().configuration()->patch_folder()); - */ + if (_save_filename.length() > 0) + dialog.set_filename(_save_filename); - int result = dialog.run(); - //bool recursive = recursive_checkbutton.get_active(); + const int result = dialog.run(); assert(result == Gtk::RESPONSE_OK || result == Gtk::RESPONSE_CANCEL || result == Gtk::RESPONSE_NONE); @@ -414,17 +412,12 @@ MachinaGUI::menu_file_save() writer.start_to_filename(filename); machine()->write_state(writer); writer.finish(); + _save_filename = filename; } } } -void -MachinaGUI::menu_file_save_as() -{ -} - - void MachinaGUI::on_pane_position_changed() { diff --git a/src/gui/MachinaGUI.hpp b/src/gui/MachinaGUI.hpp index 46d4884..47142b0 100644 --- a/src/gui/MachinaGUI.hpp +++ b/src/gui/MachinaGUI.hpp @@ -81,6 +81,8 @@ protected: bool _refresh; + string _save_filename; + boost::shared_ptr _canvas; boost::shared_ptr _engine; -- cgit v1.2.1