From c10b7632ebcedff280c4be1357977ae26eff4eaa Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Wed, 8 Feb 2023 14:29:36 +0100 Subject: feat: add possibility of launching many tabs at once. also, personalize this: - enable extensions - change to my css - change relative paths. fix various bugs: - set the zoom level in notebook_append, not in notebook_init - have a handly debug option for valgrind --- build.sh | 5 +++-- config.h | 2 +- plugins/readability/readability.c | 2 +- plugins/stand_in/stand_in.c | 27 --------------------------- plugins/stand_in/stand_in.c.old | 27 +++++++++++++++++++++++++++ plugins/style/style.c | 2 +- rose.c | 28 +++++++++++++++++++++------- style.css | 19 +++++++++++++++++-- user-scripts/ubuntu-20.04/rose.desktop | 2 +- user-scripts/valgrind-notes.md | 9 +++++++++ 10 files changed, 81 insertions(+), 42 deletions(-) delete mode 100644 plugins/stand_in/stand_in.c create mode 100644 plugins/stand_in/stand_in.c.old create mode 100644 user-scripts/valgrind-notes.md diff --git a/build.sh b/build.sh index 561d03d..3518b0a 100755 --- a/build.sh +++ b/build.sh @@ -2,9 +2,10 @@ CC=clang SRC=rose.c -REQS=./plugins/*/*.c # REQS=./plugins/stand_in/stand_in.c +REQS=./plugins/*/*.c DEPS='webkit2gtk-4.0' +DEBUG= #'-g' INCS=`pkg-config --cflags ${DEPS}` LIBS=`pkg-config --libs ${DEPS}` @@ -13,4 +14,4 @@ LIBS=`pkg-config --libs ${DEPS}` WYEBAB='-L/usr/lib/wyebrowser/adblock.so' # cp -f config.def.h config.h -$CC $INCS $REQS $SRC -o rose $LIBS $WYEBAB +$CC $DEBUG $INCS $REQS $SRC -o rose $LIBS $WYEBAB diff --git a/config.h b/config.h index ae87a76..970823e 100644 --- a/config.h +++ b/config.h @@ -20,7 +20,7 @@ #define GTK "gtk-application-prefer-dark-theme", false, "gtk-enable-animations", false #define ROSE_HOMEPAGE true -#define HOME ROSE_HOMEPAGE ? "file:///home/loki/Documents/core/software/fresh/C/rose-browser/rose-bud-personal/user-scripts/ubuntu-20.04/rose-images/rose-homepage.png" : "https://lite.duckduckgo.com/html" +#define HOME ROSE_HOMEPAGE ? "file:///home/loki/Documents/core/software/fresh/C/rose-browser/rose-browser/user-scripts/ubuntu-20.04/rose-images/rose-homepage.png" : "https://lite.duckduckgo.com/html" #define SEARCH "https://lite.duckduckgo.com/html/?q=%s" #define CACHE_DIR "/home/loki/.cache/rose" diff --git a/plugins/readability/readability.c b/plugins/readability/readability.c index d7d1ed9..0ae9d44 100644 --- a/plugins/readability/readability.c +++ b/plugins/readability/readability.c @@ -4,7 +4,7 @@ #define READABILITY_N 84251 + 1 void read_readability_js(char* string){ - FILE *fp=fopen("/home/loki/Documents/core/software/fresh/C/rose-browser/rose-bud-personal/plugins/readability/readability.js", "r"); + FILE *fp=fopen("/home/loki/Documents/core/software/fresh/C/rose-browser/rose-browser/plugins/readability/readability.js", "r"); if (!fp) { // fp is NULL, fopen failed fprintf(stderr, "Failed to open file\n"); string=NULL; diff --git a/plugins/stand_in/stand_in.c b/plugins/stand_in/stand_in.c deleted file mode 100644 index dbcc7e8..0000000 --- a/plugins/stand_in/stand_in.c +++ /dev/null @@ -1,27 +0,0 @@ -/* Why this file is needed: - * If the plugins are disabled, - * their conditionals will never resolve - * and their functionality never comes into play - * but the compiler still wants to know their type -*/ - -int libre_redirect(const char* uri, char* uri_filtered){ - return 0; -} -void str_init(char* str, int n){ - -}; - -int str_replace_start(const char* string, const char* target, - const char* replacement, char* output){ - return 1; -}; - -void read_readability_js(char* string){ - -} - -void read_style_js(char* string){ - -} - diff --git a/plugins/stand_in/stand_in.c.old b/plugins/stand_in/stand_in.c.old new file mode 100644 index 0000000..dbcc7e8 --- /dev/null +++ b/plugins/stand_in/stand_in.c.old @@ -0,0 +1,27 @@ +/* Why this file is needed: + * If the plugins are disabled, + * their conditionals will never resolve + * and their functionality never comes into play + * but the compiler still wants to know their type +*/ + +int libre_redirect(const char* uri, char* uri_filtered){ + return 0; +} +void str_init(char* str, int n){ + +}; + +int str_replace_start(const char* string, const char* target, + const char* replacement, char* output){ + return 1; +}; + +void read_readability_js(char* string){ + +} + +void read_style_js(char* string){ + +} + diff --git a/plugins/style/style.c b/plugins/style/style.c index dc2da8a..7e8ddf0 100644 --- a/plugins/style/style.c +++ b/plugins/style/style.c @@ -4,7 +4,7 @@ #define STYLE_N 794 + 1 void read_style_js(char* string){ - FILE *fp=fopen("/home/loki/Documents/core/software/fresh/C/rose-browser/rose-bud-personal/plugins/style/style.js", "r"); + FILE *fp=fopen("/home/loki/Documents/core/software/fresh/C/rose-browser/rose-browser/plugins/style/style.js", "r"); if (!fp) { // fp is NULL, fopen failed fprintf(stderr, "Failed to open file\n"); string=NULL; diff --git a/rose.c b/rose.c index c23a00d..4f668d6 100644 --- a/rose.c +++ b/rose.c @@ -21,9 +21,9 @@ // #include "plugins/stand_in/stand_in.h" -int LIBRE_REDIRECT_ENABLED = false; -int READABILITY_ENABLED = false; -int CUSTOM_STYLE_ENABLED = false; +int LIBRE_REDIRECT_ENABLED = true; +int READABILITY_ENABLED = true; +int CUSTOM_STYLE_ENABLED = true; // to enable plugins, // 1. Enable them: @@ -210,6 +210,7 @@ void notebook_append(GtkNotebook *notebook, const char *uri) load_uri(view, (uri) ? uri : HOME); 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); } void show_bar(GtkNotebook *notebook) @@ -413,8 +414,9 @@ void notebook_init(GtkNotebook *notebook, const char *uri) notebook_append(notebook, uri); } -void setup(GtkNotebook *notebook, const char *uri) +void setup(GtkNotebook *notebook, int argc, char **argv) { + // Define GTK entities window = GTK_WINDOW(gtk_window_new(0)); notebook = GTK_NOTEBOOK(gtk_notebook_new()); bar = GTK_HEADER_BAR(gtk_header_bar_new()); @@ -422,19 +424,31 @@ void setup(GtkNotebook *notebook, const char *uri) search = GTK_ENTRY(gtk_entry_new_with_buffer(search_buf)); gtk_window_set_default_size(window, WIDTH, HEIGHT); window_init(notebook); - notebook_init(notebook, uri); + + // Initialize with first uri + char *first_uri = argc > 1 ? argv[1] : NULL; + notebook_init(notebook, first_uri); g_object_set(gtk_settings_get_default(), GTK, NULL); + // More GTK stuff gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(notebook)); gtk_widget_show_all(GTK_WIDGET(window)); gtk_widget_hide(GTK_WIDGET(bar)); - webkit_web_view_set_zoom_level(notebook_get_webview(notebook), ZOOM); + + // Deal with more uris, if this is necessary. + if(argc > 2){ + gtk_notebook_set_show_tabs(notebook, true); + for(int i = 2; i 1 ? argv[1] : NULL); + setup(notebook, argc, argv); gtk_main(); + // this point is never reached, since gtk_main(); never exits. } diff --git a/style.css b/style.css index 45805d7..c7c07b6 100644 --- a/style.css +++ b/style.css @@ -10,7 +10,10 @@ margin: 0px; outline-color: @Lavender; color: @Text; - border-bottom-color: @Base; + border-color: white; + font-size: 16px; + /*@Base; */ + /* border-bottom-color: @Base; */ } window, notebook, headerbar { @@ -20,11 +23,21 @@ window, notebook, headerbar { tabs { background-color: @Base; padding: 3px; + outline-color: white; + border-color: @Base; } tab { background-color: @Base; + margin: 2px 5px 2px 0px; + padding: 5px; + border-style: solid; + /*border-color: white; + border-bottom-color: white; + outline-color: white; margin: 5px; + padding-left: 10px; + padding-right: 10px; */ } entry { @@ -33,5 +46,7 @@ entry { } entry:focus { - box-shadow: none; + background-color: @Surface0; + padding-left: 10px; + } diff --git a/user-scripts/ubuntu-20.04/rose.desktop b/user-scripts/ubuntu-20.04/rose.desktop index 42e7f43..213beb8 100755 --- a/user-scripts/ubuntu-20.04/rose.desktop +++ b/user-scripts/ubuntu-20.04/rose.desktop @@ -6,4 +6,4 @@ Terminal=false Exec= /usr/bin/rose Name=Rose Comment=Minimalistic browser -Icon=/home/loki/Documents/core/software/fresh/C/rose-browser/rose-bud-personal/user-scripts/ubuntu-20.04/rose-images/rose-desktop-icon.png +Icon=/home/loki/Documents/core/software/fresh/C/rose-browser/rose-browser/user-scripts/ubuntu-20.04/rose-images/rose-desktop-icon.png diff --git a/user-scripts/valgrind-notes.md b/user-scripts/valgrind-notes.md new file mode 100644 index 0000000..1fa2e1d --- /dev/null +++ b/user-scripts/valgrind-notes.md @@ -0,0 +1,9 @@ +In case you arrive at a segmentation fault when working on rose, you can use valgrind. + +To do this, you can compile rose with the `DEBUG` value in `build.sh` set to `-g` + +and then: + +``` +valgrind --track-origins=yes ./rose +``` -- cgit v1.2.3