#include "pbd/stacktrace.h"
-#include "i18n.h"
+#include "pbd/i18n.h"
using namespace Gtkmm2ext;
using namespace Gtk;
using std::string;
-Tabbable::Tabbable (Widget& w, const string& name)
+Tabbable::Tabbable (Widget& w, const string& name, bool tabbed_by_default)
: WindowProxy (name)
, _contents (w)
, _parent_notebook (0)
- , tab_requested_by_state (true)
+ , tab_requested_by_state (tabbed_by_default)
{
}
if (and_pack_it) {
Gtk::Container* parent = _contents.get_parent();
if (parent) {
+ _contents.hide ();
parent->remove (_contents);
}
_own_notebook.append_page (_contents);
+ _contents.show ();
}
return win;
tab_requested_by_state = false;
- _window->show_all ();
_window->present ();
}
}
}
+/** 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)) {
+ /* Use WindowProxy method which will rotate then hide */
+ toggle();
+ }
+}
+
void
Tabbable::make_visible ()
{
if (_window && (current_toplevel() == _window)) {
+ set_pos ();
_window->present ();
} else {
save_pos_and_size ();
+ _contents.hide ();
_contents.get_parent()->remove (_contents);
/* leave the window around */
_parent_notebook->set_tab_detachable (_contents);
_parent_notebook->set_tab_reorderable (_contents);
_parent_notebook->set_current_page (_parent_notebook->page_num (_contents));
+ _contents.show ();
/* have to force this on, which is semantically correct, since
* the user has effectively asked for it.
Tabbable::hide_tab ()
{
if (tabbed()) {
+ _contents.hide();
_parent_notebook->remove_page (_contents);
StateChange (*this);
}
add_to_notebook (*_parent_notebook, _tab_title);
}
_parent_notebook->set_current_page (_parent_notebook->page_num (_contents));
+ _contents.show ();
+ current_toplevel()->present ();
}
}
{
XMLNode& node (WindowProxy::get_state());
- node.add_property (X_("tabbed"), tabbed() ? X_("yes") : X_("no"));
+ node.set_property (X_("tabbed"), tabbed());
return node;
}
XMLNode* window_node = node.child ("Window");
if (window_node) {
- const XMLProperty* prop = window_node->property (X_("tabbed"));
- if (prop) {
- tab_requested_by_state = PBD::string_is_affirmative (prop->value());
- }
+ window_node->get_property (X_("tabbed"), tab_requested_by_state);
}
if (!_visible) {
{
StateChange (*this);
}
-