diff options
author | Patrick McDermott <pj@pehjota.net> | 2017-09-28 14:56:05 (EDT) |
---|---|---|
committer | Patrick McDermott <pj@pehjota.net> | 2017-09-28 14:56:05 (EDT) |
commit | b56847c0f2afce6df436bbab32231ba4c44da301 (patch) | |
tree | f37d4ab0129612c1f82cf0448ac2e8c02d417031 | |
parent | ed2e24de47d5ccd32c258426ccf010aeb98768b8 (diff) | |
download | marquee-b56847c0f2afce6df436bbab32231ba4c44da301.zip marquee-b56847c0f2afce6df436bbab32231ba4c44da301.tar.gz marquee-b56847c0f2afce6df436bbab32231ba4c44da301.tar.bz2 |
mq_window_get_current_tab(): New function
-rw-r--r-- | src/window.c | 16 | ||||
-rw-r--r-- | src/window.h | 4 |
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 |