commit: 4e947ca306fa2e4ce84011fd79419adec9862b17
parent: c11c1a8f35b0ee89df956029f2a77d55d5a28c42
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Fri, 26 Apr 2019 19:57:54 +0200
badwolf: Define commonCb_key_press_event()
Diffstat:
M | badwolf.c | 33 | +++++++++++++++++++++++++++++++++ |
1 file changed, 33 insertions(+), 0 deletions(-)
diff --git a/badwolf.c b/badwolf.c
@@ -34,6 +34,7 @@ struct Client
};
static gboolean WebViewCb_close(WebKitWebView *webView, gpointer user_data);
+static gboolean commonCb_key_press_event(struct Client *browser, GdkEvent *event);
static gboolean WebViewCb_web_process_terminated(WebKitWebView *webView,
WebKitWebProcessTerminationReason reason,
gpointer user_data);
@@ -87,6 +88,38 @@ WebViewCb_close(WebKitWebView *webView, gpointer user_data)
}
static gboolean
+commonCb_key_press_event(struct Client *browser, GdkEvent *event)
+{
+ GtkNotebook *notebook = GTK_NOTEBOOK(browser->window->notebook);
+
+ if(((GdkEventKey *)event)->state & GDK_CONTROL_MASK)
+ {
+ switch(((GdkEventKey *)event)->keyval)
+ {
+ case GDK_KEY_F4: webkit_web_view_try_close(browser->webView); return TRUE;
+ case GDK_KEY_r:
+ if(((GdkEventKey *)event)->state & GDK_SHIFT_MASK)
+ webkit_web_view_reload_bypass_cache(browser->webView);
+ else
+ webkit_web_view_reload(browser->webView);
+
+ return TRUE;
+ case GDK_KEY_f: gtk_widget_grab_focus(browser->search); return TRUE;
+ case GDK_KEY_l: gtk_widget_grab_focus(browser->location); return TRUE;
+ case GDK_KEY_Page_Down: gtk_notebook_next_page(notebook); return TRUE;
+ case GDK_KEY_Page_Up: gtk_notebook_prev_page(notebook); return TRUE;
+ case GDK_KEY_t:
+ badwolf_new_tab(notebook, new_browser(browser->window, NULL, NULL));
+ return TRUE;
+ case GDK_KEY_bracketleft: webkit_web_view_go_back(browser->webView); return TRUE;
+ case GDK_KEY_bracketright: webkit_web_view_go_forward(browser->webView); return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+static gboolean
WebViewCb_web_process_terminated(WebKitWebView *webView,
WebKitWebProcessTerminationReason reason,
gpointer user_data)