summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/window.c16
-rw-r--r--src/window.h4
2 files changed, 20 insertions, 0 deletions
diff --git a/src/window.c b/src/window.c
index 258fcbf..be034f8 100644
--- a/src/window.c
+++ b/src/window.c
@@ -28,6 +28,14 @@
#include "tab.h"
static void
+switch_page_cb(GtkNotebook __attribute__((unused)) *notebook,
+ GtkWidget __attribute__((unused)) *page, guint page_num,
+ MqWindow *window)
+{
+ window->current_tab = page_num;
+}
+
+static void
update_positions(GtkNotebook __attribute__((unused)) *notebook,
GtkWidget __attribute__((unused)) *child,
guint __attribute__((unused)) page_num, MqWindow *window)
@@ -60,6 +68,8 @@ mq_window_new(MqApplication *application, const gchar **uris)
gtk_widget_set_can_focus(window->notebook, FALSE);
gtk_container_add(GTK_CONTAINER(window->window),
window->notebook);
+ g_signal_connect(window->notebook, "switch-page",
+ G_CALLBACK(switch_page_cb), window);
g_signal_connect(window->notebook, "page-reordered",
G_CALLBACK(update_positions), window);
@@ -97,3 +107,9 @@ mq_window_insert_tab(MqWindow *window, GtkWidget *tab_page,
gtk_widget_show_all(tab_page);
gtk_widget_show_all(tab_label);
}
+
+guint
+mq_window_get_current_tab(MqWindow *window)
+{
+ return window->current_tab;
+}
diff --git a/src/window.h b/src/window.h
index 962106e..03cd327 100644
--- a/src/window.h
+++ b/src/window.h
@@ -34,6 +34,7 @@ struct MqWindow {
GtkWidget *window;
GtkWidget *notebook;
MqTab *root_tab;
+ guint current_tab;
};
MqWindow *
@@ -46,4 +47,7 @@ void
mq_window_insert_tab(MqWindow *window, GtkWidget *tab_page,
GtkWidget *tab_label, gint position);
+guint
+mq_window_get_current_tab(MqWindow *window);
+
#endif