hopefully get dynamic tabbable menu state right this time
[ardour.git] / libs / gtkmm2ext / gtkmm2ext / tabbable.h
1 /*
2     Copyright (C) 2015 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __gtkmm2ext_tabbable_h__
21 #define __gtkmm2ext_tabbable_h__
22
23 #include <gtkmm/bin.h>
24 #include <gtkmm/box.h>
25 #include <gtkmm/button.h>
26 #include <gtkmm/image.h>
27 #include <gtkmm/label.h>
28
29 #include "gtkmm2ext/cairo_icon.h"
30 #include "gtkmm2ext/window_proxy.h"
31 #include "gtkmm2ext/visibility.h"
32
33 namespace Gtk {
34         class Window;
35         class Notebook;
36 }
37
38 namespace Gtkmm2ext {
39
40 class VisibilityTracker;
41
42 class LIBGTKMM2EXT_API Tabbable : public WindowProxy {
43   public:
44         Tabbable (Gtk::Widget&, const std::string&);
45         ~Tabbable ();
46
47         void add_to_notebook (Gtk::Notebook& notebook, const std::string& tab_title);
48         void make_visible ();
49         void make_invisible ();
50         void attach ();
51         void detach ();
52         
53         Gtk::Widget& contents() const { return _contents; }
54         
55         Gtk::Window* get (bool create = false);
56         Gtk::Window* own_window () { return get (false); } 
57         virtual Gtk::Window* use_own_window (bool and_pack_it);
58
59         bool has_own_window () const;
60         bool is_tabbed () const;
61
62         void set_default_tabbed (bool yn);
63         
64         virtual void show_window ();
65
66         bool window_visible ();
67         bool tabbed() const;
68
69         Gtk::Window* current_toplevel () const;
70
71         Gtk::Notebook* tab_root_drop ();
72
73         int set_state (const XMLNode&, int version);
74         XMLNode& get_state ();
75         
76         static std::string xml_node_name();
77
78         sigc::signal1<void,Tabbable&> StateChange;
79         
80   protected:
81         bool delete_event_handler (GdkEventAny *ev);
82         
83   private:
84         Gtk::Widget&   _contents;
85         Gtk::Notebook  _own_notebook;
86         Gtk::Notebook* _parent_notebook;
87         std::string    _tab_title;
88         Gtk::HBox      _tab_box;
89         Gtk::Label     _tab_label;
90         Gtk::Button    _tab_close_button;
91         CairoIcon       tab_close_image;
92         bool            tab_requested_by_state;
93         
94         void show_tab ();
95         void hide_tab ();
96         void tab_close_clicked ();
97         void show_own_window (bool and_pack_it);
98         void window_mapped ();
99         void window_unmapped ();
100 };
101
102
103 }
104
105 #endif