simplify plugins code a bit.

This commit is contained in:
NunoSempere 2024-02-11 15:56:53 +01:00
parent afe93518a9
commit 70e8cb880e
2 changed files with 17 additions and 21 deletions

View File

@ -30,11 +30,10 @@ LIBRE_REDIRECT=./plugins/libre_redirect/libre_redirect.c ./plugins/libre_redirec
CUSTOM_STYLES=./plugins/style/style.c
READABILITY=./plugins/readability/readability.c
SHORTCUTS=./plugins/shortcuts/shortcuts.c
STAND_IN=./plugins/stand_in/stand_in.c # gives function definitions for the above, which do nothing
PLUGS=$(LIBRE_REDIRECT) $(READABILITY) $(CUSTOM_STYLES) $(SHORTCUTS)
# PLUGS=$(STAND_IN)
PLUGINS=$(LIBRE_REDIRECT) $(READABILITY) $(CUSTOM_STYLES) $(SHORTCUTS)
# PLUGINS=$(STAND_IN)
# Note that if you want some plugins but not others,
# You should edit the stand_in.c file
@ -56,7 +55,7 @@ CURRENT_CACHE_DIR=/home/$(USER)/.cache/rose
DEFAULT_DIR=/home/loki/Documents/core/software/fresh/C/rose-browser/rosenrot
CURRENT_DIR=`pwd`
build: $(SRC) $(PLUGS) $(CONFIG)
build: $(SRC) $(PLUGINS) $(CONFIG)
# Recompute constants
cd plugins/readability/ && sh recompute_READABILITY_N.sh
cd plugins/style && sh recompute_STYLE_N.sh
@ -70,10 +69,10 @@ build: $(SRC) $(PLUGS) $(CONFIG)
sed -i "s|$(DEFAULT_DIR)|$(CURRENT_DIR)|g" {} +
# Compile rosenrot
GIO_MODULE_DIR=/usr/lib/x86_64-linux-gnu/gio/modules/
$(CC) $(WARNINGS) $(OPTIMIZED) $(DEBUG) $(INCS) $(PLUGS) $(SRC) -o rose $(LIBS) $(ADBLOCK)
$(CC) $(WARNINGS) $(OPTIMIZED) $(DEBUG) $(INCS) $(PLUGINS) $(SRC) -o rose $(LIBS) $(ADBLOCK)
lint:
clang-tidy $(SRC) $(PLUGS) -- -Wall -O3 `pkg-config --cflags 'webkit2gtk-4.0'` -o rose `pkg-config --libs 'webkit2gtk-4.0'`
clang-tidy $(SRC) $(PLUGINS) -- -Wall -O3 `pkg-config --cflags 'webkit2gtk-4.0'` -o rose `pkg-config --libs 'webkit2gtk-4.0'`
inspect: build
GTK_DEBUG=interactive ./rose
@ -96,5 +95,5 @@ clean:
rm rose
rm $(CACHE_DIR)
format: $(SRC) $(PLUGS)
$(FORMATTER) $(SRC) $(PLUGS) $(rose.h)
format: $(SRC) $(PLUGINS)
$(FORMATTER) $(SRC) $(PLUGINS) $(rose.h)

23
rose.c
View File

@ -18,25 +18,22 @@ static GtkEntryBuffer* bar_line_text;
static enum { _SEARCH, _FIND, _HIDDEN } bar_entry_mode;
/* Plugins */
// #include "plugins/stand_in/stand_in.h"
int LIBRE_REDIRECT_ENABLED = true;
int READABILITY_ENABLED = true;
int CUSTOM_STYLE_ENABLED = true;
int CUSTOM_USER_AGENT = false;
int NUM_TABS = 0;
/*
To disable plugins:
1. set their corresponding variable to false
2. you could also look into this file at commit afe93518a for an approach using stand-in code.
3. recompile
// To disable plugins: set their variable to false.
// To exise plugins:
// 1. Enable them:
// - uncomment their #include statement
// - set their variable to true
// - in build.sh, uncomment: REQS= #./plugins/*/*.c
// 2. Remove stand_in code;
// - Add an #include "plugins/stand_in/stand_in.h" line, and modify
// stand_in.c so as to include stand-in functions for the excluded plugin
// - In the make file, include the stand_in.c file and exclude the
// relevant plugin
To remove plugins completely;
1. Remove the corresponding code in this file by looking for the variables above.
2. Remove PLUGIN and $(PLUGIN) from the makefiel
3. Recompile
*/
WebKitWebView* webview_new()
{