aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/engine/Machine.cpp2
-rw-r--r--src/engine/Node.cpp9
-rw-r--r--src/gui/MachinaGUI.cpp62
-rw-r--r--src/gui/main.cpp2
4 files changed, 67 insertions, 8 deletions
diff --git a/src/engine/Machine.cpp b/src/engine/Machine.cpp
index e7247c8..a2d650d 100644
--- a/src/engine/Machine.cpp
+++ b/src/engine/Machine.cpp
@@ -227,7 +227,7 @@ Machine::write_state(Raul::RDFWriter& writer)
RdfId(RdfId::RESOURCE, "machina:node"),
(*n)->id());
}
-}
+}
} // namespace Machina
diff --git a/src/engine/Node.cpp b/src/engine/Node.cpp
index 224718e..8bf9246 100644
--- a/src/engine/Node.cpp
+++ b/src/engine/Node.cpp
@@ -125,8 +125,13 @@ Node::write_state(Raul::RDFWriter& writer)
RdfId(RdfId::RESOURCE, "machina:Node"));
writer.write(_id,
- RdfId(RdfId::RESOURCE, "machina:duration"),
- Raul::Atom((float)_duration));
+ RdfId(RdfId::RESOURCE, "machina:duration"),
+ Raul::Atom((float)_duration));
+
+ for (Node::EdgeList::const_iterator e = _outgoing_edges.begin();
+ e != _outgoing_edges.end(); ++e)
+ std::cerr << "FIXME: write edge\n";
+
}
diff --git a/src/gui/MachinaGUI.cpp b/src/gui/MachinaGUI.cpp
index ee81979..59c035e 100644
--- a/src/gui/MachinaGUI.cpp
+++ b/src/gui/MachinaGUI.cpp
@@ -360,11 +360,63 @@ void
MachinaGUI::menu_file_save()
{
cerr << "save\n";
-
- Raul::RDFWriter writer;
- writer.start_to_filename("test.machina.ttl");
- machine()->write_state(writer);
- writer.finish();}
+
+ 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());
+ */
+
+ int result = dialog.run();
+ //bool recursive = recursive_checkbutton.get_active();
+
+ assert(result == Gtk::RESPONSE_OK || result == Gtk::RESPONSE_CANCEL || result == Gtk::RESPONSE_NONE);
+
+ if (result == Gtk::RESPONSE_OK) {
+ string filename = dialog.get_filename();
+ if (filename.length() < 12 || filename.substr(filename.length()-12) != ".machina.ttl")
+ filename += ".machina.ttl";
+
+ bool confirm = false;
+ std::fstream fin;
+ fin.open(filename.c_str(), std::ios::in);
+ if (fin.is_open()) { // File exists
+ string msg = "A file named \"";
+ msg += filename + "\" already exists.\n\nDo you want to replace it?";
+ Gtk::MessageDialog confirm_dialog(dialog,
+ 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;
+ }
+ fin.close();
+
+ if (confirm) {
+ Raul::RDFWriter writer;
+ writer.start_to_filename(filename);
+ machine()->write_state(writer);
+ writer.finish();
+ }
+ }
+}
void
diff --git a/src/gui/main.cpp b/src/gui/main.cpp
index d6c846e..9928a90 100644
--- a/src/gui/main.cpp
+++ b/src/gui/main.cpp
@@ -51,7 +51,9 @@ main(int argc, char** argv)
Gnome::Canvas::init();
Gtk::Main app(argc, argv);
+ driver->activate();
MachinaGUI gui(engine);
+
app.run(*gui.window());
} catch (std::string msg) {