summaryrefslogtreecommitdiffstats
path: root/src/Patchage.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-03-16 13:56:45 +0000
committerDavid Robillard <d@drobilla.net>2014-03-16 13:56:45 +0000
commitedc149fe5a8fca653b0201bf0449c0392daae03e (patch)
tree6482a97655cf7799a6f89e22f3c5fb80e5f68891 /src/Patchage.cpp
parentf54cfb8daa8d893c0acf05e8eb75705b62862914 (diff)
downloadpatchage-edc149fe5a8fca653b0201bf0449c0392daae03e.tar.gz
patchage-edc149fe5a8fca653b0201bf0449c0392daae03e.tar.bz2
patchage-edc149fe5a8fca653b0201bf0449c0392daae03e.zip
Support for DOT export for rendering with GraphViz (implement #949).
git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@5341 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/Patchage.cpp')
-rw-r--r--src/Patchage.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/Patchage.cpp b/src/Patchage.cpp
index a0bc1ca..efc2c6b 100644
--- a/src/Patchage.cpp
+++ b/src/Patchage.cpp
@@ -26,6 +26,7 @@
#include <gtkmm/button.h>
#include <gtkmm/filechooserdialog.h>
+#include <gtkmm/messagedialog.h>
#include <gtkmm/menuitem.h>
#include <gtkmm/stock.h>
#include <gtkmm/treemodel.h>
@@ -89,6 +90,7 @@ Patchage::Patchage(int argc, char** argv)
, INIT_WIDGET(_menu_alsa_connect)
, INIT_WIDGET(_menu_alsa_disconnect)
, INIT_WIDGET(_menu_file_quit)
+ , INIT_WIDGET(_menu_draw)
, INIT_WIDGET(_menu_help_about)
, INIT_WIDGET(_menu_jack_connect)
, INIT_WIDGET(_menu_jack_disconnect)
@@ -181,6 +183,8 @@ Patchage::Patchage(int argc, char** argv)
sigc::mem_fun(this, &Patchage::on_store_positions));
_menu_file_quit->signal_activate().connect(
sigc::mem_fun(this, &Patchage::on_quit));
+ _menu_draw->signal_activate().connect(
+ sigc::mem_fun(this, &Patchage::on_draw));
_menu_view_refresh->signal_activate().connect(
sigc::mem_fun(this, &Patchage::refresh));
_menu_view_arrange->signal_activate().connect(
@@ -649,6 +653,35 @@ Patchage::on_quit()
}
void
+Patchage::on_draw()
+{
+ Gtk::FileChooserDialog dialog("Draw to DOT", Gtk::FILE_CHOOSER_ACTION_SAVE);
+ dialog.set_transient_for(*_main_win);
+ 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;
+
+ if (dialog.run() == Gtk::RESPONSE_OK) {
+ std::string filename = dialog.get_filename();
+ if (filename.find(".") == std::string::npos)
+ filename += ".dot";
+
+ if (Glib::file_test(filename, Glib::FILE_TEST_EXISTS)) {
+ Gtk::MessageDialog dialog(
+ std::string("File exists! Overwrite ") + filename + "?",
+ true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_YES_NO, true);
+ dialog.set_transient_for(*_main_win);
+ if (dialog.run() != Gtk::RESPONSE_YES) {
+ return;
+ }
+ }
+
+ _canvas->export_dot(filename.c_str());
+ }
+}
+
+void
Patchage::on_show_messages()
{
_messages_win->present();