GTK docking interfaces and more

By using this site, you agree to have cookies stored on your device, strictly for functional purposes, such as storing your session and preferences.

Dismiss

Rename empty child to ""

roundabout,
created on Sunday, 9 March 2025, 18:47:18 (1741546038), received on Sunday, 9 March 2025, 18:47:21 (1741546041)
Author identity: vlad <vlad.muntoiu@gmail.com>

9cd29d359c5d7a555de5b9cadbf744ff7595e3e4

gpanthera.cc

@@ -68,7 +68,7 @@ namespace gPanthera {

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    auto close_action = Gio::SimpleAction::create("close");
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    close_action->signal_activate().connect([this](const Glib::VariantBase&) {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        if(this->stack) {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        this->stack->set_visible_child("empty");
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        this->stack->set_visible_child("");
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        }
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    });
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    action_group->add_action(close_action);
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        

@@ -200,15 +200,15 @@ namespace gPanthera {

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    stacks.erase(std::ranges::remove(stacks, stack).begin(), stacks.end());
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                }
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            DockStack::DockStack(std::shared_ptr<LayoutManager> layout, const Glib::ustring &name) : Gtk::Stack(), layout(layout), name(name) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                auto *empty_child = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL, 0);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                add(*empty_child, "empty");
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            DockStack::DockStack(std::shared_ptr<LayoutManager> layout, const Glib::ustring &name) : BaseStack(), layout(layout), name(name) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                auto empty_child = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL, 0);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                this->add(*empty_child, "");
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    // Add the stack to a layout manager
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    this->layout->add_stack(this);
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                // Hide the stack when the empty child is visible
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                // Hide the stack when no child is visible
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    this->property_visible_child_name().signal_changed().connect([this]() {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    if(this->get_visible_child_name() == "empty") {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    if(this->get_visible_child_name() == "") {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                            this->hide();
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        } else {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                            this->show();
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        

@@ -217,12 +217,12 @@ namespace gPanthera {

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    // Also hide when the visible child is removed
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    this->signal_child_removed.connect([this](Gtk::Widget* const &child) {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    if(this->get_visible_child_name() == "" || this->get_visible_child_name() == "empty") {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    if(this->get_visible_child_name() == "") {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                            this->hide();
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        }
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    });
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                this->set_visible_child("empty");
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                this->set_visible_child("");
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    this->hide();
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                }
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        

@@ -294,7 +294,7 @@ namespace gPanthera {

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    this->add_controller(drag_source);
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    this->signal_clicked().connect([this, pane]() {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        if(pane->get_stack()->get_visible_child_name() == pane->get_identifier()) {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        pane->get_stack()->set_visible_child("empty");
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        pane->get_stack()->set_visible_child("");
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        } else {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                            pane->get_stack()->set_visible_child(pane->get_identifier());
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        }
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        

@@ -365,7 +365,7 @@ namespace gPanthera {

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    for(auto *widget = stack->get_first_child(); widget; widget = widget->get_next_sibling()) {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        if(auto pane = dynamic_cast<DockablePane*>(widget)) {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                            auto *button = Gtk::make_managed<DockButton>(pane);
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        if(pane->get_identifier() != Glib::ustring("empty")) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        if(pane->get_identifier() != Glib::ustring("")) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                                append(*button);
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                            }
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        }
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                            
                                

gpanthera.hh

@@ -59,11 +59,15 @@ namespace gPanthera {

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    void remove_stack(DockStack *stack);
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                };
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            class DockStack : public Gtk::Stack {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            private:
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            class BaseStack : public Gtk::Stack {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                public:
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    sigc::signal<void(Gtk::Widget*)> signal_child_added;
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    sigc::signal<void(Gtk::Widget*)> signal_child_removed;
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            };
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            class DockStack : public BaseStack {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            private:
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            public:
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    std::shared_ptr<LayoutManager> layout;
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    Glib::ustring name;
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    explicit DockStack(std::shared_ptr<LayoutManager> layout, const Glib::ustring &name);