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 CUSTOM_STYLES=./plugins/style/style.c
READABILITY=./plugins/readability/readability.c READABILITY=./plugins/readability/readability.c
SHORTCUTS=./plugins/shortcuts/shortcuts.c SHORTCUTS=./plugins/shortcuts/shortcuts.c
STAND_IN=./plugins/stand_in/stand_in.c # gives function definitions for the above, which do nothing STAND_IN=./plugins/stand_in/stand_in.c # gives function definitions for the above, which do nothing
PLUGS=$(LIBRE_REDIRECT) $(READABILITY) $(CUSTOM_STYLES) $(SHORTCUTS) PLUGINS=$(LIBRE_REDIRECT) $(READABILITY) $(CUSTOM_STYLES) $(SHORTCUTS)
# PLUGS=$(STAND_IN) # PLUGINS=$(STAND_IN)
# Note that if you want some plugins but not others, # Note that if you want some plugins but not others,
# You should edit the stand_in.c file # 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 DEFAULT_DIR=/home/loki/Documents/core/software/fresh/C/rose-browser/rosenrot
CURRENT_DIR=`pwd` CURRENT_DIR=`pwd`
build: $(SRC) $(PLUGS) $(CONFIG) build: $(SRC) $(PLUGINS) $(CONFIG)
# Recompute constants # Recompute constants
cd plugins/readability/ && sh recompute_READABILITY_N.sh cd plugins/readability/ && sh recompute_READABILITY_N.sh
cd plugins/style && sh recompute_STYLE_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" {} + sed -i "s|$(DEFAULT_DIR)|$(CURRENT_DIR)|g" {} +
# Compile rosenrot # Compile rosenrot
GIO_MODULE_DIR=/usr/lib/x86_64-linux-gnu/gio/modules/ 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: 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 inspect: build
GTK_DEBUG=interactive ./rose GTK_DEBUG=interactive ./rose
@ -96,5 +95,5 @@ clean:
rm rose rm rose
rm $(CACHE_DIR) rm $(CACHE_DIR)
format: $(SRC) $(PLUGS) format: $(SRC) $(PLUGINS)
$(FORMATTER) $(SRC) $(PLUGS) $(rose.h) $(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; static enum { _SEARCH, _FIND, _HIDDEN } bar_entry_mode;
/* Plugins */ /* Plugins */
// #include "plugins/stand_in/stand_in.h"
int LIBRE_REDIRECT_ENABLED = true; int LIBRE_REDIRECT_ENABLED = true;
int READABILITY_ENABLED = true; int READABILITY_ENABLED = true;
int CUSTOM_STYLE_ENABLED = true; int CUSTOM_STYLE_ENABLED = true;
int CUSTOM_USER_AGENT = false; int CUSTOM_USER_AGENT = false;
int NUM_TABS = 0; 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 remove plugins completely;
// To exise plugins: 1. Remove the corresponding code in this file by looking for the variables above.
2. Remove PLUGIN and $(PLUGIN) from the makefiel
// 1. Enable them: 3. Recompile
// - 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
WebKitWebView* webview_new() WebKitWebView* webview_new()
{ {