diff options
author | David Robillard <d@drobilla.net> | 2009-05-11 18:05:24 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-05-11 18:05:24 +0000 |
commit | 698c38587bd4f0133a132dc363098ff8298ec47b (patch) | |
tree | abcab2ab196d995fbcc52a4e62c4f5d496b6a754 /src/gui/PatchWindow.cpp | |
parent | 9ea901df533b0326e715ced10b9e9970239da515 (diff) | |
download | ingen-698c38587bd4f0133a132dc363098ff8298ec47b.tar.gz ingen-698c38587bd4f0133a132dc363098ff8298ec47b.tar.bz2 ingen-698c38587bd4f0133a132dc363098ff8298ec47b.zip |
* New ontology.
* Display human names on patch ports on creation, if enabled.
* Fix copy/paste of subpatches.
* Split properties into "properties" (class properties) and "variables" (instance properties).
* Names are kind of a legacy leftover...
* Remove special set poly / enable / etc events in favour of just setting properties (less API, extensible, RDF compatible).
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1973 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/gui/PatchWindow.cpp')
-rw-r--r-- | src/gui/PatchWindow.cpp | 78 |
1 files changed, 49 insertions, 29 deletions
diff --git a/src/gui/PatchWindow.cpp b/src/gui/PatchWindow.cpp index 14aab7d9..e8e2d7e0 100644 --- a/src/gui/PatchWindow.cpp +++ b/src/gui/PatchWindow.cpp @@ -394,7 +394,7 @@ PatchWindow::event_import_location() void PatchWindow::event_save() { - GraphObject::Variables::const_iterator doc = _patch->variables().find("ingen:document"); + GraphObject::Properties::const_iterator doc = _patch->variables().find("ingen:document"); if (doc == _patch->variables().end()) { event_save_as(); } else { @@ -410,38 +410,56 @@ PatchWindow::event_save() void PatchWindow::event_save_as() { - Gtk::FileChooserDialog dialog(*this, "Save Patch", Gtk::FILE_CHOOSER_ACTION_SAVE); - - dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - Gtk::Button* save_button = dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK); - save_button->property_has_default() = true; - - Gtk::FileFilter filt; - filt.add_pattern("*.ingen.ttl"); - filt.set_name("Ingen patches"); - filt.add_pattern("*.ingen.lv2"); - filt.set_name("Ingen bundles"); - dialog.set_filter(filt); - - // Set current folder to most sensible default - GraphObject::Variables::const_iterator doc = _patch->variables().find("ingen:document"); - if (doc != _patch->variables().end()) - dialog.set_uri(doc->second.get_string()); - else if (App::instance().configuration()->patch_folder().length() > 0) - dialog.set_current_folder(App::instance().configuration()->patch_folder()); - - int result = dialog.run(); - //bool recursive = recursive_checkbutton.get_active(); - - if (result == Gtk::RESPONSE_OK) { + while (true) { + Gtk::FileChooserDialog dialog(*this, "Save Patch", Gtk::FILE_CHOOSER_ACTION_SAVE); + + dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); + Gtk::Button* save_button = dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK); + save_button->property_has_default() = true; + + Gtk::FileFilter filt; + filt.add_pattern("*.ingen.ttl"); + filt.set_name("Ingen patches"); + filt.add_pattern("*.ingen.lv2"); + filt.set_name("Ingen bundles"); + dialog.set_filter(filt); + + // Set current folder to most sensible default + GraphObject::Properties::const_iterator doc = _patch->variables().find("ingen:document"); + if (doc != _patch->variables().end()) + dialog.set_uri(doc->second.get_string()); + else if (App::instance().configuration()->patch_folder().length() > 0) + dialog.set_current_folder(App::instance().configuration()->patch_folder()); + + if (dialog.run() != Gtk::RESPONSE_OK) + break; + string filename = dialog.get_filename(); + + string base = filename.substr(0, filename.find(".")); + if (base.find("/") != string::npos) + base = base.substr(base.find_last_of("/") + 1); + + if (!Symbol::is_valid(base)) { + Gtk::MessageDialog error_dialog(*this, + "<b>Ingen patch file names must be valid symbols</b>", true, + Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); + error_dialog.set_secondary_text( + "The first character must be _, a-z, or A-Z, and " + "subsequent characters must be _, a-z, A-Z, or 0-9."); + error_dialog.run(); + continue; + } + const bool is_bundle = filename.find(".ingen.lv2") != string::npos; const bool is_patch = filename.find(".ingen.ttl") != string::npos; - + // Save a bundle by default if (!is_bundle && !is_patch) filename += ".ingen.ttl"; + _patch->set_property("lv2:symbol", Atom(base.c_str())); + bool confirm = true; std::fstream fin; fin.open(filename.c_str(), std::ios::in); @@ -449,11 +467,11 @@ PatchWindow::event_save_as() string msg = "File already exists! Are you sure you want to overwrite "; msg += filename + "?"; Gtk::MessageDialog confirm_dialog(*this, - msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_YES_NO, true); + msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_YES_NO, true); confirm = (confirm_dialog.run() == Gtk::RESPONSE_YES); } fin.close(); - + if (confirm) { const Glib::ustring uri = Glib::filename_to_uri(filename); App::instance().loader()->save_patch(_patch, uri); @@ -462,8 +480,10 @@ PatchWindow::event_save_as() (boost::format("Wrote %1% to %2%") % _patch->path() % uri).str(), STATUS_CONTEXT_PATCH); } + + App::instance().configuration()->set_patch_folder(dialog.get_current_folder()); + break; } - App::instance().configuration()->set_patch_folder(dialog.get_current_folder()); } |