GTK docking interfaces

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

Shortcuts and bug fixes

roundabout,
created on Friday, 25 April 2025, 12:11:18 (1745583078), received on Friday, 25 April 2025, 12:11:24 (1745583084)
Author identity: vlad <vlad.muntoiu@gmail.com>

a23d1282a96e911cd0f497e78799ff43c3614c62

gpanthera.cc

@@ -633,10 +633,7 @@ namespace gPanthera {

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    drop_target->signal_drop().connect([this](const Glib::ValueBase &value, double x, double y) {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        if(const auto &widget = static_cast<const Glib::Value<ContentPage*>&>(value).get()) {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                            if(auto page = dynamic_cast<ContentPage*>(widget)) {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                            if(page->get_parent() == this->stack) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                this->stack->remove(*page);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                            }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                            this->stack->add(*page);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                            this->stack->add_page(*page);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                            }
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        }
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        

@@ -920,15 +917,19 @@ namespace gPanthera {

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                }
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                void ContentTab::close() {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                if(!this->page->signal_close.emit()) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    if(this->page->get_next_sibling()) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        this->page->content_manager->set_last_operated_page(static_cast<ContentPage*>(this->page->get_next_sibling()));
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        this->page->get_stack()->set_visible_child(*this->page->get_next_sibling());
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    } else if(this->page->get_prev_sibling()) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        this->page->content_manager->set_last_operated_page(static_cast<ContentPage*>(this->page->get_prev_sibling()));
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        this->page->get_stack()->set_visible_child(*this->page->get_prev_sibling());
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                page->close();
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            void ContentPage::close() {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                if(!this->signal_close.emit()) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    if(this->get_next_sibling()) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        this->content_manager->set_last_operated_page(static_cast<ContentPage*>(this->get_next_sibling()));
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        this->get_stack()->set_visible_child(*this->get_next_sibling());
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    } else if(this->get_prev_sibling()) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        this->content_manager->set_last_operated_page(static_cast<ContentPage*>(this->get_prev_sibling()));
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        this->get_stack()->set_visible_child(*this->get_prev_sibling());
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        }
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    this->page->redock(nullptr);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    this->redock(nullptr);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    }
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                }
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                            
                                

gpanthera.hh

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

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    ContentStack *last_stack = nullptr;
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    ContentPage(std::shared_ptr<ContentManager> content_manager, ContentStack *stack, Gtk::Widget *child, Gtk::Widget *tab_widget);
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    sigc::signal<bool()> signal_close;
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                void close();
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    Gtk::Widget *get_tab_widget() const;
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    void redock(ContentStack *stack);
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    void set_tab_widget(Gtk::Widget *tab_widget);
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                            
                                

panthera-www.cc

@@ -18,6 +18,9 @@ protected:

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                std::shared_ptr<gPanthera::ContentManager> content_manager;
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                static void notify_callback(GObject *object, GParamSpec *pspec, gpointer data) {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                if(!gtk_widget_get_parent(GTK_WIDGET(object))) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    return;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    auto parent = gtk_widget_get_parent(gtk_widget_get_parent(GTK_WIDGET(object)));
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    if(auto page = dynamic_cast<gPanthera::ContentPage*>(Glib::wrap(parent))) {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        if(g_strcmp0(pspec->name, "title") == 0) {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        

@@ -44,6 +47,8 @@ protected:

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    g_signal_connect(webview, "notify", G_CALLBACK(notify_callback), page->gobj());
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    webkit_web_view_load_uri(webview, "about:blank");
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    stack->add_page(*page);
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                stack->set_visible_child(*page);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                content_manager->set_last_operated_page(page);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                }
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                void on_startup() override {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        

@@ -134,7 +139,11 @@ protected:

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    outer_grid->attach(*outer_paned, 1, 1, 1, 1);
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    window->set_child(*outer_grid);
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    debug_button->signal_clicked().connect([this]() {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    std::cout << "Last operated page: " << content_manager->get_last_operated_page()->get_name() << std::endl;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    if(content_manager->get_last_operated_page()) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        std::cout << "Last operated page: " << content_manager->get_last_operated_page()->get_name() << std::endl;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    } else {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        std::cout << "No page operated!" << std::endl;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    });
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    // TODO: Use the last operated page and allow opening tabs next to the last operated page using certain panes
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    // Load the existing layout, if it exists
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        

@@ -162,6 +171,22 @@ protected:

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        layout_file_out.close();
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        std::cout << "Layout changed: " << layout_manager->get_layout_as_json() << std::endl;
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    });
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                auto new_tab_action = Gio::SimpleAction::create("new_tab");
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                new_tab_action->signal_activate().connect([this](const Glib::VariantBase&) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    on_new_tab(nullptr);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                });
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                add_action(new_tab_action);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                set_accels_for_action("app.new_tab", {"<Primary>T"});
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                auto close_tab_action = Gio::SimpleAction::create("close_tab");
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                close_tab_action->signal_activate().connect([this](const Glib::VariantBase&) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    auto page = content_manager->get_last_operated_page();
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    if(page) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        page->close();
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                });
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                add_action(close_tab_action);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                set_accels_for_action("app.close_tab", {"<Primary>W"});
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                }
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                void on_activate() override {