From 361c8421df8361033161372cc2392647c8a75920 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 20 Nov 2015 09:27:41 -0500 Subject: provide Tabbable::change_visibility(), which has slightly odd semantics that are neither toggle nor one-shot --- libs/gtkmm2ext/gtkmm2ext/tabbable.h | 1 + libs/gtkmm2ext/tabbable.cc | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) (limited to 'libs') diff --git a/libs/gtkmm2ext/gtkmm2ext/tabbable.h b/libs/gtkmm2ext/gtkmm2ext/tabbable.h index 9df2800d97..c9b06ac3ca 100644 --- a/libs/gtkmm2ext/gtkmm2ext/tabbable.h +++ b/libs/gtkmm2ext/gtkmm2ext/tabbable.h @@ -47,6 +47,7 @@ class LIBGTKMM2EXT_API Tabbable : public WindowProxy { void add_to_notebook (Gtk::Notebook& notebook, const std::string& tab_title); void make_visible (); void make_invisible (); + void change_visibility (); void attach (); void detach (); diff --git a/libs/gtkmm2ext/tabbable.cc b/libs/gtkmm2ext/tabbable.cc index 928e501751..1c720591f5 100644 --- a/libs/gtkmm2ext/tabbable.cc +++ b/libs/gtkmm2ext/tabbable.cc @@ -170,6 +170,32 @@ Tabbable::show_window () } } +/** If this Tabbable is currently parented by a tab, ensure that the tab is the + * current one. If it is parented by a window, then toggle the visibility of + * that window. + */ +void +Tabbable::change_visibility () +{ + if (tabbed()) { + _parent_notebook->set_current_page (_parent_notebook->page_num (_contents)); + return; + } + + if (tab_requested_by_state) { + /* should be tabbed, but currently isn't parented by a notebook */ + return; + } + + if (_window && (current_toplevel() == _window)) { + if (_window->is_visible ()) { + _window->hide (); + } else { + _window->present (); + } + } +} + void Tabbable::make_visible () { @@ -358,4 +384,3 @@ Tabbable::window_unmapped () { StateChange (*this); } - -- cgit v1.2.3