Summary Files Commits Branches @commit @diff @stats
path: root / badwolf.c
diff options
context:
space:
mode:
1 files changed, 12 insertions, 6 deletions
-rw-r--r--badwolf.c18
diff --git a/badwolf.c b/badwolf.c
index d7d1001..184c4a3 100644
--- a/badwolf.c
+++ b/badwolf.c
@@ -286,7 +286,7 @@ WebViewCb_create(WebKitWebView *related_web_view,
struct Window *window = (struct Window *)user_data;
struct Client *browser = new_browser(window, NULL, related_web_view);
- if(badwolf_new_tab(GTK_NOTEBOOK(window->notebook), browser) < 0)
+ if(badwolf_new_tab(GTK_NOTEBOOK(window->notebook), browser, FALSE) < 0)
return NULL;
else
return browser->webView;
@@ -824,7 +824,8 @@ new_browser(struct Window *window, const gchar *target_url, WebKitWebView *relat
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
@@ -832,7 +833,7 @@ new_browser(struct Window *window, const gchar *target_url, WebKitWebView *relat
* -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");
@@ -849,6 +850,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;
}
@@ -859,7 +865,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
@@ -967,10 +973,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);