summaryrefslogtreecommitdiffstats
path: root/src/gui/PatchWindow.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-11-28 00:41:01 +0000
committerDavid Robillard <d@drobilla.net>2008-11-28 00:41:01 +0000
commit66f214e9dae0e808ba48165f31ffecd92239f291 (patch)
tree7decf9ff6466a5a3eb980767b8b8a518f3847a59 /src/gui/PatchWindow.cpp
parent32a6198748b61d6d7a6b4246e156f5a8516a2abd (diff)
downloadingen-66f214e9dae0e808ba48165f31ffecd92239f291.tar.gz
ingen-66f214e9dae0e808ba48165f31ffecd92239f291.tar.bz2
ingen-66f214e9dae0e808ba48165f31ffecd92239f291.zip
Add File->Draw to render patch to graphviz (which can then be used to draw to PDF or SVG or PNG or whatever).
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1810 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/gui/PatchWindow.cpp')
-rw-r--r--src/gui/PatchWindow.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/gui/PatchWindow.cpp b/src/gui/PatchWindow.cpp
index 30806c7c..7d9980df 100644
--- a/src/gui/PatchWindow.cpp
+++ b/src/gui/PatchWindow.cpp
@@ -69,6 +69,7 @@ PatchWindow::PatchWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glad
xml->get_widget("patch_save_menuitem", _menu_save);
xml->get_widget("patch_save_as_menuitem", _menu_save_as);
xml->get_widget("patch_upload_menuitem", _menu_upload);
+ xml->get_widget("patch_draw_menuitem", _menu_draw);
xml->get_widget("patch_edit_controls_menuitem", _menu_edit_controls);
xml->get_widget("patch_cut_menuitem", _menu_cut);
xml->get_widget("patch_copy_menuitem", _menu_copy);
@@ -106,6 +107,8 @@ PatchWindow::PatchWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glad
sigc::mem_fun(this, &PatchWindow::event_save_as));
_menu_upload->signal_activate().connect(
sigc::mem_fun(this, &PatchWindow::event_upload));
+ _menu_draw->signal_activate().connect(
+ sigc::mem_fun(this, &PatchWindow::event_draw));
_menu_edit_controls->signal_activate().connect(
sigc::mem_fun(this, &PatchWindow::event_edit_controls));
_menu_copy->signal_activate().connect(
@@ -460,6 +463,49 @@ PatchWindow::event_upload()
void
+PatchWindow::event_draw()
+{
+ Gtk::FileChooserDialog dialog(*this, "Draw to DOT", 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;
+
+ int result = dialog.run();
+
+ if (result == Gtk::RESPONSE_OK) {
+ string filename = dialog.get_filename();
+ if (filename.find(".") == string::npos)
+ filename += ".dot";
+
+ bool confirm = false;
+ std::fstream fin;
+ fin.open(filename.c_str(), std::ios::in);
+ if (fin.is_open()) { // File exists
+ const string msg = string("File exists!\n")
+ + "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;
+ }
+ fin.close();
+
+ if (confirm) {
+ _view->canvas()->render_to_dot(filename);
+ _status_bar->push(
+ (boost::format("Rendered %1% to %2%") % _patch->path() % filename).str(),
+ STATUS_CONTEXT_PATCH);
+ }
+ }
+}
+
+
+void
PatchWindow::event_edit_controls()
{
if (_view)