From dce0c6d795e416ae257c124e7d69b8e809ec8c6e Mon Sep 17 00:00:00 2001 From: fenze Date: Fri, 13 May 2022 14:08:29 +0200 Subject: [PATCH] add reload and zoomreset keybinds --- config.h | 32 ++++++++++++++++++-------------- keyconf.h | 5 ++++- makefile | 4 ++-- window.c | 14 ++++++++++++++ 4 files changed, 38 insertions(+), 17 deletions(-) diff --git a/config.h b/config.h index 4be78eb..4803bf8 100644 --- a/config.h +++ b/config.h @@ -2,24 +2,28 @@ #include "keyconf.h" static const int dark_mode = 1; +// static const char *cachedir = "/home/{user}/.cache/rose/"; static const char *cachedir = "/home/fenze/.cache/rose/"; static const char *homepage = "https://duckduckgo.com"; #define MODKEY GDK_CONTROL_MASK static Key keys[] = { - { MODKEY, GDK_KEY_h, goback }, - { MODKEY, GDK_KEY_l, goforward }, - { MODKEY, GDK_KEY_y, copy_url }, - { MODKEY, GDK_KEY_p, paste_url }, - { MODKEY, GDK_KEY_e, search }, - { MODKEY, GDK_KEY_equal, zoomin }, - { MODKEY, GDK_KEY_minus, zoomout }, - { MODKEY, GDK_KEY_i, inspector }, - { MODKEY, GDK_KEY_j, down }, - { MODKEY, GDK_KEY_k, up }, - { MODKEY, GDK_KEY_f, find }, - { MODKEY, GDK_KEY_n, findnext }, - { MODSHIFT, GDK_KEY_N, findprev }, - { 0, GDK_KEY_F11, fullscreen } + { MODKEY, GDK_KEY_h, goback }, + { MODKEY, GDK_KEY_l, goforward }, + { MODKEY, GDK_KEY_y, copy_url }, + { MODKEY, GDK_KEY_p, paste_url }, + { MODKEY, GDK_KEY_e, search }, + { MODSHIFT, GDK_KEY_K, zoomin }, + { MODSHIFT, GDK_KEY_J, zoomout }, + { MODSHIFT, GDK_KEY_Q, zoomreset }, + { MODKEY, GDK_KEY_i, inspector }, + { MODKEY, GDK_KEY_j, down }, + { MODKEY, GDK_KEY_k, up }, + { MODKEY, GDK_KEY_f, find }, + { MODKEY, GDK_KEY_n, findnext }, + { MODSHIFT, GDK_KEY_N, findprev }, + { MODKEY, GDK_KEY_r, reload }, + { MODSHIFT, GDK_KEY_R, reloadforce }, + { 0, GDK_KEY_F11, fullscreen } }; diff --git a/keyconf.h b/keyconf.h index 272b6c9..c1d303b 100644 --- a/keyconf.h +++ b/keyconf.h @@ -24,6 +24,9 @@ enum { findprev, zoomin, zoomout, + zoomreset, down, - up + up, + reload, + reloadforce }; diff --git a/makefile b/makefile index f6b5d13..7a0fc30 100644 --- a/makefile +++ b/makefile @@ -1,6 +1,6 @@ CC = clang -CFLAGS = `pkg-config --cflags gtk4 webkit2gtk-5.0 x11 gstreamer-gl-1.0` -LIBS = `pkg-config --libs gtk4 webkit2gtk-5.0 x11 gstreamer-gl-1.0` +CFLAGS = `pkg-config --cflags gtk4 webkit2gtk-5.0 x11` +LIBS = `pkg-config --libs gtk4 webkit2gtk-5.0 x11` OPTIONS = -Dgtk_doc=false -Dintrospection=false \ -DG_DISABLE_CAST_CHECKS \ -Dcloudproviders=false \ diff --git a/window.c b/window.c index 7610486..cebbe81 100644 --- a/window.c +++ b/window.c @@ -135,6 +135,11 @@ static gboolean key_press_callback(RoseWindow *window, webkit_web_view_set_zoom_level(window->webview, zoom); break; + case zoomreset: + zoom = 1; + webkit_web_view_set_zoom_level(window->webview, zoom); + break; + case inspector: window->inspector = webkit_web_view_get_inspector(window->webview); if (webkit_web_inspector_is_attached(window->inspector)) @@ -151,6 +156,14 @@ static gboolean key_press_callback(RoseWindow *window, case down: webkit_web_view_run_javascript(window->webview, "window.scrollBy(0,100);", NULL, NULL, NULL); break; + + case reload: + webkit_web_view_reload(window->webview); + break; + + case reloadforce: + webkit_web_view_reload_bypass_cache(window->webview); + break; } } } @@ -187,6 +200,7 @@ guint rose_window_show(GtkApplication *app, RoseWindow *window, const char *url) g_signal_connect(G_OBJECT(w), "destroy", G_CALLBACK(destroy), window); + g_signal_connect(G_OBJECT(window->webview), "web-process-terminated", G_CALLBACK(destroy), window);