summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-11-30 19:56:36 +0000
committerDavid Robillard <d@drobilla.net>2008-11-30 19:56:36 +0000
commit684a8fd8fd54a391662e72b1113ddbda14e66612 (patch)
treec1f8896711e45e4102f1968fde465199e7373fd1 /src/gui
parent56a392e69a378f28d25b6b66feb62e36125da20c (diff)
downloadingen-684a8fd8fd54a391662e72b1113ddbda14e66612.tar.gz
ingen-684a8fd8fd54a391662e72b1113ddbda14e66612.tar.bz2
ingen-684a8fd8fd54a391662e72b1113ddbda14e66612.zip
Some support for bundle saving.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1831 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/LoadPatchWindow.cpp19
-rw-r--r--src/gui/PatchWindow.cpp44
-rw-r--r--src/gui/ThreadedLoader.cpp9
3 files changed, 43 insertions, 29 deletions
diff --git a/src/gui/LoadPatchWindow.cpp b/src/gui/LoadPatchWindow.cpp
index caa6c8bf..5da4b459 100644
--- a/src/gui/LoadPatchWindow.cpp
+++ b/src/gui/LoadPatchWindow.cpp
@@ -45,19 +45,26 @@ LoadPatchWindow::LoadPatchWindow(BaseObjectType* cobject, const Glib::RefPtr<Gno
xml->get_widget("load_patch_ok_button", _ok_button);
xml->get_widget("load_patch_cancel_button", _cancel_button);
- _poly_from_current_radio->signal_toggled().connect(sigc::mem_fun(this, &LoadPatchWindow::poly_from_file_selected));
- _poly_from_file_radio->signal_toggled().connect(sigc::mem_fun(this, &LoadPatchWindow::poly_from_file_selected));
- _poly_from_user_radio->signal_toggled().connect(sigc::mem_fun(this, &LoadPatchWindow::poly_from_user_selected));
- _ok_button->signal_clicked().connect(sigc::mem_fun(this, &LoadPatchWindow::ok_clicked));
- _cancel_button->signal_clicked().connect(sigc::mem_fun(this, &LoadPatchWindow::cancel_clicked));
+ _poly_from_current_radio->signal_toggled().connect(
+ sigc::mem_fun(this, &LoadPatchWindow::poly_from_file_selected));
+ _poly_from_file_radio->signal_toggled().connect(
+ sigc::mem_fun(this, &LoadPatchWindow::poly_from_file_selected));
+ _poly_from_user_radio->signal_toggled().connect(
+ sigc::mem_fun(this, &LoadPatchWindow::poly_from_user_selected));
+ _ok_button->signal_clicked().connect(
+ sigc::mem_fun(this, &LoadPatchWindow::ok_clicked));
+ _cancel_button->signal_clicked().connect(
+ sigc::mem_fun(this, &LoadPatchWindow::cancel_clicked));
_poly_from_current_radio->set_active(true);
Gtk::FileFilter filt;
filt.add_pattern("*.om");
filt.set_name("Om patch files (XML, DEPRECATED) (*.om)");
+ filt.add_pattern("*.ingen.lv2");
+ filt.set_name("Ingen bundles (*.ingen.lv2)");
filt.add_pattern("*.ingen.ttl");
- filt.set_name("Ingen patch files (RDF, *.ingen.ttl)");
+ filt.set_name("Ingen patch files (*.ingen.ttl)");
set_filter(filt);
// Add global examples directory to "shortcut folders" (bookmarks)
diff --git a/src/gui/PatchWindow.cpp b/src/gui/PatchWindow.cpp
index 7d9980df..707f5f0e 100644
--- a/src/gui/PatchWindow.cpp
+++ b/src/gui/PatchWindow.cpp
@@ -393,10 +393,10 @@ PatchWindow::event_save()
if (doc == _patch->variables().end()) {
event_save_as();
} else {
- const Glib::ustring& filename = Glib::filename_from_uri(doc->second.get_string());
- App::instance().loader()->save_patch(_patch, filename);
+ const Glib::ustring& document_uri = doc->second.get_string();
+ App::instance().loader()->save_patch(_patch, document_uri);
_status_bar->push(
- (boost::format("Wrote %1% to %2%") % _patch->path() % filename).str(),
+ (boost::format("Wrote %1% to %2%") % _patch->path() % document_uri).str(),
STATUS_CONTEXT_PATCH);
}
}
@@ -411,6 +411,13 @@ PatchWindow::event_save_as()
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())
@@ -423,10 +430,14 @@ PatchWindow::event_save_as()
if (result == Gtk::RESPONSE_OK) {
string filename = dialog.get_filename();
- if (filename.length() < 11 || filename.substr(filename.length()-10) != ".ingen.ttl")
+ 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";
- bool confirm = false;
+ bool confirm = true;
std::fstream fin;
fin.open(filename.c_str(), std::ios::in);
if (fin.is_open()) { // File exists
@@ -434,20 +445,16 @@ PatchWindow::event_save_as()
msg += filename + "?";
Gtk::MessageDialog confirm_dialog(*this,
msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_YES_NO, true);
- if (confirm_dialog.run() == Gtk::RESPONSE_YES)
- confirm = true;
- else
- confirm = false;
- } else { // File doesn't exist
- confirm = true;
+ confirm = (confirm_dialog.run() == Gtk::RESPONSE_YES);
}
fin.close();
if (confirm) {
- App::instance().loader()->save_patch(_patch, filename);
- _patch->set_variable("ingen:document", Atom(Glib::filename_to_uri(filename).c_str()));
+ const Glib::ustring uri = Glib::filename_to_uri(filename);
+ App::instance().loader()->save_patch(_patch, uri);
+ _patch->set_variable("ingen:document", Atom(uri.c_str()));
_status_bar->push(
- (boost::format("Wrote %1% to %2%") % _patch->path() % filename).str(),
+ (boost::format("Wrote %1% to %2%") % _patch->path() % uri).str(),
STATUS_CONTEXT_PATCH);
}
}
@@ -478,7 +485,7 @@ PatchWindow::event_draw()
if (filename.find(".") == string::npos)
filename += ".dot";
- bool confirm = false;
+ bool confirm = true;
std::fstream fin;
fin.open(filename.c_str(), std::ios::in);
if (fin.is_open()) { // File exists
@@ -486,12 +493,7 @@ PatchWindow::event_draw()
+ "Are you sure you want to overwrite " + filename + "?";
Gtk::MessageDialog confirm_dialog(*this,
msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_YES_NO, true);
- if (confirm_dialog.run() == Gtk::RESPONSE_YES)
- confirm = true;
- else
- confirm = false;
- } else { // File doesn't exist
- confirm = true;
+ confirm = (confirm_dialog.run() == Gtk::RESPONSE_YES);
}
fin.close();
diff --git a/src/gui/ThreadedLoader.cpp b/src/gui/ThreadedLoader.cpp
index 087ade58..d2bfec76 100644
--- a/src/gui/ThreadedLoader.cpp
+++ b/src/gui/ThreadedLoader.cpp
@@ -147,8 +147,13 @@ ThreadedLoader::save_patch(SharedPtr<PatchModel> model, const string& filename)
void
ThreadedLoader::save_patch_event(SharedPtr<PatchModel> model, const string& filename)
{
- if (App::instance().serialiser())
- App::instance().serialiser()->to_file(model, filename);
+ if (App::instance().serialiser()) {
+ Serialiser::Record r(model, filename);
+ if (filename.find(".ingen.lv2") != string::npos)
+ App::instance().serialiser()->write_bundle(r);
+ else
+ App::instance().serialiser()->to_file(r);
+ }
}