logo

badwolf

Unnamed repository; edit this file 'description' to name the repository.
commit: 9a30193a956daea1a88a903437e01e4759a729c8
parent: 9a186b4bc0dca9533c0697cde7cc36fe35a9c978
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Fri, 21 Jun 2019 01:14:31 +0200

Merge branch 'release-0.2', from release 0.2.1

Diffstat:

Mbadwolf.112+++++++++---
Mbadwolf.c41+++++++++++++++++++++++++++++++----------
2 files changed, 40 insertions(+), 13 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 { @@ -369,7 +369,9 @@ webView_tab_label_change(struct Client *browser, const gchar *title) gtk_notebook_set_tab_label( GTK_NOTEBOOK(notebook), browser->box, badwolf_new_tab_box(title, browser)); + gtk_notebook_set_menu_label_text(GTK_NOTEBOOK(notebook), browser->box, title); + // Set the window title if the title change was on the current tab if(get_tab_position(GTK_CONTAINER(notebook), browser->box) == gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook))) gtk_window_set_title(GTK_WINDOW(browser->window->main_window), title); @@ -404,11 +406,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 @@ -456,7 +464,7 @@ locationCb_activate(GtkEntry *location, gpointer user_data) char *target_url; struct Client *browser = (struct Client *)user_data; - target_url = ensure_uri_scheme((char *)gtk_entry_get_text(location), FALSE); + target_url = ensure_uri_scheme((char *)gtk_entry_get_text(location), TRUE); if(target_url != NULL) webkit_web_view_load_uri(browser->webView, target_url); @@ -529,8 +537,10 @@ 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)); - target_url = ensure_uri_scheme(target_url, (related_web_view != NULL)); + 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); @@ -550,7 +560,7 @@ new_browser(struct Window *window, gchar *target_url, WebKitWebView *related_web browser->webView = WEBKIT_WEB_VIEW(g_object_new(WEBKIT_TYPE_WEB_VIEW, "web-context", - webkit_web_context_new_ephemeral(), + web_context, "related-view", related_web_view, "settings", @@ -642,21 +652,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)); @@ -707,7 +727,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, "");