summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--src/gui/PatchWindow.cpp46
-rw-r--r--src/gui/PatchWindow.hpp2
-rw-r--r--src/gui/ingen_gui.glade16
3 files changed, 64 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)
diff --git a/src/gui/PatchWindow.hpp b/src/gui/PatchWindow.hpp
index 5cfa2936..007d51b7 100644
--- a/src/gui/PatchWindow.hpp
+++ b/src/gui/PatchWindow.hpp
@@ -85,6 +85,7 @@ private:
void event_save();
void event_save_as();
void event_upload();
+ void event_draw();
void event_edit_controls();
void event_copy();
void event_paste();
@@ -119,6 +120,7 @@ private:
Gtk::MenuItem* _menu_save;
Gtk::MenuItem* _menu_save_as;
Gtk::MenuItem* _menu_upload;
+ Gtk::MenuItem* _menu_draw;
Gtk::CheckMenuItem* _menu_edit_controls;
Gtk::MenuItem* _menu_cut;
Gtk::MenuItem* _menu_copy;
diff --git a/src/gui/ingen_gui.glade b/src/gui/ingen_gui.glade
index 402e5466..b10e0425 100644
--- a/src/gui/ingen_gui.glade
+++ b/src/gui/ingen_gui.glade
@@ -103,6 +103,22 @@
</widget>
</child>
<child>
+ <widget class="GtkImageMenuItem" id="patch_draw_menuitem">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Draw...</property>
+ <property name="use_underline">True</property>
+ <signal name="activate" handler="on_patch_draw_menuitem_activate"/>
+ <accelerator key="P" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+ <child internal-child="image">
+ <widget class="GtkImage" id="image2127">
+ <property name="visible">True</property>
+ <property name="stock">gtk-print</property>
+ <property name="icon_size">1</property>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ <child>
<widget class="GtkSeparatorMenuItem" id="separator11">
<property name="visible">True</property>
</widget>