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

Add an URL entry

roundabout,
created on Tuesday, 29 April 2025, 15:06:40 (1745939200), received on Tuesday, 29 April 2025, 15:06:42 (1745939202)
Author identity: vlad <vlad.muntoiu@gmail.com>

e6d3137fad421e97621f8f7baee363b5053a0c6f

panthera-www.cc

@@ -16,6 +16,7 @@ class PantheraWww : public Gtk::Application {

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            protected:
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                std::shared_ptr<gPanthera::LayoutManager> layout_manager;
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                std::shared_ptr<gPanthera::ContentManager> content_manager;
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            Gtk::Entry *url_bar = nullptr;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                static void notify_callback(GObject *object, GParamSpec *pspec, gpointer data) {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    if(!gtk_widget_get_parent(GTK_WIDGET(object))) {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        

@@ -31,6 +32,19 @@ protected:

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    }
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                }
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            static void notify_focused_callback(GObject *object, GParamSpec *pspec, gpointer data) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                if(!gtk_widget_get_parent(GTK_WIDGET(object))) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    return;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                auto this_ = static_cast<PantheraWww*>(data);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                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, "uri") == 0) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        this_->url_bar->set_text(webkit_web_view_get_uri(WEBKIT_WEB_VIEW(object)));
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                void on_new_tab(gPanthera::ContentStack *stack) {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    if(!stack) {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        // Find the current area
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        

@@ -137,6 +151,41 @@ protected:

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    inner_paned->set_end_child(*dock_stack_1);
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    outer_paned->set_end_child(*inner_paned);
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    outer_grid->attach(*outer_paned, 1, 1, 1, 1);
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                auto main_toolbar = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::HORIZONTAL, 8);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                url_bar = Gtk::make_managed<Gtk::Entry>();
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                url_bar->set_placeholder_text("Enter URL");
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                url_bar->set_hexpand(true);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                auto go_button = Gtk::make_managed<Gtk::Button>("Go");
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                main_toolbar->append(*url_bar);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                main_toolbar->append(*go_button);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                outer_grid->attach(*main_toolbar, 0, 0, 2, 1);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                auto load_url_callback = [this]() {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    auto page = content_manager->get_last_operated_page();
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    if(page) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        if(auto webview = WEBKIT_WEB_VIEW(page->get_child()->get_first_child()->gobj())) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                            webkit_web_view_load_uri(webview, url_bar->get_text().c_str());
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                };
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                go_button->signal_clicked().connect(load_url_callback);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                url_bar->signal_activate().connect(load_url_callback);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                content_manager->signal_page_operated.connect([this](gPanthera::ContentPage *page) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    if(!page->get_child()) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        return;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    if(!page->get_child()->get_first_child()) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        return;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    url_bar->set_text(webkit_web_view_get_uri(WEBKIT_WEB_VIEW(page->get_child()->get_first_child()->gobj())));
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    guint url_update_handler = g_signal_connect(page->get_child()->get_first_child()->gobj(), "notify", G_CALLBACK(notify_focused_callback), this);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    std::shared_ptr<sigc::connection> control_signal_handler = std::make_shared<sigc::connection>();
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    *control_signal_handler = page->signal_control_status_changed.connect([this, page, control_signal_handler, url_update_handler](bool controlled) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        if(!controlled) {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                            control_signal_handler->disconnect();
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                            g_signal_handler_disconnect(page->get_child()->get_first_child()->gobj(), url_update_handler);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    });
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                });
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    window->set_child(*outer_grid);
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    debug_button->signal_clicked().connect([this]() {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        if(content_manager->get_last_operated_page()) {