logo

badwolf

Minimalist and privacy-oriented WebKitGTK+ browser
commit: b93b710b012f65adf2dd3c2e0f809b8f0ee070f8
parent: d9cd162c1af558f75d508f4dd75b6b7f162e0700
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Fri, 21 Jun 2019 01:17:19 +0200

Merge branch 'release-0.2', from release 0.2.1

Diffstat:

Mbadwolf.112+++++++++---
Mbadwolf.c33++++++++++++++++++++++++++-------
2 files changed, 35 insertions(+), 10 deletions(-)

diff --git a/badwolf.1 b/badwolf.1 @@ -20,10 +20,12 @@ will probably get added at a later release. .Sh KEYBINDINGS The following section lists the keybinding by their action, each item is described by the widget the focus is on or .Aq any -if it works for the whole window, followed by the keybind it grabs. C is short for Control, S is short for Shift. +if it works for the whole window, followed by the keybind it grabs. A is short for Alt, C is short for Control, S is short for Shift. .Bl -width Ds -tag .It webview C-Scroll Zooms the webpage in/out. +.It webview C-0 +Resets webpage zoom to 100%. .It any C-t Creates a new tab (in a new session, similar as pressing the button) .It browser C-F4 @@ -32,10 +34,14 @@ Closes the current tab Focuses on the search entry .It browser C-l Focuses on the location(URL) entry -.It browser C-S-r / C-r +.It browser C-S-r / C-r, browser F5 Reloads the current tab (with/without clearing cache) -.It browser Alt-[ / C-] +.It browser C-[ / C-] Go back/forward in current tab’s history +.It any A-Left / A-Right +Go to the previous/next tab +.It any F1 +Shows the about dialog .El .Ss DEFAULT ONES Here is a incomplete list of the default Webkit/GTK keybindings: diff --git a/badwolf.c b/badwolf.c @@ -12,7 +12,7 @@ #include <webkit2/webkit2.h> const gchar *homepage = "https://hacktivis.me/projects/badwolf"; -const gchar *version = "0.2.0"; +const gchar *version = "0.2.1"; struct Window { @@ -430,11 +430,17 @@ WebViewCb_mouse_target_changed(WebKitWebView *webView, (void)webView; (void)modifiers; struct Client *browser = (struct Client *)user_data; - const gchar *link_uri = webkit_hit_test_result_get_link_uri(hit); - gtk_label_set_text(GTK_LABEL(browser->statuslabel), webkit_uri_for_display(link_uri)); + if(webkit_hit_test_result_context_is_link(hit)) + { + const gchar *link_uri = webkit_hit_test_result_get_link_uri(hit); - return TRUE; + gtk_label_set_text(GTK_LABEL(browser->statuslabel), webkit_uri_for_display(link_uri)); + } + else + gtk_label_set_text(GTK_LABEL(browser->statuslabel), NULL); + + return FALSE; } static gboolean @@ -643,9 +649,11 @@ SearchEntryCb_stop__search(GtkSearchEntry *search, gpointer user_data) struct Client * new_browser(struct Window *window, gchar *target_url, WebKitWebView *related_web_view) { - struct Client *browser = g_malloc(sizeof(struct Client)); + struct Client *browser = g_try_malloc(sizeof(struct Client)); target_url = ensure_uri_scheme(target_url, (related_web_view == NULL)); + if(browser == NULL) return NULL; + browser->window = window; browser->box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); browser->toolbar = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); @@ -770,21 +778,31 @@ new_browser(struct Window *window, gchar *target_url, WebKitWebView *related_web return browser; } +/* badwolf_new_tab: Inserts struct Client *browser in GtkNotebook *notebook + * + * returns: + * 0 : Ran successfully + * -1 : Failed to insert a page for browser->box + * -2 : browser is NULL + */ int badwolf_new_tab(GtkNotebook *notebook, struct Client *browser) { gint current_page = gtk_notebook_get_current_page(notebook); gchar *title = _("New tab"); + if(browser == NULL) return -2; + gtk_widget_show_all(browser->box); - if(gtk_notebook_insert_page(notebook, browser->box, NULL, (current_page + 2)) == -1) + if(gtk_notebook_insert_page(notebook, browser->box, NULL, (current_page + 1)) == -1) { return -1; } gtk_notebook_set_tab_reorderable(notebook, browser->box, TRUE); gtk_notebook_set_tab_label(notebook, browser->box, badwolf_new_tab_box(title, browser)); + gtk_notebook_set_menu_label_text(GTK_NOTEBOOK(notebook), browser->box, title); gtk_widget_queue_draw(GTK_WIDGET(notebook)); @@ -835,7 +853,8 @@ get_tab_position(GtkContainer *notebook, GtkWidget *child) int main(int argc, char *argv[]) { - struct Window *window = g_malloc(sizeof(struct Client)); + // getting an abort if this one fails to alloc + struct Window *window = g_malloc(sizeof(struct Window)); gchar *target_url = NULL; setlocale(LC_ALL, "");