roundabout,
created on Tuesday, 4 March 2025, 17:49:14 (1741110554),
received on Tuesday, 4 March 2025, 17:49:17 (1741110557)
Author identity: vlad <vlad.muntoiu@gmail.com>
7a48e24902663cb13254c528039800ace7e6d707
gpanthera.cc
@@ -110,6 +110,10 @@ namespace gPanthera {
this->append(child);
}
Gtk::Stack *DockablePane::get_stack() const {
return stack;
}
void DockablePane::redock(DockStack *stack) {
if(this->window != nullptr) {
this->window->hide();
@@ -216,6 +220,7 @@ namespace gPanthera {
};
stack->signal_child_added.connect(update_callback);
stack->signal_child_removed.connect(update_callback);
this->get_style_context()->add_class("gpanthera-dock-switcher");
}
DockStackSwitcher::~DockStackSwitcher() {
@@ -232,17 +237,21 @@ namespace gPanthera {
this->set_valign(Gtk::Align::CENTER);
this->get_style_context()->add_class("toggle");
this->get_style_context()->add_class("gpanthera-dock-button");
this->pane->last_stack->property_visible_child_name().signal_changed().connect([this]() {
if(this->pane->last_stack->get_visible_child_name() == this->pane->get_identifier()) {
this->get_style_context()->add_class("checked");
this->get_style_context()->add_class("gpanthera-dock-button-active");
active_style_handler = this->pane->get_stack()->property_visible_child_name().signal_changed().connect([this]() {
if(this->pane->get_stack()->get_visible_child_name() == this->pane->get_identifier()) {
this->add_css_class("checked");
this->add_css_class("gpanthera-dock-button-active");
} else {
this->get_style_context()->remove_class("checked");
this->get_style_context()->remove_class("gpanthera-dock-button-active");
this->remove_css_class("checked");
this->remove_css_class("gpanthera-dock-button-active");
}
});
}
DockButton::~DockButton() {
active_style_handler.disconnect();
}
void DockStackSwitcher::update_buttons() {
auto old_buttons = collect_children(*this);
for(auto *button : old_buttons) {
gpanthera.hh
@@ -29,6 +29,7 @@ namespace gPanthera {
public:
DockStack *last_stack = nullptr;
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);
Gtk::Stack *get_stack() const;
Glib::ustring get_identifier() const;
Gtk::Image *get_icon() const;
Gtk::Label *get_label();
@@ -74,9 +75,11 @@ namespace gPanthera {
class DockButton : public Gtk::Button {
private:
sigc::connection active_style_handler;
public:
DockablePane *pane;
explicit DockButton(DockablePane *pane);
~DockButton();
};
class DockStackSwitcher : public Gtk::Box {
panthera-www.cc
@@ -40,15 +40,15 @@ protected:
dock_stack_2->set_expand(true);
auto outer_grid = Gtk::make_managed<Gtk::Grid>();
outer_grid->attach(*switcher_1, 0, 1, 1, 1);
outer_grid->attach(*switcher_2, 1, 2, 1, 1);
outer_grid->attach(*switcher_2, 0, 1, 1, 1);
outer_grid->attach(*switcher_1, 1, 2, 1, 1);
auto outer_paned = Gtk::make_managed<Gtk::Paned>(Gtk::Orientation::HORIZONTAL);
outer_paned->set_start_child(*dock_stack_1);
outer_paned->set_start_child(*dock_stack_2);
auto inner_paned = Gtk::make_managed<Gtk::Paned>(Gtk::Orientation::VERTICAL);
auto content = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL, 0);
content->append(*Gtk::make_managed<Gtk::Label>("Main content"));
inner_paned->set_start_child(*content);
inner_paned->set_end_child(*dock_stack_2);
inner_paned->set_end_child(*dock_stack_1);
outer_paned->set_end_child(*inner_paned);
outer_grid->attach(*outer_paned, 1, 1, 1, 1);
window->set_child(*outer_grid);