From a4203e01ac071b081e848f7e4c9ebea20c2194d7 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 4 Dec 2009 22:37:52 +0000 Subject: [PATCH] Some tweaks to fix bug with the tab handling when rescanning or when ports disappear. git-svn-id: svn://localhost/ardour2/branches/3.0@6287 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/port_matrix.cc | 23 +++++++++++++++-------- gtk2_ardour/port_matrix.h | 2 +- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/gtk2_ardour/port_matrix.cc b/gtk2_ardour/port_matrix.cc index 3a84910d49..551a98cdda 100644 --- a/gtk2_ardour/port_matrix.cc +++ b/gtk2_ardour/port_matrix.cc @@ -57,7 +57,7 @@ PortMatrix::PortMatrix (Window* parent, Session& session, DataType type) _min_height_divisor (1), _show_only_bundles (false), _inhibit_toggle_show_only_bundles (false), - _in_setup_notebooks (false) + _ignore_notebook_page_selected (false) { _body = new PortMatrixBody (this); @@ -614,14 +614,17 @@ PortMatrix::bundle_changed (ARDOUR::Bundle::Change c) void PortMatrix::setup_notebooks () { - _in_setup_notebooks = true; - int const h_current_page = _hnotebook.get_current_page (); int const v_current_page = _vnotebook.get_current_page (); remove_notebook_pages (_hnotebook); remove_notebook_pages (_vnotebook); + /* for some reason best known to GTK, erroneous switch_page signals seem to be generated + when adding pages to notebooks, so ignore them */ + + _ignore_notebook_page_selected = true; + for (PortGroupList::List::const_iterator i = _ports[_row_index].begin(); i != _ports[_row_index].end(); ++i) { HBox* dummy = manage (new HBox); dummy->show (); @@ -636,15 +639,21 @@ PortMatrix::setup_notebooks () _hnotebook.append_page (*dummy, (*i)->name); } + _ignore_notebook_page_selected = false; + _vnotebook.set_tab_pos (POS_LEFT); _hnotebook.set_tab_pos (POS_TOP); if (h_current_page != -1 && _hnotebook.get_n_pages() > h_current_page) { _hnotebook.set_current_page (h_current_page); + } else { + _hnotebook.set_current_page (0); } if (v_current_page != -1 && _vnotebook.get_n_pages() > v_current_page) { _vnotebook.set_current_page (v_current_page); + } else { + _vnotebook.set_current_page (0); } if (_hnotebook.get_n_pages() <= 1) { @@ -658,8 +667,6 @@ PortMatrix::setup_notebooks () } else { _vnotebook.show (); } - - _in_setup_notebooks = false; } void @@ -675,10 +682,10 @@ PortMatrix::remove_notebook_pages (Notebook& n) void PortMatrix::v_page_selected (GtkNotebookPage *, guint n) { - if (_in_setup_notebooks) { + if (_ignore_notebook_page_selected) { return; } - + PortGroupList& p = _ports[_row_index]; n = p.size() - n - 1; @@ -701,7 +708,7 @@ PortMatrix::v_page_selected (GtkNotebookPage *, guint n) void PortMatrix::h_page_selected (GtkNotebookPage *, guint n) { - if (_in_setup_notebooks) { + if (_ignore_notebook_page_selected) { return; } diff --git a/gtk2_ardour/port_matrix.h b/gtk2_ardour/port_matrix.h index 278b5a7ced..78914f0c25 100644 --- a/gtk2_ardour/port_matrix.h +++ b/gtk2_ardour/port_matrix.h @@ -203,7 +203,7 @@ private: int _min_height_divisor; bool _show_only_bundles; bool _inhibit_toggle_show_only_bundles; - bool _in_setup_notebooks; + bool _ignore_notebook_page_selected; }; #endif