diff options
-rw-r--r-- | src/Configuration.cpp | 7 | ||||
-rw-r--r-- | src/Configuration.hpp | 6 | ||||
-rw-r--r-- | src/JackDriver.cpp | 12 | ||||
-rw-r--r-- | src/Patchage.cpp | 17 | ||||
-rw-r--r-- | src/Patchage.hpp | 3 | ||||
-rw-r--r-- | src/patchage.ui | 11 |
6 files changed, 47 insertions, 9 deletions
diff --git a/src/Configuration.cpp b/src/Configuration.cpp index 93a3538..d9537c0 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -40,9 +40,10 @@ Configuration::Configuration() , _window_size(640, 480) , _zoom(1.0) , _font_size(12.0) + , _messages_height(0) , _show_toolbar(true) , _show_messages(false) - , _messages_height(0) + , _sort_ports(true) { #ifdef PATCHAGE_USE_LIGHT_THEME _port_colors[JACK_AUDIO] = _default_port_colors[JACK_AUDIO] = 0xA4BC8CFF; @@ -200,6 +201,8 @@ Configuration::load() file >> _sprung_layout; } else if (key == "show_messages") { file >> _show_messages; + } else if (key == "sort_ports") { + file >> _sort_ports; } else if (key == "messages_height") { file >> _messages_height; } else if (key == "port_color") { @@ -224,7 +227,6 @@ Configuration::load() << type_name << "'" << std::endl; } } else if (key == "module_position" || key[0] == '\"') { - Coord loc; std::string name; file.ignore(1, '\"'); @@ -301,6 +303,7 @@ Configuration::save() file << "show_toolbar " << _show_toolbar << std::endl; file << "sprung_layout " << _sprung_layout << std::endl; file << "show_messages " << _show_messages << std::endl; + file << "sort_ports " << _sort_ports << std::endl; file << "messages_height " << _messages_height << std::endl; file << std::hex << std::uppercase; diff --git a/src/Configuration.hpp b/src/Configuration.hpp index 3907510..127a4a8 100644 --- a/src/Configuration.hpp +++ b/src/Configuration.hpp @@ -65,6 +65,9 @@ public: bool get_show_messages() const { return _show_messages; } void set_show_messages(bool show_messages) { _show_messages = show_messages; } + bool get_sort_ports() const { return _sort_ports; } + void set_sort_ports(bool sort_ports) { _sort_ports = sort_ports; } + int get_messages_height() const { return _messages_height; } void set_messages_height(int height) { _messages_height = height; } @@ -96,10 +99,11 @@ private: Coord _window_size; float _zoom; float _font_size; + int _messages_height; bool _show_toolbar; bool _sprung_layout; bool _show_messages; - int _messages_height; + bool _sort_ports; }; #endif // PATCHAGE_CONFIGURATION_HPP diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp index a72bd8f..5daedae 100644 --- a/src/JackDriver.cpp +++ b/src/JackDriver.cpp @@ -206,11 +206,13 @@ JackDriver::create_port(PatchageModule& parent, jack_port_t* port, PortID id) boost::optional<int> order; #ifdef HAVE_JACK_METADATA - const jack_uuid_t uuid = jack_port_uuid(port); - const std::string order_str = get_property(uuid, JACKEY_ORDER); - label = get_property(uuid, JACK_METADATA_PRETTY_NAME); - if (!order_str.empty()) { - order = atoi(order_str.c_str()); + const jack_uuid_t uuid = jack_port_uuid(port); + if (_app->conf()->get_sort_ports()) { + const std::string order_str = get_property(uuid, JACKEY_ORDER); + label = get_property(uuid, JACK_METADATA_PRETTY_NAME); + if (!order_str.empty()) { + order = atoi(order_str.c_str()); + } } #endif diff --git a/src/Patchage.cpp b/src/Patchage.cpp index 91755e1..b9386cb 100644 --- a/src/Patchage.cpp +++ b/src/Patchage.cpp @@ -142,6 +142,7 @@ Patchage::Patchage(int argc, char** argv) , INIT_WIDGET(_menu_view_toolbar) , INIT_WIDGET(_menu_view_refresh) , INIT_WIDGET(_menu_view_human_names) + , INIT_WIDGET(_menu_view_sort_ports) , INIT_WIDGET(_menu_zoom_in) , INIT_WIDGET(_menu_zoom_out) , INIT_WIDGET(_menu_zoom_normal) @@ -255,6 +256,8 @@ Patchage::Patchage(int argc, char** argv) sigc::mem_fun(this, &Patchage::refresh)); _menu_view_human_names->signal_activate().connect( sigc::mem_fun(this, &Patchage::on_view_human_names)); + _menu_view_sort_ports->signal_activate().connect( + sigc::mem_fun(this, &Patchage::on_view_sort_ports)); _menu_view_arrange->signal_activate().connect( sigc::mem_fun(this, &Patchage::on_arrange)); _menu_view_sprung_layout->signal_activate().connect( @@ -307,7 +310,9 @@ Patchage::Patchage(int argc, char** argv) _conf->load(); _canvas->set_zoom(_conf->get_zoom()); _canvas->set_font_size(_conf->get_font_size()); - _canvas->set_port_order(port_order, NULL); + if (_conf->get_sort_ports()) { + _canvas->set_port_order(port_order, NULL); + } _main_win->resize( static_cast<int>(_conf->get_window_size().x), @@ -352,6 +357,7 @@ Patchage::Patchage(int argc, char** argv) update_state(); _menu_view_toolbar->set_active(_conf->get_show_toolbar()); _menu_view_sprung_layout->set_active(_conf->get_sprung_layout()); + _menu_view_sort_ports->set_active(_conf->get_sort_ports()); _status_text->set_pixels_inside_wrap(2); _status_text->set_left_margin(4); _status_text->set_right_margin(4); @@ -812,6 +818,15 @@ Patchage::on_view_human_names() } void +Patchage::on_view_sort_ports() +{ + const bool sort_ports = this->sort_ports(); + _canvas->set_port_order(sort_ports ? port_order : NULL, NULL); + _conf->set_sort_ports(sort_ports); + refresh(); +} + +void Patchage::on_zoom_in() { const float zoom = _canvas->get_zoom() * 1.25; diff --git a/src/Patchage.hpp b/src/Patchage.hpp index 2ce0984..cf550f0 100644 --- a/src/Patchage.hpp +++ b/src/Patchage.hpp @@ -92,6 +92,7 @@ public: void store_window_location(); bool show_human_names() const { return _menu_view_human_names->get_active(); } + bool sort_ports() const { return _menu_view_sort_ports->get_active(); } protected: class BufferSizeColumns : public Gtk::TreeModel::ColumnRecord { @@ -112,6 +113,7 @@ protected: void on_view_toolbar(); void on_store_positions(); void on_view_human_names(); + void on_view_sort_ports(); void on_zoom_in(); void on_zoom_out(); void on_zoom_normal(); @@ -174,6 +176,7 @@ protected: Widget<Gtk::CheckMenuItem> _menu_view_toolbar; Widget<Gtk::MenuItem> _menu_view_refresh; Widget<Gtk::CheckMenuItem> _menu_view_human_names; + Widget<Gtk::CheckMenuItem> _menu_view_sort_ports; Widget<Gtk::ImageMenuItem> _menu_zoom_in; Widget<Gtk::ImageMenuItem> _menu_zoom_out; Widget<Gtk::ImageMenuItem> _menu_zoom_normal; diff --git a/src/patchage.ui b/src/patchage.ui index 42312bb..ec5f935 100644 --- a/src/patchage.ui +++ b/src/patchage.ui @@ -913,6 +913,17 @@ Nedko Arnaudov <nedko@arnaudov.name></property> </object> </child> <child> + <object class="GtkCheckMenuItem" id="menu_view_sort_ports"> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_Sort Ports by Name</property> + <property name="use_underline">True</property> + <property name="active">True</property> + <accelerator key="S" 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> |