summaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/Patchage.cpp33
-rw-r--r--src/Patchage.hpp2
-rw-r--r--src/patchage.ui15
3 files changed, 50 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();
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<Gtk::MenuItem> _menu_alsa_connect;
Widget<Gtk::MenuItem> _menu_alsa_disconnect;
Widget<Gtk::MenuItem> _menu_file_quit;
+ Widget<Gtk::MenuItem> _menu_draw;
Widget<Gtk::MenuItem> _menu_help_about;
Widget<Gtk::MenuItem> _menu_jack_connect;
Widget<Gtk::MenuItem> _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
@@ -774,6 +774,21 @@ Nedko Arnaudov &lt;nedko@arnaudov.name&gt;</property>
</object>
</child>
<child>
+ <object class="GtkSeparatorMenuItem" id="menu_file_draw_sep">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="menu_draw">
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_Draw</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ <child>
<object class="GtkSeparatorMenuItem" id="menu_file_quit_sep">
<property name="visible">True</property>
<property name="can_focus">False</property>