aboutsummaryrefslogtreecommitdiffstats
path: root/gtk-gui.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-01-01 10:20:22 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-01-01 10:20:22 -0800
commit8f364d0094aa0c2999708dca0e1ac6fefed67837 (patch)
tree3158c5274a760b97f04257075a97c17b249a44ad /gtk-gui.c
parent91ca0d2cf669881f40a71c2ec9f05b7e5caba509 (diff)
downloadsubsurface-8f364d0094aa0c2999708dca0e1ac6fefed67837.tar.gz
Use the Left and Right keys to switch between divecomputers
The existing code had the somewhat retarded Ctrl-C binding for displaying the next divecomputer and no way to go back to the previous one. With this commit we use our keyboard grab to map Left and Right to previous and next divecomputer. Much nicer. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'gtk-gui.c')
-rw-r--r--gtk-gui.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/gtk-gui.c b/gtk-gui.c
index f241fd313..2b9068681 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -1021,6 +1021,13 @@ static void toggle_zoom(GtkWidget *w, gpointer data)
repaint_dive();
}
+static void prev_dc(GtkWidget *w, gpointer data)
+{
+ dc_number--;
+ /* If the dc number underflows, we'll "wrap around" and use the last dc */
+ repaint_dive();
+}
+
static void next_dc(GtkWidget *w, gpointer data)
{
dc_number++;
@@ -1053,7 +1060,8 @@ static GtkActionEntry menu_items[] = {
{ "ViewProfile", NULL, N_("Profile"), CTRLCHAR "2", NULL, G_CALLBACK(view_profile) },
{ "ViewInfo", NULL, N_("Info"), CTRLCHAR "3", NULL, G_CALLBACK(view_info) },
{ "ViewThree", NULL, N_("Three"), CTRLCHAR "4", NULL, G_CALLBACK(view_three) },
- { "NextDC", NULL, N_("Next DC"), CTRLCHAR "C", NULL, G_CALLBACK(next_dc) },
+ { "PrevDC", NULL, N_("Prev DC"), NULL, NULL, G_CALLBACK(prev_dc) },
+ { "NextDC", NULL, N_("Next DC"), NULL, NULL, G_CALLBACK(next_dc) },
};
static gint nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]);
@@ -1095,6 +1103,7 @@ static const gchar* ui_string = " \
<menuitem name=\"Profile\" action=\"ViewProfile\" /> \
<menuitem name=\"Info\" action=\"ViewInfo\" /> \
<menuitem name=\"Paned\" action=\"ViewThree\" /> \
+ <menuitem name=\"PrevDC\" action=\"PrevDC\" /> \
<menuitem name=\"NextDC\" action=\"NextDC\" /> \
</menu> \
</menu> \
@@ -1142,6 +1151,12 @@ static gboolean on_key_press(GtkWidget *w, GdkEventKey *event, GtkWidget *diveli
case GDK_KEY_Down:
select_next_dive();
return TRUE;
+ case GDK_KEY_Left:
+ prev_dc(NULL, NULL);
+ return TRUE;
+ case GDK_KEY_Right:
+ next_dc(NULL, NULL);
+ return TRUE;
}
return FALSE;
}