diff options
author | David Robillard <d@drobilla.net> | 2014-04-06 06:14:04 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2014-04-06 06:14:04 +0000 |
commit | d1678ff80fe301569215904fcd886f257136b062 (patch) | |
tree | 114aecfbd5a9697d76ccd3941103004b5722534a | |
parent | 96442dec20443f41ba75e599fe89eb5dd338919a (diff) | |
download | patchage-d1678ff80fe301569215904fcd886f257136b062.tar.gz patchage-d1678ff80fe301569215904fcd886f257136b062.tar.bz2 patchage-d1678ff80fe301569215904fcd886f257136b062.zip |
Support port pretty names via new Jack metadata API.
git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@5357 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | src/AlsaDriver.cpp | 5 | ||||
-rw-r--r-- | src/JackDriver.cpp | 21 | ||||
-rw-r--r-- | src/Patchage.cpp | 28 | ||||
-rw-r--r-- | src/Patchage.hpp | 4 | ||||
-rw-r--r-- | src/PatchageModule.cpp | 5 | ||||
-rw-r--r-- | src/PatchageModule.hpp | 3 | ||||
-rw-r--r-- | src/PatchagePort.hpp | 31 | ||||
-rw-r--r-- | src/patchage.ui | 17 | ||||
-rw-r--r-- | wscript | 6 |
10 files changed, 109 insertions, 12 deletions
@@ -11,6 +11,7 @@ patchage (UNRELEASED) unstable; * Support for DOT export for rendering with GraphViz. * Use XDG_CONFIG_HOME instead of ~/.patchagerc. * Make port colours configurable. + * Support port pretty names via new Jack metadata API. -- David Robillard <d@drobilla.net> (UNRELEASED) diff --git a/src/AlsaDriver.cpp b/src/AlsaDriver.cpp index 78a0a16..26ae553 100644 --- a/src/AlsaDriver.cpp +++ b/src/AlsaDriver.cpp @@ -311,8 +311,9 @@ AlsaDriver::create_port(PatchageModule& parent, const string& name, bool is_input, snd_seq_addr_t addr) { PatchagePort* ret = new PatchagePort( - parent, ALSA_MIDI, name, is_input, - _app->conf()->get_port_color(ALSA_MIDI)); + parent, ALSA_MIDI, name, "", is_input, + _app->conf()->get_port_color(ALSA_MIDI), + _app->show_human_names()); dynamic_cast<PatchageCanvas*>(parent.canvas())->index_port( PortID(addr, is_input), ret); diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp index 8f80a56..db06480 100644 --- a/src/JackDriver.cpp +++ b/src/JackDriver.cpp @@ -31,6 +31,9 @@ #include "PatchageModule.hpp" #include "Queue.hpp" #include "patchage_config.h" +#ifdef HAVE_JACK_METADATA +#include <jack/metadata.h> +#endif using std::endl; using std::string; @@ -191,10 +194,24 @@ JackDriver::create_port(PatchageModule& parent, jack_port_t* port, PortID id) return NULL; } + std::string label; +#ifdef HAVE_JACK_METADATA + const jack_uuid_t uuid = jack_port_uuid(port); + char* pretty_name = NULL; + char* type = NULL; + jack_get_property(uuid, JACK_METADATA_PRETTY_NAME, &pretty_name, &type); + if (pretty_name) { + label = pretty_name; + } + jack_free(pretty_name); + jack_free(type); +#endif + PatchagePort* ret( - new PatchagePort(parent, port_type, jack_port_short_name(port), + new PatchagePort(parent, port_type, jack_port_short_name(port), label, (jack_port_flags(port) & JackPortIsInput), - _app->conf()->get_port_color(port_type))); + _app->conf()->get_port_color(port_type), + _app->show_human_names())); if (id.type != PortID::NULL_PORT_ID) { dynamic_cast<PatchageCanvas*>(parent.canvas())->index_port(id, ret); diff --git a/src/Patchage.cpp b/src/Patchage.cpp index 716ecdb..fc1c31e 100644 --- a/src/Patchage.cpp +++ b/src/Patchage.cpp @@ -103,6 +103,7 @@ Patchage::Patchage(int argc, char** argv) , INIT_WIDGET(_menu_view_messages) , INIT_WIDGET(_menu_view_legend) , INIT_WIDGET(_menu_view_refresh) + , INIT_WIDGET(_menu_view_human_names) , INIT_WIDGET(_menu_zoom_in) , INIT_WIDGET(_menu_zoom_out) , INIT_WIDGET(_menu_zoom_normal) @@ -190,6 +191,8 @@ Patchage::Patchage(int argc, char** argv) sigc::mem_fun(this, &Patchage::on_draw)); _menu_view_refresh->signal_activate().connect( sigc::mem_fun(this, &Patchage::refresh)); + _menu_view_human_names->signal_activate().connect( + sigc::mem_fun(this, &Patchage::on_view_human_names)); _menu_view_arrange->signal_activate().connect( sigc::mem_fun(this, &Patchage::on_arrange)); _menu_view_messages->signal_activate().connect( @@ -630,6 +633,31 @@ Patchage::on_help_about() _about_win->hide(); } +static void +update_labels(GanvNode* node, void* data) +{ + const bool human_names = *(const bool*)data; + if (GANV_IS_MODULE(node)) { + Ganv::Module* gmod = Glib::wrap(GANV_MODULE(node)); + PatchageModule* pmod = dynamic_cast<PatchageModule*>(gmod); + if (pmod) { + for (Ganv::Port* gport : *gmod) { + PatchagePort* pport = dynamic_cast<PatchagePort*>(gport); + if (pport) { + pport->show_human_name(human_names); + } + } + } + } +} + +void +Patchage::on_view_human_names() +{ + bool human_names = show_human_names(); + _canvas->for_each_node(update_labels, &human_names); +} + void Patchage::on_zoom_in() { diff --git a/src/Patchage.hpp b/src/Patchage.hpp index af87472..7c1278d 100644 --- a/src/Patchage.hpp +++ b/src/Patchage.hpp @@ -85,6 +85,8 @@ public: void update_state(); void store_window_location(); + bool show_human_names() const { return _menu_view_human_names->get_active(); } + protected: void connect_widgets(); @@ -97,6 +99,7 @@ protected: void on_show_messages(); void on_view_legend(); void on_store_positions(); + void on_view_human_names(); void on_zoom_in(); void on_zoom_out(); void on_zoom_normal(); @@ -152,6 +155,7 @@ protected: Widget<Gtk::MenuItem> _menu_view_messages; Widget<Gtk::CheckMenuItem> _menu_view_legend; Widget<Gtk::MenuItem> _menu_view_refresh; + Widget<Gtk::CheckMenuItem> _menu_view_human_names; Widget<Gtk::ImageMenuItem> _menu_zoom_in; Widget<Gtk::ImageMenuItem> _menu_zoom_out; Widget<Gtk::ImageMenuItem> _menu_zoom_normal; diff --git a/src/PatchageModule.cpp b/src/PatchageModule.cpp index 2cdc977..b929eeb 100644 --- a/src/PatchageModule.cpp +++ b/src/PatchageModule.cpp @@ -147,8 +147,9 @@ PatchagePort* PatchageModule::get_port(const std::string& name) { for (iterator p = begin(); p != end(); ++p) { - if ((*p)->get_label() == name) { - return dynamic_cast<PatchagePort*>(*p); + PatchagePort* pport = dynamic_cast<PatchagePort*>(*p); + if (pport && pport->name() == name) { + return pport; } } diff --git a/src/PatchageModule.hpp b/src/PatchageModule.hpp index 67e80d1..1566e9c 100644 --- a/src/PatchageModule.hpp +++ b/src/PatchageModule.hpp @@ -52,7 +52,8 @@ public: void show_dialog() {} void store_location(double x, double y); - ModuleType type() const { return _type; } + ModuleType type() const { return _type; } + const std::string& name() const { return _name; } protected: bool on_event(GdkEvent* ev); diff --git a/src/PatchagePort.hpp b/src/PatchagePort.hpp index 0ddbc6e..29dae48 100644 --- a/src/PatchagePort.hpp +++ b/src/PatchagePort.hpp @@ -29,6 +29,7 @@ #include "Configuration.hpp" #include "PatchageCanvas.hpp" +#include "PatchageModule.hpp" #include "PortID.hpp" #include "patchage_config.h" @@ -40,10 +41,17 @@ public: PatchagePort(Ganv::Module& module, PortType type, const std::string& name, + const std::string& human_name, bool is_input, - uint32_t color) - : Port(module, name, is_input, color) + uint32_t color, + bool show_human_name) + : Port(module, + (show_human_name && !human_name.empty()) ? human_name : name, + is_input, + color) , _type(type) + , _name(name) + , _human_name(human_name) { signal_event().connect( sigc::mem_fun(this, &PatchagePort::on_event)); @@ -53,9 +61,18 @@ public: /** Returns the full name of this port, as "modulename:portname" */ std::string full_name() const { - return std::string(get_module()->get_label()) + ":" + get_label(); + PatchageModule* pmod = dynamic_cast<PatchageModule*>(get_module()); + return std::string(pmod->name()) + ":" + _name; } + void show_human_name(bool human) { + if (human && !_human_name.empty()) { + set_label(_human_name.c_str()); + } else { + set_label(_name.c_str()); + } + } + bool on_event(GdkEvent* ev) { if (ev->type != GDK_BUTTON_PRESS || ev->button.button != 3) { return false; @@ -70,10 +87,14 @@ public: return true; } - PortType type() const { return _type; } + PortType type() const { return _type; } + const std::string& name() const { return _name; } + const std::string& human_name() const { return _human_name; } private: - PortType _type; + PortType _type; + std::string _name; + std::string _human_name; }; #endif // PATCHAGE_PATCHAGEPORT_HPP diff --git a/src/patchage.ui b/src/patchage.ui index 8202dde..c6c8028 100644 --- a/src/patchage.ui +++ b/src/patchage.ui @@ -900,6 +900,23 @@ Nedko Arnaudov <nedko@arnaudov.name></property> </object> </child> <child> + <object class="GtkSeparatorMenuItem" id="menuitem0"> + <property name="visible">True</property> + <property name="can_focus">False</property> + </object> + </child> + <child> + <object class="GtkCheckMenuItem" id="menu_view_human_names"> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_Human Names</property> + <property name="use_underline">True</property> + <property name="active">True</property> + <accelerator key="H" signal="activate" modifiers="GDK_CONTROL_MASK"/> + </object> + </child> + <child> <object class="GtkSeparatorMenuItem" id="menuitem1"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -84,6 +84,11 @@ def configure(conf): autowaf.define(conf, 'PATCHAGE_LIBJACK', 1) if not Options.options.no_jack_session: autowaf.define(conf, 'PATCHAGE_JACK_SESSION', 1) + conf.check(function_name='jack_get_property', + header_name='jack/metadata.h', + define_name='HAVE_JACK_METADATA', + uselib='JACK', + mandatory=False) # Use Alsa if present unless --no-alsa if not Options.options.no_alsa: @@ -113,6 +118,7 @@ def configure(conf): autowaf.display_msg(conf, "Jack (D-Bus)", conf.is_defined('HAVE_JACK_DBUS')) autowaf.display_msg(conf, "Jack (libjack)", conf.is_defined('PATCHAGE_LIBJACK')) autowaf.display_msg(conf, "Jack Session", conf.is_defined('PATCHAGE_JACK_SESSION')) + autowaf.display_msg(conf, "Jack Metadata", conf.is_defined('HAVE_JACK_METADATA')) autowaf.display_msg(conf, "Alsa Sequencer", conf.is_defined('HAVE_ALSA')) if Options.platform == 'darwin': autowaf.display_msg(conf, "Mac Integration", conf.is_defined('HAVE_GTK_OSX')) |