From edc149fe5a8fca653b0201bf0449c0392daae03e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 16 Mar 2014 13:56:45 +0000 Subject: 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 --- src/Patchage.cpp | 33 +++++++++++++++++++++++++++++++++ src/Patchage.hpp | 2 ++ src/patchage.ui | 15 +++++++++++++++ 3 files changed, 50 insertions(+) (limited to 'src') 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 #include +#include #include #include #include @@ -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( @@ -648,6 +652,35 @@ Patchage::on_quit() _canvas.reset(); } +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() { diff --git a/src/Patchage.hpp b/src/Patchage.hpp index 5f54b91..54399bc 100644 --- a/src/Patchage.hpp +++ b/src/Patchage.hpp @@ -92,6 +92,7 @@ protected: void on_messages_clear(); void on_messages_close(); void on_quit(); + void on_draw(); void on_show_messages(); void on_store_positions(); void on_zoom_in(); @@ -134,6 +135,7 @@ protected: Widget _menu_alsa_connect; Widget _menu_alsa_disconnect; Widget _menu_file_quit; + Widget _menu_draw; Widget _menu_help_about; Widget _menu_jack_connect; Widget _menu_jack_disconnect; diff --git a/src/patchage.ui b/src/patchage.ui index 8be29f2..8dd0138 100644 --- a/src/patchage.ui +++ b/src/patchage.ui @@ -773,6 +773,21 @@ Nedko Arnaudov <nedko@arnaudov.name> + + + True + False + + + + + False + True + False + _Draw + True + + True -- cgit v1.2.1