aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArslaan Pathan <[email protected]>2026-04-05 23:17:23 +1200
committerArslaan Pathan <[email protected]>2026-04-05 23:17:23 +1200
commit0a959b0924d9e48e3b1cc59b681eec06f06ce0b4 (patch)
tree89348ccbeb01bc8f601520c637c474f8069d3822
parent3ab659c927d1284595e870e34377c834c5fd838c (diff)
downloadcinnamon-browser-0a959b0924d9e48e3b1cc59b681eec06f06ce0b4.tar.xz
cinnamon-browser-0a959b0924d9e48e3b1cc59b681eec06f06ce0b4.zip
Make the useragent actually work by actually SETTING THE FIELD and add persistent session storage
-rw-r--r--config.def.h1
-rw-r--r--main.c9
2 files changed, 9 insertions, 1 deletions
diff --git a/config.def.h b/config.def.h
index ce526bb..c69eb9f 100644
--- a/config.def.h
+++ b/config.def.h
@@ -27,6 +27,7 @@ extern void set_mode(Cinnamon* cinnamon, int new_mode);
#define NO_QUIT_ON_CLOSE_LAST_TAB
/* hide the tab bar, unless a keybind or command shows it */
#define HIDE_TAB_BAR
+#define USERAGENT "Mozilla/5.0 (X11; Linux aarch64) AppleWebKit/605.1.15 (KHTML, like Gecko) cinnamon/1.0 (git.arslaancodes.com/cinnamon-browser.git) Safari/605.1.15"
/* Keybind definitions */
/* we use the _kbd prefix here just because, idk, good practice to keep keybinds isolated? in practice use whatever the hell you want as long as it doesnt interfere with builtin functions */
diff --git a/main.c b/main.c
index c8268ee..8bc8246 100644
--- a/main.c
+++ b/main.c
@@ -11,6 +11,7 @@ typedef struct {
GtkWidget *notebook;
GtkWidget *cmdbar;
GtkWidget *indicator;
+ WebKitWebContext *web_context;
} Cinnamon;
typedef struct {
@@ -142,7 +143,7 @@ void set_mode(Cinnamon* cinnamon, int new_mode) {
}
void tabopen(Cinnamon* cinnamon) {
- GtkWidget *webview = webkit_web_view_new();
+ GtkWidget *webview = webkit_web_view_new_with_context(cinnamon->web_context);
gtk_notebook_append_page(GTK_NOTEBOOK(cinnamon->notebook), webview, gtk_label_new("New Tab"));
g_signal_connect(webview, "notify::title", G_CALLBACK(on_title_changed), cinnamon->notebook);
/* HOMEPAGE and USERAGENT defined in config.h */
@@ -190,6 +191,12 @@ int main(int argc, char *argv[]) {
// gtk_container_add(GTK_CONTAINER(cinnamon.window), cinnamon.notebook);
gtk_box_pack_start(GTK_BOX(vbox), cinnamon.notebook, TRUE, TRUE, 0);
+ /* initialize web context to save cookies */
+ WebKitWebsiteDataManager *data_manager = webkit_website_data_manager_new("base-data-directory", g_build_filename(g_get_user_data_dir(), "cinnamon", NULL),"base-cache-directory", g_build_filename(g_get_user_cache_dir(), "cinnamon", NULL), NULL);
+ cinnamon.web_context = webkit_web_context_new_with_website_data_manager(data_manager);
+ WebKitCookieManager *cookie_manager = webkit_web_context_get_cookie_manager(cinnamon.web_context);
+ webkit_cookie_manager_set_persistent_storage(cookie_manager, g_build_filename(g_get_user_data_dir(), "cinnamon", "cookies.sqlite", NULL), WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE);
+
/* Create initial tab */
tabopen(&cinnamon);