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
This commit is contained in:
NunoSempere 2023-02-08 14:29:36 +01:00
parent 2db650d7cc
commit c10b7632eb
9 changed files with 54 additions and 15 deletions

View File

@ -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

View File

@ -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"

View File

@ -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;

View File

@ -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;

28
rose.c
View File

@ -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<argc; i++){
notebook_append(notebook, argv[i]);
}
}
}
int main(int argc, char **argv)
{
GtkNotebook *notebook;
gtk_init(NULL, NULL);
setup(notebook, argc > 1 ? argv[1] : NULL);
setup(notebook, argc, argv);
gtk_main();
// this point is never reached, since gtk_main(); never exits.
}

View File

@ -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;
}

View File

@ -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

View File

@ -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
```