From 5e7587dd992decae5baf16847e1ab0c3cdba3821 Mon Sep 17 00:00:00 2001 From: fenze Date: Thu, 17 Nov 2022 16:57:11 +0000 Subject: [PATCH] Fix webkit bg color error, add rose-nativefier --- .clang-format | 37 ++++++ README.md | 3 +- build.sh | 5 +- compile_flags.txt | 27 +++++ install.sh | 3 +- rose | Bin 0 -> 38760 bytes rose-nativefier | 9 ++ rose.c | 298 +++++++++++++++++++--------------------------- 8 files changed, 203 insertions(+), 179 deletions(-) create mode 100644 .clang-format create mode 100644 compile_flags.txt create mode 100755 rose create mode 100755 rose-nativefier diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..69e6656 --- /dev/null +++ b/.clang-format @@ -0,0 +1,37 @@ +# vim:ft=yaml + +IndentWidth: 8 +BreakBeforeBraces: Linux +UseTab: Always +AlignArrayOfStructures: Left +AllowShortFunctionsOnASingleLine: Empty +AllowShortIfStatementsOnASingleLine: WithoutElse +AllowShortLoopsOnASingleLine: True +AlwaysBreakBeforeMultilineStrings: True +BreakBeforeTernaryOperators: True +BreakStringLiterals: True +ColumnLimit: 100 +IncludeBlocks: Regroup +KeepEmptyLinesAtTheStartOfBlocks: True +RemoveBracesLLVM: True +SortIncludes: CaseInsensitive +SortUsingDeclarations: True +SpaceAfterLogicalNot: True +SpaceAfterCStyleCast: True +SpaceAfterTemplateKeyword: False +PointerAlignment: Right +SpaceBeforeAssignmentOperators: True +SpaceBeforeCaseColon: False +SpaceBeforeCpp11BracedList: True +SpaceBeforeCtorInitializerColon: False +SpaceBeforeInheritanceColon: False +SpaceBeforeParens: Custom +SpaceBeforeParensOptions: + AfterControlStatements: True + AfterForeachMacros: True + AfterFunctionDeclarationName: False + AfterFunctionDefinitionName: False + AfterIfMacros: True + AfterOverloadedOperator: False + BeforeNonEmptyParentheses: False +SpaceBeforeRangeBasedForLoopColon: True diff --git a/README.md b/README.md index 4ece966..454067a 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,8 @@ - ~400L code base - custom gtk and websites css - hackable without any knowledge - + - builtin script nativefier + # ### 👐 Contribute See [contributing.md](https://github.com/mini-rose/rose/.github/contributing.md). diff --git a/build.sh b/build.sh index 9bb339f..cffe9d5 100755 --- a/build.sh +++ b/build.sh @@ -5,4 +5,7 @@ DEPS=('webkit2gtk-4.0') INCS=`pkg-config --cflags ${DEPS[@]}` LIBS=`pkg-config --libs ${DEPS[@]}` -$CC $INCS $LIBS $SRC -o rose +# Optional adblocking depends on https://github.com/jun7/wyebadblock +WYEBAB='-L/usr/lib/wyebrowser/adblock.so' + +$CC $INCS $LIBS $SRC $WYEBAB -o rose diff --git a/compile_flags.txt b/compile_flags.txt new file mode 100644 index 0000000..7fd8daf --- /dev/null +++ b/compile_flags.txt @@ -0,0 +1,27 @@ +-I/usr/include/webkitgtk-4.0 +-I/usr/include/glib-2.0 +-I/usr/lib/glib-2.0/include +-I/usr/include/sysprof-4 +-I/usr/include/gtk-3.0 +-I/usr/include/pango-1.0 +-I/usr/include/harfbuzz +-I/usr/include/freetype2 +-I/usr/include/libpng16 +-I/usr/include/libmount +-I/usr/include/blkid +-I/usr/include/fribidi +-I/usr/include/cairo +-I/usr/include/lzo +-I/usr/include/pixman-1 +-I/usr/include/gdk-pixbuf-2.0 +-I/usr/include/gio-unix-2.0 +-I/usr/include/cloudproviders +-I/usr/include/atk-1.0 +-I/usr/include/at-spi2-atk/2.0 +-I/usr/include/at-spi-2.0 +-I/usr/include/dbus-1.0 +-I/usr/lib/dbus-1.0/include +-I/usr/include/libsoup-2.4 +-I/usr/include/libxml2 +-pthread + diff --git a/install.sh b/install.sh index c04c668..ffed296 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,6 @@ ./build.sh && { cp -f rose /usr/bin mkdir -p /usr/share/themes/rose - cp ./style.css /usr/share/themes/rose/ + cp style.css /usr/share/themes/rose/ + cp rose-nativefier /usr/bin } diff --git a/rose b/rose new file mode 100755 index 0000000000000000000000000000000000000000..3dde429d4088d3a72032936e0014351a734f0b5b GIT binary patch literal 38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I-P%=5B_NnA4iL6`|0-_H03%HU15BQ z;vZD-;L$Xfz7p(HRD7`>;Y^qHq|?VAfP{h~z5^yvD#2?2a(LC4qc zDQL<+;Lz#(YdK9ng)qJYp?Uotgr-f53|E+ciOT=~(3U#Beh)*_6G~90Us(S85YG6^ zm7IRBL(?G@kp%x58)d&Q0i#_p4Jn;kf7R=->>sAn^{%lmz+=X*QSmhu?^-9fPu`-wE3d{dp6<^n% z{(GUO6IK7wN_4(8f21J3UhmWNE-k2NVfrr?#P8cE1vR}en=y$OrvEZv{QFS!Axh|V zU;TuOcqnPd0uG z4BR0uoWsqRBzxBJHT?@h%=r2}DqF?py0+-$<|tRXWp{5szn9*4-( zrSq@nmG=atgj!bB;@S4E0j^s!{laqU_~&XtMJY?C>2wueqPcUwN`E*9314CU`4>X1 z%M|SkN$wtATntwzyT~E_!W(5I{?*=e1*}?EHzlP1r`sg`SwVyX*5W!lu|oSj(k0{X zD(G-JzNXhX#IKFZ_?K%z$!2Y(;Tu(a6`Up8)V " +} + +test -z "$1" || test -z "$2" || { + echo -e "#!/bin/sh\n\nrose $2" > /usr/bin/$1 +} diff --git a/rose.c b/rose.c index 2b6a2d1..8914048 100644 --- a/rose.c +++ b/rose.c @@ -10,24 +10,19 @@ * Author: fenze */ -#include #include "config.h" -#define CACHE \ - "base-cache-directory", CACHE_DIR, \ - "base-data-directory", CACHE_DIR, \ - "disk-cache-directory", CACHE_DIR, \ - "dom-cache-directory", CACHE_DIR, \ - "hsts-cache-directory", CACHE_DIR, \ - "indexeddb-directory", CACHE_DIR, \ - "itp-directory", CACHE_DIR, \ - "local-storage-directory", CACHE_DIR, \ - "offline-application-cache-directory", CACHE_DIR, \ - "service-worker-registrations-directory", CACHE_DIR +#include -enum { - _SEARCH, _FIND -}; +#define CACHE \ + "base-cache-directory", CACHE_DIR, "base-data-directory", CACHE_DIR, \ + "disk-cache-directory", CACHE_DIR, "dom-cache-directory", CACHE_DIR, \ + "hsts-cache-directory", CACHE_DIR, "indexeddb-directory", CACHE_DIR, "itp-directory", \ + CACHE_DIR, "local-storage-directory", CACHE_DIR, \ + "offline-application-cache-directory", CACHE_DIR, \ + "service-worker-registrations-directory", CACHE_DIR + +enum { _SEARCH, _FIND }; static int entry_mode; static GtkWindow *window; @@ -45,47 +40,32 @@ WebKitWebView *webview_new() settings = webkit_settings_new_with_settings(WEBKIT, NULL); web_context = webkit_web_context_new_with_website_data_manager( - webkit_website_data_manager_new(CACHE, NULL) - ); + webkit_website_data_manager_new(CACHE, NULL)); contentmanager = webkit_user_content_manager_new(); cookiemanager = webkit_web_context_get_cookie_manager(web_context); - webkit_cookie_manager_set_persistent_storage( - cookiemanager, CACHE_DIR"/cookies.sqlite", - WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE - ); + webkit_cookie_manager_set_persistent_storage(cookiemanager, CACHE_DIR "/cookies.sqlite", + WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE); - webkit_cookie_manager_set_accept_policy( - cookiemanager, WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS - ); + webkit_cookie_manager_set_accept_policy(cookiemanager, WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS); - webkit_web_context_set_process_model( - web_context, - WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES - ); + webkit_web_context_set_process_model(web_context, + WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES); if (g_file_get_contents("~/.config/rose/style.css", &style, NULL, NULL)) webkit_user_content_manager_add_style_sheet( - contentmanager, - webkit_user_style_sheet_new( - style, WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES, - WEBKIT_USER_STYLE_LEVEL_USER, NULL, NULL)); + contentmanager, + webkit_user_style_sheet_new(style, WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES, + WEBKIT_USER_STYLE_LEVEL_USER, NULL, NULL)); - return g_object_new( - WEBKIT_TYPE_WEB_VIEW, - "settings", settings, - "web-context", web_context, - "user-content-manager", contentmanager, - NULL - ); + return g_object_new(WEBKIT_TYPE_WEB_VIEW, "settings", settings, "web-context", web_context, + "user-content-manager", contentmanager, NULL); } void load_uri(WebKitWebView *view, const char *uri) { - if (g_str_has_prefix(uri, "http://") - || g_str_has_prefix(uri, "https://") - || g_str_has_prefix(uri, "file://") - || g_str_has_prefix(uri, "about:")) { + if (g_str_has_prefix(uri, "http://") || g_str_has_prefix(uri, "https://") || + g_str_has_prefix(uri, "file://") || g_str_has_prefix(uri, "about:")) { webkit_web_view_load_uri(view, uri); } else { char tmp[strlen(uri) + strlen(SEARCH)]; @@ -94,13 +74,11 @@ void load_uri(WebKitWebView *view, const char *uri) } } -void load_changed(WebKitWebView* self, WebKitLoadEvent load_event, GtkNotebook *notebook) +void load_changed(WebKitWebView *self, WebKitLoadEvent load_event, GtkNotebook *notebook) { if (load_event == WEBKIT_LOAD_FINISHED) { - gtk_notebook_set_tab_label_text( - notebook, GTK_WIDGET(self), - webkit_web_view_get_title(self) - ); + gtk_notebook_set_tab_label_text(notebook, GTK_WIDGET(self), + webkit_web_view_get_title(self)); gtk_widget_hide(GTK_WIDGET(bar)); } } @@ -115,14 +93,14 @@ void notebook_append(GtkNotebook *notebook, const char *uri) WebKitWebView *view = webview_new(); - gtk_widget_set_visual (GTK_WIDGET (window), rgba_visual); + gtk_widget_set_visual(GTK_WIDGET(window), rgba_visual); g_signal_connect(view, "load_changed", G_CALLBACK(load_changed), notebook); int n = gtk_notebook_append_page(notebook, GTK_WIDGET(view), NULL); gtk_notebook_set_tab_reorderable(notebook, GTK_WIDGET(view), true); gtk_widget_show_all(GTK_WIDGET(window)); gtk_widget_hide(GTK_WIDGET(bar)); - webkit_web_view_set_background_color(view, rgba); + webkit_web_view_set_background_color(view, &rgba); load_uri(view, (uri) ? uri : HOME); gtk_notebook_set_current_page(notebook, n); } @@ -130,10 +108,7 @@ void notebook_append(GtkNotebook *notebook, const char *uri) WebKitWebView *notebook_get_webview(GtkNotebook *notebook) { return WEBKIT_WEB_VIEW( - gtk_notebook_get_nth_page( - notebook, gtk_notebook_get_current_page(notebook) - ) - ); + gtk_notebook_get_nth_page(notebook, gtk_notebook_get_current_page(notebook))); } void show_bar(GtkNotebook *notebook) @@ -146,10 +121,7 @@ void show_bar(GtkNotebook *notebook) gtk_window_set_focus(window, GTK_WIDGET(search)); } else { const char *search_text = webkit_find_controller_get_search_text( - webkit_web_view_get_find_controller( - notebook_get_webview(notebook) - ) - ); + webkit_web_view_get_find_controller(notebook_get_webview(notebook))); if (search_text != NULL) gtk_entry_buffer_set_text(search_buf, search_text, strlen(search_text)); @@ -165,117 +137,98 @@ int handle_key(func id, GtkNotebook *notebook) static bool is_fullscreen = 0; switch (id) { - case goback: - webkit_web_view_go_back(notebook_get_webview(notebook)); + case goback: + webkit_web_view_go_back(notebook_get_webview(notebook)); + break; + case goforward: + webkit_web_view_go_forward(notebook_get_webview(notebook)); + break; + + case refresh: + webkit_web_view_reload(notebook_get_webview(notebook)); + break; + case refresh_force: + webkit_web_view_reload_bypass_cache(notebook_get_webview(notebook)); + break; + + case back_to_home: + load_uri(notebook_get_webview(notebook), HOME); + break; + + case zoomin: + webkit_web_view_set_zoom_level(notebook_get_webview(notebook), (zoom += ZOOM_VAL)); + break; + + case zoomout: + webkit_web_view_set_zoom_level(notebook_get_webview(notebook), (zoom -= ZOOM_VAL)); + break; + + case zoom_reset: + webkit_web_view_set_zoom_level(notebook_get_webview(notebook), (zoom = ZOOM)); + break; + + case prev_tab: + if (gtk_notebook_get_current_page(notebook) == 0) { + gtk_notebook_set_current_page(notebook, + gtk_notebook_get_n_pages(notebook) - 1); + } else { + gtk_notebook_prev_page(notebook); + } + + break; + + case next_tab: + if (gtk_notebook_get_current_page(notebook) == + gtk_notebook_get_n_pages(notebook) - 1) { + notebook_append(notebook, NULL); + gtk_notebook_set_show_tabs(notebook, true); + } else { + gtk_notebook_next_page(notebook); + } + break; + + case close_tab: + gtk_notebook_remove_page(notebook, gtk_notebook_get_current_page(notebook)); + + switch (gtk_notebook_get_n_pages(notebook)) { + case 0: + exit(0); break; - case goforward: - webkit_web_view_go_forward(notebook_get_webview(notebook)); + case 1: + gtk_notebook_set_show_tabs(notebook, false); break; + } - case refresh: - webkit_web_view_reload(notebook_get_webview(notebook)); - break; - case refresh_force: - webkit_web_view_reload_bypass_cache(notebook_get_webview(notebook)); - break; + break; - case back_to_home: - load_uri(notebook_get_webview(notebook), HOME); - break; + case toggle_fullscreen: + if (is_fullscreen) + gtk_window_unfullscreen(window); + else + gtk_window_fullscreen(window); - case zoomin: - webkit_web_view_set_zoom_level( - notebook_get_webview(notebook), - (zoom += ZOOM_VAL) - ); - break; + is_fullscreen = ! is_fullscreen; + break; - case zoomout: - webkit_web_view_set_zoom_level( - notebook_get_webview(notebook), - (zoom -= ZOOM_VAL) - ); - break; + case show_searchbar: + entry_mode = _SEARCH; + show_bar(notebook); + break; - case zoom_reset: - webkit_web_view_set_zoom_level( - notebook_get_webview(notebook), - (zoom = ZOOM) - ); - break; + case show_finder: + entry_mode = _FIND; + show_bar(notebook); + break; - case prev_tab: - if (gtk_notebook_get_current_page(notebook) == 0) { - gtk_notebook_set_current_page( - notebook, - gtk_notebook_get_n_pages(notebook) - 1 - ); - } else { - gtk_notebook_prev_page(notebook); - } + case finder_next: + webkit_find_controller_search_next( + webkit_web_view_get_find_controller(notebook_get_webview(notebook))); + break; - break; - - case next_tab: - if (gtk_notebook_get_current_page(notebook) - == gtk_notebook_get_n_pages(notebook) - 1) { - notebook_append(notebook, NULL); - gtk_notebook_set_show_tabs(notebook, true); - } else { - gtk_notebook_next_page(notebook); - } - break; - - case close_tab: - gtk_notebook_remove_page( - notebook, - gtk_notebook_get_current_page(notebook) - ); - - - switch (gtk_notebook_get_n_pages(notebook)) { - case 0: exit(0); - break; - case 1: gtk_notebook_set_show_tabs(notebook, false); - break; - } - - break; - - case toggle_fullscreen: - if (is_fullscreen) - gtk_window_unfullscreen(window); - else - gtk_window_fullscreen(window); - - is_fullscreen = !is_fullscreen; - break; - - case show_searchbar: - entry_mode = _SEARCH; - show_bar(notebook); - break; - - case show_finder: - entry_mode = _FIND; - show_bar(notebook); - break; - - case finder_next: - webkit_find_controller_search_next( - webkit_web_view_get_find_controller( - notebook_get_webview(notebook) - ) - ); - break; - - case finder_prev: - webkit_find_controller_search_previous( - webkit_web_view_get_find_controller( - notebook_get_webview(notebook) - ) - ); - break; + case finder_prev: + webkit_find_controller_search_previous( + webkit_web_view_get_find_controller(notebook_get_webview(notebook))); + break; } return 1; @@ -286,8 +239,7 @@ int keypress(void *self, GdkEvent *e, GtkNotebook *notebook) (void) self; for (int i = 0; i < sizeof(keys) / sizeof(keys[0]); i++) - if (e->key.keyval == keys[i].key - && e->key.state == keys[i].mod) + if (e->key.keyval == keys[i].key && e->key.state == keys[i].mod) return handle_key(keys[i].id, notebook); return 0; @@ -296,18 +248,13 @@ int keypress(void *self, GdkEvent *e, GtkNotebook *notebook) void search_activate(GtkEntry *self, GtkNotebook *notebook) { if (entry_mode == _SEARCH) - load_uri(notebook_get_webview(notebook), - gtk_entry_buffer_get_text(search_buf)); + load_uri(notebook_get_webview(notebook), gtk_entry_buffer_get_text(search_buf)); else if (entry_mode == _FIND) webkit_find_controller_search( - webkit_web_view_get_find_controller( - notebook_get_webview(notebook) - ), - gtk_entry_buffer_get_text(search_buf), - WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE - | WEBKIT_FIND_OPTIONS_WRAP_AROUND, - G_MAXUINT - ); + webkit_web_view_get_find_controller(notebook_get_webview(notebook)), + gtk_entry_buffer_get_text(search_buf), + WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE | WEBKIT_FIND_OPTIONS_WRAP_AROUND, + G_MAXUINT); gtk_widget_hide(GTK_WIDGET(bar)); } @@ -317,9 +264,8 @@ void window_init(GtkNotebook *notebook) GtkCssProvider *css = gtk_css_provider_new(); gtk_css_provider_load_from_path(css, "/usr/share/themes/rose/style.css", NULL); - gtk_style_context_add_provider_for_screen( - gdk_screen_get_default(), - GTK_STYLE_PROVIDER(css), 800); + gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(css), + 800); gtk_entry_buffer_new("", 0); gtk_entry_set_alignment(search, 0.48); @@ -339,7 +285,7 @@ void notebook_init(GtkNotebook *notebook, const char *uri) notebook_append(notebook, uri); } -void setup(GtkNotebook *notebook, const char* uri) +void setup(GtkNotebook *notebook, const char *uri) { window = GTK_WINDOW(gtk_window_new(0)); notebook = GTK_NOTEBOOK(gtk_notebook_new());