diff options
-rw-r--r-- | src/Patchage.cpp | 49 | ||||
-rw-r--r-- | src/Patchage.hpp | 4 | ||||
-rw-r--r-- | src/patchage.ui | 5 | ||||
-rw-r--r-- | wscript | 2 |
4 files changed, 38 insertions, 22 deletions
diff --git a/src/Patchage.cpp b/src/Patchage.cpp index facc7bd..67e390f 100644 --- a/src/Patchage.cpp +++ b/src/Patchage.cpp @@ -108,7 +108,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_export_dot) + , INIT_WIDGET(_menu_export_image) , INIT_WIDGET(_menu_help_about) , INIT_WIDGET(_menu_jack_connect) , INIT_WIDGET(_menu_jack_disconnect) @@ -219,8 +219,8 @@ Patchage::Patchage(int argc, char** argv) _menu_file_quit->signal_activate().connect( sigc::mem_fun(this, &Patchage::on_quit)); - _menu_export_dot->signal_activate().connect( - sigc::mem_fun(this, &Patchage::on_export_dot)); + _menu_export_image->signal_activate().connect( + sigc::mem_fun(this, &Patchage::on_export_image)); _menu_view_refresh->signal_activate().connect( sigc::mem_fun(this, &Patchage::refresh)); _menu_view_human_names->signal_activate().connect( @@ -893,31 +893,46 @@ Patchage::on_quit() } void -Patchage::on_export_dot() +Patchage::on_export_image() { - Gtk::FileChooserDialog dialog("Export to DOT", Gtk::FILE_CHOOSER_ACTION_SAVE); - dialog.set_transient_for(*_main_win); + Gtk::FileChooserDialog dialog("Export Image", Gtk::FILE_CHOOSER_ACTION_SAVE); dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); + dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK); + dialog.set_default_response(Gtk::RESPONSE_OK); + dialog.set_transient_for(*_main_win); + + typedef std::map<std::string, std::string> Types; + Types types; + types["*.dot"] = "Graphviz DOT"; + types["*.pdf"] = "Portable Document Format"; + types["*.ps"] = "PostScript"; + types["*.svg"] = "Scalable Vector Graphics"; + for (Types::const_iterator t = types.begin(); t != types.end(); ++t) { + Gtk::FileFilter filt; + filt.add_pattern(t->first); + filt.set_name(t->second); + dialog.add_filter(filt); + } - Gtk::Button* save_button = dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK); - save_button->property_has_default() = true; + Gtk::CheckButton* bg_but = new Gtk::CheckButton("Draw _Background", true); + Gtk::Alignment* extra = new Gtk::Alignment(1.0, 0.5, 0.0, 0.0); + bg_but->set_active(true); + extra->add(*Gtk::manage(bg_but)); + extra->show_all(); + dialog.set_extra_widget(*Gtk::manage(extra)); if (dialog.run() == Gtk::RESPONSE_OK) { - std::string filename = dialog.get_filename(); - if (filename.find(".") == std::string::npos) - filename += ".dot"; - + const std::string filename = dialog.get_filename(); if (Glib::file_test(filename, Glib::FILE_TEST_EXISTS)) { - Gtk::MessageDialog dialog( + Gtk::MessageDialog confirm( 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) { + confirm.set_transient_for(dialog); + if (confirm.run() != Gtk::RESPONSE_YES) { return; } } - - _canvas->export_dot(filename.c_str()); + _canvas->export_image(filename.c_str(), bg_but->get_active()); } } diff --git a/src/Patchage.hpp b/src/Patchage.hpp index 2cc9347..b234b0d 100644 --- a/src/Patchage.hpp +++ b/src/Patchage.hpp @@ -99,7 +99,7 @@ protected: void on_sprung_layout_toggled(); void on_help_about(); void on_quit(); - void on_export_dot(); + void on_export_image(); void on_view_messages(); void on_view_toolbar(); void on_store_positions(); @@ -150,7 +150,7 @@ protected: Widget<Gtk::MenuItem> _menu_alsa_connect; Widget<Gtk::MenuItem> _menu_alsa_disconnect; Widget<Gtk::MenuItem> _menu_file_quit; - Widget<Gtk::MenuItem> _menu_export_dot; + Widget<Gtk::MenuItem> _menu_export_image; 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 bd828b2..686ad41 100644 --- a/src/patchage.ui +++ b/src/patchage.ui @@ -765,12 +765,13 @@ Nedko Arnaudov <nedko@arnaudov.name></property> </object> </child> <child> - <object class="GtkMenuItem" id="menu_export_dot"> + <object class="GtkMenuItem" id="menu_export_image"> <property name="use_action_appearance">False</property> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="label" translatable="yes">_Export DOT...</property> + <property name="label" translatable="yes">_Export Image...</property> <property name="use_underline">True</property> + <accelerator key="e" signal="activate" modifiers="GDK_CONTROL_MASK"/> </object> </child> <child> @@ -58,7 +58,7 @@ def configure(conf): autowaf.check_pkg(conf, 'gtkmm-2.4', uselib_store='GTKMM', atleast_version='2.12.0', mandatory=True) autowaf.check_pkg(conf, 'ganv-1', uselib_store='GANV', - atleast_version='1.4.0', mandatory=True) + atleast_version='1.5.0', mandatory=True) if conf.env.DEST_OS == 'darwin': autowaf.check_pkg(conf, 'gtk-mac-integration', uselib_store='GTK_OSX', |