13
0

provide a sigc::signal to track display state changes for a Tabbable

This commit is contained in:
Paul Davis 2015-07-22 21:13:33 -04:00
parent e2e75d8346
commit 1c41f75488
2 changed files with 10 additions and 3 deletions

View File

@ -64,6 +64,7 @@ class LIBGTKMM2EXT_API Tabbable : public WindowProxy {
virtual void show_window (); virtual void show_window ();
bool window_visible (); bool window_visible ();
bool tabbed() const;
Gtk::Window* current_toplevel () const; Gtk::Window* current_toplevel () const;
@ -73,6 +74,8 @@ class LIBGTKMM2EXT_API Tabbable : public WindowProxy {
XMLNode& get_state (); XMLNode& get_state ();
static std::string xml_node_name(); static std::string xml_node_name();
sigc::signal1<void,Tabbable&> StateChange;
protected: protected:
bool delete_event_handler (GdkEventAny *ev); bool delete_event_handler (GdkEventAny *ev);
@ -92,7 +95,6 @@ class LIBGTKMM2EXT_API Tabbable : public WindowProxy {
void hide_tab (); void hide_tab ();
void tab_close_clicked (); void tab_close_clicked ();
void show_own_window (bool and_pack_it); void show_own_window (bool and_pack_it);
bool tabbed() const;
}; };

View File

@ -101,7 +101,7 @@ Tabbable::window_visible ()
return false; return false;
} }
return visible(); return _window->is_visible();
} }
Window* Window*
@ -153,6 +153,7 @@ Tabbable::show_own_window (bool and_pack_it)
_window->show_all (); _window->show_all ();
_window->present (); _window->present ();
StateChange (*this);
} }
Gtk::Notebook* Gtk::Notebook*
@ -201,6 +202,7 @@ Tabbable::make_invisible ()
{ {
if (_window && (current_toplevel() == _window)) { if (_window && (current_toplevel() == _window)) {
_window->hide (); _window->hide ();
StateChange (*this);
} else { } else {
hide_tab (); hide_tab ();
} }
@ -254,6 +256,7 @@ Tabbable::attach ()
*/ */
tab_requested_by_state = true; tab_requested_by_state = true;
StateChange (*this);
} }
bool bool
@ -285,6 +288,7 @@ Tabbable::hide_tab ()
{ {
if (tabbed()) { if (tabbed()) {
_parent_notebook->remove_page (_contents); _parent_notebook->remove_page (_contents);
StateChange (*this);
} }
} }
@ -296,6 +300,7 @@ Tabbable::show_tab ()
add_to_notebook (*_parent_notebook, _tab_title); add_to_notebook (*_parent_notebook, _tab_title);
} }
_parent_notebook->set_current_page (_parent_notebook->page_num (_contents)); _parent_notebook->set_current_page (_parent_notebook->page_num (_contents));
StateChange (*this);
} }
} }
@ -314,7 +319,7 @@ Tabbable::xml_node_name()
bool bool
Tabbable::tabbed () const Tabbable::tabbed () const
{ {
return _parent_notebook && (_parent_notebook->page_num (_contents) >= 0); return _parent_notebook && (_parent_notebook->page_num (_contents) > 0);
} }
XMLNode& XMLNode&