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

Page detaching

roundabout,
created on Wednesday, 19 March 2025, 17:46:50 (1742406410), received on Wednesday, 19 March 2025, 17:46:53 (1742406413)
Author identity: vlad <vlad.muntoiu@gmail.com>

ab50053f3c13c802172364c5914694ac8320a734

gpanthera.cc

@@ -701,16 +701,15 @@ namespace gPanthera {

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    drag_source->signal_drag_cancel().connect([this](const Glib::RefPtr<Gdk::Drag>&, Gdk::DragCancelReason reason) {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        if(reason == Gdk::DragCancelReason::NO_TARGET) {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                            auto stack = dynamic_cast<ContentStack*>(this->page->get_stack());
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        this->set_opacity(1);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        return stack->signal_detach.emit(this->page);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        bool result = stack->signal_detach.emit(this->page);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        if(!result) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                            this->set_opacity(1);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        return result;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        }
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        this->set_opacity(1);
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        return false;
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    }, false);
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                // Pop out if dragged to an external location
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                drag_source->signal_drag_end().connect([this](const Glib::RefPtr<Gdk::Drag>&, bool) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    this->set_opacity(1);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                }, false);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                }
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                void ContentTab::update_active_style() {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        

@@ -750,9 +749,15 @@ namespace gPanthera {

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                            this->stack->remove(*this);
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        }
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    }
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                auto old_stack = this->stack;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    this->stack = stack;
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    this->last_stack = stack;
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    this->stack->add(*this);
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                if(old_stack) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    if(!old_stack->get_first_child()) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        old_stack->signal_leave_empty.emit();
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                }
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                Gtk::Widget *ContentPage::get_child() const {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        

@@ -780,4 +785,10 @@ namespace gPanthera {

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                void ContentPage::set_tab_widget(Gtk::Widget *tab_widget) {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    this->tab_widget = tab_widget;
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                }
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            ContentWindow::ContentWindow(ContentNotebook *notebook) : notebook(notebook) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                this->set_child(*notebook);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                this->set_decorated(true);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                this->set_resizable(true);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            } // namespace gPanthera
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                            
                                

gpanthera.hh

@@ -152,6 +152,7 @@ namespace gPanthera {

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    sigc::signal<bool(ContentPage*)> signal_detach;
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    std::shared_ptr<ContentManager> content_manager;
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    std::shared_ptr<Gtk::DropTarget> drop_target;
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                sigc::signal<void()> signal_leave_empty;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    explicit ContentStack(std::shared_ptr<ContentManager> content_manager);
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    void make_paned(Gtk::Orientation orientation, Gtk::PackType pack_type);
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    void add_page(ContentPage &child);
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        

@@ -180,6 +181,13 @@ namespace gPanthera {

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                public:
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    ContentNotebook(ContentStack *stack, ContentTabBar *switcher);
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                };
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            class ContentWindow : public Gtk::Window {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            private:
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                ContentNotebook *notebook;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            public:
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                ContentWindow(ContentNotebook *notebook);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            };
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            } // namespace gPanthera
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            #endif // GPANTHERA_LIBRARY_H
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                            
                                

panthera-www.cc

@@ -65,7 +65,17 @@ protected:

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    auto page_2 = Gtk::make_managed<gPanthera::ContentPage>(content_manager, content_stack, page_2_content, page_2_tab);
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    content_stack->signal_detach.connect([](gPanthera::ContentPage *widget) {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        std::cout << "Detaching " << widget->get_name() << std::endl;
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    return false;  // Widget not actually detached
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    auto new_stack = Gtk::make_managed<gPanthera::ContentStack>(widget->content_manager);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    auto new_switcher = Gtk::make_managed<gPanthera::ContentTabBar>(new_stack, Gtk::Orientation::HORIZONTAL);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    auto new_notebook = Gtk::make_managed<gPanthera::ContentNotebook>(new_stack, new_switcher);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    auto window = new gPanthera::ContentWindow(new_notebook);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    widget->redock(new_stack);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    window->present();
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    new_stack->signal_leave_empty.connect([window]() {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        window->close();
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        delete window;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    });
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    return true;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    });
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    content->set_name("content_box");
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    auto content_notebook = Gtk::make_managed<gPanthera::ContentNotebook>(content_stack, content_stack_switcher);