logo

badwolf

Minimalist and privacy-oriented WebKitGTK+ browser
commit: eaf289e8ebb017f7de4081a1564737da044dd341
parent: e94212d51be4e15e12a67e633baa32f0a0d6273b
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sat,  4 Jul 2020 07:15:29 +0200

Switch automatically to a tab when user-requested

This changes behavior but doesn't breaks meaning nor documentation and
significantly improves usability.
So meant to be applied directly into 1.0.x release branch.

Closes: https://gitlab.com/lanodan/badWolf/-/issues/8

Diffstat:

Mbadwolf.c18++++++++++++------
Mbadwolf.h2+-
Mkeybindings.c6++++--
Mpo/messages.pot18+++++++++---------
4 files changed, 26 insertions(+), 18 deletions(-)

diff --git a/badwolf.c b/badwolf.c @@ -300,7 +300,7 @@ WebViewCb_create(WebKitWebView *related_web_view, browser = new_browser(old_browser->window, NULL, old_browser); - if(badwolf_new_tab(GTK_NOTEBOOK(old_browser->window->notebook), browser) < 0) + if(badwolf_new_tab(GTK_NOTEBOOK(old_browser->window->notebook), browser, FALSE) < 0) return NULL; else return browser->webView; @@ -839,7 +839,8 @@ new_browser(struct Window *window, const gchar *target_url, struct Client *old_b return browser; } -/* badwolf_new_tab: Inserts struct Client *browser in GtkNotebook *notebook +/* badwolf_new_tab: Inserts struct Client *browser in GtkNotebook *notebook + * and optionally switches selected tab to it. * * returns: * 0 : Ran successfully @@ -847,7 +848,7 @@ new_browser(struct Window *window, const gchar *target_url, struct Client *old_b * -2 : browser is NULL */ int -badwolf_new_tab(GtkNotebook *notebook, struct Client *browser) +badwolf_new_tab(GtkNotebook *notebook, struct Client *browser, bool auto_switch) { gint current_page = gtk_notebook_get_current_page(notebook); gchar *title = _("New tab"); @@ -864,6 +865,11 @@ badwolf_new_tab(GtkNotebook *notebook, struct Client *browser) gtk_widget_queue_draw(GTK_WIDGET(notebook)); + if(auto_switch) + { + gtk_notebook_set_current_page(notebook, gtk_notebook_page_num(notebook, browser->box)); + } + return 0; } @@ -874,7 +880,7 @@ new_tabCb_clicked(GtkButton *new_tab, gpointer user_data) struct Window *window = (struct Window *)user_data; struct Client *browser = new_browser(window, NULL, NULL); - badwolf_new_tab(GTK_NOTEBOOK(window->notebook), browser); + badwolf_new_tab(GTK_NOTEBOOK(window->notebook), browser, TRUE); } static void @@ -982,10 +988,10 @@ main(int argc, char *argv[]) gtk_widget_show_all(window->main_window); if(argc == 1) - badwolf_new_tab(GTK_NOTEBOOK(window->notebook), new_browser(window, NULL, NULL)); + badwolf_new_tab(GTK_NOTEBOOK(window->notebook), new_browser(window, NULL, NULL), FALSE); else for(int i = 1; i < argc; ++i) - badwolf_new_tab(GTK_NOTEBOOK(window->notebook), new_browser(window, argv[i], NULL)); + badwolf_new_tab(GTK_NOTEBOOK(window->notebook), new_browser(window, argv[i], NULL), FALSE); gtk_notebook_set_current_page(GTK_NOTEBOOK(window->notebook), 1); diff --git a/badwolf.h b/badwolf.h @@ -39,6 +39,6 @@ GtkWidget *badwolf_new_tab_box(const gchar *title, struct Client *browser); void webView_tab_label_change(struct Client *browser, const gchar *title); struct Client * new_browser(struct Window *window, const gchar *target_url, struct Client *old_browser); -int badwolf_new_tab(GtkNotebook *notebook, struct Client *browser); +int badwolf_new_tab(GtkNotebook *notebook, struct Client *browser, bool auto_switch); gint badwolf_get_tab_position(GtkContainer *notebook, GtkWidget *child); #endif /* BADWOLF_H_INCLUDED */ diff --git a/keybindings.c b/keybindings.c @@ -14,7 +14,7 @@ about_dialogCb_activate_link(GtkAboutDialog *about_dialog, gchar *uri, gpointer (void)about_dialog; struct Window *window = (struct Window *)user_data; - badwolf_new_tab(GTK_NOTEBOOK(window->notebook), new_browser(window, uri, NULL)); + badwolf_new_tab(GTK_NOTEBOOK(window->notebook), new_browser(window, uri, NULL), FALSE); gtk_widget_destroy(GTK_WIDGET(about_dialog)); @@ -112,7 +112,9 @@ commonCb_key_press_event(struct Window *window, GdkEvent *event, struct Client * { 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; + case GDK_KEY_t: + badwolf_new_tab(notebook, new_browser(window, NULL, NULL), TRUE); + return TRUE; } } } diff --git a/po/messages.pot b/po/messages.pot @@ -6,9 +6,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Badwolf 1.0.0+g498bce5.develop\n" +"Project-Id-Version: Badwolf 1.0.0+ge94212d.develop\n" "Report-Msgid-Bugs-To: contact+badwolf-msgid@hacktivis.me\n" -"POT-Creation-Date: 2020-07-04 06:53+0200\n" +"POT-Creation-Date: 2020-07-04 07:13+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -41,7 +41,7 @@ msgstr "" msgid "Badwolf Downloads" msgstr "" -#: badwolf.c:913 +#: badwolf.c:919 #, c-format msgid "Buildtime WebKit version: %d.%d.%d\n" msgstr "" @@ -100,11 +100,11 @@ msgid "" "Runtime WebKit version: %d.%d.%d" msgstr "" -#: badwolf.c:853 +#: badwolf.c:854 msgid "New tab" msgstr "" -#: badwolf.c:962 +#: badwolf.c:968 msgid "Open new tab" msgstr "" @@ -112,12 +112,12 @@ msgstr "" msgid "Out of Memory" msgstr "" -#: badwolf.c:911 +#: badwolf.c:917 #, c-format msgid "Running Badwolf version: %s\n" msgstr "" -#: badwolf.c:918 +#: badwolf.c:924 #, c-format msgid "Runtime WebKit version: %d.%d.%d\n" msgstr "" @@ -167,12 +167,12 @@ msgstr "" msgid "the web process terminated for an unknown reason.\n" msgstr "" -#: badwolf.c:925 +#: badwolf.c:931 #, c-format msgid "webkit-web-extension directory set to: %s\n" msgstr "" #. TRANSLATOR Ignore this entry. Done for forcing Unicode in xgettext. -#: badwolf.c:996 +#: badwolf.c:1002 msgid "ΓΈ" msgstr ""