From fbaf8cd9ca890314260e58b2ae318dd87f4faa19 Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Mon, 24 Nov 2025 13:17:54 -0300 Subject: [PATCH] remove GTK3 --- .gitignore | 2 +- license => LICENSE.md | 2 +- README.md | 24 +- TODO.md => ROADMAP.md | 6 +- makefile | 83 ++-- plugins/plugins.mk | 15 - rosenrot-mklink | 17 - rosenrot3.c | 454 ------------------ config.h => src/config.h | 2 +- {images => src/images}/0-architecture.png | Bin {images => src/images}/1-startup.png | Bin {images => src/images}/2-blog.png | Bin {images => src/images}/3-init.png | Bin {images => src/images}/4-money-stuff-raw.png | Bin .../images}/5-money-stuff-readability.png | Bin {images => src/images}/6-multiple-tabs.png | Bin .../images}/7-hello-world-search.png | Bin .../images}/architecture.excalidraw | 0 .../images}/flower-imgs/rose-homepage-2.png | Bin .../images}/flower-imgs/rose-homepage.png | Bin .../images}/flower-imgs/rose-src.txt | 0 {images => src/images}/flower-imgs/rose.png | Bin {images => src/images}/flower-imgs/rose2.png | Bin .../flower-imgs/rosenrot-desktop-icon.png | Bin .../plugins}/libre_redirect/README.md | 0 .../plugins}/libre_redirect/libre_redirect.c | 0 .../plugins}/libre_redirect/libre_redirect.h | 0 .../str_replace_test/build-example.sh | 0 .../libre_redirect/str_replace_test/example.c | 0 {plugins => src/plugins}/plugins.h | 0 src/plugins/plugins.mk | 15 + .../plugins}/readability/README.md | 0 .../plugins}/readability/readability | Bin .../plugins}/readability/readability.c | 0 .../plugins}/readability/readability.h | 0 .../plugins}/readability/readability.js | 0 .../readability/recompute_READABILITY_N.sh | 0 {plugins => src/plugins}/shortcuts/README.md | 0 .../plugins}/shortcuts/shortcuts.c | 0 .../plugins}/shortcuts/shortcuts.h | 0 {plugins => src/plugins}/stand_in/stand_in.c | 0 {plugins => src/plugins}/stand_in/stand_in.h | 0 {plugins => src/plugins}/strings/strings.c | 0 {plugins => src/plugins}/strings/strings.h | 0 {plugins => src/plugins}/style/README.md | 0 .../plugins}/style/recompute_STYLE_N.sh | 0 {plugins => src/plugins}/style/style.c | 0 {plugins => src/plugins}/style/style.h | 0 {plugins => src/plugins}/style/style.js | 0 rosenrot4.c => src/rosenrot.c | 0 .../styles-gtk}/style-gtk4-large.css | 0 {styles-gtk => src/styles-gtk}/style-gtk4.css | 0 .../artifacts/compile_flags/compile_flags.txt | 0 .../compile_flags/get-compile-flags.sh | 0 .../install-with-dependencies-gtk4.sh | 2 +- .../debian-12/rosenrot-desktop-icon.png | Bin .../user-scripts}/debian-12/rosenrot.desktop | 0 .../styles/images/style-nuno.png | Bin .../styles/images/style-original.png | Bin .../user-scripts}/styles/style-v1.css | 0 .../user-scripts}/styles/style-v2.css | 0 .../user-scripts}/styles/style-v3.css | 0 .../user-scripts}/ubuntu-20.04/README.md | 0 .../ubuntu-20.04/install-with-dependencies.sh | 0 .../ubuntu-20.04/rose-GIO_MODULE_DIR.desktop | 0 .../ubuntu-20.04/rose-images/rose-1.png | Bin .../ubuntu-20.04/rose-images/rose-2.png | Bin .../rose-images/rose-desktop-icon.png | Bin .../rose-images/rose-homepage-1.6-zoom.png | Bin .../rose-images/rose-homepage-2.png | Bin .../rose-images/rose-homepage.png | Bin .../ubuntu-20.04/rose-images/rose-src.txt | 0 .../user-scripts}/ubuntu-20.04/rose.desktop | 0 .../user-scripts}/ubuntu-20.04/rose.sh | 0 .../install-with-dependencies-gtk4.sh | 1 - .../ubuntu-24.04/rosenrot-desktop-icon.png | Bin .../ubuntu-24.04/rosenrot.desktop | 0 .../user-scripts}/valgrind-notes.md | 0 styles-gtk/style-gtk3.css | 41 -- .../install-with-dependencies-gtk3.sh | 42 -- .../install-with-dependencies-gtk3.sh | 42 -- warnings.txt | 64 --- 82 files changed, 65 insertions(+), 747 deletions(-) rename license => LICENSE.md (96%) rename TODO.md => ROADMAP.md (96%) delete mode 100644 plugins/plugins.mk delete mode 100755 rosenrot-mklink delete mode 100644 rosenrot3.c rename config.h => src/config.h (99%) rename {images => src/images}/0-architecture.png (100%) rename {images => src/images}/1-startup.png (100%) rename {images => src/images}/2-blog.png (100%) rename {images => src/images}/3-init.png (100%) rename {images => src/images}/4-money-stuff-raw.png (100%) rename {images => src/images}/5-money-stuff-readability.png (100%) rename {images => src/images}/6-multiple-tabs.png (100%) rename {images => src/images}/7-hello-world-search.png (100%) rename {images => src/images}/architecture.excalidraw (100%) rename {images => src/images}/flower-imgs/rose-homepage-2.png (100%) rename {images => src/images}/flower-imgs/rose-homepage.png (100%) rename {images => src/images}/flower-imgs/rose-src.txt (100%) rename {images => src/images}/flower-imgs/rose.png (100%) rename {images => src/images}/flower-imgs/rose2.png (100%) rename {images => src/images}/flower-imgs/rosenrot-desktop-icon.png (100%) rename {plugins => src/plugins}/libre_redirect/README.md (100%) rename {plugins => src/plugins}/libre_redirect/libre_redirect.c (100%) rename {plugins => src/plugins}/libre_redirect/libre_redirect.h (100%) rename {plugins => src/plugins}/libre_redirect/str_replace_test/build-example.sh (100%) rename {plugins => src/plugins}/libre_redirect/str_replace_test/example.c (100%) rename {plugins => src/plugins}/plugins.h (100%) create mode 100644 src/plugins/plugins.mk rename {plugins => src/plugins}/readability/README.md (100%) rename {plugins => src/plugins}/readability/readability (100%) rename {plugins => src/plugins}/readability/readability.c (100%) rename {plugins => src/plugins}/readability/readability.h (100%) rename {plugins => src/plugins}/readability/readability.js (100%) rename {plugins => src/plugins}/readability/recompute_READABILITY_N.sh (100%) rename {plugins => src/plugins}/shortcuts/README.md (100%) rename {plugins => src/plugins}/shortcuts/shortcuts.c (100%) rename {plugins => src/plugins}/shortcuts/shortcuts.h (100%) rename {plugins => src/plugins}/stand_in/stand_in.c (100%) rename {plugins => src/plugins}/stand_in/stand_in.h (100%) rename {plugins => src/plugins}/strings/strings.c (100%) rename {plugins => src/plugins}/strings/strings.h (100%) rename {plugins => src/plugins}/style/README.md (100%) rename {plugins => src/plugins}/style/recompute_STYLE_N.sh (100%) rename {plugins => src/plugins}/style/style.c (100%) rename {plugins => src/plugins}/style/style.h (100%) rename {plugins => src/plugins}/style/style.js (100%) rename rosenrot4.c => src/rosenrot.c (100%) rename {styles-gtk => src/styles-gtk}/style-gtk4-large.css (100%) rename {styles-gtk => src/styles-gtk}/style-gtk4.css (100%) rename {user-scripts => src/user-scripts}/artifacts/compile_flags/compile_flags.txt (100%) rename {user-scripts => src/user-scripts}/artifacts/compile_flags/get-compile-flags.sh (100%) rename {user-scripts => src/user-scripts}/debian-12/install-with-dependencies-gtk4.sh (99%) rename {user-scripts => src/user-scripts}/debian-12/rosenrot-desktop-icon.png (100%) rename {user-scripts => src/user-scripts}/debian-12/rosenrot.desktop (100%) rename {user-scripts => src/user-scripts}/styles/images/style-nuno.png (100%) rename {user-scripts => src/user-scripts}/styles/images/style-original.png (100%) rename {user-scripts => src/user-scripts}/styles/style-v1.css (100%) rename {user-scripts => src/user-scripts}/styles/style-v2.css (100%) rename {user-scripts => src/user-scripts}/styles/style-v3.css (100%) rename {user-scripts => src/user-scripts}/ubuntu-20.04/README.md (100%) rename {user-scripts => src/user-scripts}/ubuntu-20.04/install-with-dependencies.sh (100%) rename {user-scripts => src/user-scripts}/ubuntu-20.04/rose-GIO_MODULE_DIR.desktop (100%) rename {user-scripts => src/user-scripts}/ubuntu-20.04/rose-images/rose-1.png (100%) rename {user-scripts => src/user-scripts}/ubuntu-20.04/rose-images/rose-2.png (100%) rename {user-scripts => src/user-scripts}/ubuntu-20.04/rose-images/rose-desktop-icon.png (100%) rename {user-scripts => src/user-scripts}/ubuntu-20.04/rose-images/rose-homepage-1.6-zoom.png (100%) rename {user-scripts => src/user-scripts}/ubuntu-20.04/rose-images/rose-homepage-2.png (100%) rename {user-scripts => src/user-scripts}/ubuntu-20.04/rose-images/rose-homepage.png (100%) rename {user-scripts => src/user-scripts}/ubuntu-20.04/rose-images/rose-src.txt (100%) rename {user-scripts => src/user-scripts}/ubuntu-20.04/rose.desktop (100%) rename {user-scripts => src/user-scripts}/ubuntu-20.04/rose.sh (100%) rename {user-scripts => src/user-scripts}/ubuntu-24.04/install-with-dependencies-gtk4.sh (98%) rename {user-scripts => src/user-scripts}/ubuntu-24.04/rosenrot-desktop-icon.png (100%) rename {user-scripts => src/user-scripts}/ubuntu-24.04/rosenrot.desktop (100%) rename {user-scripts => src/user-scripts}/valgrind-notes.md (100%) delete mode 100644 styles-gtk/style-gtk3.css delete mode 100644 user-scripts/debian-12/install-with-dependencies-gtk3.sh delete mode 100644 user-scripts/ubuntu-24.04/install-with-dependencies-gtk3.sh delete mode 100644 warnings.txt diff --git a/.gitignore b/.gitignore index 22e1448..343ee4a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -rosenrot # don't save the binary file, as it doesn't play nicely with https://difftastic.wilfred.me.uk webkit/ +out/ diff --git a/license b/LICENSE.md similarity index 96% rename from license rename to LICENSE.md index 514be1d..1362e74 100644 --- a/license +++ b/LICENSE.md @@ -1,6 +1,6 @@ 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 of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 1a12bf5..947f816 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 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) @@ -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 ``` -make build # by default using webkitgtk6/gtk4; see also build3 +make build make install # or sudo make install 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 - 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 -- 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. @@ -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. - [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. ### 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). - 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). ### 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. - surf has a larger community, with patches and modifications. - 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. ## 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`. - 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. -- 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. +- 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 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 "architecture" of the application looks as follows: ![](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. - -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. +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). ### Ubuntu 20.04 diff --git a/TODO.md b/ROADMAP.md similarity index 96% rename from TODO.md rename to ROADMAP.md index c96dc2a..9d95778 100644 --- a/TODO.md +++ b/ROADMAP.md @@ -1,7 +1,7 @@ # To do - [ ] 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 - [ ] etc. - [ ] 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. - [ ] Fix bug about distorted audio. Maybe related to [this pipewire issue]()? - See whether it even exists at all -- [ ] Finish cleaning up GTK4 version -- [ ] Think about best way of having GTK4 version alongside +- [x] Finish cleaning up GTK4 version +- [-] Think about best way of having GTK4 version alongside - [ ] Shortcut to resize window # Previously done diff --git a/makefile b/makefile index 5c96c9b..cc43513 100644 --- a/makefile +++ b/makefile @@ -8,25 +8,19 @@ DEBUG=-g STD=-std=c99 # maybe consider moving to c11 and using safer string handling 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 -SRC_4=rosenrot4.c -DEPS_4='webkitgtk-6.0' -INCS_4=`pkg-config --cflags ${DEPS_4}` `pkg-config --cflags gtk4` -LIBS_4=`pkg-config --libs ${DEPS_4}` `pkg-config --libs gtk4` +SRC=src/rosenrot.c +DEPS='webkitgtk-6.0' +INCS=`pkg-config --cflags ${DEPS}` `pkg-config --cflags gtk4` +LIBS=`pkg-config --libs ${DEPS}` `pkg-config --libs gtk4` DEPRECATION_FLAGS=-DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED # User config -CONFIG=config.h +CONFIG=src/config.h # Plugins -include plugins/plugins.mk -# PLUGINS=./plugins/stand_in/stand_in.c +include src/plugins/plugins.mk +# PLUGINS=./src/plugins/stand_in/stand_in.c ADBLOCK='-L/usr/lib/wyebrowser/adblock.so' # optional adblocking; depends on https://github.com/jun7/wyebadblock ## Formatter @@ -39,42 +33,35 @@ MAINTAINER_CACHE_DIR=/home/nuno/.cache/rosenrot USER_CACHE_DIR=/home/`whoami`/.cache/rosenrot RUNTIME_FILES_DIR=/opt/rosenrot/ -build: $(SRC_4) $(PLUGINS) $(CONFIG) constants user_cache - $(CC) $(STD) $(WARNINGS) $(SECURITY) $(DEPRECATION_FLAGS) $(OPTIMIZED_MORE) $(DEBUG) $(INCS_4) $(PLUGINS) $(SRC_4) -o rosenrot $(LIBS_4) $(ADBLOCK) +build: $(SRC) $(PLUGINS) $(CONFIG) constants user_cache + $(CC) $(STD) $(WARNINGS) $(SECURITY) $(DEPRECATION_FLAGS) $(OPTIMIZED_MORE) $(DEBUG) $(INCS) $(PLUGINS) $(SRC) -o out/rosenrot $(LIBS) $(ADBLOCK) @echo -build3: $(SRC_3) $(PLUGINS) $(CONFIG) constants user_cache - $(CC) $(STD) $(WARNINGS) $(SECURITY) $(OPTIMIZED_MORE) $(DEBUG) $(INCS_3) $(PLUGINS) $(SRC_3) -o rosenrot $(LIBS_3) $(ADBLOCK) - @echo - -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 +format: $(SRC) $(PLUGINS) + $(FORMATTER_C) $(SRC) $(PLUGINS) $(CONFIG) + $(FORMATTER_JS) src/plugins/readability/readability.js + $(FORMATTER_JS) src/plugins/style/style.js # Installation -install: rosenrot runtime_files - cp -f rosenrot /usr/bin - cp rosenrot-mklink /usr/bin +install: out/rosenrot runtime_files + cp -f out/rosenrot /usr/bin/rosenrot @echo uninstall: - rm -r /opt/rosenrot - rm /usr/bin/rosenrot - rm /usr/bin/rosenrot-mklink - rm $(USER_CACHE_DIR) + rm -rf /opt/rosenrot + rm -f /usr/bin/rosenrot + rm -rf $(USER_CACHE_DIR) clean: - rm -f rosenrot + rm -f out/rosenrot rm -rf $(USER_CACHE_DIR) constants: @echo @echo "# Computing constants" - cd plugins/readability/ && sh recompute_READABILITY_N.sh - cd plugins/style && sh recompute_STYLE_N.sh + cd src/plugins/readability/ && sh recompute_READABILITY_N.sh + cd src/plugins/style && sh recompute_STYLE_N.sh @echo user_cache: @@ -88,13 +75,12 @@ user_cache: runtime_files: @echo sudo mkdir -p /opt/rosenrot/ - sudo cp styles-gtk/style-gtk3.css /opt/rosenrot/ - sudo cp styles-gtk/style-gtk4.css /opt/rosenrot/ + sudo cp src/styles-gtk/style-gtk4.css /opt/rosenrot/ sudo touch /opt/rosenrot/uris.txt sudo chmod a+rw /opt/rosenrot/uris.txt - sudo cp -r images/flower-imgs /opt/rosenrot/ - sudo cp plugins/style/style.js /opt/rosenrot/ - sudo cp plugins/readability/readability.js /opt/rosenrot/ + sudo cp -r src/images/flower-imgs /opt/rosenrot/ + sudo cp src/plugins/style/style.js /opt/rosenrot/ + sudo cp src/plugins/readability/readability.js /opt/rosenrot/ # More misc recipes @@ -104,22 +90,19 @@ lint: fast: $(SRC) $(PLUGINS) $(CONFIG) rm -f *.gcda 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" sleep 2 - ./rosenrot - $(CC) $(WARNINGS) $(SECURITY) $(OPTIMIZED_MORE) -fprofile-use $(INCS_4) $(PLUGINS) $(SRC_4) -o rosenrot $(LIBS_4) $(ADBLOCK) + ./out/rosenrot + $(CC) $(WARNINGS) $(SECURITY) $(OPTIMIZED_MORE) -fprofile-use $(INCS) $(PLUGINS) $(SRC) -o out/rosenrot $(LIBS) $(ADBLOCK) rm -f *.gcda -inspect: rosenrot - GTK_DEBUG=interactive ./rosenrot +inspect: out/rosenrot + GTK_DEBUG=interactive ./out/rosenrot -diagnose_deprecations: rosenrot - G_ENABLE_DIAGNOSTIC=1 ./rosenrot - -view-gtk3-version: - dpkg -l libgtk-3-0 +diagnose_deprecations: out/rosenrot + G_ENABLE_DIAGNOSTIC=1 ./out/rosenrot twitter: sudo mkdir -p /usr/bin/rosenrot-browser - sudo cp rosenrot /usr/bin/rosenrot-browser/twitter + sudo cp out/rosenrot /usr/bin/rosenrot-browser/twitter diff --git a/plugins/plugins.mk b/plugins/plugins.mk deleted file mode 100644 index 87141cc..0000000 --- a/plugins/plugins.mk +++ /dev/null @@ -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) - - diff --git a/rosenrot-mklink b/rosenrot-mklink deleted file mode 100755 index d8f5be6..0000000 --- a/rosenrot-mklink +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -test "$1" = "--help" || test -z "$1" && { - printf "%s\n" "usage: rosenrot-mklink " \ - "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 -} diff --git a/rosenrot3.c b/rosenrot3.c deleted file mode 100644 index ceef82f..0000000 --- a/rosenrot3.c +++ /dev/null @@ -1,454 +0,0 @@ -#include -#include -#include -#include - -#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(); -} diff --git a/config.h b/src/config.h similarity index 99% rename from config.h rename to src/config.h index 1a1f3c5..98f7bba 100644 --- a/config.h +++ b/src/config.h @@ -8,7 +8,7 @@ #define BAR_WIDTH FULL_WIDTH/2 /* More user config */ -#define ZOOM_START_LEVEL 1.5 +#define ZOOM_START_LEVEL 2.0 #define ZOOM_STEPSIZE .1 #define MAX_NUM_TABS 8 // 0 or false for unlimited tabs #define SEARCH "https://search.brave.com/search?q=%s" diff --git a/images/0-architecture.png b/src/images/0-architecture.png similarity index 100% rename from images/0-architecture.png rename to src/images/0-architecture.png diff --git a/images/1-startup.png b/src/images/1-startup.png similarity index 100% rename from images/1-startup.png rename to src/images/1-startup.png diff --git a/images/2-blog.png b/src/images/2-blog.png similarity index 100% rename from images/2-blog.png rename to src/images/2-blog.png diff --git a/images/3-init.png b/src/images/3-init.png similarity index 100% rename from images/3-init.png rename to src/images/3-init.png diff --git a/images/4-money-stuff-raw.png b/src/images/4-money-stuff-raw.png similarity index 100% rename from images/4-money-stuff-raw.png rename to src/images/4-money-stuff-raw.png diff --git a/images/5-money-stuff-readability.png b/src/images/5-money-stuff-readability.png similarity index 100% rename from images/5-money-stuff-readability.png rename to src/images/5-money-stuff-readability.png diff --git a/images/6-multiple-tabs.png b/src/images/6-multiple-tabs.png similarity index 100% rename from images/6-multiple-tabs.png rename to src/images/6-multiple-tabs.png diff --git a/images/7-hello-world-search.png b/src/images/7-hello-world-search.png similarity index 100% rename from images/7-hello-world-search.png rename to src/images/7-hello-world-search.png diff --git a/images/architecture.excalidraw b/src/images/architecture.excalidraw similarity index 100% rename from images/architecture.excalidraw rename to src/images/architecture.excalidraw diff --git a/images/flower-imgs/rose-homepage-2.png b/src/images/flower-imgs/rose-homepage-2.png similarity index 100% rename from images/flower-imgs/rose-homepage-2.png rename to src/images/flower-imgs/rose-homepage-2.png diff --git a/images/flower-imgs/rose-homepage.png b/src/images/flower-imgs/rose-homepage.png similarity index 100% rename from images/flower-imgs/rose-homepage.png rename to src/images/flower-imgs/rose-homepage.png diff --git a/images/flower-imgs/rose-src.txt b/src/images/flower-imgs/rose-src.txt similarity index 100% rename from images/flower-imgs/rose-src.txt rename to src/images/flower-imgs/rose-src.txt diff --git a/images/flower-imgs/rose.png b/src/images/flower-imgs/rose.png similarity index 100% rename from images/flower-imgs/rose.png rename to src/images/flower-imgs/rose.png diff --git a/images/flower-imgs/rose2.png b/src/images/flower-imgs/rose2.png similarity index 100% rename from images/flower-imgs/rose2.png rename to src/images/flower-imgs/rose2.png diff --git a/images/flower-imgs/rosenrot-desktop-icon.png b/src/images/flower-imgs/rosenrot-desktop-icon.png similarity index 100% rename from images/flower-imgs/rosenrot-desktop-icon.png rename to src/images/flower-imgs/rosenrot-desktop-icon.png diff --git a/plugins/libre_redirect/README.md b/src/plugins/libre_redirect/README.md similarity index 100% rename from plugins/libre_redirect/README.md rename to src/plugins/libre_redirect/README.md diff --git a/plugins/libre_redirect/libre_redirect.c b/src/plugins/libre_redirect/libre_redirect.c similarity index 100% rename from plugins/libre_redirect/libre_redirect.c rename to src/plugins/libre_redirect/libre_redirect.c diff --git a/plugins/libre_redirect/libre_redirect.h b/src/plugins/libre_redirect/libre_redirect.h similarity index 100% rename from plugins/libre_redirect/libre_redirect.h rename to src/plugins/libre_redirect/libre_redirect.h diff --git a/plugins/libre_redirect/str_replace_test/build-example.sh b/src/plugins/libre_redirect/str_replace_test/build-example.sh similarity index 100% rename from plugins/libre_redirect/str_replace_test/build-example.sh rename to src/plugins/libre_redirect/str_replace_test/build-example.sh diff --git a/plugins/libre_redirect/str_replace_test/example.c b/src/plugins/libre_redirect/str_replace_test/example.c similarity index 100% rename from plugins/libre_redirect/str_replace_test/example.c rename to src/plugins/libre_redirect/str_replace_test/example.c diff --git a/plugins/plugins.h b/src/plugins/plugins.h similarity index 100% rename from plugins/plugins.h rename to src/plugins/plugins.h diff --git a/src/plugins/plugins.mk b/src/plugins/plugins.mk new file mode 100644 index 0000000..595e461 --- /dev/null +++ b/src/plugins/plugins.mk @@ -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) + + diff --git a/plugins/readability/README.md b/src/plugins/readability/README.md similarity index 100% rename from plugins/readability/README.md rename to src/plugins/readability/README.md diff --git a/plugins/readability/readability b/src/plugins/readability/readability similarity index 100% rename from plugins/readability/readability rename to src/plugins/readability/readability diff --git a/plugins/readability/readability.c b/src/plugins/readability/readability.c similarity index 100% rename from plugins/readability/readability.c rename to src/plugins/readability/readability.c diff --git a/plugins/readability/readability.h b/src/plugins/readability/readability.h similarity index 100% rename from plugins/readability/readability.h rename to src/plugins/readability/readability.h diff --git a/plugins/readability/readability.js b/src/plugins/readability/readability.js similarity index 100% rename from plugins/readability/readability.js rename to src/plugins/readability/readability.js diff --git a/plugins/readability/recompute_READABILITY_N.sh b/src/plugins/readability/recompute_READABILITY_N.sh similarity index 100% rename from plugins/readability/recompute_READABILITY_N.sh rename to src/plugins/readability/recompute_READABILITY_N.sh diff --git a/plugins/shortcuts/README.md b/src/plugins/shortcuts/README.md similarity index 100% rename from plugins/shortcuts/README.md rename to src/plugins/shortcuts/README.md diff --git a/plugins/shortcuts/shortcuts.c b/src/plugins/shortcuts/shortcuts.c similarity index 100% rename from plugins/shortcuts/shortcuts.c rename to src/plugins/shortcuts/shortcuts.c diff --git a/plugins/shortcuts/shortcuts.h b/src/plugins/shortcuts/shortcuts.h similarity index 100% rename from plugins/shortcuts/shortcuts.h rename to src/plugins/shortcuts/shortcuts.h diff --git a/plugins/stand_in/stand_in.c b/src/plugins/stand_in/stand_in.c similarity index 100% rename from plugins/stand_in/stand_in.c rename to src/plugins/stand_in/stand_in.c diff --git a/plugins/stand_in/stand_in.h b/src/plugins/stand_in/stand_in.h similarity index 100% rename from plugins/stand_in/stand_in.h rename to src/plugins/stand_in/stand_in.h diff --git a/plugins/strings/strings.c b/src/plugins/strings/strings.c similarity index 100% rename from plugins/strings/strings.c rename to src/plugins/strings/strings.c diff --git a/plugins/strings/strings.h b/src/plugins/strings/strings.h similarity index 100% rename from plugins/strings/strings.h rename to src/plugins/strings/strings.h diff --git a/plugins/style/README.md b/src/plugins/style/README.md similarity index 100% rename from plugins/style/README.md rename to src/plugins/style/README.md diff --git a/plugins/style/recompute_STYLE_N.sh b/src/plugins/style/recompute_STYLE_N.sh similarity index 100% rename from plugins/style/recompute_STYLE_N.sh rename to src/plugins/style/recompute_STYLE_N.sh diff --git a/plugins/style/style.c b/src/plugins/style/style.c similarity index 100% rename from plugins/style/style.c rename to src/plugins/style/style.c diff --git a/plugins/style/style.h b/src/plugins/style/style.h similarity index 100% rename from plugins/style/style.h rename to src/plugins/style/style.h diff --git a/plugins/style/style.js b/src/plugins/style/style.js similarity index 100% rename from plugins/style/style.js rename to src/plugins/style/style.js diff --git a/rosenrot4.c b/src/rosenrot.c similarity index 100% rename from rosenrot4.c rename to src/rosenrot.c diff --git a/styles-gtk/style-gtk4-large.css b/src/styles-gtk/style-gtk4-large.css similarity index 100% rename from styles-gtk/style-gtk4-large.css rename to src/styles-gtk/style-gtk4-large.css diff --git a/styles-gtk/style-gtk4.css b/src/styles-gtk/style-gtk4.css similarity index 100% rename from styles-gtk/style-gtk4.css rename to src/styles-gtk/style-gtk4.css diff --git a/user-scripts/artifacts/compile_flags/compile_flags.txt b/src/user-scripts/artifacts/compile_flags/compile_flags.txt similarity index 100% rename from user-scripts/artifacts/compile_flags/compile_flags.txt rename to src/user-scripts/artifacts/compile_flags/compile_flags.txt diff --git a/user-scripts/artifacts/compile_flags/get-compile-flags.sh b/src/user-scripts/artifacts/compile_flags/get-compile-flags.sh similarity index 100% rename from user-scripts/artifacts/compile_flags/get-compile-flags.sh rename to src/user-scripts/artifacts/compile_flags/get-compile-flags.sh diff --git a/user-scripts/debian-12/install-with-dependencies-gtk4.sh b/src/user-scripts/debian-12/install-with-dependencies-gtk4.sh similarity index 99% rename from user-scripts/debian-12/install-with-dependencies-gtk4.sh rename to src/user-scripts/debian-12/install-with-dependencies-gtk4.sh index 81a3a6a..0b10738 100644 --- a/user-scripts/debian-12/install-with-dependencies-gtk4.sh +++ b/src/user-scripts/debian-12/install-with-dependencies-gtk4.sh @@ -16,7 +16,7 @@ wget https://easylist.to/easylist/easylist.txt cd - cd ../.. -make build4 +make build sudo make install cd - diff --git a/user-scripts/debian-12/rosenrot-desktop-icon.png b/src/user-scripts/debian-12/rosenrot-desktop-icon.png similarity index 100% rename from user-scripts/debian-12/rosenrot-desktop-icon.png rename to src/user-scripts/debian-12/rosenrot-desktop-icon.png diff --git a/user-scripts/debian-12/rosenrot.desktop b/src/user-scripts/debian-12/rosenrot.desktop similarity index 100% rename from user-scripts/debian-12/rosenrot.desktop rename to src/user-scripts/debian-12/rosenrot.desktop diff --git a/user-scripts/styles/images/style-nuno.png b/src/user-scripts/styles/images/style-nuno.png similarity index 100% rename from user-scripts/styles/images/style-nuno.png rename to src/user-scripts/styles/images/style-nuno.png diff --git a/user-scripts/styles/images/style-original.png b/src/user-scripts/styles/images/style-original.png similarity index 100% rename from user-scripts/styles/images/style-original.png rename to src/user-scripts/styles/images/style-original.png diff --git a/user-scripts/styles/style-v1.css b/src/user-scripts/styles/style-v1.css similarity index 100% rename from user-scripts/styles/style-v1.css rename to src/user-scripts/styles/style-v1.css diff --git a/user-scripts/styles/style-v2.css b/src/user-scripts/styles/style-v2.css similarity index 100% rename from user-scripts/styles/style-v2.css rename to src/user-scripts/styles/style-v2.css diff --git a/user-scripts/styles/style-v3.css b/src/user-scripts/styles/style-v3.css similarity index 100% rename from user-scripts/styles/style-v3.css rename to src/user-scripts/styles/style-v3.css diff --git a/user-scripts/ubuntu-20.04/README.md b/src/user-scripts/ubuntu-20.04/README.md similarity index 100% rename from user-scripts/ubuntu-20.04/README.md rename to src/user-scripts/ubuntu-20.04/README.md diff --git a/user-scripts/ubuntu-20.04/install-with-dependencies.sh b/src/user-scripts/ubuntu-20.04/install-with-dependencies.sh similarity index 100% rename from user-scripts/ubuntu-20.04/install-with-dependencies.sh rename to src/user-scripts/ubuntu-20.04/install-with-dependencies.sh diff --git a/user-scripts/ubuntu-20.04/rose-GIO_MODULE_DIR.desktop b/src/user-scripts/ubuntu-20.04/rose-GIO_MODULE_DIR.desktop similarity index 100% rename from user-scripts/ubuntu-20.04/rose-GIO_MODULE_DIR.desktop rename to src/user-scripts/ubuntu-20.04/rose-GIO_MODULE_DIR.desktop diff --git a/user-scripts/ubuntu-20.04/rose-images/rose-1.png b/src/user-scripts/ubuntu-20.04/rose-images/rose-1.png similarity index 100% rename from user-scripts/ubuntu-20.04/rose-images/rose-1.png rename to src/user-scripts/ubuntu-20.04/rose-images/rose-1.png diff --git a/user-scripts/ubuntu-20.04/rose-images/rose-2.png b/src/user-scripts/ubuntu-20.04/rose-images/rose-2.png similarity index 100% rename from user-scripts/ubuntu-20.04/rose-images/rose-2.png rename to src/user-scripts/ubuntu-20.04/rose-images/rose-2.png diff --git a/user-scripts/ubuntu-20.04/rose-images/rose-desktop-icon.png b/src/user-scripts/ubuntu-20.04/rose-images/rose-desktop-icon.png similarity index 100% rename from user-scripts/ubuntu-20.04/rose-images/rose-desktop-icon.png rename to src/user-scripts/ubuntu-20.04/rose-images/rose-desktop-icon.png diff --git a/user-scripts/ubuntu-20.04/rose-images/rose-homepage-1.6-zoom.png b/src/user-scripts/ubuntu-20.04/rose-images/rose-homepage-1.6-zoom.png similarity index 100% rename from user-scripts/ubuntu-20.04/rose-images/rose-homepage-1.6-zoom.png rename to src/user-scripts/ubuntu-20.04/rose-images/rose-homepage-1.6-zoom.png diff --git a/user-scripts/ubuntu-20.04/rose-images/rose-homepage-2.png b/src/user-scripts/ubuntu-20.04/rose-images/rose-homepage-2.png similarity index 100% rename from user-scripts/ubuntu-20.04/rose-images/rose-homepage-2.png rename to src/user-scripts/ubuntu-20.04/rose-images/rose-homepage-2.png diff --git a/user-scripts/ubuntu-20.04/rose-images/rose-homepage.png b/src/user-scripts/ubuntu-20.04/rose-images/rose-homepage.png similarity index 100% rename from user-scripts/ubuntu-20.04/rose-images/rose-homepage.png rename to src/user-scripts/ubuntu-20.04/rose-images/rose-homepage.png diff --git a/user-scripts/ubuntu-20.04/rose-images/rose-src.txt b/src/user-scripts/ubuntu-20.04/rose-images/rose-src.txt similarity index 100% rename from user-scripts/ubuntu-20.04/rose-images/rose-src.txt rename to src/user-scripts/ubuntu-20.04/rose-images/rose-src.txt diff --git a/user-scripts/ubuntu-20.04/rose.desktop b/src/user-scripts/ubuntu-20.04/rose.desktop similarity index 100% rename from user-scripts/ubuntu-20.04/rose.desktop rename to src/user-scripts/ubuntu-20.04/rose.desktop diff --git a/user-scripts/ubuntu-20.04/rose.sh b/src/user-scripts/ubuntu-20.04/rose.sh similarity index 100% rename from user-scripts/ubuntu-20.04/rose.sh rename to src/user-scripts/ubuntu-20.04/rose.sh diff --git a/user-scripts/ubuntu-24.04/install-with-dependencies-gtk4.sh b/src/user-scripts/ubuntu-24.04/install-with-dependencies-gtk4.sh similarity index 98% rename from user-scripts/ubuntu-24.04/install-with-dependencies-gtk4.sh rename to src/user-scripts/ubuntu-24.04/install-with-dependencies-gtk4.sh index 96557b9..c3844ed 100644 --- a/user-scripts/ubuntu-24.04/install-with-dependencies-gtk4.sh +++ b/src/user-scripts/ubuntu-24.04/install-with-dependencies-gtk4.sh @@ -20,7 +20,6 @@ sudo apt install libgtk-4-dev cd ../.. make build -make runtime-files sudo make install cd - diff --git a/user-scripts/ubuntu-24.04/rosenrot-desktop-icon.png b/src/user-scripts/ubuntu-24.04/rosenrot-desktop-icon.png similarity index 100% rename from user-scripts/ubuntu-24.04/rosenrot-desktop-icon.png rename to src/user-scripts/ubuntu-24.04/rosenrot-desktop-icon.png diff --git a/user-scripts/ubuntu-24.04/rosenrot.desktop b/src/user-scripts/ubuntu-24.04/rosenrot.desktop similarity index 100% rename from user-scripts/ubuntu-24.04/rosenrot.desktop rename to src/user-scripts/ubuntu-24.04/rosenrot.desktop diff --git a/user-scripts/valgrind-notes.md b/src/user-scripts/valgrind-notes.md similarity index 100% rename from user-scripts/valgrind-notes.md rename to src/user-scripts/valgrind-notes.md diff --git a/styles-gtk/style-gtk3.css b/styles-gtk/style-gtk3.css deleted file mode 100644 index 35eec0b..0000000 --- a/styles-gtk/style-gtk3.css +++ /dev/null @@ -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; - -} diff --git a/user-scripts/debian-12/install-with-dependencies-gtk3.sh b/user-scripts/debian-12/install-with-dependencies-gtk3.sh deleted file mode 100644 index fd2db47..0000000 --- a/user-scripts/debian-12/install-with-dependencies-gtk3.sh +++ /dev/null @@ -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="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" diff --git a/user-scripts/ubuntu-24.04/install-with-dependencies-gtk3.sh b/user-scripts/ubuntu-24.04/install-with-dependencies-gtk3.sh deleted file mode 100644 index fd2db47..0000000 --- a/user-scripts/ubuntu-24.04/install-with-dependencies-gtk3.sh +++ /dev/null @@ -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="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" diff --git a/warnings.txt b/warnings.txt deleted file mode 100644 index 0af8ca6..0000000 --- a/warnings.txt +++ /dev/null @@ -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: - | ^~~~ - -