From 4e947ca306fa2e4ce84011fd79419adec9862b17 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Fri, 26 Apr 2019 19:57:54 +0200 Subject: badwolf: Define commonCb_key_press_event() --- badwolf.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/badwolf.c b/badwolf.c index 475cc28..471ae9f 100644 --- 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); @@ -86,6 +87,38 @@ WebViewCb_close(WebKitWebView *webView, gpointer user_data) return TRUE; } +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, -- cgit v1.3.1-23-gd82d From 8806bcb782b2e3e415007441ee37858791dd2ad1 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Fri, 26 Apr 2019 20:11:00 +0200 Subject: Hook webView to commonCb_key_press_event --- badwolf.1 | 18 +++++++++++++++--- badwolf.c | 15 +++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/badwolf.1 b/badwolf.1 index 49b7955..b97a01e 100644 --- a/badwolf.1 +++ b/badwolf.1 @@ -20,10 +20,22 @@ will probably get added at a later release. .Sh KEYBINDINGS For now it only has the default Webkit/GTK keybindings, which notably are (C for Control, S for Shift): .Bl -width Ds -tag -.It any C-PageUp, any C-PageDown, tabs arrows -When WebView isn't focused (bug to fix) this allows to move from one tab to another. -.It search C-g, search C-S-g +.It any C-PageUp / C-PageDown +Go to the previous/next tab +.It search C-g / C-S-g When the search box is focused it goes to the Next/Previous search term. +.It webview C-F4 +Closes the current tab +.It webview C-S-r / C-r +Reloads the current tab (with/without clearing cache) +.It webview C-f +Focuses on the search entry +.It webview C-l +Focuses on the location(URL) entry +.It webview C-t +Creates a new tab (unrelated, similar as pressing the button) +.It webview C-[ / C-] +Go back/forward in current tab’s history .El .Sh BUGS You can submit contributions or tickets to diff --git a/badwolf.c b/badwolf.c index 471ae9f..10a1ce4 100644 --- a/badwolf.c +++ b/badwolf.c @@ -35,6 +35,8 @@ 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_key_press_event(WebKitWebView *webView, GdkEvent *event, gpointer user_data); static gboolean WebViewCb_web_process_terminated(WebKitWebView *webView, WebKitWebProcessTerminationReason reason, gpointer user_data); @@ -119,6 +121,17 @@ commonCb_key_press_event(struct Client *browser, GdkEvent *event) return FALSE; } +static gboolean +WebViewCb_key_press_event(WebKitWebView *webView, GdkEvent *event, gpointer user_data) +{ + (void)webView; + struct Client *browser = (struct Client *)user_data; + + if(commonCb_key_press_event(browser, event)) return TRUE; + + return FALSE; +} + static gboolean WebViewCb_web_process_terminated(WebKitWebView *webView, WebKitWebProcessTerminationReason reason, @@ -470,6 +483,8 @@ new_browser(struct Window *window, gchar *target_url, WebKitWebView *related_web browser); g_signal_connect(browser->webView, "create", G_CALLBACK(WebViewCb_create), window); g_signal_connect(browser->webView, "close", G_CALLBACK(WebViewCb_close), browser); + g_signal_connect( + browser->webView, "key-press-event", G_CALLBACK(WebViewCb_key_press_event), browser); g_signal_connect(browser->search, "next-match", G_CALLBACK(SearchEntryCb_next__match), browser); g_signal_connect( -- cgit v1.3.1-23-gd82d From 47c494da006c5a034f2cf3b26299c0edf46a840b Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Fri, 26 Apr 2019 21:09:23 +0200 Subject: Add window-wide keybinds --- badwolf.1 | 2 +- badwolf.c | 67 ++++++++++++++++++++++++++++++++++++++++++--------------------- 2 files changed, 46 insertions(+), 23 deletions(-) diff --git a/badwolf.1 b/badwolf.1 index b97a01e..bc82d74 100644 --- a/badwolf.1 +++ b/badwolf.1 @@ -32,7 +32,7 @@ Reloads the current tab (with/without clearing cache) Focuses on the search entry .It webview C-l Focuses on the location(URL) entry -.It webview C-t +.It window C-t, webview C-t Creates a new tab (unrelated, similar as pressing the button) .It webview C-[ / C-] Go back/forward in current tab’s history diff --git a/badwolf.c b/badwolf.c index 10a1ce4..aeca324 100644 --- a/badwolf.c +++ b/badwolf.c @@ -34,9 +34,12 @@ struct Client }; static gboolean WebViewCb_close(WebKitWebView *webView, gpointer user_data); -static gboolean commonCb_key_press_event(struct Client *browser, GdkEvent *event); +static gboolean +commonCb_key_press_event(struct Window *window, GdkEvent *event, struct Client *browser); static gboolean WebViewCb_key_press_event(WebKitWebView *webView, GdkEvent *event, gpointer user_data); +static gboolean +main_windowCb_key_press_event(GtkWidget *widget, GdkEvent *event, gpointer user_data); static gboolean WebViewCb_web_process_terminated(WebKitWebView *webView, WebKitWebProcessTerminationReason reason, gpointer user_data); @@ -90,31 +93,38 @@ WebViewCb_close(WebKitWebView *webView, gpointer user_data) } static gboolean -commonCb_key_press_event(struct Client *browser, GdkEvent *event) +commonCb_key_press_event(struct Window *window, GdkEvent *event, struct Client *browser) { - GtkNotebook *notebook = GTK_NOTEBOOK(browser->window->notebook); + GtkNotebook *notebook = GTK_NOTEBOOK(window->notebook); if(((GdkEventKey *)event)->state & GDK_CONTROL_MASK) { - switch(((GdkEventKey *)event)->keyval) + if(browser != NULL) + { + 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_bracketleft: webkit_web_view_go_back(browser->webView); return TRUE; + case GDK_KEY_bracketright: webkit_web_view_go_forward(browser->webView); return TRUE; + } + } + else { - 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; + switch(((GdkEventKey *)event)->keyval) + { + 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(window, NULL, NULL)); return TRUE; + } } } @@ -127,11 +137,21 @@ WebViewCb_key_press_event(WebKitWebView *webView, GdkEvent *event, gpointer user (void)webView; struct Client *browser = (struct Client *)user_data; - if(commonCb_key_press_event(browser, event)) return TRUE; + if(commonCb_key_press_event(browser->window, event, browser)) return TRUE; return FALSE; } +static gboolean +main_windowCb_key_press_event(GtkWidget *widget, GdkEvent *event, gpointer user_data) +{ + (void)widget; + struct Window *window = (struct Window *)user_data; + + if(commonCb_key_press_event(window, event, NULL)) return TRUE; + + return FALSE; +} static gboolean WebViewCb_web_process_terminated(WebKitWebView *webView, WebKitWebProcessTerminationReason reason, @@ -605,6 +625,9 @@ main(int argc, char *argv[]) badwolf_new_tab(GTK_NOTEBOOK(window->notebook), new_browser(window, target_url, NULL)); + g_signal_connect( + window->main_window, "key-press-event", G_CALLBACK(main_windowCb_key_press_event), window); + g_signal_connect(window->main_window, "destroy", G_CALLBACK(gtk_main_quit), NULL); g_signal_connect(window->new_tab, "clicked", G_CALLBACK(new_tabCb_clicked), window); g_signal_connect(window->notebook, "switch-page", G_CALLBACK(notebookCb_switch__page), window); -- cgit v1.3.1-23-gd82d From 5d0681c28107c3a18b552f270743940da40808c8 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Fri, 26 Apr 2019 21:15:06 +0200 Subject: Hook browser->box to commonCb_key_press_event --- badwolf.1 | 20 ++++++++++---------- badwolf.c | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/badwolf.1 b/badwolf.1 index bc82d74..e996fd1 100644 --- a/badwolf.1 +++ b/badwolf.1 @@ -22,20 +22,20 @@ For now it only has the default Webkit/GTK keybindings, which notably are (C for .Bl -width Ds -tag .It any C-PageUp / C-PageDown Go to the previous/next tab -.It search C-g / C-S-g -When the search box is focused it goes to the Next/Previous search term. -.It webview C-F4 +.It any C-t +Creates a new tab (unrelated, similar as pressing the button) +.It browser C-F4 Closes the current tab -.It webview C-S-r / C-r -Reloads the current tab (with/without clearing cache) -.It webview C-f +.It browser C-f Focuses on the search entry -.It webview C-l +.It browser C-l Focuses on the location(URL) entry -.It window C-t, webview C-t -Creates a new tab (unrelated, similar as pressing the button) -.It webview C-[ / C-] +.It browser C-S-r / C-r +Reloads the current tab (with/without clearing cache) +.It browser C-[ / C-] Go back/forward in current tab’s history +.It search C-g / C-S-g +When the search box is focused it goes to the Next/Previous search term. .El .Sh BUGS You can submit contributions or tickets to diff --git a/badwolf.c b/badwolf.c index aeca324..1fef34e 100644 --- a/badwolf.c +++ b/badwolf.c @@ -40,6 +40,7 @@ static gboolean WebViewCb_key_press_event(WebKitWebView *webView, GdkEvent *event, gpointer user_data); static gboolean main_windowCb_key_press_event(GtkWidget *widget, GdkEvent *event, gpointer user_data); +static gboolean boxCb_key_press_event(GtkWidget *widget, GdkEvent *event, gpointer user_data); static gboolean WebViewCb_web_process_terminated(WebKitWebView *webView, WebKitWebProcessTerminationReason reason, gpointer user_data); @@ -142,6 +143,17 @@ WebViewCb_key_press_event(WebKitWebView *webView, GdkEvent *event, gpointer user return FALSE; } +static gboolean +boxCb_key_press_event(GtkWidget *widget, GdkEvent *event, gpointer user_data) +{ + (void)widget; + struct Client *browser = (struct Client *)user_data; + + if(commonCb_key_press_event(browser->window, event, browser)) return TRUE; + + return FALSE; +} + static gboolean main_windowCb_key_press_event(GtkWidget *widget, GdkEvent *event, gpointer user_data) { @@ -513,6 +525,8 @@ new_browser(struct Window *window, gchar *target_url, WebKitWebView *related_web browser->search, "search-changed", G_CALLBACK(SearchEntryCb_search__changed), browser); g_signal_connect(browser->search, "stop-search", G_CALLBACK(SearchEntryCb_stop__search), browser); + g_signal_connect(browser->box, "key-press-event", G_CALLBACK(boxCb_key_press_event), browser); + if(related_web_view == NULL) webkit_web_view_load_uri(browser->webView, target_url); return browser; -- cgit v1.3.1-23-gd82d From d918809562b2a16bfe246a6a1a8780ede37a5cd8 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Tue, 7 May 2019 09:24:46 +0200 Subject: badwolf.c: Add version information on launch --- badwolf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/badwolf.c b/badwolf.c index 1fef34e..ab52452 100644 --- a/badwolf.c +++ b/badwolf.c @@ -10,6 +10,8 @@ #include /* LC_* */ #include +const gchar *version = "0.1.1"; + struct Window { GtkWidget *main_window; @@ -605,6 +607,7 @@ main(int argc, char *argv[]) bind_textdomain_codeset(PACKAGE, "UTF-8"); textdomain(PACKAGE); + g_fprintf(stderr, _("Running Badwolf version: %s\n"), version); g_fprintf(stderr, _("Buildtime WebKit version: %d.%d.%d\n"), WEBKIT_MAJOR_VERSION, -- cgit v1.3.1-23-gd82d From b1a14aaf4a74535607ef3df56eb14dce0fdc91b9 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Wed, 8 May 2019 02:49:12 +0200 Subject: badwolf.c: Show decoded URI for statusbar --- badwolf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/badwolf.c b/badwolf.c index 1fef34e..fc02a78 100644 --- a/badwolf.c +++ b/badwolf.c @@ -317,7 +317,7 @@ WebViewCb_mouse_target_changed(WebKitWebView *webView, 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), link_uri); + gtk_label_set_text(GTK_LABEL(browser->statuslabel), webkit_uri_for_display(link_uri)); return TRUE; } -- cgit v1.3.1-23-gd82d From b916efeea04fe83d4da3d1bc4c972d71939bfe3b Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Wed, 8 May 2019 03:54:27 +0200 Subject: Add a decoded uri tooltip for location entry --- badwolf.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/badwolf.c b/badwolf.c index fc02a78..6a4fa3b 100644 --- a/badwolf.c +++ b/badwolf.c @@ -202,6 +202,11 @@ WebViewCb_notify__uri(WebKitWebView *webView, GParamSpec *pspec, gpointer user_d gtk_entry_set_text(GTK_ENTRY(browser->location), location_uri); + if(webkit_uri_for_display(location_uri) != location_uri) + gtk_widget_set_tooltip_text(browser->location, webkit_uri_for_display(location_uri)); + else + gtk_widget_set_has_tooltip(browser->location, false); + return TRUE; } -- cgit v1.3.1-23-gd82d From 9e8324381a639d0a2c85d7590dd5cf1bb84f8f4f Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 11 May 2019 01:39:43 +0200 Subject: Makefile: Fix .mo building target for BSD make --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 2635716..c6f21fe 100644 --- a/Makefile +++ b/Makefile @@ -17,9 +17,9 @@ LIBS = `pkg-config --libs $(DEPS)` all: $(OBJS) $(TRANS) -%.mo: - mkdir -p locale/$*/LC_MESSAGES - msgfmt -o locale/$*/LC_MESSAGES/$(PACKAGE).mo po/$*.po +${TRANS}: + mkdir -p locale/${@:.mo=}/LC_MESSAGES + msgfmt -o locale/${@:.mo=}/LC_MESSAGES/$(PACKAGE).mo po/${@:.mo=.po} po/messages.pot: xgettext --keyword=_ --language=C -o $@ --add-comments --sort-output -j badwolf.c -- cgit v1.3.1-23-gd82d From 9c5a0d2b96d928364621cdd6eec7b93b10afec7c Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Tue, 9 Apr 2019 15:11:22 +0200 Subject: badwolf.c: Add zoom on ctrl+scroll --- badwolf.1 | 10 +++++++++- badwolf.c | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/badwolf.1 b/badwolf.1 index e996fd1..76dab96 100644 --- a/badwolf.1 +++ b/badwolf.1 @@ -18,7 +18,15 @@ Runtime configuration specific to .Nm will probably get added at a later release. .Sh KEYBINDINGS -For now it only has the default Webkit/GTK keybindings, which notably are (C for Control, S for Shift): +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. +.Bl -width Ds -tag +.It webview C-Scroll +Zooms the webpage in/out. +.El +.Ss DEFAULT ONES +Here is a incomplete list of the default Webkit/GTK keybindings: .Bl -width Ds -tag .It any C-PageUp / C-PageDown Go to the previous/next tab diff --git a/badwolf.c b/badwolf.c index 1fef34e..e8cd46a 100644 --- a/badwolf.c +++ b/badwolf.c @@ -322,6 +322,26 @@ WebViewCb_mouse_target_changed(WebKitWebView *webView, return TRUE; } +static gboolean +WebViewCb_scroll_event(GtkWidget *widget, GdkEvent *event, gpointer data) +{ + (void)widget; + struct Client *browser = (struct Client *)data; + gdouble delta_x, delta_y; + gfloat zoom; + + if(((GdkEventScroll *)event)->state & GDK_CONTROL_MASK) + { + gdk_event_get_scroll_deltas(event, &delta_x, &delta_y); + zoom = webkit_web_view_get_zoom_level(WEBKIT_WEB_VIEW(browser->webView)); + zoom -= delta_y * 0.1; + webkit_web_view_set_zoom_level(WEBKIT_WEB_VIEW(browser->webView), zoom); + return TRUE; + } + + return FALSE; +} + static WebKitWebView * WebViewCb_create(WebKitWebView *related_web_view, WebKitNavigationAction *navigation_action, @@ -517,6 +537,7 @@ new_browser(struct Window *window, gchar *target_url, WebKitWebView *related_web g_signal_connect(browser->webView, "close", G_CALLBACK(WebViewCb_close), browser); g_signal_connect( browser->webView, "key-press-event", G_CALLBACK(WebViewCb_key_press_event), browser); + g_signal_connect(browser->webView, "scroll-event", G_CALLBACK(WebViewCb_scroll_event), browser); g_signal_connect(browser->search, "next-match", G_CALLBACK(SearchEntryCb_next__match), browser); g_signal_connect( -- cgit v1.3.1-23-gd82d From f57a127d718c116f0e11cb543fbcad2359df9c86 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 13 Apr 2019 20:57:35 +0200 Subject: badwolf.1: Add "search Escape" default binding --- badwolf.1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/badwolf.1 b/badwolf.1 index 76dab96..f039518 100644 --- a/badwolf.1 +++ b/badwolf.1 @@ -44,6 +44,8 @@ Reloads the current tab (with/without clearing cache) Go back/forward in current tab’s history .It search C-g / C-S-g When the search box is focused it goes to the Next/Previous search term. +.It search Escape +Cancels current search .El .Sh BUGS You can submit contributions or tickets to -- cgit v1.3.1-23-gd82d From 459d50c30cd1b14946ed16267b8417625d6246a9 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 11 May 2019 03:57:01 +0200 Subject: badwolf.c: C-0 resets zoom --- badwolf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/badwolf.c b/badwolf.c index e8cd46a..aac360b 100644 --- a/badwolf.c +++ b/badwolf.c @@ -116,6 +116,7 @@ commonCb_key_press_event(struct Window *window, GdkEvent *event, struct Client * case GDK_KEY_l: gtk_widget_grab_focus(browser->location); 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; + case GDK_KEY_0: webkit_web_view_set_zoom_level(WEBKIT_WEB_VIEW(browser->webView), 1); return TRUE; } } else -- cgit v1.3.1-23-gd82d From 30a0219b792593e0c6a51d9659041ce9fcc005e8 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 27 Apr 2019 19:38:13 +0200 Subject: badwolf.c: Add Alt+{Left,Right} for history, Add F5 --- badwolf.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/badwolf.c b/badwolf.c index aac360b..35ce0eb 100644 --- a/badwolf.c +++ b/badwolf.c @@ -93,6 +93,15 @@ WebViewCb_close(WebKitWebView *webView, gpointer user_data) return TRUE; } +/* commonCb_key_press_event: Global callback for keybindings + * + * Theses shortcuts should be avoided as much as possible: + * - Single key shortcuts (ie. backspace and space) + * - Triple key shortcuts (except for Ctrl+Shift) + * - Unix Terminal shortcuts (specially Ctrl-W) + * + * loosely follows https://developer.gnome.org/hig/stable/keyboard-input.html + */ static gboolean commonCb_key_press_event(struct Window *window, GdkEvent *event, struct Client *browser) { @@ -129,6 +138,23 @@ commonCb_key_press_event(struct Window *window, GdkEvent *event, struct Client * } } } + if((((GdkEventKey *)event)->state & GDK_MOD1_MASK) && brower != NULL) + ) + { + switch(((GdkEventKey *)event)->keyval) + { + case GDK_KEY_Left: gtk_notebook_prev_page(notebook); return TRUE; + case GDK_KEY_Right: gtk_notebook_next_page(notebook); return TRUE; + } + } + + if(browser != NULL) + { + switch(((GdkEventKey *)event)->keyval) + { + case GDK_KEY_F5: webkit_web_view_reload(browser->webView); return TRUE; + } + } return FALSE; } -- cgit v1.3.1-23-gd82d From c52e8e485de7b79ccec10f615d417a9193c7cff4 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Fri, 3 May 2019 04:06:24 +0200 Subject: badwolf.c: Add about dialog --- badwolf.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/badwolf.c b/badwolf.c index ab52452..652de01 100644 --- a/badwolf.c +++ b/badwolf.c @@ -10,6 +10,7 @@ #include /* LC_* */ #include +const gchar *homepage = "https://hacktivis.me/projects/badwolf"; const gchar *version = "0.1.1"; struct Window @@ -79,6 +80,23 @@ static void notebookCb_switch__page(GtkNotebook *notebook, GtkWidget *page, guint page_num, gpointer user_data); gint get_tab_position(GtkContainer *notebook, GtkWidget *child); +static void +badwolf_about_dialog(GtkWindow *main_window) +{ + // clang-format off + gtk_show_about_dialog( + main_window, + "license", "SPDX-License-Identifier: BSD-3-Clause", + "copyright", "2019 Haelwenn (lanodan) Monnier ", + "website", homepage, + "comments", "Minimalist and privacy-oriented WebKitGTK+ browser", + "version", version, + //FIXME: "logo-icon-name", g_get_application_name(), + NULL + ); + // clang-format on +} + static gboolean WebViewCb_close(WebKitWebView *webView, gpointer user_data) { @@ -130,6 +148,10 @@ commonCb_key_press_event(struct Window *window, GdkEvent *event, struct Client * } } } + else if(((GdkEventKey *)event)->keyval == GDK_KEY_F1) + { + badwolf_about_dialog(GTK_WINDOW(window->main_window)); + } return FALSE; } @@ -651,6 +673,7 @@ main(int argc, char *argv[]) gtk_widget_show(window->new_tab); gtk_widget_show_all(window->main_window); + gtk_main(); return 0; } -- cgit v1.3.1-23-gd82d From 183076aaf641506afce054d9e6f20334772cdaf0 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 11 May 2019 04:20:24 +0200 Subject: .gitignore: Ignore binairies --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 4c0463c..0f3b962 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -badwolf \ No newline at end of file +/badwolf +/locale -- cgit v1.3.1-23-gd82d From ab42e3cac5967732cd9eebe82248512328058c67 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 11 May 2019 04:56:08 +0200 Subject: badwolf.c: Fix typo --- badwolf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/badwolf.c b/badwolf.c index 9d181d9..1cdaab6 100644 --- a/badwolf.c +++ b/badwolf.c @@ -161,7 +161,7 @@ commonCb_key_press_event(struct Window *window, GdkEvent *event, struct Client * } } - if((((GdkEventKey *)event)->state & GDK_MOD1_MASK) && brower != NULL) + if((((GdkEventKey *)event)->state & GDK_MOD1_MASK) && browser != NULL) { switch(((GdkEventKey *)event)->keyval) { -- cgit v1.3.1-23-gd82d From 72bbbd0101a67f169629f952a158f3b1ae00b3ac Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 11 May 2019 04:48:17 +0200 Subject: Makefile: po/messages.pot depends on badwolf.c --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c6f21fe..85c938b 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ ${TRANS}: mkdir -p locale/${@:.mo=}/LC_MESSAGES msgfmt -o locale/${@:.mo=}/LC_MESSAGES/$(PACKAGE).mo po/${@:.mo=.po} -po/messages.pot: +po/messages.pot: badwolf.c xgettext --keyword=_ --language=C -o $@ --add-comments --sort-output -j badwolf.c po/%.po: po/messages.pot -- cgit v1.3.1-23-gd82d From e725cc9ed52539205ff9c702f6915e162f474170 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 11 May 2019 04:54:36 +0200 Subject: Makefile: translations depends on po/%.po --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 85c938b..74ddedd 100644 --- a/Makefile +++ b/Makefile @@ -17,16 +17,16 @@ LIBS = `pkg-config --libs $(DEPS)` all: $(OBJS) $(TRANS) -${TRANS}: - mkdir -p locale/${@:.mo=}/LC_MESSAGES - msgfmt -o locale/${@:.mo=}/LC_MESSAGES/$(PACKAGE).mo po/${@:.mo=.po} - po/messages.pot: badwolf.c xgettext --keyword=_ --language=C -o $@ --add-comments --sort-output -j badwolf.c po/%.po: po/messages.pot msgmerge --update $@ $< +${TRANS}: po/${@:.mo=.po} + mkdir -p locale/${@:.mo=}/LC_MESSAGES + msgfmt -o locale/${@:.mo=}/LC_MESSAGES/$(PACKAGE).mo po/${@:.mo=.po} + .c: $(CC) -std=c11 $(CFLAGS) $(CDEPS) -o $@ $< $(LDFLAGS) $(LIBS) -- cgit v1.3.1-23-gd82d From a78e6dff7950b1dcc0fb043ecc3dc31dbef3dfe0 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 11 May 2019 05:05:56 +0200 Subject: po/messages.pot: Bump --- po/messages.pot | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/po/messages.pot b/po/messages.pot index ca6c9dc..8266e03 100644 --- a/po/messages.pot +++ b/po/messages.pot @@ -6,8 +6,8 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Badwolf 0.1.0\n" -"POT-Creation-Date: 2019-04-18 13:16+0200\n" +"Project-Id-Version: Badwolf 0.1.1\n" +"POT-Creation-Date: 2019-05-11 05:03+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: \"Haelwenn (lanodan) Monnier \"\n" "Language: en\n" @@ -15,52 +15,57 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: badwolf.c:527 +#: badwolf.c:527 badwolf.c:692 #, c-format msgid "Buildtime WebKit version: %d.%d.%d\n" msgstr "" -#: badwolf.c:457 +#: badwolf.c:457 badwolf.c:621 msgid "New tab" msgstr "" -#: badwolf.c:549 +#: badwolf.c:549 badwolf.c:714 msgid "Open new tab" msgstr "" -#: badwolf.c:532 +#: badwolf.c:690 +#, c-format +msgid "Running Badwolf version: %s\n" +msgstr "" + +#: badwolf.c:532 badwolf.c:697 #, c-format msgid "Runtime WebKit version: %d.%d.%d\n" msgstr "" -#: badwolf.c:373 +#: badwolf.c:373 badwolf.c:532 msgid "Toggle javascript" msgstr "" -#: badwolf.c:413 +#: badwolf.c:413 badwolf.c:572 msgid "search in current page" msgstr "" -#: badwolf.c:100 +#: badwolf.c:100 badwolf.c:234 msgid "the web process crashed.\n" msgstr "" -#: badwolf.c:104 +#: badwolf.c:104 badwolf.c:238 msgid "the web process exceeded the memory limit.\n" msgstr "" -#: badwolf.c:108 +#: badwolf.c:108 badwolf.c:242 msgid "the web process terminated for an unknown reason.\n" msgstr "" -#: badwolf.c:101 +#: badwolf.c:101 badwolf.c:235 msgid "title|Crashed" msgstr "" -#: badwolf.c:105 +#: badwolf.c:105 badwolf.c:239 msgid "title|Out of Memory" msgstr "" -#: badwolf.c:109 +#: badwolf.c:109 badwolf.c:243 msgid "title|Unknown Crash" msgstr "" -- cgit v1.3.1-23-gd82d From e440a33e371d5741a3f49bc44727665adabbe023 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 11 May 2019 05:09:50 +0200 Subject: po/fr.po: Bump --- po/fr.po | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/po/fr.po b/po/fr.po index bfc9aac..b86e20a 100644 --- a/po/fr.po +++ b/po/fr.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Badwolf 0.1.0\n" -"POT-Creation-Date: 2019-04-18 13:16+0200\n" -"PO-Revision-Date: 2019-04-11 09:28+0200\n" +"POT-Creation-Date: 2019-05-11 05:03+0200\n" +"PO-Revision-Date: 2019-05-11 05:03+0200\n" "Last-Translator: \n" "Language-Team: French\n" "Language: fr\n" @@ -16,55 +16,60 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" -#: badwolf.c:527 +#: badwolf.c:527 badwolf.c:692 #, c-format msgid "Buildtime WebKit version: %d.%d.%d\n" msgstr "Version WebKit à la compilation: %d.%d.%d\n" -#: badwolf.c:457 +#: badwolf.c:457 badwolf.c:621 msgid "New tab" msgstr "Nouvel onglet" -#: badwolf.c:549 +#: badwolf.c:549 badwolf.c:714 msgid "Open new tab" msgstr "Ouvrir un nouvel onglet" -#: badwolf.c:532 +#: badwolf.c:690 +#, c-format +msgid "Running Badwolf version: %s\n" +msgstr "Version de Badwolf: %s\n" + +#: badwolf.c:532 badwolf.c:697 #, c-format msgid "Runtime WebKit version: %d.%d.%d\n" msgstr "Version WebKit au lancement: %d.%d.%d\n" -#: badwolf.c:373 +#: badwolf.c:373 badwolf.c:532 msgid "Toggle javascript" msgstr "Activer/Désactiver javascript" -#: badwolf.c:413 +#: badwolf.c:413 badwolf.c:572 msgid "search in current page" msgstr "recherche dans la page courante" -#: badwolf.c:100 +#: badwolf.c:100 badwolf.c:234 #, fuzzy msgid "the web process crashed.\n" msgstr "le processus web à cessé de fonctionner.\n" -#: badwolf.c:104 +#: badwolf.c:104 badwolf.c:238 #, fuzzy msgid "the web process exceeded the memory limit.\n" msgstr "le processus web à dépassé la limitation de mémoire.\n" -#: badwolf.c:108 +#: badwolf.c:108 badwolf.c:242 #, fuzzy msgid "the web process terminated for an unknown reason.\n" msgstr "le processus web s’est interrompu pour une raison inconnue.\n" -#: badwolf.c:101 +#: badwolf.c:101 badwolf.c:235 msgid "title|Crashed" msgstr "title|Crash" -#: badwolf.c:105 +#: badwolf.c:105 badwolf.c:239 msgid "title|Out of Memory" msgstr "title|Dépassement Mémoire" -#: badwolf.c:109 +#: badwolf.c:109 badwolf.c:243 msgid "title|Unknown Crash" msgstr "title|Crash inconnu" -- cgit v1.3.1-23-gd82d From 3ba43be13812acf9b8d12186d74468cd0e295b79 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 11 May 2019 07:57:07 +0200 Subject: Add a simple way to fix the URL It tries to load it as a file before trying a URL to avoid loading something meant as local. Closes: https://gitlab.com/lanodan/badWolf/issues/6 --- Makefile | 2 +- badwolf.1 | 2 +- badwolf.c | 35 ++++++++++++++++++++++++++++++++--- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 74ddedd..7bd30db 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ TRANS = fr.mo CC = cc CFLAGS = -g -Wall -Wextra -CDEPS = `pkg-config --cflags $(DEPS)` -DDATADIR=\"$(DATADIR)\" -DPACKAGE=\"$(PACKAGE)\" +CDEPS = `pkg-config --cflags $(DEPS)` -DDATADIR=\"$(DATADIR)\" -DPACKAGE=\"$(PACKAGE)\" -D_DEFAULT_SOURCE LIBS = `pkg-config --libs $(DEPS)` all: $(OBJS) $(TRANS) diff --git a/badwolf.1 b/badwolf.1 index f039518..0d0d75a 100644 --- a/badwolf.1 +++ b/badwolf.1 @@ -9,7 +9,7 @@ .Sh SYNOPSIS .Nm .Op Ar webkit/gtk options -.Op Ar url +.Op Ar url or path .Sh DESCRIPTION .Nm is a minimalist browser that care about privacy, it is based on WebKitGTK and thus also accepts WebKitGTK (and depdendencies) flags and environment variables, unfortunately there doesn't seems to be manpages for theses. diff --git a/badwolf.c b/badwolf.c index 1cdaab6..abc0fef 100644 --- a/badwolf.c +++ b/badwolf.c @@ -8,6 +8,7 @@ #include /* g_fprintf() */ #include #include /* LC_* */ +#include /* realpath() */ #include const gchar *homepage = "https://hacktivis.me/projects/badwolf"; @@ -36,6 +37,7 @@ struct Client GtkWidget *search; }; +gchar *ensure_uri_scheme(gchar *text); static gboolean WebViewCb_close(WebKitWebView *webView, gpointer user_data); static gboolean commonCb_key_press_event(struct Window *window, GdkEvent *event, struct Client *browser); @@ -80,6 +82,33 @@ static void notebookCb_switch__page(GtkNotebook *notebook, GtkWidget *page, guint page_num, gpointer user_data); gint get_tab_position(GtkContainer *notebook, GtkWidget *child); +gchar * +ensure_uri_scheme(gchar *text) +{ + if(text == NULL) return "about:blank"; + + char *scheme = g_uri_parse_scheme(text); + + if(scheme != NULL) + return text; + else + { + gchar *f; + char *path; + path = realpath(text, NULL); + + if(path != NULL) + { + f = g_strdup_printf("file://%s", path); + free(path); + } + else + f = g_strdup_printf("http://%s", text); + + return f; + } +} + static void badwolf_about_dialog(GtkWindow *main_window) { @@ -425,10 +454,10 @@ WebViewCb_create(WebKitWebView *related_web_view, static gboolean locationCb_activate(GtkEntry *location, gpointer user_data) { - const char *target_url; + char *target_url; struct Client *browser = (struct Client *)user_data; - target_url = gtk_entry_get_text(location); + target_url = ensure_uri_scheme((char *)gtk_entry_get_text(location)); if(target_url != NULL) webkit_web_view_load_uri(browser->webView, target_url); @@ -502,7 +531,7 @@ struct Client * new_browser(struct Window *window, gchar *target_url, WebKitWebView *related_web_view) { struct Client *browser = g_malloc(sizeof(struct Client)); - if(target_url == NULL) target_url = "about:blank"; + target_url = ensure_uri_scheme(target_url); browser->window = window; browser->box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); -- cgit v1.3.1-23-gd82d From 47be92a843fe469256ec136dd13f5b2ee69c7d27 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 11 May 2019 08:16:38 +0200 Subject: ensure_uri_scheme: Don’t try to resolve as a file on opening a related view MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- badwolf.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/badwolf.c b/badwolf.c index abc0fef..246ad76 100644 --- a/badwolf.c +++ b/badwolf.c @@ -37,7 +37,7 @@ struct Client GtkWidget *search; }; -gchar *ensure_uri_scheme(gchar *text); +gchar *ensure_uri_scheme(gchar *text, gbool try_file); static gboolean WebViewCb_close(WebKitWebView *webView, gpointer user_data); static gboolean commonCb_key_press_event(struct Window *window, GdkEvent *event, struct Client *browser); @@ -83,15 +83,15 @@ notebookCb_switch__page(GtkNotebook *notebook, GtkWidget *page, guint page_num, gint get_tab_position(GtkContainer *notebook, GtkWidget *child); gchar * -ensure_uri_scheme(gchar *text) +ensure_uri_scheme(gchar *text, gbool try_file) { if(text == NULL) return "about:blank"; char *scheme = g_uri_parse_scheme(text); - if(scheme != NULL) - return text; - else + if(scheme != NULL) return text; + + if(try_file) { gchar *f; char *path; @@ -101,12 +101,11 @@ ensure_uri_scheme(gchar *text) { f = g_strdup_printf("file://%s", path); free(path); + return f; } - else - f = g_strdup_printf("http://%s", text); - - return f; } + + return g_strdup_printf("http://%s", text); } static void @@ -457,7 +456,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)); + target_url = ensure_uri_scheme((char *)gtk_entry_get_text(location), FALSE); if(target_url != NULL) webkit_web_view_load_uri(browser->webView, target_url); @@ -531,7 +530,7 @@ 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); + target_url = ensure_uri_scheme(target_url, (related_web_view != NULL)); browser->window = window; browser->box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); -- cgit v1.3.1-23-gd82d From 346048a59fad3f6bfd2e3be4d821a8d89612b2d1 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sun, 12 May 2019 05:48:58 +0200 Subject: badwolf.1: Fix history nav and default keybinds --- badwolf.1 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/badwolf.1 b/badwolf.1 index 0d0d75a..1c7c739 100644 --- a/badwolf.1 +++ b/badwolf.1 @@ -24,12 +24,6 @@ if it works for the whole window, followed by the keybind it grabs. C is short f .Bl -width Ds -tag .It webview C-Scroll Zooms the webpage in/out. -.El -.Ss DEFAULT ONES -Here is a incomplete list of the default Webkit/GTK keybindings: -.Bl -width Ds -tag -.It any C-PageUp / C-PageDown -Go to the previous/next tab .It any C-t Creates a new tab (unrelated, similar as pressing the button) .It browser C-F4 @@ -40,8 +34,14 @@ Focuses on the search entry Focuses on the location(URL) entry .It browser C-S-r / C-r Reloads the current tab (with/without clearing cache) -.It browser C-[ / C-] +.It browser Alt-[ / C-] Go back/forward in current tab’s history +.El +.Ss DEFAULT ONES +Here is a incomplete list of the default Webkit/GTK keybindings: +.Bl -width Ds -tag +.It any C-PageUp / C-PageDown +Go to the previous/next tab .It search C-g / C-S-g When the search box is focused it goes to the Next/Previous search term. .It search Escape -- cgit v1.3.1-23-gd82d From 47917409e60e75bd7f1df27f2257d0ea99536e21 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sun, 12 May 2019 06:00:20 +0200 Subject: badwolf.c: x/gbool / c/gboolean / --- badwolf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/badwolf.c b/badwolf.c index 246ad76..64ba32a 100644 --- a/badwolf.c +++ b/badwolf.c @@ -37,7 +37,7 @@ struct Client GtkWidget *search; }; -gchar *ensure_uri_scheme(gchar *text, gbool try_file); +gchar *ensure_uri_scheme(gchar *text, gboolean try_file); static gboolean WebViewCb_close(WebKitWebView *webView, gpointer user_data); static gboolean commonCb_key_press_event(struct Window *window, GdkEvent *event, struct Client *browser); @@ -83,7 +83,7 @@ notebookCb_switch__page(GtkNotebook *notebook, GtkWidget *page, guint page_num, gint get_tab_position(GtkContainer *notebook, GtkWidget *child); gchar * -ensure_uri_scheme(gchar *text, gbool try_file) +ensure_uri_scheme(gchar *text, gboolean try_file) { if(text == NULL) return "about:blank"; -- cgit v1.3.1-23-gd82d From 7cf0adb99a8d16e95f500e69d3cdda26c0719f24 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sun, 12 May 2019 06:30:12 +0200 Subject: badwolf.c: Bump to 0.2.0 --- badwolf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/badwolf.c b/badwolf.c index 64ba32a..b91d4da 100644 --- a/badwolf.c +++ b/badwolf.c @@ -12,7 +12,7 @@ #include const gchar *homepage = "https://hacktivis.me/projects/badwolf"; -const gchar *version = "0.1.1"; +const gchar *version = "0.2.0"; struct Window { -- cgit v1.3.1-23-gd82d From fb531698c4e5f3c0c2f7a9151222ba8aaa6bd1e7 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Mon, 13 May 2019 10:42:01 +0200 Subject: badwolf.1: Reword C-t session bit --- badwolf.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/badwolf.1 b/badwolf.1 index 1c7c739..54ce1ac 100644 --- a/badwolf.1 +++ b/badwolf.1 @@ -25,7 +25,7 @@ if it works for the whole window, followed by the keybind it grabs. C is short f .It webview C-Scroll Zooms the webpage in/out. .It any C-t -Creates a new tab (unrelated, similar as pressing the button) +Creates a new tab (in a new session, similar as pressing the button) .It browser C-F4 Closes the current tab .It browser C-f -- cgit v1.3.1-23-gd82d