remove GTK3

This commit is contained in:
NunoSempere 2025-11-24 13:17:54 -03:00
parent 8eea7b1372
commit fbaf8cd9ca
82 changed files with 65 additions and 747 deletions

2
.gitignore vendored
View File

@ -1,3 +1,3 @@
rosenrot
# don't save the binary file, as it doesn't play nicely with https://difftastic.wilfred.me.uk # don't save the binary file, as it doesn't play nicely with https://difftastic.wilfred.me.uk
webkit/ webkit/
out/

View File

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2022-2024 Nuño Sempere Copyright (c) 2022-2025 Nuño Sempere
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -1,6 +1,6 @@
# Rosenrot # Rosenrot
Rosenrot is a small browser forked from an earlier version of [rose](https://github.com/mini-rose/rose). It has some additional quality of life improvements tailored to my (@NunoSempere) tastes and setup, and detailed installation instructions for Debian 12. Because of the ease of hackability, the minimalism, the unobstrusiveness, it gives me a more comfortable way of navigating the web than normal browsers. Rosenrot is a small browser based on webkitgtk6/gtk4. Because of the ease of hackability, the minimalism, the unobstrusiveness, it gives me a more comfortable way of navigating the web than normal browsers.
![](https://raw.githubusercontent.com/NunoSempere/rosenrot-browser/master/images/3-init.png) ![](https://raw.githubusercontent.com/NunoSempere/rosenrot-browser/master/images/3-init.png)
@ -15,7 +15,7 @@ You can see detailed instructions [here](./user-scripts/debian-12/), for Debian
The general steps are to install dependencies, and then The general steps are to install dependencies, and then
``` ```
make build # by default using webkitgtk6/gtk4; see also build3 make build
make install # or sudo make install make install # or sudo make install
rose rose
``` ```
@ -44,7 +44,7 @@ You can also create a rose.desktop file so that it will show up in your desktop
- Custom style: Override the css of predetermined websites - Custom style: Override the css of predetermined websites
- Max number of tabs (by default 8), configurable. - Max number of tabs (by default 8), configurable.
- Stand in plugin: Mimick function definitions which do nothing for the above plugins so that they can be quickly removed - Stand in plugin: Mimick function definitions which do nothing for the above plugins so that they can be quickly removed
- For now, both GTK3 and GTK4-based versions—eventually only the GTK4 version will remain - Fully GTK4 based, but see the git history for the GTK3 version as well.
You can see some screenshots in the [images](./images) folder. You can see some screenshots in the [images](./images) folder.
@ -67,14 +67,14 @@ Here are projects with their own rendering engines which could appeal to users o
- [lynx](https://lynx.invisible-island.net/) (links, elinks), [w3m](https://w3m.sourceforge.net/): command line browsers. - [lynx](https://lynx.invisible-island.net/) (links, elinks), [w3m](https://w3m.sourceforge.net/): command line browsers.
- [dillo](https://github.com/dillo-browser/dillo/). Has its own rendering engine, and no javascript. - [dillo](https://github.com/dillo-browser/dillo/). Has its own rendering engine, and no javascript.
- [Ladybird](https://github.com/LadybirdBrowser/ladybird). Initially from the InitialSerenityOS, it later became its own project. Uses its own html and javascript engine. Compiling it on a mainstream linux distribution is now doable. - [Ladybird](https://github.com/LadybirdBrowser/ladybird). Initially from the SerenityOS, it later became its own project. Uses its own html and javascript engine. Compiling it on a mainstream linux distribution is now doable.
- [servo](https://github.com/servo/servo). Firefox/Mozilla. An in-development browser engine written in Rust, meant to replace Gecko. Could be extremely cool once it is ready, but it has been many years in development. - [servo](https://github.com/servo/servo). Firefox/Mozilla. An in-development browser engine written in Rust, meant to replace Gecko. Could be extremely cool once it is ready, but it has been many years in development.
### Relationship with [rose](https://github.com/mini-rose/rose) ### Relationship with [rose](https://github.com/mini-rose/rose)
- Rose is a small browser based on webkit2gtk. Previously, it described itself as aiming to be a "basement for creating your own browser using [the] gtk and webkit libraries". It has since diverged into a more featureful small browser with lua bindings, and rebased its history. You can see the original, minimal version [here](https://github.com/NunoSempere/rosenrot-browser/blob/a45d1c70f58586fed97df70650e5d066b73d0a0d/rose.c). - Rose is a small browser based on webkit2gtk. Previously, it described itself as aiming to be a "basement for creating your own browser using [the] gtk and webkit libraries". It has since diverged into a more featureful small browser with lua bindings, and rebased its history. You can see the original, minimal version [here](https://github.com/NunoSempere/rosenrot-browser/blob/a45d1c70f58586fed97df70650e5d066b73d0a0d/rose.c).
- Rosenrot is my (@NunoSempere's) fork from that earlier minimal rose, the GTK 3 version. It has accumulated quality of life features and, honestly, cruft, that I like, like a "readability" plugin that simplifies annoying websites like [Matt Levine's Money Stuff newsletter](https://www.bloomberg.com/opinion/articles/2022-10-18/matt-levine-s-money-stuff-credit-suisse-was-a-reverse-meme-stock). It also incorporates ad-blocking. - Rosenrot is my (@NunoSempere's) fork from that earlier minimal rose, the GTK 3 version. It has accumulated quality of life features and, honestly, cruft, that I like, like a "readability" plugin that simplifies annoying websites like [Matt Levine's Money Stuff newsletter](https://www.bloomberg.com/opinion/articles/2022-10-18/matt-levine-s-money-stuff-credit-suisse-was-a-reverse-meme-stock). It also incorporates ad-blocking.
- rose updated to allow compilation with an up-to-date version of webkit on both GTK3 and GTK4 earlier, though rosenrot now offers this as well. - rose updated to allow compilation with an up-to-date version of webkit, and rosenrot now uses GTK4 and WebKitGTK 6.0.
- Rosenrot is also a song by the German hardcore rock band [Rammstein](https://www.youtube.com/watch?v=af59U2BRRAU). - Rosenrot is also a song by the German hardcore rock band [Rammstein](https://www.youtube.com/watch?v=af59U2BRRAU).
### Comparison with [surf](https://git.suckless.org/surf/file/surf.c.html) ### Comparison with [surf](https://git.suckless.org/surf/file/surf.c.html)
@ -86,7 +86,7 @@ Here are projects with their own rendering engines which could appeal to users o
- Anecdotically, surf feels slower, though I haven't tested this rigorously. - Anecdotically, surf feels slower, though I haven't tested this rigorously.
- surf has a larger community, with patches and modifications. - surf has a larger community, with patches and modifications.
- surf is more opinionated, but also less amateurish. - surf is more opinionated, but also less amateurish.
- Like rosenrot until not so long ago, it [uses](https://git.suckless.org/surf/file/config.mk.html#l15) an obsolete & deprecated version of [webkit](https://blogs.gnome.org/mcatanzaro/2023/03/21/webkitgtk-api-for-gtk-4-is-now-stable/) (2.40, with GTK3) - It [uses](https://git.suckless.org/surf/file/config.mk.html#l15) an obsolete & deprecated version of [webkit](https://blogs.gnome.org/mcatanzaro/2023/03/21/webkitgtk-api-for-gtk-4-is-now-stable/) (2.40, with GTK3)
- My recommendation would be to use rosenrot, and if you find some feature missing, either look how surf does it and import it to rose, or move to surf. But then again, I've built rosenrot to cater to my own tastes, so I'd say that. - My recommendation would be to use rosenrot, and if you find some feature missing, either look how surf does it and import it to rose, or move to surf. But then again, I've built rosenrot to cater to my own tastes, so I'd say that.
## Folk wisdom ## Folk wisdom
@ -95,21 +95,17 @@ Of general interest:
- I just found out that you can inspect a GTK application with the GTK explorer if you set a certain command-line variable. Try this with `make inspect`. - I just found out that you can inspect a GTK application with the GTK explorer if you set a certain command-line variable. Try this with `make inspect`.
- Static variables keep their value between invocations. - Static variables keep their value between invocations.
- By default the searchbar is pretty gigantic. I've made this so because I'm a bit myopic, but also work with my laptop in a laptop stand. Anyways, if you are a more normal person you can change this in the style/style-gtk4.css style/style-gtk3.css files. - By default the searchbar is pretty gigantic. I've made this so because I'm a bit myopic, but also work with my laptop in a laptop stand. Anyways, if you are a more normal person you can change this in the styles-gtk/style-gtk4.css file.
- The gtk style usage isn't updated until installation. This is because by default rose uses the theme located in /opt/rosenrot/style-gtk3/4.css, and that file isn't updated until make install. - The gtk style usage isn't updated until installation. This is because by default rosenrot uses the theme located in /opt/rosenrot/style-gtk4.css, and that file isn't updated until make install.
- The [min](https://git.nunosempere.com/open.source/rosenrot/src/branch/min) branch contains a minimalistic version of rosenrot, in one c file with 320 lines (256 without comments and extra newlines). It might be of interest to developers and those seeking to understand the code. - The [min](https://git.nunosempere.com/open.source/rosenrot/src/branch/min) branch contains a minimalistic version of rosenrot, in one c file with 320 lines (256 without comments and extra newlines). It might be of interest to developers and those seeking to understand the code.
The "architecture" of the application looks as follows: The "architecture" of the application looks as follows:
![](https://raw.githubusercontent.com/NunoSempere/rosenrot-browser/master/images/0-architecture.png) ![](https://raw.githubusercontent.com/NunoSempere/rosenrot-browser/master/images/0-architecture.png)
### webkit2gtk-4.0 vs webkit2gtk-4.1 vs webkit2gtk-6.0 ### WebKitGTK and GTK4
See [this blog post](https://blogs.gnome.org/mcatanzaro/2023/03/21/webkitgtk-api-for-gtk-4-is-now-stable/) for details. webkit2gtk-4.0 is deprecated, webkit2gtk-4.1 is the current [stable](https://webkitgtk.org/reference/webkit2gtk/stable/index.html) release and uses GTK3. webkit2gtk-6.0 is the current [unstable](https://webkitgtk.org/reference/webkitgtk/unstable/index.html) release, and uses GTK4. Rosenrot uses webkit2gtk-6.0 and GTK4. See [this blog post](https://blogs.gnome.org/mcatanzaro/2023/03/21/webkitgtk-api-for-gtk-4-is-now-stable/) for details about WebKitGTK versions. Migration instructions for webkit2gtk-6 and GTK4 can be seen [here](https://github.com/WebKit/WebKit/blob/ed1422596dce5ff012e64a38faf402ac1674fc7e/Source/WebKit/gtk/migrating-to-webkitgtk-6.0.md) and [here](https://docs.gtk.org/gtk4/migrating-3to4.html).
Migration instructions for migration to webkit2gtk-6 and GTK4 can be seen [here](https://github.com/WebKit/WebKit/blob/ed1422596dce5ff012e64a38faf402ac1674fc7e/Source/WebKit/gtk/migrating-to-webkitgtk-6.0.md) and [here](https://docs.gtk.org/gtk4/migrating-3to4.html).
Rosenrot currently supports both the stable webkit2gtk-4.1/GTK3 release, and a newer release using webkit2gtk-6.0/GTK4. Eventually the later will become the only version. Readers might want to look through the history to see a bit about the updating process; commits related to the transition are tagged with the "GTK4: " label.
### Ubuntu 20.04 ### Ubuntu 20.04

View File

@ -1,7 +1,7 @@
# To do # To do
- [ ] Look into improving speed and performance: - [ ] Look into improving speed and performance:
- [ ] Creating objects only once, e.g., for js strings that I execte - [x] Creating objects only once, e.g., for js strings that I execte
- [ ] Look into using global controllers, rather than one for each webview - [ ] Look into using global controllers, rather than one for each webview
- [ ] etc. - [ ] etc.
- [ ] Move to a later C standard (C11?) and use safer string handling functions provided by it. - [ ] Move to a later C standard (C11?) and use safer string handling functions provided by it.
@ -12,8 +12,8 @@
- [ ] This time, use something other than Whatsapp as an example syslink. - [ ] This time, use something other than Whatsapp as an example syslink.
- [ ] Fix bug about distorted audio. Maybe related to [this pipewire issue](<https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1547>)? - [ ] Fix bug about distorted audio. Maybe related to [this pipewire issue](<https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1547>)?
- See whether it even exists at all - See whether it even exists at all
- [ ] Finish cleaning up GTK4 version - [x] Finish cleaning up GTK4 version
- [ ] Think about best way of having GTK4 version alongside - [-] Think about best way of having GTK4 version alongside
- [ ] Shortcut to resize window - [ ] Shortcut to resize window
# Previously done # Previously done

View File

@ -8,25 +8,19 @@ DEBUG=-g
STD=-std=c99 # maybe consider moving to c11 and using safer string handling STD=-std=c99 # maybe consider moving to c11 and using safer string handling
SECURITY=-fstack-protector-strong # detect stack buffer overflows at runtime SECURITY=-fstack-protector-strong # detect stack buffer overflows at runtime
# Dependencies for WebkitGTK4/GTK3
SRC_3=rosenrot3.c
DEPS_3='webkit2gtk-4.1'
INCS_3=`pkg-config --cflags ${DEPS_3}`
LIBS_3=`pkg-config --libs ${DEPS_3}`
# Dependencies for WebkitGTK6/GTK4 # Dependencies for WebkitGTK6/GTK4
SRC_4=rosenrot4.c SRC=src/rosenrot.c
DEPS_4='webkitgtk-6.0' DEPS='webkitgtk-6.0'
INCS_4=`pkg-config --cflags ${DEPS_4}` `pkg-config --cflags gtk4` INCS=`pkg-config --cflags ${DEPS}` `pkg-config --cflags gtk4`
LIBS_4=`pkg-config --libs ${DEPS_4}` `pkg-config --libs gtk4` LIBS=`pkg-config --libs ${DEPS}` `pkg-config --libs gtk4`
DEPRECATION_FLAGS=-DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED DEPRECATION_FLAGS=-DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED
# User config # User config
CONFIG=config.h CONFIG=src/config.h
# Plugins # Plugins
include plugins/plugins.mk include src/plugins/plugins.mk
# PLUGINS=./plugins/stand_in/stand_in.c # PLUGINS=./src/plugins/stand_in/stand_in.c
ADBLOCK='-L/usr/lib/wyebrowser/adblock.so' # optional adblocking; depends on https://github.com/jun7/wyebadblock ADBLOCK='-L/usr/lib/wyebrowser/adblock.so' # optional adblocking; depends on https://github.com/jun7/wyebadblock
## Formatter ## Formatter
@ -39,42 +33,35 @@ MAINTAINER_CACHE_DIR=/home/nuno/.cache/rosenrot
USER_CACHE_DIR=/home/`whoami`/.cache/rosenrot USER_CACHE_DIR=/home/`whoami`/.cache/rosenrot
RUNTIME_FILES_DIR=/opt/rosenrot/ RUNTIME_FILES_DIR=/opt/rosenrot/
build: $(SRC_4) $(PLUGINS) $(CONFIG) constants user_cache build: $(SRC) $(PLUGINS) $(CONFIG) constants user_cache
$(CC) $(STD) $(WARNINGS) $(SECURITY) $(DEPRECATION_FLAGS) $(OPTIMIZED_MORE) $(DEBUG) $(INCS_4) $(PLUGINS) $(SRC_4) -o rosenrot $(LIBS_4) $(ADBLOCK) $(CC) $(STD) $(WARNINGS) $(SECURITY) $(DEPRECATION_FLAGS) $(OPTIMIZED_MORE) $(DEBUG) $(INCS) $(PLUGINS) $(SRC) -o out/rosenrot $(LIBS) $(ADBLOCK)
@echo @echo
build3: $(SRC_3) $(PLUGINS) $(CONFIG) constants user_cache format: $(SRC) $(PLUGINS)
$(CC) $(STD) $(WARNINGS) $(SECURITY) $(OPTIMIZED_MORE) $(DEBUG) $(INCS_3) $(PLUGINS) $(SRC_3) -o rosenrot $(LIBS_3) $(ADBLOCK) $(FORMATTER_C) $(SRC) $(PLUGINS) $(CONFIG)
@echo $(FORMATTER_JS) src/plugins/readability/readability.js
$(FORMATTER_JS) src/plugins/style/style.js
format: $(SRC_3) $(SRC_4) $(PLUGINS)
$(FORMATTER_C) $(SRC_3) $(PLUGINS) $(config.h)
$(FORMATTER_C) $(SRC_4_greenfield) $(PLUGINS) $(config.h)
$(FORMATTER_JS) plugins/readability/readability.js
$(FORMATTER_JS) plugins/style/style.js
# Installation # Installation
install: rosenrot runtime_files install: out/rosenrot runtime_files
cp -f rosenrot /usr/bin cp -f out/rosenrot /usr/bin/rosenrot
cp rosenrot-mklink /usr/bin
@echo @echo
uninstall: uninstall:
rm -r /opt/rosenrot rm -rf /opt/rosenrot
rm /usr/bin/rosenrot rm -f /usr/bin/rosenrot
rm /usr/bin/rosenrot-mklink rm -rf $(USER_CACHE_DIR)
rm $(USER_CACHE_DIR)
clean: clean:
rm -f rosenrot rm -f out/rosenrot
rm -rf $(USER_CACHE_DIR) rm -rf $(USER_CACHE_DIR)
constants: constants:
@echo @echo
@echo "# Computing constants" @echo "# Computing constants"
cd plugins/readability/ && sh recompute_READABILITY_N.sh cd src/plugins/readability/ && sh recompute_READABILITY_N.sh
cd plugins/style && sh recompute_STYLE_N.sh cd src/plugins/style && sh recompute_STYLE_N.sh
@echo @echo
user_cache: user_cache:
@ -88,13 +75,12 @@ user_cache:
runtime_files: runtime_files:
@echo @echo
sudo mkdir -p /opt/rosenrot/ sudo mkdir -p /opt/rosenrot/
sudo cp styles-gtk/style-gtk3.css /opt/rosenrot/ sudo cp src/styles-gtk/style-gtk4.css /opt/rosenrot/
sudo cp styles-gtk/style-gtk4.css /opt/rosenrot/
sudo touch /opt/rosenrot/uris.txt sudo touch /opt/rosenrot/uris.txt
sudo chmod a+rw /opt/rosenrot/uris.txt sudo chmod a+rw /opt/rosenrot/uris.txt
sudo cp -r images/flower-imgs /opt/rosenrot/ sudo cp -r src/images/flower-imgs /opt/rosenrot/
sudo cp plugins/style/style.js /opt/rosenrot/ sudo cp src/plugins/style/style.js /opt/rosenrot/
sudo cp plugins/readability/readability.js /opt/rosenrot/ sudo cp src/plugins/readability/readability.js /opt/rosenrot/
# More misc recipes # More misc recipes
@ -104,22 +90,19 @@ lint:
fast: $(SRC) $(PLUGINS) $(CONFIG) fast: $(SRC) $(PLUGINS) $(CONFIG)
rm -f *.gcda rm -f *.gcda
GIO_MODULE_DIR=/usr/lib/x86_64-linux-gnu/gio/modules/ GIO_MODULE_DIR=/usr/lib/x86_64-linux-gnu/gio/modules/
$(CC) $(WARNINGS) $(SECURITY) $(OPTIMIZED_MORE) -fprofile-generate $(INCS_4) $(PLUGINS) $(SRC_4) -o rosenrot $(LIBS_4) $(ADBLOCK) $(CC) $(WARNINGS) $(SECURITY) $(OPTIMIZED_MORE) -fprofile-generate $(INCS) $(PLUGINS) $(SRC) -o out/rosenrot $(LIBS) $(ADBLOCK)
@echo "Now use the browser for a while to gather some profiling data" @echo "Now use the browser for a while to gather some profiling data"
sleep 2 sleep 2
./rosenrot ./out/rosenrot
$(CC) $(WARNINGS) $(SECURITY) $(OPTIMIZED_MORE) -fprofile-use $(INCS_4) $(PLUGINS) $(SRC_4) -o rosenrot $(LIBS_4) $(ADBLOCK) $(CC) $(WARNINGS) $(SECURITY) $(OPTIMIZED_MORE) -fprofile-use $(INCS) $(PLUGINS) $(SRC) -o out/rosenrot $(LIBS) $(ADBLOCK)
rm -f *.gcda rm -f *.gcda
inspect: rosenrot inspect: out/rosenrot
GTK_DEBUG=interactive ./rosenrot GTK_DEBUG=interactive ./out/rosenrot
diagnose_deprecations: rosenrot diagnose_deprecations: out/rosenrot
G_ENABLE_DIAGNOSTIC=1 ./rosenrot G_ENABLE_DIAGNOSTIC=1 ./out/rosenrot
view-gtk3-version:
dpkg -l libgtk-3-0
twitter: twitter:
sudo mkdir -p /usr/bin/rosenrot-browser sudo mkdir -p /usr/bin/rosenrot-browser
sudo cp rosenrot /usr/bin/rosenrot-browser/twitter sudo cp out/rosenrot /usr/bin/rosenrot-browser/twitter

View File

@ -1,15 +0,0 @@
## Shared
COMMON_CODE=./plugins/strings/strings.c
## Plugins
CUSTOM_STYLES=./plugins/style/style.c
SHORTCUTS=./plugins/shortcuts/shortcuts.c
READABILITY=./plugins/readability/readability.c
LIBRE_REDIRECT=./plugins/libre_redirect/libre_redirect.c
STAND_IN=./plugins/stand_in/stand_in.c # gives function definitions for the above, which do nothing
PLUGINS=$(COMMON_CODE) $(CUSTOM_STYLES) $(SHORTCUTS) $(READABILITY) $(LIBRE_REDIRECT)
# PLUGINS=$(STAND_IN)

View File

@ -1,17 +0,0 @@
#!/bin/sh
test "$1" = "--help" || test -z "$1" && {
printf "%s\n" "usage: rosenrot-mklink <alias> <url>" \
"Create a /usr/bin link to a website."
exit
}
test -z "$2" || {
test -f "/usr/bin/$1" && {
echo "/usr/bin/$1 already exists, remove it first"
exit 1
}
printf "#!/bin/sh\n\nrosenrot %s" "$2" > /usr/bin/$1
chmod +x /usr/bin/$1
}

View File

@ -1,454 +0,0 @@
#include <gdk/gdk.h>
#include <stdlib.h>
#include <string.h>
#include <webkit2/webkit2.h>
#include "config.h"
#include "plugins/plugins.h"
/* Global variables */
static GtkNotebook* notebook;
static GtkWindow* window;
typedef enum { _SEARCH, _FIND, _HIDDEN } Bar_entry_mode;
static struct {
GtkHeaderBar* widget;
GtkEntry* line;
GtkEntryBuffer* line_text;
Bar_entry_mode entry_mode;
} bar;
static int num_tabs = 0;
static int custom_style_enabled = 1;
/* Forward declarations */
void toggle_bar(GtkNotebook* notebook, Bar_entry_mode mode);
void notebook_create_new_tab(GtkNotebook* notebook, const char* uri);
/* Utils */
WebKitWebView* notebook_get_webview(GtkNotebook* notebook)
{
return WEBKIT_WEB_VIEW(gtk_notebook_get_nth_page(notebook, gtk_notebook_get_current_page(notebook)));
}
/* Load content*/
void load_uri(WebKitWebView* view, const char* uri)
{
bool is_empty_uri = (strlen(uri) == 0);
if (is_empty_uri) {
webkit_web_view_load_uri(view, "");
toggle_bar(notebook, _SEARCH);
return;
}
bool has_direct_uri_prefix = g_str_has_prefix(uri, "http://") || g_str_has_prefix(uri, "https://") || g_str_has_prefix(uri, "file://") || g_str_has_prefix(uri, "about:");
if (has_direct_uri_prefix){
webkit_web_view_load_uri(view, uri);
return;
}
bool has_common_domain_extension = (strstr(uri, ".com") || strstr(uri, ".org"));
if (has_common_domain_extension){
char tmp[strlen("https://") + strlen(uri) + 1];
snprintf(tmp, sizeof(tmp), "https://%s", uri);
webkit_web_view_load_uri(view, tmp);
return;
}
int l = SHORTCUT_N + strlen(uri) + 1;
char uri_expanded[l];
str_init(uri_expanded, l);
int check = shortcut_expand(uri, uri_expanded);
bool has_shortcut = (check == 2);
if (has_shortcut){
webkit_web_view_load_uri(view, uri_expanded);
return;
}
char tmp[strlen(uri) + strlen(SEARCH)];
snprintf(tmp, sizeof(tmp), SEARCH, uri);
webkit_web_view_load_uri(view, tmp);
}
/* Deal with new load or changed load */
void redirect_if_annoying(WebKitWebView* view, const char* uri)
{
if (LIBRE_REDIRECT_ENABLED) {
int l = LIBRE_N + strlen(uri) + 1;
char uri_filtered[l];
str_init(uri_filtered, l);
int check = libre_redirect(uri, uri_filtered);
if (check == 2) webkit_web_view_load_uri(view, uri_filtered);
}
}
void set_custom_style(WebKitWebView* view)
{
if (custom_style_enabled) {
char* style_js = malloc(STYLE_N + 1);
if (style_js == NULL) {
fprintf(stderr, "Failed to allocate memory for style_js\n");
return;
}
read_style_js(style_js);
if (style_js != NULL) {
webkit_web_view_evaluate_javascript(view, style_js, -1, NULL, "rosenrot-style-plugin", NULL, NULL, NULL);
}
free(style_js);
}
}
void handle_signal_load_changed(WebKitWebView* self, WebKitLoadEvent load_event,
GtkNotebook* notebook)
{
switch (load_event) {
// https://webkitgtk.org/reference/webkit2gtk/2.5.1/WebKitWebView.html
case WEBKIT_LOAD_STARTED:
case WEBKIT_LOAD_COMMITTED:
set_custom_style(self);
case WEBKIT_LOAD_REDIRECTED:
redirect_if_annoying(self, webkit_web_view_get_uri(self));
break;
case WEBKIT_LOAD_FINISHED: {
set_custom_style(self);
/* Add gtk tab title */
const char* webpage_title = webkit_web_view_get_title(self);
const int max_length = 25;
char tab_title[max_length + 1];
if (webpage_title != NULL) {
for (int i = 0; i < (max_length); i++) {
tab_title[i] = webpage_title[i];
if (webpage_title[i] == '\0') {
break;
}
}
tab_title[max_length] = '\0';
}
gtk_notebook_set_tab_label_text(notebook, GTK_WIDGET(self),
webpage_title == NULL ? "" : tab_title);
}
}
}
/* New tabs */
WebKitWebView* create_new_webview()
{
char* style;
WebKitSettings* settings = webkit_settings_new_with_settings(WEBKIT_DEFAULT_SETTINGS, NULL);
if (CUSTOM_USER_AGENT) {
webkit_settings_set_user_agent(
settings,
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, "
"like Gecko) Chrome/120.0.0.0 Safari/537.3");
// https://www.useragents.me
}
WebKitWebContext* web_context = webkit_web_context_new_with_website_data_manager(webkit_website_data_manager_new(DATA_MANAGER_OPTS, NULL));
WebKitUserContentManager* contentmanager = webkit_user_content_manager_new();
WebKitCookieManager* cookiemanager = webkit_web_context_get_cookie_manager(web_context);
webkit_cookie_manager_set_persistent_storage(cookiemanager, DATA_DIR "/cookies.sqlite", WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE);
webkit_cookie_manager_set_accept_policy(cookiemanager, WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS);
if (g_file_get_contents("~/opt/rosenrot/style.css", &style, NULL, NULL)) {
webkit_user_content_manager_add_style_sheet(
contentmanager, webkit_user_style_sheet_new(style, WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES, WEBKIT_USER_STYLE_LEVEL_USER, NULL, NULL));
}
WebKitWebView* view = g_object_new(WEBKIT_TYPE_WEB_VIEW, "settings", settings, "web-context", web_context, "user-content-manager", contentmanager, NULL);
return view;
}
GtkWidget* handle_signal_create_new_tab(WebKitWebView* self,
WebKitNavigationAction* navigation_action,
GtkNotebook* notebook)
{
if (num_tabs < MAX_NUM_TABS || num_tabs == 0) {
WebKitURIRequest* uri_request = webkit_navigation_action_get_request(navigation_action);
const char* uri = webkit_uri_request_get_uri(uri_request);
printf("Creating new window: %s\n", uri);
notebook_create_new_tab(notebook, uri);
gtk_notebook_set_show_tabs(notebook, true);
} else {
webkit_web_view_evaluate_javascript(self, "alert('Too many tabs, not opening a new one')", -1, NULL, "rosenrot-alert-numtabs", NULL, NULL, NULL);
}
return ABORT_REQUEST_ON_CURRENT_TAB;
}
void notebook_create_new_tab(GtkNotebook* notebook, const char* uri)
{
if (num_tabs < MAX_NUM_TABS || MAX_NUM_TABS == 0) {
WebKitWebView* view = create_new_webview();
g_signal_connect(view, "load_changed", G_CALLBACK(handle_signal_load_changed), notebook);
g_signal_connect(view, "create", G_CALLBACK(handle_signal_create_new_tab), notebook);
int n = gtk_notebook_append_page(notebook, GTK_WIDGET(view), NULL);
gtk_notebook_set_tab_reorderable(notebook, GTK_WIDGET(view), true);
gtk_widget_show_all(GTK_WIDGET(window));
gtk_widget_hide(GTK_WIDGET(bar.widget));
load_uri(view, (uri) ? uri : HOME);
set_custom_style(view);
gtk_notebook_set_current_page(notebook, n);
gtk_notebook_set_tab_label_text(notebook, GTK_WIDGET(view), "-");
webkit_web_view_set_zoom_level(view, ZOOM_START_LEVEL);
num_tabs += 1;
} else {
webkit_web_view_evaluate_javascript(notebook_get_webview(notebook), "alert('Too many tabs, not opening a new one')",
-1, NULL, "rosenrot-alert-numtabs", NULL, NULL, NULL);
}
}
/* Top bar */
void toggle_bar(GtkNotebook* notebook, Bar_entry_mode mode)
{
bar.entry_mode = mode;
switch (bar.entry_mode) {
case _SEARCH: {
const char* url = webkit_web_view_get_uri(notebook_get_webview(notebook));
gtk_entry_set_placeholder_text(bar.line, "Search");
gtk_entry_buffer_set_text(bar.line_text, url, strlen(url));
gtk_widget_show(GTK_WIDGET(bar.widget));
gtk_window_set_focus(window, GTK_WIDGET(bar.line));
break;
}
case _FIND: {
const char* search_text = webkit_find_controller_get_search_text(
webkit_web_view_get_find_controller(notebook_get_webview(notebook)));
if (search_text != NULL)
gtk_entry_buffer_set_text(bar.line_text, search_text, strlen(search_text));
gtk_entry_set_placeholder_text(bar.line, "Find");
gtk_widget_show(GTK_WIDGET(bar.widget));
gtk_window_set_focus(window, GTK_WIDGET(bar.line));
break;
}
case _HIDDEN:
gtk_widget_hide(GTK_WIDGET(bar.widget));
}
}
// Handle what happens when the user is on the bar and presses enter
void handle_signal_bar_press_enter(GtkEntry* self, GtkNotebook* notebook)
{
if (bar.entry_mode == _SEARCH)
load_uri(notebook_get_webview(notebook), gtk_entry_buffer_get_text(bar.line_text));
else if (bar.entry_mode == _FIND)
webkit_find_controller_search(
webkit_web_view_get_find_controller(notebook_get_webview(notebook)),
gtk_entry_buffer_get_text(bar.line_text),
WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE | WEBKIT_FIND_OPTIONS_WRAP_AROUND,
G_MAXUINT);
gtk_widget_hide(GTK_WIDGET(bar.widget));
}
/* Shortcuts */
int handle_shortcut(func id, GtkNotebook* notebook)
{
static double zoom = ZOOM_START_LEVEL;
static bool is_fullscreen = 0;
WebKitWebView* view = notebook_get_webview(notebook);
switch (id) {
case goback:
webkit_web_view_go_back(view);
break;
case goforward:
webkit_web_view_go_forward(view);
break;
case toggle_custom_style: /* Ctrl s + Ctrl Shift R to reload */
custom_style_enabled ^= 1;
// fallthrough
case refresh:
webkit_web_view_reload(view);
break;
case refresh_force:
webkit_web_view_reload_bypass_cache(view);
break;
case back_to_home:
load_uri(view, HOME);
break;
case zoomin:
webkit_web_view_set_zoom_level(view,
(zoom += ZOOM_STEPSIZE));
break;
case zoomout:
webkit_web_view_set_zoom_level(view,
(zoom -= ZOOM_STEPSIZE));
break;
case zoom_reset:
webkit_web_view_set_zoom_level(view,
(zoom = ZOOM_START_LEVEL));
break;
case prev_tab:; // declarations aren't statements
// https://stackoverflow.com/questions/92396/why-cant-variables-be-declared-in-a-switch-statement
int n = gtk_notebook_get_n_pages(notebook);
int k = gtk_notebook_get_current_page(notebook);
int l = (n + k - 1) % n;
gtk_notebook_set_current_page(notebook, l);
break;
case next_tab:;
int m = gtk_notebook_get_n_pages(notebook);
int i = gtk_notebook_get_current_page(notebook);
int j = (i + 1) % m;
gtk_notebook_set_current_page(notebook, j);
break;
case close_tab:
num_tabs -= 1;
switch(num_tabs){
case 0:
exit(0);
break;
case 1:
gtk_notebook_set_show_tabs(notebook, false);
// fallthrough
default:
gtk_notebook_remove_page(notebook, gtk_notebook_get_current_page(notebook));
}
break;
case toggle_fullscreen:
if (is_fullscreen)
gtk_window_unfullscreen(window);
else
gtk_window_fullscreen(window);
is_fullscreen = !is_fullscreen;
break;
case show_searchbar:
toggle_bar(notebook, _SEARCH);
break;
case show_finder:
toggle_bar(notebook, _FIND);
break;
case finder_next:
webkit_find_controller_search_next(webkit_web_view_get_find_controller(view));
break;
case finder_prev:
webkit_find_controller_search_previous(webkit_web_view_get_find_controller(view));
break;
case new_tab:
notebook_create_new_tab(notebook, NULL);
gtk_notebook_set_show_tabs(notebook, true);
toggle_bar(notebook, _SEARCH);
break;
case hide_bar:
toggle_bar(notebook, _HIDDEN);
break;
case halve_window:
gtk_window_resize(window, FULL_WIDTH/2, HEIGHT);
break;
case rebig_window:
gtk_window_resize(window, FULL_WIDTH, HEIGHT);
break;
case prettify: {
if (READABILITY_ENABLED) {
char* readability_js = malloc(READABILITY_N + 1);
if (readability_js == NULL) {
fprintf(stderr, "Failed to allocate memory for readability_js\n");
break;
}
read_readability_js(readability_js);
if (readability_js != NULL) {
webkit_web_view_evaluate_javascript(view, readability_js, -1, NULL, "rosenrot-readability-plugin", NULL, NULL, NULL);
}
free(readability_js);
}
break;
}
}
return 1;
}
// Listen to key presses and call shortcuts if needed.
int handle_signal_keypress(void* self, GdkEvent* event, GtkNotebook* notebook)
{
(void)self;
guint event_keyval = 0;
gdk_event_get_keyval(event, &event_keyval);
GdkModifierType event_state = 0;
gdk_event_get_state(event, &event_state);
if (0) {
printf("Keypress state: %d\n", event_state);
printf("Keypress value: %d\n", event_keyval);
}
for (int i = 0; i < sizeof(shortcut) / sizeof(shortcut[0]); i++)
if ((event_state & shortcut[i].mod || shortcut[i].mod == 0x0) && event_keyval == shortcut[i].key)
return handle_shortcut(shortcut[i].id, notebook);
/*
If I wanted to bind button presses, like the extra button in the mouse,
I would have to bind the button-press-event signal instead.
Some links in case I go down that road:
- https://docs.gtk.org/gtk3/signal.Widget.button-press-event.html
- https://docs.gtk.org/gdk3/union.Event.html
- https://docs.gtk.org/gdk3/struct.EventButton.html
*/
return 0;
}
int main(int argc, char** argv)
{
/* Initialize GTK in general */
gtk_init(NULL, NULL); // https://docs.gtk.org/gtk3/func.init.html
g_object_set(gtk_settings_get_default(), GTK_SETTINGS_CONFIG_H, NULL); // https://docs.gtk.org/gobject/method.Object.set.html
GtkCssProvider* css = gtk_css_provider_new();
gtk_css_provider_load_from_path(css, "/opt/rosenrot/style-gtk3.css", NULL);
gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(css), 800);
/* Initialize GTK objects. These are declared as static globals at the top of this file */
// Window
window = GTK_WINDOW(gtk_window_new(0));
gtk_window_set_default_size(window, WIDTH, HEIGHT);
// Notebook
notebook = GTK_NOTEBOOK(gtk_notebook_new());
gtk_notebook_set_show_tabs(notebook, false);
gtk_notebook_set_show_border(notebook, false);
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(notebook));
// Bar
bar.line_text = GTK_ENTRY_BUFFER(gtk_entry_buffer_new("", 0));
bar.line = GTK_ENTRY(gtk_entry_new_with_buffer(bar.line_text));
gtk_entry_set_alignment(bar.line, 0.48);
gtk_widget_set_size_request(GTK_WIDGET(bar.line), BAR_WIDTH, -1);
bar.widget = GTK_HEADER_BAR(gtk_header_bar_new());
gtk_header_bar_set_custom_title(bar.widget, GTK_WIDGET(bar.line));
gtk_window_set_titlebar(window, GTK_WIDGET(bar.widget));
// Signals
g_signal_connect(window, "key-press-event", G_CALLBACK(handle_signal_keypress), notebook);
g_signal_connect(window, "destroy", G_CALLBACK(exit), notebook);
g_signal_connect(bar.line, "activate", G_CALLBACK(handle_signal_bar_press_enter), notebook);
/* Load first tab */
char* first_uri = argc > 1 ? argv[1] : HOME;
notebook_create_new_tab(notebook, first_uri);
/* Show to user */
gtk_widget_show_all(GTK_WIDGET(window));
if (argc != 0) gtk_widget_hide(GTK_WIDGET(bar.widget));
/* Deal with more tabs */
if (argc > 2) {
gtk_notebook_set_show_tabs(notebook, true);
for (int i = 2; i < argc; i++) {
notebook_create_new_tab(notebook, argv[i]);
}
}
gtk_main();
}

View File

@ -8,7 +8,7 @@
#define BAR_WIDTH FULL_WIDTH/2 #define BAR_WIDTH FULL_WIDTH/2
/* More user config */ /* More user config */
#define ZOOM_START_LEVEL 1.5 #define ZOOM_START_LEVEL 2.0
#define ZOOM_STEPSIZE .1 #define ZOOM_STEPSIZE .1
#define MAX_NUM_TABS 8 // 0 or false for unlimited tabs #define MAX_NUM_TABS 8 // 0 or false for unlimited tabs
#define SEARCH "https://search.brave.com/search?q=%s" #define SEARCH "https://search.brave.com/search?q=%s"

View File

Before

Width:  |  Height:  |  Size: 2.4 MiB

After

Width:  |  Height:  |  Size: 2.4 MiB

View File

Before

Width:  |  Height:  |  Size: 257 KiB

After

Width:  |  Height:  |  Size: 257 KiB

View File

Before

Width:  |  Height:  |  Size: 534 KiB

After

Width:  |  Height:  |  Size: 534 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 250 KiB

After

Width:  |  Height:  |  Size: 250 KiB

View File

Before

Width:  |  Height:  |  Size: 198 KiB

After

Width:  |  Height:  |  Size: 198 KiB

View File

Before

Width:  |  Height:  |  Size: 258 KiB

After

Width:  |  Height:  |  Size: 258 KiB

View File

Before

Width:  |  Height:  |  Size: 123 KiB

After

Width:  |  Height:  |  Size: 123 KiB

View File

Before

Width:  |  Height:  |  Size: 142 KiB

After

Width:  |  Height:  |  Size: 142 KiB

View File

Before

Width:  |  Height:  |  Size: 474 KiB

After

Width:  |  Height:  |  Size: 474 KiB

View File

Before

Width:  |  Height:  |  Size: 474 KiB

After

Width:  |  Height:  |  Size: 474 KiB

View File

Before

Width:  |  Height:  |  Size: 111 KiB

After

Width:  |  Height:  |  Size: 111 KiB

View File

Before

Width:  |  Height:  |  Size: 739 KiB

After

Width:  |  Height:  |  Size: 739 KiB

15
src/plugins/plugins.mk Normal file
View File

@ -0,0 +1,15 @@
## Shared
COMMON_CODE=./src/plugins/strings/strings.c
## Plugins
CUSTOM_STYLES=./src/plugins/style/style.c
SHORTCUTS=./src/plugins/shortcuts/shortcuts.c
READABILITY=./src/plugins/readability/readability.c
LIBRE_REDIRECT=./src/plugins/libre_redirect/libre_redirect.c
STAND_IN=./src/plugins/stand_in/stand_in.c # gives function definitions for the above, which do nothing
PLUGINS=$(COMMON_CODE) $(CUSTOM_STYLES) $(SHORTCUTS) $(READABILITY) $(LIBRE_REDIRECT)
# PLUGINS=$(STAND_IN)

View File

@ -16,7 +16,7 @@ wget https://easylist.to/easylist/easylist.txt
cd - cd -
cd ../.. cd ../..
make build4 make build
sudo make install sudo make install
cd - cd -

View File

Before

Width:  |  Height:  |  Size: 739 KiB

After

Width:  |  Height:  |  Size: 739 KiB

View File

Before

Width:  |  Height:  |  Size: 178 KiB

After

Width:  |  Height:  |  Size: 178 KiB

View File

Before

Width:  |  Height:  |  Size: 175 KiB

After

Width:  |  Height:  |  Size: 175 KiB

View File

Before

Width:  |  Height:  |  Size: 625 KiB

After

Width:  |  Height:  |  Size: 625 KiB

View File

Before

Width:  |  Height:  |  Size: 474 KiB

After

Width:  |  Height:  |  Size: 474 KiB

View File

Before

Width:  |  Height:  |  Size: 739 KiB

After

Width:  |  Height:  |  Size: 739 KiB

View File

Before

Width:  |  Height:  |  Size: 102 KiB

After

Width:  |  Height:  |  Size: 102 KiB

View File

Before

Width:  |  Height:  |  Size: 142 KiB

After

Width:  |  Height:  |  Size: 142 KiB

View File

Before

Width:  |  Height:  |  Size: 474 KiB

After

Width:  |  Height:  |  Size: 474 KiB

View File

@ -20,7 +20,6 @@ sudo apt install libgtk-4-dev
cd ../.. cd ../..
make build make build
make runtime-files
sudo make install sudo make install
cd - cd -

View File

Before

Width:  |  Height:  |  Size: 739 KiB

After

Width:  |  Height:  |  Size: 739 KiB

View File

@ -1,41 +0,0 @@
* {
font-size: 25px;
color: #333;
}
/* Make titlebar pretty gigantic. I'm pretty myopic. */
.titlebar {
padding: 10px;
font-size: 30px;
}
.titlebar * {
padding: 10px;
font-size: 27px;
}
header * {
font-size: 20px;
padding: 5px;
}
tabs {
padding: 3px;
}
tab {
margin: 2px 5px 4px 0px; /* top right bottom left */
padding: 5px;
border-style: solid;
font-size: 27px;
}
entry {
padding-left: 10px;
}
entry:focus {
padding-left: 10px;
}

View File

@ -1,42 +0,0 @@
# Key dependencies
sudo apt install git vim gcc make
sudo apt install libwebkit2gtk-4.1-dev
# Optional adblock
git clone https://github.com/jun7/wyebadblock
cd wyebadblock
sudo apt install gstreamer1.0-plugins-good gstreamer1.0-libav
WEBKITVER=4.1 make
sudo WEBKITVER=4.1 make install
cd ..
mkdir -p ~/.config/wyebadblock
cd ~/.config/wyebadblock
wget https://easylist.to/easylist/easylist.txt
cd -
cd ../..
make build3 # or just make
sudo make install
cd -
# Debian desktop icon
chmod +x rosenrot.desktop
sudo cp rosenrot.desktop /usr/share/applications
mkdir -p /opt/rosenrot
sudo cp rosenrot-desktop-icon.png /opt/rosenrot/
# Optionally, set a shortcut (within GNOME)
# https://askubuntu.com/questions/597395/how-to-set-custom-keyboard-shortcuts-from-terminal/1007035#1007035
name="rose"
binding="<CTRL><SHIFT>W"
action="/usr/bin/rosenrot"
media_keys=org.gnome.settings-daemon.plugins.media-keys
custom_kbd=org.gnome.settings-daemon.plugins.media-keys.custom-keybinding
kbd_path=/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/$name/
new_bindings=`gsettings get $media_keys custom-keybindings | sed -e"s>'\]>','$kbd_path']>"| sed -e"s>@as \[\]>['$kbd_path']>"`
gsettings set $media_keys custom-keybindings "$new_bindings"
gsettings set $custom_kbd:$kbd_path name "$name"
gsettings set $custom_kbd:$kbd_path binding "$binding"
gsettings set $custom_kbd:$kbd_path command "$action"

View File

@ -1,42 +0,0 @@
# Key dependencies
sudo apt install git vim gcc make
sudo apt install libwebkit2gtk-4.1-dev
# Optional adblock
git clone https://github.com/jun7/wyebadblock
cd wyebadblock
sudo apt install gstreamer1.0-plugins-good gstreamer1.0-libav
WEBKITVER=4.1 make
sudo WEBKITVER=4.1 make install
cd ..
mkdir -p ~/.config/wyebadblock
cd ~/.config/wyebadblock
wget https://easylist.to/easylist/easylist.txt
cd -
cd ../..
make build3 # or just make
sudo make install
cd -
# Debian desktop icon
chmod +x rosenrot.desktop
sudo cp rosenrot.desktop /usr/share/applications
mkdir -p /opt/rosenrot
sudo cp rosenrot-desktop-icon.png /opt/rosenrot/
# Optionally, set a shortcut (within GNOME)
# https://askubuntu.com/questions/597395/how-to-set-custom-keyboard-shortcuts-from-terminal/1007035#1007035
name="rose"
binding="<CTRL><SHIFT>W"
action="/usr/bin/rosenrot"
media_keys=org.gnome.settings-daemon.plugins.media-keys
custom_kbd=org.gnome.settings-daemon.plugins.media-keys.custom-keybinding
kbd_path=/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/$name/
new_bindings=`gsettings get $media_keys custom-keybindings | sed -e"s>'\]>','$kbd_path']>"| sed -e"s>@as \[\]>['$kbd_path']>"`
gsettings set $media_keys custom-keybindings "$new_bindings"
gsettings set $custom_kbd:$kbd_path name "$name"
gsettings set $custom_kbd:$kbd_path binding "$binding"
gsettings set $custom_kbd:$kbd_path command "$action"

View File

@ -1,64 +0,0 @@
rosenrot4.c:29:50: warning: declaration of notebook shadows a global declaration [-Wshadow]
29 | WebKitWebView* notebook_get_webview(GtkNotebook* notebook) /* TODO: Think through whether to pass global variables or not */
| ~~~~~~~~~~~~~^~~~~~~~
rosenrot4.c:10:21: note: shadowed declaration is here
10 | static GtkNotebook* notebook;
| ^~~~~~~~
rosenrot4.c: In function handle_signal_load_changed:
rosenrot4.c:104:18: warning: declaration of notebook shadows a global declaration [-Wshadow]
104 | GtkNotebook* notebook)
| ~~~~~~~~~~~~~^~~~~~~~
rosenrot4.c:10:21: note: shadowed declaration is here
10 | static GtkNotebook* notebook;
| ^~~~~~~~
rosenrot4.c: In function handle_signal_create_new_tab:
rosenrot4.c:164:18: warning: declaration of notebook shadows a global declaration [-Wshadow]
164 | GtkNotebook* notebook)
| ~~~~~~~~~~~~~^~~~~~~~
rosenrot4.c:10:21: note: shadowed declaration is here
10 | static GtkNotebook* notebook;
| ^~~~~~~~
rosenrot4.c: In function notebook_create_new_tab:
rosenrot4.c:182:43: warning: declaration of notebook shadows a global declaration [-Wshadow]
182 | void notebook_create_new_tab(GtkNotebook* notebook, const char* uri)
| ~~~~~~~~~~~~~^~~~~~~~
rosenrot4.c:10:21: note: shadowed declaration is here
10 | static GtkNotebook* notebook;
| ^~~~~~~~
rosenrot4.c: In function toggle_bar:
rosenrot4.c:212:30: warning: declaration of notebook shadows a global declaration [-Wshadow]
212 | void toggle_bar(GtkNotebook* notebook, Bar_entry_mode mode)
| ~~~~~~~~~~~~~^~~~~~~~
rosenrot4.c:10:21: note: shadowed declaration is here
10 | static GtkNotebook* notebook;
| ^~~~~~~~
rosenrot4.c: In function handle_signal_bar_press_enter:
rosenrot4.c:249:65: warning: declaration of notebook shadows a global declaration [-Wshadow]
249 | void handle_signal_bar_press_enter(GtkEntry* self, GtkNotebook* notebook) /* consider passing notebook as the data here? */
| ~~~~~~~~~~~~~^~~~~~~~
rosenrot4.c:10:21: note: shadowed declaration is here
10 | static GtkNotebook* notebook;
| ^~~~~~~~
rosenrot4.c:271:13: warning: format not a string literal, argument types not checked [-Wformat-nonliteral]
271 | snprintf(js_command, sizeof(js_command), js_template, bar_line_text);
| ^~~~~~~~
rosenrot4.c: In function handle_shortcut:
rosenrot4.c:428:13: warning: format not a string literal, argument types not checked [-Wformat-nonliteral]
428 | snprintf(cmd, sizeof(cmd), brave_command, uri);
| ^~~~~~~~
rosenrot4.c: In function handle_signal_keypress:
rosenrot4.c:448:23: warning: comparison of integer expressions of different signedness: int and long unsigned int [-Wsign-compare]
448 | for (int i = 0; i < sizeof(shortcut) / sizeof(shortcut[0]); i++) {
| ^
rosenrot4.c:449:75: warning: comparison of integer expressions of different signedness: int and unsigned int [-Wsign-compare]
449 | if ((state & shortcut[i].mod || shortcut[i].mod == 0x0) && keyval == shortcut[i].key) {
| ^~
rosenrot4.c: In function handle_signal_load_changed:
rosenrot4.c:110:13: warning: this statement may fall through [-Wimplicit-fallthrough=]
110 | set_custom_style(self);
| ^~~~~~~~~~~~~~~~~~~~~~
rosenrot4.c:111:9: note: here
111 | case WEBKIT_LOAD_REDIRECTED:
| ^~~~