make it possible to not tearoff tearoff boxes :(
authorPaul Davis <paul@linuxaudiosystems.com>
Tue, 11 Nov 2008 07:02:00 +0000 (07:02 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 11 Nov 2008 07:02:00 +0000 (07:02 +0000)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@4135 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/gtkmm2ext/gtkmm2ext/tearoff.h
libs/gtkmm2ext/tearoff.cc

index 5e80892b98a7c3e0d083e434b9e612fd91d3f6f3..737a6ddd03441b95ddf8a90933e7b84e69f0edc0 100644 (file)
@@ -34,6 +34,8 @@ class TearOff : public Gtk::HBox
        virtual ~TearOff ();
 
        void set_visible (bool yn);
+       void set_can_be_torn_off (bool);
+       bool can_be_torn_off () const { return _can_be_torn_off; }
 
        sigc::signal<void> Detach;
        sigc::signal<void> Attach;
@@ -55,6 +57,7 @@ class TearOff : public Gtk::HBox
        double         drag_y;
        bool           dragging;
        bool          _visible;
+       bool          _can_be_torn_off;
 
        gint tearoff_click (GdkEventButton*);
        gint close_click (GdkEventButton*);
index 3df70ad54b85840863ad012ae42206c7c13cbef9..31de30131896baf8603488a76a88d6654e874147 100644 (file)
@@ -36,6 +36,7 @@ TearOff::TearOff (Widget& c, bool allow_resize)
 {
        dragging = false;
        _visible = true;
+       _can_be_torn_off = true;
 
        tearoff_event_box.add (tearoff_arrow);
        tearoff_event_box.set_events (BUTTON_PRESS_MASK|BUTTON_RELEASE_MASK);
@@ -78,6 +79,21 @@ TearOff::~TearOff ()
 {
 }
 
+void
+TearOff::set_can_be_torn_off (bool yn)
+{
+       if (yn != _can_be_torn_off) {
+               if (yn) {
+                       tearoff_arrow.set_no_show_all (false);
+                       tearoff_arrow.show ();
+               } else {
+                       tearoff_arrow.set_no_show_all (true);
+                       tearoff_arrow.hide ();
+               }
+               _can_be_torn_off = yn;
+       }
+}
+
 void
 TearOff::set_visible (bool yn)
 {
@@ -102,13 +118,16 @@ TearOff::set_visible (bool yn)
 gint
 TearOff::tearoff_click (GdkEventButton* ev)
 {
-       remove (contents);
-       window_box.pack_start (contents);
-       own_window.set_name (get_name());
-       close_event_box.set_name (get_name());
-       own_window.show_all ();
-       hide ();
-       Detach ();
+       if (_can_be_torn_off) {
+               remove (contents);
+               window_box.pack_start (contents);
+               own_window.set_name (get_name());
+               close_event_box.set_name (get_name());
+               own_window.show_all ();
+               hide ();
+               Detach ();
+       }
+
        return true;
 }