Skip to content

Commit 258aa8d

Browse files
committed
GTK4: Continue updating, tweak makefile
1 parent 6fd0a9e commit 258aa8d

11 files changed

+101
-104
lines changed

README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ Rosenrot is a small browser forked from an earlier version of [rose](https://git
1010

1111
### Installation and usage
1212

13-
You can see detailed instructions [here](./user-scripts/debian-12/install-with-dependencies.sh), for Debian 12 in particular—though they should generalize easily to other distributions.
13+
You can see detailed instructions [here](./user-scripts/debian-12/), for Debian 12 in particular—though they should generalize easily to other distributions.
1414

1515
The general steps are to install dependencies, and then
1616

1717
```
18-
make build
18+
make build # by default using webkitgtk6/gtk4; see also build3
1919
make install # or sudo make install
2020
rose
2121
```
@@ -44,6 +44,7 @@ You can also create a rose.desktop file so that it will show up in your desktop
4444
- Custom style: Override the css of predetermined websites
4545
- Max number of tabs (by default 8), configurable.
4646
- Stand in plugin: Mimick function definitions which do nothing for the above plugins so that they can be quickly removed
47+
- For now, both GTK3 and GTK4-based versions—eventually only the GTK4 version will remain
4748

4849
You can see some screenshots in the [images](./images) folder.
4950

@@ -66,14 +67,14 @@ Here are projects with their own rendering engines which could appeal to users o
6667

6768
- [lynx](https://lynx.invisible-island.net/) (links, elinks), [w3m](https://w3m.sourceforge.net/): command line browsers.
6869
- [dillo](https://github.com/dillo-browser/dillo/). Has its own rendering engine, and no javascript.
69-
- [Ladybird](https://github.com/SerenityOS/serenity/tree/master/Ladybird). SerenityOS. Uses its own html and javascript engine. Compiling it on a mainstream Linux distribution, and documenting instructions could be an interesting project, but the few times I've tried that I've failed.
70+
- [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.
7071
- [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.
7172

7273
### Relationship with [rose](https://github.com/mini-rose/rose)
7374

7475
- 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).
75-
- The current version offers compilation with both GTK3 and GTK4, and an up to date version of webkit.
76-
- Rosenrot is my (@NunoSempere's) fork from that earlier minimal rose. 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.
76+
- 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.
77+
- rose updated to allow compilation with an up-to-date version of both GTK3 and GTK4 earlier, though rosenrot now offers this as well.
7778
- Rosenrot is also a song by the German hardcore rock band [Rammstein](https://www.youtube.com/watch?v=af59U2BRRAU).
7879

7980
### Comparison with [surf](https://git.suckless.org/surf/file/surf.c.html)
@@ -85,9 +86,8 @@ Here are projects with their own rendering engines which could appeal to users o
8586
- Anecdotically, surf feels slower, though I haven't tested this rigorously.
8687
- surf has a larger community, with patches and modifications.
8788
- surf is more opinionated, but also less amateurish.
88-
- Like rosenrot until very recently, 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/)
89-
- 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.
90-
- But then again, I've built rosenrot to cater to my own tastes, so I'd say that.
89+
- 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)
90+
- 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.
9191

9292
## Folk wisdom
9393

@@ -109,7 +109,7 @@ See [this blog post](https://blogs.gnome.org/mcatanzaro/2023/03/21/webkitgtk-api
109109

110110
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).
111111

112-
Rosenrot is currently on the stable webkit2gtk-4.1 release using GTK3, and has removed deprecated webkit apis. It has plans to eventually migrate to webkit2gtk-6.0 eventually but not soon, because the GTK4 rewrite seems onerous.
112+
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.
113113

114114
### Ubuntu 20.04
115115

TODO.md

+16-9
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,8 @@
88
- [ ] This time, use something other than Whatsapp as an example syslink.
99
- [ ] Fix bug about distorted audio. Maybe related to [this pipewire issue](<https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1547>)?
1010
- See whether it even exists at all
11-
- [ ] Upgrade to GTK-4 / Webkitgtk 6.0? Will take a fair amount of time, since GTK4 redesigns the application model somewhat.
12-
- Instructions for webkit-6.0 [here](https://github.com/WebKit/WebKit/blob/ed1422596dce5ff012e64a38faf402ac1674fc7e/Source/WebKit/gtk/migrating-to-webkitgtk-6.0.md)
13-
- Instructions for GTK-4 [here](https://docs.gtk.org/gtk4/migrating-3to4.html)
14-
- [ ] Prepare for GTK-3 to GTK-4 transition
15-
- [ ] Understand wtf is going on with signals and events: <https://docs.gtk.org/gtk4/migrating-3to4.html#stop-using-gtkwidget-event-signals>. <https://github.com/mini-rose/rose-browser/blob/288bf060d095c4895946669ae50d14193168b69c/src/window.c#L42>
16-
- [ ] Stop using direct access to GdkEvent structs
17-
- [ ] Remove webkit2gtk-4.1 and download webkit2gtk-6.0
18-
- [ ] Attempt to compile
11+
- [ ] Finish cleaning up GTK4 version
12+
- [ ] Think about best way of having GTK4 version alongside
1913

2014
# Previously done
2115

@@ -59,4 +53,17 @@
5953
- Useful for opening links in new tab when clicking on them and selecting that option
6054
- And for actually opening links with the href new_tab option.
6155
- Links: [1](<https://docs.gtk.org/gobject/func.signal_connect.html>), [2](<https://webkitgtk.org/reference/webkit2gtk/2.37.90/signal.AutomationSession.create-web-view.html>), [3](<https://webkitgtk.org/reference/webkit2gtk/2.26.0/WebKitWebView.html#WebKitWebView-create>), [4](<https://stackoverflow.com/questions/40180757/webkit2gtk-get-new-window-link>)
62-
56+
- [x] Upgrade to GTK-4 / Webkitgtk 6.0? Will take a fair amount of time, since GTK4 redesigns the application model somewhat.
57+
- Instructions for webkit-6.0 [here](https://github.com/WebKit/WebKit/blob/ed1422596dce5ff012e64a38faf402ac1674fc7e/Source/WebKit/gtk/migrating-to-webkitgtk-6.0.md)
58+
- Instructions for GTK-4 [here](https://docs.gtk.org/gtk4/migrating-3to4.html)
59+
- [x] Prepare for GTK-3 to GTK-4 transition
60+
- [x] Understand wtf is going on with signals and events: <https://docs.gtk.org/gtk4/migrating-3to4.html#stop-using-gtkwidget-event-signals>. <https://github.com/mini-rose/rose-browser/blob/288bf060d095c4895946669ae50d14193168b69c/src/window.c#L42>
61+
- [x] Stop using direct access to GdkEvent structs
62+
- [ ] ~~Remove webkit2gtk-4.1 and download webkit2gtk-6.0~~ => Actually just use both
63+
- [x] Attempt to compile
64+
- Notes for others:
65+
- Searching github
66+
- Creating a minimal version, e.g., having only one signal going on
67+
- Looking at how https://github.com/mini-rose/rose-browser/ does things
68+
- Printf statements
69+
- GTK ressources: https://docs.gtk.org/gtk4, https://docs.gtk.org/gobject/, https://docs.gtk.org/gdk4/

makefile

+31-37
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ CC=gcc # alternatives: tcc, clang, zig cc
33
WARNINGS=-Wall
44
OPTIMIZED_SOME=-O3
55
OPTIMIZED_MORE=-Ofast -march=native -funit-at-a-time -flto # binary will not be compatible with other computers, but may be much faster
6-
DEBUG=
6+
DEBUG=#-g
77
STD=-std=c99 # maybe consider moving to c11 and using safer string handling
88

99
# Dependencies for WebkitGTK4/GTK3
@@ -17,7 +17,7 @@ SRC_4=rosenrot4.c
1717
DEPS_4='webkitgtk-6.0'
1818
INCS_4=`pkg-config --cflags ${DEPS_4}` `pkg-config --cflags gtk4`
1919
LIBS_4=`pkg-config --libs ${DEPS_4}` `pkg-config --libs gtk4`
20-
# DEPRECATION_FLAGS=-DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED
20+
DEPRECATION_FLAGS=-DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED
2121

2222
# User config
2323
CONFIG=config.h
@@ -37,20 +37,36 @@ MAINTAINER_CACHE_DIR=/home/nuno/.cache/rosenrot
3737
USER_CACHE_DIR=/home/`whoami`/.cache/rosenrot
3838
RUNTIME_FILES_DIR=/opt/rosenrot/
3939

40-
# Start 3 to 4 transition
41-
# https://docs.gtk.org/gtk4/migrating-3to4.html
42-
# https://github.com/WebKit/WebKit/blob/ed1422596dce5ff012e64a38faf402ac1674fc7e/Source/WebKit/gtk/migrating-to-webkitgtk-6.0.md
43-
44-
build: $(SRC_3) $(PLUGINS) $(CONFIG) constants user_cache
40+
build3: $(SRC_3) $(PLUGINS) $(CONFIG) constants user_cache
4541
$(CC) $(STD) $(WARNINGS) $(OPTIMIZED_MORE) $(DEBUG) $(INCS_3) $(PLUGINS) $(SRC_3) -o rosenrot $(LIBS_3) $(ADBLOCK)
4642
@echo
4743

48-
build4: $(SRC_4) $(PLUGINS) $(CONFIG) constants user_cache
44+
build: $(SRC_4) $(PLUGINS) $(CONFIG) constants user_cache
4945
$(CC) $(STD) $(WARNINGS) $(DEPRECATION_FLAGS) $(OPTIMIZED_MORE) $(DEBUG) $(INCS_4) $(PLUGINS) $(SRC_4) -o rosenrot $(LIBS_4) $(ADBLOCK)
5046
@echo
5147

52-
diagnose:
53-
G_ENABLE_DIAGNOSTIC=1 ./rosenrot
48+
format: $(SRC_3) $(SRC_4) $(PLUGINS)
49+
$(FORMATTER_C) $(SRC_3) $(PLUGINS) $(config.h)
50+
$(FORMATTER_C) $(SRC_4_greenfield) $(PLUGINS) $(config.h)
51+
$(FORMATTER_JS) plugins/readability/readability.js
52+
$(FORMATTER_JS) plugins/style/style.js
53+
54+
# Installation
55+
56+
install: rosenrot runtime_files
57+
cp -f rosenrot /usr/bin
58+
cp rosenrot-mklink /usr/bin
59+
@echo
60+
61+
uninstall:
62+
rm -r /opt/rosenrot
63+
rm /usr/bin/rosenrot
64+
rm /usr/bin/rosenrot-mklink
65+
rm $(USER_CACHE_DIR)
66+
67+
clean:
68+
rm rosenrot
69+
rm $(USER_CACHE_DIR)
5470

5571
constants:
5672
@echo
@@ -70,45 +86,25 @@ user_cache:
7086
runtime_files:
7187
@echo
7288
sudo mkdir -p /opt/rosenrot/
73-
sudo cp style-gtk3.css /opt/rosenrot/style.css
89+
sudo cp styles-gtk/style-gtk3.css /opt/rosenrot/
90+
sudo cp styles-gtk/style-gtk4.css /opt/rosenrot/
7491
sudo cp -r images/flower-imgs /opt/rosenrot/
7592
sudo cp plugins/style/style.js /opt/rosenrot/
7693
sudo cp plugins/readability/readability.js /opt/rosenrot/
7794

78-
install: rosenrot runtime_files
79-
cp -f rosenrot /usr/bin
80-
cp rosenrot-mklink /usr/bin
81-
@echo
82-
83-
uninstall:
84-
rm -r /opt/rosenrot
85-
rm /usr/bin/rosenrot
86-
rm /usr/bin/rosenrot-mklink
87-
rm $(USER_CACHE_DIR)
88-
89-
clean:
90-
rm rosenrot
91-
rm $(USER_CACHE_DIR)
92-
93-
format: $(SRC) $(PLUGINS)
94-
$(FORMATTER_C) $(SRC) $(PLUGINS) $(rosenrot.h)
95-
$(FORMATTER_C) $(SRC_4) $(PLUGINS) $(rosenrot.h)
96-
$(FORMATTER_C) $(SRC_4_greenfield) $(PLUGINS) $(rosenrot.h)
97-
$(FORMATTER_JS) plugins/readability/readability.js
98-
$(FORMATTER_JS) plugins/style/style.js
95+
# More misc recipes
9996

10097
lint:
10198
clang-tidy $(SRC) $(PLUGINS) -- -Wall -O3 $(INCS) -o rosenrot $(LIBS)
102-
## A few more commands:
10399

104100
fast: $(SRC) $(PLUGINS) $(CONFIG)
105101
rm -f *.gcda
106102
GIO_MODULE_DIR=/usr/lib/x86_64-linux-gnu/gio/modules/
107-
$(CC) $(WARNINGS) $(OPTIMIZED_MORE) -fprofile-generate $(INCS) $(PLUGINS) $(SRC) -o rosenrot $(LIBS) $(ADBLOCK)
103+
$(CC) $(WARNINGS) $(OPTIMIZED_MORE) -fprofile-generate $(INCS_4) $(PLUGINS) $(SRC_4) -o rosenrot $(LIBS_4) $(ADBLOCK)
108104
@echo "Now use the browser for a while to gather some profiling data"
109105
sleep 2
110106
./rosenrot
111-
$(CC) $(WARNINGS) $(OPTIMIZED_MORE) -fprofile-use $(INCS) $(PLUGINS) $(SRC) -o rosenrot $(LIBS) $(ADBLOCK)
107+
$(CC) $(WARNINGS) $(OPTIMIZED_MORE) -fprofile-use $(INCS_4) $(PLUGINS) $(SRC_4) -o rosenrot $(LIBS_4) $(ADBLOCK)
112108
rm -f *.gcda
113109

114110
inspect: rosenrot
@@ -123,5 +119,3 @@ view-gtk3-version:
123119
twitter:
124120
sudo mkdir -p /usr/bin/rosenrot-browser
125121
sudo cp rosenrot /usr/bin/rosenrot-browser/twitter
126-
127-
# COMPILETIME_DEPRECATION_WARNINGS=#-DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED # turns out that webkit2gtk-4.1 is using some deprecated stuff, lol

rosenrot3.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ int main(int argc, char** argv)
390390
gtk_init(NULL, NULL); // https://docs.gtk.org/gtk3/func.init.html
391391
g_object_set(gtk_settings_get_default(), GTK_SETTINGS_CONFIG_H, NULL); // https://docs.gtk.org/gobject/method.Object.set.html
392392
GtkCssProvider* css = gtk_css_provider_new();
393-
gtk_css_provider_load_from_path(css, "/opt/rosenrot/style.css", NULL);
393+
gtk_css_provider_load_from_path(css, "/opt/rosenrot/style-gtk3.css", NULL);
394394
gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(css), 800); /* might change with GTK4/webkitgtk6.0 */
395395

396396
/* Initialize GTK objects. These are declared as static globals at the top of this file */

rosenrot4.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ int main(int argc, char** argv)
399399
gtk_init();
400400
g_object_set(gtk_settings_get_default(), GTK_SETTINGS_CONFIG_H, NULL); // https://docs.gtk.org/gobject/method.Object.set.html
401401
GtkCssProvider* css = gtk_css_provider_new();
402-
gtk_css_provider_load_from_path(css, "/opt/rosenrot/style.css");
402+
gtk_css_provider_load_from_path(css, "/opt/rosenrot/style-gtk4.css");
403403
gtk_style_context_add_provider_for_display(gdk_display_get_default(), GTK_STYLE_PROVIDER(css), GTK_STYLE_PROVIDER_PRIORITY_USER);
404404

405405
// Create the main window

scratchpad/makefile

-2
This file was deleted.

scratchpad/test.c

-42
This file was deleted.
File renamed without changes.
File renamed without changes.

user-scripts/debian-12/install-with-dependencies.sh user-scripts/debian-12/install-with-dependencies-gtk3.sh

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Key dependencies
22
sudo apt install git vim gcc make
33
sudo apt install libwebkit2gtk-4.1-dev
4-
# sudo apt install libwebkitgtk-6.0-dev
5-
# sudo apt install libgtk-4-dev
64

75
# Optional adblock
86
git clone https://github.com/jun7/wyebadblock
@@ -18,7 +16,7 @@ wget https://easylist.to/easylist/easylist.txt
1816
cd -
1917

2018
cd ../..
21-
make build # or just make
19+
make build3 # or just make
2220
sudo make install
2321

2422
cd -
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Key dependencies
2+
sudo apt install libwebkitgtk-6.0-dev
3+
sudo apt install libgtk-4-dev
4+
5+
# Optional adblock
6+
git clone https://github.com/jun7/wyebadblock
7+
cd wyebadblock
8+
sudo apt install gstreamer1.0-plugins-good gstreamer1.0-libav
9+
WEBKITVER=4.1 make
10+
sudo WEBKITVER=4.1 make install
11+
12+
cd ..
13+
mkdir -p ~/.config/wyebadblock
14+
cd ~/.config/wyebadblock
15+
wget https://easylist.to/easylist/easylist.txt
16+
cd -
17+
18+
cd ../..
19+
make build4
20+
sudo make install
21+
22+
cd -
23+
# Debian desktop icon
24+
chmod +x rosenrot.desktop
25+
sudo cp rosenrot.desktop /usr/share/applications
26+
mkdir -p /opt/rosenrot
27+
sudo cp rosenrot-desktop-icon.png /opt/rosenrot/
28+
29+
# Optionally, set a shortcut (within GNOME)
30+
# https://askubuntu.com/questions/597395/how-to-set-custom-keyboard-shortcuts-from-terminal/1007035#1007035
31+
name="rose"
32+
binding="<CTRL><SHIFT>W"
33+
action="/usr/bin/rosenrot"
34+
35+
media_keys=org.gnome.settings-daemon.plugins.media-keys
36+
custom_kbd=org.gnome.settings-daemon.plugins.media-keys.custom-keybinding
37+
kbd_path=/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/$name/
38+
new_bindings=`gsettings get $media_keys custom-keybindings | sed -e"s>'\]>','$kbd_path']>"| sed -e"s>@as \[\]>['$kbd_path']>"`
39+
gsettings set $media_keys custom-keybindings "$new_bindings"
40+
gsettings set $custom_kbd:$kbd_path name "$name"
41+
gsettings set $custom_kbd:$kbd_path binding "$binding"
42+
gsettings set $custom_kbd:$kbd_path command "$action"

0 commit comments

Comments
 (0)