summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/notebook.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/notebook.c b/src/notebook.c
index 118a42e..bdcbacb 100644
--- a/src/notebook.c
+++ b/src/notebook.c
@@ -125,8 +125,16 @@ switch_page_cb(MqNotebook *notebook, MqTabPage *page,
}
static void
+new_tab_clicked_cb(GtkWidget G_GNUC_UNUSED *button, MqNotebook *notebook)
+{
+ mq_notebook_insert_sibling(notebook, NULL, notebook->current_page);
+}
+
+static void
mq_notebook_init(MqNotebook *notebook)
{
+ GtkWidget *new_tab_button;
+
notebook->tree = MQ_TAB_TREE(mq_tree_insert_root_allocated(
MQ_TREE(g_new0(MqTabTree, 1)), NULL));
@@ -135,6 +143,16 @@ mq_notebook_init(MqNotebook *notebook)
gtk_notebook_set_group_name(GTK_NOTEBOOK(notebook), "mq-tabs");
gtk_widget_set_can_focus(GTK_WIDGET(notebook), FALSE);
+ new_tab_button = gtk_button_new_from_icon_name("tab-new-symbolic",
+ GTK_ICON_SIZE_BUTTON);
+ gtk_button_set_relief(GTK_BUTTON(new_tab_button), GTK_RELIEF_NONE);
+ gtk_widget_set_tooltip_text(new_tab_button, "New tab");
+ gtk_notebook_set_action_widget(GTK_NOTEBOOK(notebook), new_tab_button,
+ GTK_PACK_START);
+ gtk_widget_show_all(new_tab_button);
+ g_signal_connect(new_tab_button, "clicked",
+ G_CALLBACK(new_tab_clicked_cb), notebook);
+
g_signal_connect(notebook, "switch-page",
G_CALLBACK(switch_page_cb), NULL);
}