add reload and zoomreset keybinds

This commit is contained in:
fenze 2022-05-13 14:08:29 +02:00
parent 9eb0c2207f
commit dce0c6d795
4 changed files with 38 additions and 17 deletions

View File

@ -2,24 +2,28 @@
#include "keyconf.h" #include "keyconf.h"
static const int dark_mode = 1; 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 *cachedir = "/home/fenze/.cache/rose/";
static const char *homepage = "https://duckduckgo.com"; static const char *homepage = "https://duckduckgo.com";
#define MODKEY GDK_CONTROL_MASK #define MODKEY GDK_CONTROL_MASK
static Key keys[] = { static Key keys[] = {
{ MODKEY, GDK_KEY_h, goback }, { MODKEY, GDK_KEY_h, goback },
{ MODKEY, GDK_KEY_l, goforward }, { MODKEY, GDK_KEY_l, goforward },
{ MODKEY, GDK_KEY_y, copy_url }, { MODKEY, GDK_KEY_y, copy_url },
{ MODKEY, GDK_KEY_p, paste_url }, { MODKEY, GDK_KEY_p, paste_url },
{ MODKEY, GDK_KEY_e, search }, { MODKEY, GDK_KEY_e, search },
{ MODKEY, GDK_KEY_equal, zoomin }, { MODSHIFT, GDK_KEY_K, zoomin },
{ MODKEY, GDK_KEY_minus, zoomout }, { MODSHIFT, GDK_KEY_J, zoomout },
{ MODKEY, GDK_KEY_i, inspector }, { MODSHIFT, GDK_KEY_Q, zoomreset },
{ MODKEY, GDK_KEY_j, down }, { MODKEY, GDK_KEY_i, inspector },
{ MODKEY, GDK_KEY_k, up }, { MODKEY, GDK_KEY_j, down },
{ MODKEY, GDK_KEY_f, find }, { MODKEY, GDK_KEY_k, up },
{ MODKEY, GDK_KEY_n, findnext }, { MODKEY, GDK_KEY_f, find },
{ MODSHIFT, GDK_KEY_N, findprev }, { MODKEY, GDK_KEY_n, findnext },
{ 0, GDK_KEY_F11, fullscreen } { MODSHIFT, GDK_KEY_N, findprev },
{ MODKEY, GDK_KEY_r, reload },
{ MODSHIFT, GDK_KEY_R, reloadforce },
{ 0, GDK_KEY_F11, fullscreen }
}; };

View File

@ -24,6 +24,9 @@ enum {
findprev, findprev,
zoomin, zoomin,
zoomout, zoomout,
zoomreset,
down, down,
up up,
reload,
reloadforce
}; };

View File

@ -1,6 +1,6 @@
CC = clang CC = clang
CFLAGS = `pkg-config --cflags 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 gstreamer-gl-1.0` LIBS = `pkg-config --libs gtk4 webkit2gtk-5.0 x11`
OPTIONS = -Dgtk_doc=false -Dintrospection=false \ OPTIONS = -Dgtk_doc=false -Dintrospection=false \
-DG_DISABLE_CAST_CHECKS \ -DG_DISABLE_CAST_CHECKS \
-Dcloudproviders=false \ -Dcloudproviders=false \

View File

@ -135,6 +135,11 @@ static gboolean key_press_callback(RoseWindow *window,
webkit_web_view_set_zoom_level(window->webview, zoom); webkit_web_view_set_zoom_level(window->webview, zoom);
break; break;
case zoomreset:
zoom = 1;
webkit_web_view_set_zoom_level(window->webview, zoom);
break;
case inspector: case inspector:
window->inspector = webkit_web_view_get_inspector(window->webview); window->inspector = webkit_web_view_get_inspector(window->webview);
if (webkit_web_inspector_is_attached(window->inspector)) if (webkit_web_inspector_is_attached(window->inspector))
@ -151,6 +156,14 @@ static gboolean key_press_callback(RoseWindow *window,
case down: case down:
webkit_web_view_run_javascript(window->webview, "window.scrollBy(0,100);", NULL, NULL, NULL); webkit_web_view_run_javascript(window->webview, "window.scrollBy(0,100);", NULL, NULL, NULL);
break; 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_signal_connect(G_OBJECT(w), "destroy",
G_CALLBACK(destroy), window); G_CALLBACK(destroy), window);
g_signal_connect(G_OBJECT(window->webview), "web-process-terminated", g_signal_connect(G_OBJECT(window->webview), "web-process-terminated",
G_CALLBACK(destroy), window); G_CALLBACK(destroy), window);