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++ • 2.76 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
Glib::ustring get_identifier() const;
33
Gtk::Image *get_icon() const;
34
Gtk::Label *get_label();
35
void redock(DockStack *stack);
36
void pop_out();
37
Gtk::Widget *get_child() const;
38
};
39
40
class DockWindow : public Gtk::Window {
41
private:
42
DockablePane *pane;
43
public:
44
explicit DockWindow(DockablePane *pane);
45
};
46
47
class LayoutManager : public Glib::ObjectBase {
48
private:
49
public:
50
std::vector<DockablePane*> panes;
51
std::vector<DockStack*> stacks;
52
LayoutManager();
53
54
void add_pane(DockablePane *pane);
55
56
void add_stack(DockStack *stack);
57
};
58
59
class DockStack : public Gtk::Stack {
60
private:
61
public:
62
sigc::signal<void(Gtk::Widget*)> signal_child_added;
63
sigc::signal<void(Gtk::Widget*)> signal_child_removed;
64
std::shared_ptr<LayoutManager> layout;
65
Glib::ustring name;
66
explicit DockStack(std::shared_ptr<LayoutManager> layout, const Glib::ustring &name);
67
68
void add_pane(DockablePane &child);
69
void add(Gtk::Widget &child, const Glib::ustring &name);
70
void remove(Gtk::Widget &child);
71
void add(Gtk::Widget &child) = delete;
72
void add(Gtk::Widget &child, const Glib::ustring &name, const Glib::ustring &title) = delete;
73
};
74
75
class DockButton : public Gtk::Button {
76
private:
77
public:
78
DockablePane *pane;
79
explicit DockButton(DockablePane *pane);
80
};
81
82
class DockStackSwitcher : public Gtk::Box {
83
private:
84
DockStack *stack;
85
sigc::connection add_handler, remove_handler;
86
public:
87
void update_buttons();
88
explicit DockStackSwitcher(DockStack *stack, Gtk::Orientation orientation = Gtk::Orientation::HORIZONTAL);
89
~DockStackSwitcher() override;
90
};
91
} // namespace gPanthera
92
93
#endif // GPANTHERA_LIBRARY_H