From aec1c37fc22a5a982e78e44611c5c385cc35f9bd Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 22 Jan 2023 17:27:38 +0200 Subject: [PATCH 50/50] gtk3.22: Add volume control key bindings See osdn #46589 Signed-off-by: Marko Lindqvist --- client/gui-gtk-3.22/gui_main.c | 39 ++++++++++++++++++++++++++-------- data/helpdata.txt | 1 + 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/client/gui-gtk-3.22/gui_main.c b/client/gui-gtk-3.22/gui_main.c index 8eaf12ccb7..a95248ea46 100644 --- a/client/gui-gtk-3.22/gui_main.c +++ b/client/gui-gtk-3.22/gui_main.c @@ -462,7 +462,35 @@ static gboolean key_press_map_canvas(GtkWidget *w, GdkEventKey *ev, } } - if (!(ev->state & GDK_CONTROL_MASK)) { + if (ev->state & GDK_SHIFT_MASK) { + bool volchange = FALSE; + + switch (ev->keyval) { + case GDK_KEY_plus: + case GDK_KEY_KP_Add: + gui_options.sound_effects_volume += 10; + volchange = TRUE; + break; + + case GDK_KEY_minus: + case GDK_KEY_KP_Subtract: + gui_options.sound_effects_volume -= 10; + volchange = TRUE; + break; + + default: + break; + } + + if (volchange) { + struct option *poption = optset_option_by_name(client_optset, "sound_effects_volume"); + + gui_options.sound_effects_volume = CLIP(0, gui_options.sound_effects_volume, 100); + option_changed(poption); + + return TRUE; + } + } else if (!(ev->state & GDK_CONTROL_MASK)) { switch (ev->keyval) { case GDK_KEY_plus: case GDK_KEY_KP_Add: @@ -594,9 +622,7 @@ static gboolean toplevel_key_press_handler(GtkWidget *w, GdkEventKey *ev, return FALSE; } - switch (ev->keyval) { - - case GDK_KEY_apostrophe: + if (ev->keyval == GDK_KEY_apostrophe) { /* Allow this even if not in main map view; chatline is present on * some other pages too */ @@ -618,12 +644,7 @@ static gboolean toplevel_key_press_handler(GtkWidget *w, GdkEventKey *ev, if (inputline_is_visible()) { inputline_grab_focus(); return TRUE; - } else { - break; } - - default: - break; } if (!gtk_widget_get_mapped(top_vbox) diff --git a/data/helpdata.txt b/data/helpdata.txt index e3687624c9..0c2925b32a 100644 --- a/data/helpdata.txt +++ b/data/helpdata.txt @@ -1704,6 +1704,7 @@ Unit Movement:\n\ Main Map (Keys):\n\ ================\n\ Some clients support zooming/scaling the map graphics with the + and - keys.\n\ + Some clients support audio volume control with Shift-+ and Shift-- keys.\n\ c: (c)enter view on active unit\n\ Shift-home: center view on capital\n\ Shift-arrows: scroll map\n\ -- 2.39.0