From b56847c0f2afce6df436bbab32231ba4c44da301 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Thu, 28 Sep 2017 14:56:05 -0400 Subject: mq_window_get_current_tab(): New function --- (limited to 'src/window.c') 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; +} -- cgit v0.9.1