roundabout,
created on Thursday, 22 May 2025, 19:23:34 (1747941814),
received on Thursday, 22 May 2025, 19:23:37 (1747941817)
Author identity: vlad <vlad.muntoiu@gmail.com>
ad3f5f8b01bcea8bef970b10b36923686e528784
panthera-www.cc
@@ -137,11 +137,17 @@ protected:
return false;
}
void on_new_tab(gPanthera::ContentStack *stack, const Glib::ustring &url = "about:blank", bool focus = true, bool new_window = false) {
std::string new_tab_page;
void on_new_tab(gPanthera::ContentStack *stack, const Glib::ustring &url = "", bool focus = true, bool new_window = false) {
if(!stack) {
// Find the current area
stack = content_manager->get_last_operated_page()->get_stack();
}
Glib::ustring url_ = url;
if(url.empty()) {
url_ = new_tab_page;
}
WebKitWebView *webview = WEBKIT_WEB_VIEW(webkit_web_view_new());
gtk_widget_set_hexpand(GTK_WIDGET(webview), true);
@@ -157,7 +163,7 @@ protected:
auto page = Gtk::make_managed<gPanthera::ContentPage>(content_manager, stack, page_content, page_tab);
g_signal_connect(webview, "notify", G_CALLBACK(notify_callback), page->gobj());
g_signal_connect(webview, "decide-policy", G_CALLBACK(on_decide_policy), this);
webkit_web_view_load_uri(webview, url.data());
webkit_web_view_load_uri(webview, url_.data());
auto cookie_manager = webkit_network_session_get_cookie_manager(webkit_web_view_get_network_session(webview));
webkit_cookie_manager_set_persistent_storage(cookie_manager, cookie_file.c_str(), WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT);
webkit_cookie_manager_set_accept_policy(cookie_manager, WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS);
@@ -441,6 +447,25 @@ protected:
add_action(close_tab_action);
set_accels_for_action("app.close_tab", {"<Primary>W"});
// Load settings
new_tab_page = "about:blank";
std::ifstream settings_file_in("settings.json");
if(settings_file_in) {
std::string settings_json((std::istreambuf_iterator<char>(settings_file_in)), std::istreambuf_iterator<char>());
settings_file_in.close();
auto json = nlohmann::json::parse(settings_json);
if(json.contains("ntp")) {
new_tab_page = json["ntp"].get<std::string>();
}
} else {
settings_file_in.close();
auto empty_json = nlohmann::json::object();
empty_json["ntp"] = "about:blank";
std::ofstream settings_file_out("settings.json");
settings_file_out << empty_json.dump(4);
settings_file_out.close();
}
// Load plugins
std::ifstream plugin_file_in("plugins.json");
if(plugin_file_in) {