[balsa/gtk3] Restore <alt>n key bindings to change mailbox tab
- From: Peter Bloomfield <PeterB src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/gtk3] Restore <alt>n key bindings to change mailbox tab
- Date: Tue, 23 Jul 2013 20:32:14 +0000 (UTC)
commit 79b8cea1da5de516fee1d6ff27f1f203cdc7ff4c
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Tue Jul 23 16:31:21 2013 -0400
Restore <alt>n key bindings to change mailbox tab
* src/main-window.c (bw_alt_n_cb), (bw_set_alt_bindings),
(balsa_window_new): restore <alt>n key bindings to change
mailbox tab.
ChangeLog | 6 ++++++
src/main-window.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 57 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 34f7484..7428789 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-07-23 Peter Bloomfield
+
+ * src/main-window.c (bw_alt_n_cb), (bw_set_alt_bindings),
+ (balsa_window_new): restore <alt>n key bindings to change
+ mailbox tab.
+
2013-07-22 Peter Bloomfield
* src/main-window.c (toolbars_activated), (identities_activated),
diff --git a/src/main-window.c b/src/main-window.c
index 9303756..d2010ad 100644
--- a/src/main-window.c
+++ b/src/main-window.c
@@ -2081,6 +2081,54 @@ bw_set_menus(BalsaWindow * window)
}
/*
+ * Implement <alt>n to switch to the n'th mailbox tab
+ * (n = 1, 2, ..., 9);
+ * <alt>0 switches to the last tab; useful when more than 9 mailboxes
+ * are open.
+ *
+ * Note that GtkNotebook natively supports <control><alt>page-up to
+ * switch one tab to the left and <control><alt>page-down to
+ * switch one tab to the right.
+ */
+
+static void
+bw_alt_n_cb(GtkAccelGroup * accel_group,
+ GObject * acceleratable,
+ guint keyval,
+ GdkModifierType modifier,
+ gpointer user_data)
+{
+ BalsaWindow *window = user_data;
+
+ gtk_notebook_set_current_page(GTK_NOTEBOOK(window->notebook),
+ keyval - GDK_KEY_1);
+}
+
+static void
+bw_set_alt_bindings(BalsaWindow * window)
+{
+ GtkAccelGroup *accel_group;
+ gint i;
+
+ accel_group = gtk_accel_group_new();
+
+ for (i = 0; i < 10; i++) {
+ gchar accel[8];
+ guint accel_key;
+ GdkModifierType accel_mods;
+ GClosure *closure;
+
+ g_snprintf(accel, sizeof(accel), "<alt>%d", i);
+ gtk_accelerator_parse(accel, &accel_key, &accel_mods);
+
+ closure = g_cclosure_new(G_CALLBACK(bw_alt_n_cb), window, NULL);
+ gtk_accel_group_connect(accel_group, accel_key, accel_mods, 0,
+ closure);
+ }
+ gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);
+}
+
+/*
* lists of actions that are enabled or disabled as groups
*/
static const gchar *const mailbox_actions[] = {
@@ -2166,6 +2214,9 @@ balsa_window_new()
/* Set up the GMenu structures */
bw_set_menus(window);
+ /* Set up <alt>n key bindings */
+ bw_set_alt_bindings(window);
+
window->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_show(window->vbox);
gtk_container_add(GTK_CONTAINER(window), window->vbox);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]