GTK docking interfaces and more

Important information: Google announced that, from September 2026, Android devices will require ALL apps to be signed by Google, effectively leading to an iOS situation. Value your right to a computer that does what you want; do not tolerate this monopolistic practice! Contact me if you don't understand why it is bad. Click to learn more.

 gpanthera.hh

View raw Download
text/x-c++ • 3.23 kiB
C++ source, ASCII text
        
            
1
#ifndef GPANTHERA_LIBRARY_H
2
#define GPANTHERA_LIBRARY_H
3
4
#include <gtkmm.h>
5
#include <glibmm.h>
6
#include <glibmm/ustring.h>
7
#include <utility>
8
#include <vector>
9
#include <memory>
10
11
namespace gPanthera {
12
void init();
13
14
class DockStack;
15
class DockWindow;
16
class LayoutManager;
17
18
class DockablePane : public Gtk::Box {
19
private:
20
Gtk::Label label;
21
Glib::ustring name;
22
Gtk::Image *icon;
23
DockStack *stack;
24
DockWindow *window = nullptr;
25
std::unique_ptr<Gtk::HeaderBar> header;
26
Gtk::Widget *child;
27
std::shared_ptr<LayoutManager> layout;
28
Glib::RefPtr<Gio::SimpleActionGroup> action_group;
29
public:
30
DockStack *last_stack = nullptr;
31
DockablePane(std::shared_ptr<LayoutManager> layout, Gtk::Widget &child, const Glib::ustring &name, const Glib::ustring &label, Gtk::Image *icon, DockStack *stack = nullptr, Gtk::Widget *custom_header = nullptr);
32
Gtk::Stack *get_stack() const;
33
Glib::ustring get_identifier() const;
34
Gtk::Image *get_icon() const;
35
Gtk::Label *get_label();
36
void redock(DockStack *stack);
37
void pop_out();
38
Gtk::Widget *get_child() const;
39
};
40
41
class DockWindow : public Gtk::Window {
42
private:
43
DockablePane *pane;
44
public:
45
explicit DockWindow(DockablePane *pane);
46
};
47
48
class LayoutManager : public Glib::ObjectBase {
49
private:
50
public:
51
std::vector<DockablePane*> panes;
52
std::vector<DockStack*> stacks;
53
LayoutManager();
54
55
void add_pane(DockablePane *pane);
56
57
void add_stack(DockStack *stack);
58
void remove_pane(DockablePane *pane);
59
void remove_stack(DockStack *stack);
60
};
61
62
class BaseStack : public Gtk::Stack {
63
public:
64
sigc::signal<void(Gtk::Widget*)> signal_child_added;
65
sigc::signal<void(Gtk::Widget*)> signal_child_removed;
66
};
67
68
class DockStack : public BaseStack {
69
private:
70
public:
71
std::shared_ptr<LayoutManager> layout;
72
Glib::ustring name;
73
explicit DockStack(std::shared_ptr<LayoutManager> layout, const Glib::ustring &name);
74
75
void add_pane(DockablePane &child);
76
void add(Gtk::Widget &child, const Glib::ustring &name);
77
void remove(Gtk::Widget &child);
78
void add(Gtk::Widget &child) = delete;
79
void add(Gtk::Widget &child, const Glib::ustring &name, const Glib::ustring &title) = delete;
80
};
81
82
class DockButton : public Gtk::Button {
83
private:
84
sigc::connection active_style_handler;
85
std::shared_ptr<Gtk::DragSource> drag_source;
86
Glib::Value<Gtk::Widget*> value;
87
void update_active_style();
88
public:
89
DockablePane *pane;
90
explicit DockButton(DockablePane *pane);
91
~DockButton();
92
};
93
94
class DockStackSwitcher : public Gtk::Box {
95
private:
96
DockStack *stack;
97
sigc::connection add_handler, remove_handler;
98
std::shared_ptr<Gtk::DropTarget> drop_target;
99
public:
100
void update_buttons();
101
explicit DockStackSwitcher(DockStack *stack, Gtk::Orientation orientation = Gtk::Orientation::HORIZONTAL);
102
DockStack *get_stack() const;
103
~DockStackSwitcher() override;
104
};
105
} // namespace gPanthera
106
107
#endif // GPANTHERA_LIBRARY_H