summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-10-23 06:45:26 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-10-23 06:59:41 (EDT)
commit8f64e939cb722d6b32ee9ef4d0d08d7d1977e7c8 (patch)
treee6e45c5a0012d37c3b2cf7208b87f0f01ac5169b /src
parent313c7d8b418139f9763c271c145af79f80ffb1e9 (diff)
downloadmarquee-8f64e939cb722d6b32ee9ef4d0d08d7d1977e7c8.zip
marquee-8f64e939cb722d6b32ee9ef4d0d08d7d1977e7c8.tar.gz
marquee-8f64e939cb722d6b32ee9ef4d0d08d7d1977e7c8.tar.bz2
MqNotebook: Add new tab button
Diffstat (limited to 'src')
-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);
}