enough with umpteen "i18n.h" files. Consolidate on pbd/i18n.h
[ardour.git] / libs / gtkmm2ext / tabbable.cc
index 4344f397491eb4cb289aa5e2668228c22e9c2e6a..5e4752454e6cfd6c8547b56799f59399b2307165 100644 (file)
@@ -29,7 +29,7 @@
 
 #include "pbd/stacktrace.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace Gtkmm2ext;
 using namespace Gtk;
@@ -39,18 +39,8 @@ Tabbable::Tabbable (Widget& w, const string& name)
        : WindowProxy (name)
        , _contents (w)
        , _parent_notebook (0)
-       , tab_close_image (ArdourIcon::CloseCross, 0xffffffff)
        , tab_requested_by_state (true)
 {
-       /* sizes will be scaled during rendering */
-       tab_close_image.set_size_request (15,15);
-
-       _tab_box.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
-       _tab_box.set_spacing (2);
-       _tab_box.pack_start (_tab_label, true, true);
-       _tab_box.pack_start (tab_close_image, false, false);
-
-       tab_close_image.signal_button_release_event().connect (sigc::mem_fun (*this, &Tabbable::tab_close_clicked));
 }
 
 Tabbable::~Tabbable ()
@@ -61,20 +51,10 @@ Tabbable::~Tabbable ()
        }
 }
 
-bool
-Tabbable::tab_close_clicked (GdkEventButton*)
-{
-       hide_tab ();
-       return true;
-}
-
 void
 Tabbable::add_to_notebook (Notebook& notebook, const string& tab_title)
 {
        _parent_notebook = &notebook;
-       _tab_title = tab_title;
-       _tab_label.set_text (tab_title);
-       _tab_box.show_all ();
 
        if (tab_requested_by_state) {
                attach ();
@@ -91,7 +71,7 @@ Tabbable::use_own_window (bool and_pack_it)
                if (parent) {
                        parent->remove (_contents);
                }
-               _own_notebook.append_page (_contents, _tab_box);
+               _own_notebook.append_page (_contents);
        }
 
        return win;
@@ -160,7 +140,6 @@ Tabbable::show_own_window (bool and_pack_it)
 
        tab_requested_by_state = false;
 
-       _window->show_all ();
        _window->present ();
 }
 
@@ -190,10 +169,34 @@ 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)) {
+               /* Use WindowProxy method which will rotate then hide */
+               toggle();
+       }
+}
+
 void
 Tabbable::make_visible ()
 {
        if (_window && (current_toplevel() == _window)) {
+               set_pos ();
                _window->present ();
        } else {
 
@@ -248,17 +251,11 @@ Tabbable::attach ()
                _window->hide ();
        }
 
-       _parent_notebook->append_page (_contents, _tab_box);
-       _contents.set_data ("close-button", &tab_close_image);
+       _parent_notebook->append_page (_contents);
        _parent_notebook->set_tab_detachable (_contents);
        _parent_notebook->set_tab_reorderable (_contents);
        _parent_notebook->set_current_page (_parent_notebook->page_num (_contents));
 
-       Gtkmm2ext::UI::instance()->set_tip (_tab_label,
-                                           string_compose (_("Drag this tab to the desktop to show %1 in its own window\n\n"
-                                                             "To put the window back, use the Window > %1 > Attach menu action"), _tab_title));
-
-
        /* have to force this on, which is semantically correct, since
         * the user has effectively asked for it.
         */
@@ -307,6 +304,7 @@ Tabbable::show_tab ()
                        add_to_notebook (*_parent_notebook, _tab_title);
                }
                _parent_notebook->set_current_page (_parent_notebook->page_num (_contents));
+               current_toplevel()->present ();
        }
 }
 
@@ -355,7 +353,7 @@ Tabbable::set_state (const XMLNode& node, int version)
        XMLNode* window_node = node.child ("Window");
 
        if (window_node) {
-               const XMLProperty* prop = window_node->property (X_("tabbed"));
+               XMLProperty const * prop = window_node->property (X_("tabbed"));
                if (prop) {
                        tab_requested_by_state = PBD::string_is_affirmative (prop->value());
                }
@@ -384,4 +382,3 @@ Tabbable::window_unmapped ()
 {
        StateChange (*this);
 }
-