summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/notebook.c27
-rw-r--r--src/notebook.h7
-rw-r--r--src/tab-label.c3
-rw-r--r--src/toolbars/navigation/main-menu.c12
-rw-r--r--src/web-view.c16
-rw-r--r--src/window.c5
6 files changed, 47 insertions, 23 deletions
diff --git a/src/notebook.c b/src/notebook.c
index b99adba..ffda497 100644
--- a/src/notebook.c
+++ b/src/notebook.c
@@ -129,7 +129,7 @@ switch_page_cb(MqNotebook *notebook, MqTabPage *page,
static void
new_tab_clicked_cb(GtkWidget G_GNUC_UNUSED *button, MqNotebook *notebook)
{
- mq_notebook_insert_child(notebook, NULL, notebook->current_page);
+ mq_notebook_insert_child(notebook, NULL, notebook->current_page, TRUE);
}
static void
@@ -347,7 +347,8 @@ insert_page(MqNotebook *notebook, MqTabTree *node, const gchar *uri)
}
MqTabPage *
-mq_notebook_insert_top(MqNotebook *notebook, const gchar *uri)
+mq_notebook_insert_top(MqNotebook *notebook, const gchar *uri,
+ gboolean foreground)
{
MqTabTree *node;
@@ -358,12 +359,18 @@ mq_notebook_insert_top(MqNotebook *notebook, const gchar *uri)
insert_page(notebook, node, uri);
+ if (foreground) {
+ notebook->current_page = node->page;
+ gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook),
+ mq_tree_position(node) - 1);
+ }
+
return node->page;
}
MqTabPage *
mq_notebook_insert_sibling(MqNotebook *notebook, const gchar *uri,
- MqTabPage *sibling)
+ MqTabPage *sibling, gboolean foreground)
{
MqTabTree *node;
@@ -377,12 +384,18 @@ mq_notebook_insert_sibling(MqNotebook *notebook, const gchar *uri,
insert_page(notebook, node, uri);
+ if (foreground) {
+ notebook->current_page = node->page;
+ gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook),
+ mq_tree_position(node) - 1);
+ }
+
return node->page;
}
MqTabPage *
mq_notebook_insert_child(MqNotebook *notebook, const gchar *uri,
- MqTabPage *child)
+ MqTabPage *child, gboolean foreground)
{
MqTabTree *node;
@@ -396,6 +409,12 @@ mq_notebook_insert_child(MqNotebook *notebook, const gchar *uri,
insert_page(notebook, node, uri);
+ if (foreground) {
+ notebook->current_page = node->page;
+ gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook),
+ mq_tree_position(node) - 1);
+ }
+
return node->page;
}
diff --git a/src/notebook.h b/src/notebook.h
index 43199f9..30f00fb 100644
--- a/src/notebook.h
+++ b/src/notebook.h
@@ -54,15 +54,16 @@ GtkWidget *
mq_notebook_new(MqWindow *window);
MqTabPage *
-mq_notebook_insert_top(MqNotebook *notebook, const gchar *uri);
+mq_notebook_insert_top(MqNotebook *notebook, const gchar *uri,
+ gboolean foreground);
MqTabPage *
mq_notebook_insert_sibling(MqNotebook *notebook, const gchar *uri,
- MqTabPage *sibling);
+ MqTabPage *sibling, gboolean foreground);
MqTabPage *
mq_notebook_insert_child(MqNotebook *notebook, const gchar *uri,
- MqTabPage *child);
+ MqTabPage *child, gboolean foreground);
gint
mq_notebook_get_n_pages(MqNotebook *notebook);
diff --git a/src/tab-label.c b/src/tab-label.c
index 0602a19..e4f6bce 100644
--- a/src/tab-label.c
+++ b/src/tab-label.c
@@ -69,7 +69,8 @@ new_tab_clicked_cb(GtkWidget G_GNUC_UNUSED *button, MqTabLabel *tab_label)
mq_notebook_insert_child(
MQ_NOTEBOOK(gtk_widget_get_parent(GTK_WIDGET(tab_label))),
NULL,
- tab_label->tab_page);
+ tab_label->tab_page,
+ TRUE);
gtk_widget_hide(tab_label->popover);
}
diff --git a/src/toolbars/navigation/main-menu.c b/src/toolbars/navigation/main-menu.c
index 9e2057a..2515033 100644
--- a/src/toolbars/navigation/main-menu.c
+++ b/src/toolbars/navigation/main-menu.c
@@ -102,10 +102,8 @@ preferences_clicked_cb(GtkButton G_GNUC_UNUSED *button, MqMainMenu *main_menu)
MQ_NOTEBOOK(gtk_widget_get_parent(
GTK_WIDGET(main_menu->tab_page))),
"about:preferences",
- main_menu->tab_page);
- /* TODO: Hack: */
- gtk_notebook_next_page(GTK_NOTEBOOK(gtk_widget_get_parent(
- GTK_WIDGET(main_menu->tab_page))));
+ main_menu->tab_page,
+ TRUE);
}
static void
@@ -116,10 +114,8 @@ about_clicked_cb(GtkButton G_GNUC_UNUSED *button, MqMainMenu *main_menu)
MQ_NOTEBOOK(gtk_widget_get_parent(
GTK_WIDGET(main_menu->tab_page))),
"about:",
- main_menu->tab_page);
- /* TODO: Hack: */
- gtk_notebook_next_page(GTK_NOTEBOOK(gtk_widget_get_parent(
- GTK_WIDGET(main_menu->tab_page))));
+ main_menu->tab_page,
+ TRUE);
}
static void
diff --git a/src/web-view.c b/src/web-view.c
index f4b6eab..ca7f4fb 100644
--- a/src/web-view.c
+++ b/src/web-view.c
@@ -74,7 +74,8 @@ menu_open_link_tab_activate_cb(GtkAction G_GNUC_UNUSED *action,
MQ_NOTEBOOK(gtk_widget_get_parent(
GTK_WIDGET(web_view->tab_page))),
webkit_hit_test_result_get_link_uri(web_view->hit_test_result),
- web_view->tab_page);
+ web_view->tab_page,
+ !mq_config_get_boolean(web_view->config, "tabs.background"));
}
static void
@@ -106,7 +107,8 @@ menu_open_image_tab_activate_cb(GtkAction G_GNUC_UNUSED *action,
MQ_NOTEBOOK(gtk_widget_get_parent(
GTK_WIDGET(web_view->tab_page))),
webkit_hit_test_result_get_image_uri(web_view->hit_test_result),
- web_view->tab_page);
+ web_view->tab_page,
+ !mq_config_get_boolean(web_view->config, "tabs.background"));
}
static void
@@ -138,7 +140,8 @@ menu_open_video_tab_activate_cb(GtkAction G_GNUC_UNUSED *action,
MQ_NOTEBOOK(gtk_widget_get_parent(
GTK_WIDGET(web_view->tab_page))),
webkit_hit_test_result_get_media_uri(web_view->hit_test_result),
- web_view->tab_page);
+ web_view->tab_page,
+ !mq_config_get_boolean(web_view->config, "tabs.background"));
}
static void
@@ -170,7 +173,8 @@ menu_open_audio_tab_activate_cb(GtkAction G_GNUC_UNUSED *action,
MQ_NOTEBOOK(gtk_widget_get_parent(
GTK_WIDGET(web_view->tab_page))),
webkit_hit_test_result_get_media_uri(web_view->hit_test_result),
- web_view->tab_page);
+ web_view->tab_page,
+ !mq_config_get_boolean(web_view->config, "tabs.background"));
}
static void
@@ -541,7 +545,9 @@ button_press_cb(GtkWidget *widget, GdkEventButton *event)
MQ_NOTEBOOK(gtk_widget_get_parent(
GTK_WIDGET(web_view->tab_page))),
webkit_hit_test_result_get_link_uri(hit_test_result),
- web_view->tab_page);
+ web_view->tab_page,
+ !mq_config_get_boolean(web_view->config,
+ "tabs.background"));
} else if (webkit_hit_test_result_context_is_editable(hit_test_result)){
/* Let WebKit handle pasting from the primary clipboard into an
* editable element. */
diff --git a/src/window.c b/src/window.c
index c8cd70b..9fa9215 100644
--- a/src/window.c
+++ b/src/window.c
@@ -201,10 +201,11 @@ constructed(GObject *object)
if (window->uris && window->uris[0]) {
for (i = 0; window->uris && window->uris[i]; ++i) {
mq_notebook_insert_top(MQ_NOTEBOOK(window->notebook),
- window->uris[i]);
+ window->uris[i], FALSE);
}
} else {
- mq_notebook_insert_top(MQ_NOTEBOOK(window->notebook), NULL);
+ mq_notebook_insert_top(MQ_NOTEBOOK(window->notebook), NULL,
+ FALSE);
}
gtk_widget_show_all(GTK_WIDGET(window));