diff options
1 files changed, 12 insertions, 6 deletions
| -rw-r--r-- | badwolf.c | 18 |
@@ -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); |