diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2021-10-23 00:44:50 +0200 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2021-10-23 00:45:29 +0200 |
commit | 5190601852e3e3a5e06a04aa41c712d860e3ffac (patch) | |
tree | 4cc3e0f8e512b3849b27ac2085df9e924b67cbf3 | |
parent | b77395b931e9509b77650cc5c89159068e70cda1 (diff) | |
download | tdv-5190601852e3e3a5e06a04aa41c712d860e3ffac.tar.gz tdv-5190601852e3e3a5e06a04aa41c712d860e3ffac.tar.xz tdv-5190601852e3e3a5e06a04aa41c712d860e3ffac.zip |
sdgui: make C-Page Up/Down wrap around
To mimic sdtui behaviour.
-rw-r--r-- | src/sdgui.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/sdgui.c b/src/sdgui.c index 5b898c7..b5ca54e 100644 --- a/src/sdgui.c +++ b/src/sdgui.c @@ -192,15 +192,18 @@ on_key_press (G_GNUC_UNUSED GtkWidget *widget, GdkEvent *event, if (accelerate_hamburger (event)) return TRUE; + GtkNotebook *notebook = GTK_NOTEBOOK (g.notebook); guint mods = event->key.state & gtk_accelerator_get_default_mod_mask (); if (mods == GDK_CONTROL_MASK) { // Can't use gtk_widget_add_accelerator() to change-current-page(-1/+1) // because that signal has arguments, which cannot be passed. + gint current = gtk_notebook_get_current_page (notebook); if (event->key.keyval == GDK_KEY_Page_Up) - return gtk_notebook_prev_page (GTK_NOTEBOOK (g.notebook)), TRUE; + return gtk_notebook_set_current_page (notebook, --current), TRUE; if (event->key.keyval == GDK_KEY_Page_Down) - return gtk_notebook_next_page (GTK_NOTEBOOK (g.notebook)), TRUE; + return gtk_notebook_set_current_page (notebook, + ++current % gtk_notebook_get_n_pages (notebook)), TRUE; } if (mods == GDK_MOD1_MASK) { @@ -208,8 +211,7 @@ on_key_press (G_GNUC_UNUSED GtkWidget *widget, GdkEvent *event, && event->key.keyval <= GDK_KEY_9) { gint n = event->key.keyval - GDK_KEY_0; - gtk_notebook_set_current_page - (GTK_NOTEBOOK (g.notebook), n ? (n - 1) : 10); + gtk_notebook_set_current_page (notebook, n ? (n - 1) : 10); return TRUE; } } |