From d232acf1c25888480ea9e80956bedd9719e06a21 Mon Sep 17 00:00:00 2001 From: Colin Clark Date: Mon, 1 Jan 2018 19:12:33 +0000 Subject: [PATCH] Context-sensitve help Implement context-sensitive help key for the following windows: exif collection duplicates image pan view search Replace all instances of the constant GDK_KEY_F1 with a call to a function which gets the key code set by the user in Preferences/Keyboard for Help --- doc/docbook/GuideOtherWindowsPanView.xml | 7 +++++- src/advanced_exif.c | 6 +++++ src/collect.c | 10 ++++++--- src/dupe.c | 9 +++++--- src/img-view.c | 6 +++++ src/layout_util.c | 28 ++++++++++++++++++++++++ src/layout_util.h | 2 ++ src/pan-view/pan-view.c | 10 +++++---- src/search.c | 9 +++++--- web/help/GuideOtherWindowsPanView.html | 5 +++++ 10 files changed, 78 insertions(+), 14 deletions(-) diff --git a/doc/docbook/GuideOtherWindowsPanView.xml b/doc/docbook/GuideOtherWindowsPanView.xml index 55ea758f..341ea390 100644 --- a/doc/docbook/GuideOtherWindowsPanView.xml +++ b/doc/docbook/GuideOtherWindowsPanView.xml @@ -22,6 +22,11 @@ You can pan the view as you pan an image in normal view mode, using left mouse button and drag. A primary mouse button click on any image will display informations about the image. Secondary mouse button will show a context menu. + + The + + available are listed in the Reference section. + Pan view recursively visits each folder under the specified folder. This can consume considerable computer resources. @@ -209,4 +214,4 @@ - + diff --git a/src/advanced_exif.c b/src/advanced_exif.c index 2a8715cb..aa7797d5 100644 --- a/src/advanced_exif.c +++ b/src/advanced_exif.c @@ -26,6 +26,7 @@ #include "metadata.h" #include "filedata.h" #include "history_list.h" +#include "layout_util.h" #include "misc.h" #include "ui_misc.h" #include "window.h" @@ -360,6 +361,11 @@ static gboolean advanced_exif_keypress(GtkWidget *widget, GdkEventKey *event, gp break; } } // if (event->state & GDK_CONTROL... + if (!stop_signal && is_help_key(event)) + { + help_window_show("GuideOtherWindowsExif.html"); + stop_signal = TRUE; + } return stop_signal; } // static gboolean advanced_exif_... diff --git a/src/collect.c b/src/collect.c index 94cfab10..33d5285c 100644 --- a/src/collect.c +++ b/src/collect.c @@ -30,6 +30,7 @@ #include "img-view.h" #include "layout.h" #include "layout_image.h" +#include "layout_util.h" #include "misc.h" #include "pixbuf_util.h" #include "print.h" @@ -992,14 +993,17 @@ static gboolean collection_window_keypress(GtkWidget *widget, GdkEventKey *event collection_remove_by_info(cw->cd, collection_table_get_focus_info(cw->table)); } break; - case GDK_KEY_F1: - help_window_show("GuideReferenceKeyboardShortcuts.html#CollectionsKeyboardShortcuts"); - break; default: stop_signal = FALSE; break; } } + if (!stop_signal && is_help_key(event)) + { + help_window_show("GuideCollections.html"); + stop_signal = TRUE; + } + return stop_signal; } diff --git a/src/dupe.c b/src/dupe.c index a5b5c83b..7de6d7b3 100644 --- a/src/dupe.c +++ b/src/dupe.c @@ -32,6 +32,7 @@ #include "img-view.h" #include "layout.h" #include "layout_image.h" +#include "layout_util.h" #include "md5-util.h" #include "menu.h" #include "misc.h" @@ -3165,14 +3166,16 @@ static gboolean dupe_window_keypress_cb(GtkWidget *widget, GdkEventKey *event, g dupe_popup_menu_pos_cb, listview, 0, GDK_CURRENT_TIME); } break; - case GDK_KEY_F1: - help_window_show("GuideReferenceKeyboardShortcuts.html#DuplicatesKeyboardShortcuts"); - break; default: stop_signal = FALSE; break; } } + if (!stop_signal && is_help_key(event)) + { + help_window_show("GuideImageSearchFindingDuplicates.html"); + stop_signal = TRUE; + } return stop_signal; } diff --git a/src/img-view.c b/src/img-view.c index 89d5df8e..c1d97625 100644 --- a/src/img-view.c +++ b/src/img-view.c @@ -32,6 +32,7 @@ #include "image-overlay.h" #include "layout.h" #include "layout_image.h" +#include "layout_util.h" #include "menu.h" #include "misc.h" #include "pixbuf_util.h" @@ -563,6 +564,11 @@ static gboolean view_window_key_press_cb(GtkWidget *widget, GdkEventKey *event, break; } } + if (!stop_signal && is_help_key(event)) + { + help_window_show("GuideOtherWindowsImageWindow.html"); + stop_signal = TRUE; + } return stop_signal; } diff --git a/src/layout_util.c b/src/layout_util.c index 0f164b56..0e3b01c1 100644 --- a/src/layout_util.c +++ b/src/layout_util.c @@ -3005,6 +3005,34 @@ void layout_util_sync(LayoutWindow *lw) // layout_menu_edit_update(lw); } +/** + * @brief Checks if event key is mapped to Help + * @param event + * @returns + * + * Used to check if the user has re-mapped the Help key + * in Preferences/Keyboard + * + * Note: help_key.accel_mods and event->state + * differ in the higher bits + */ +gboolean is_help_key(GdkEventKey *event) +{ + GtkAccelKey help_key; + gboolean ret = FALSE; + guint mask = GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK; + + if (gtk_accel_map_lookup_entry("/MenuActions/HelpContents", &help_key)) + { + if (help_key.accel_key == event->keyval && + (help_key.accel_mods & mask) == (event->state & mask)) + { + ret = TRUE; + } + } + + return ret; +} /* *----------------------------------------------------------------------------- diff --git a/src/layout_util.h b/src/layout_util.h index fc77d84c..e887669f 100644 --- a/src/layout_util.h +++ b/src/layout_util.h @@ -71,5 +71,7 @@ void layout_bars_close(LayoutWindow *lw); void layout_exif_window_new(LayoutWindow *lw); +gboolean is_help_key(GdkEventKey *event); + #endif /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ diff --git a/src/pan-view/pan-view.c b/src/pan-view/pan-view.c index 60104778..e9d57fbf 100644 --- a/src/pan-view/pan-view.c +++ b/src/pan-view/pan-view.c @@ -29,6 +29,7 @@ #include "history_list.h" #include "image.h" #include "img-view.h" +#include "layout_util.h" #include "menu.h" #include "metadata.h" #include "misc.h" @@ -1299,15 +1300,16 @@ static gboolean pan_window_key_press_cb(GtkWidget *widget, GdkEventKey *event, g case '/': pan_search_toggle_visible(pw, TRUE); break; - case GDK_KEY_F1: - help_window_show("GuideReferenceKeyboardShortcuts.html#PanViewKeyboardShortcuts"); - break; - default: stop_signal = FALSE; break; } } } + if (!stop_signal && is_help_key(event)) + { + help_window_show("GuideOtherWindowsPanView.html"); + stop_signal = TRUE; + } return stop_signal; } diff --git a/src/search.c b/src/search.c index 7ded659b..257b0acf 100644 --- a/src/search.c +++ b/src/search.c @@ -32,6 +32,7 @@ #include "image-load.h" #include "img-view.h" #include "layout.h" +#include "layout_util.h" #include "math.h" #include "menu.h" #include "metadata.h" @@ -1367,9 +1368,6 @@ static gboolean search_result_keypress_cb(GtkWidget *widget, GdkEventKey *event, search_result_menu_pos_cb, sd, 0, GDK_CURRENT_TIME); } break; - case GDK_KEY_F1: - help_window_show("GuideReferenceKeyboardShortcuts.html#SearchKeyboardShortcuts"); - break; default: stop_signal = FALSE; break; @@ -1401,6 +1399,11 @@ static gboolean search_window_keypress_cb(GtkWidget *widget, GdkEventKey *event, break; } } + if (!stop_signal && is_help_key(event)) + { + help_window_show("GuideImageSearchSearch.html"); + stop_signal = TRUE; + } return stop_signal; } diff --git a/web/help/GuideOtherWindowsPanView.html b/web/help/GuideOtherWindowsPanView.html index 1b93553d..090d0627 100644 --- a/web/help/GuideOtherWindowsPanView.html +++ b/web/help/GuideOtherWindowsPanView.html @@ -464,6 +464,11 @@ dd.answer div.label { float: left; } You can pan the view as you pan an image in normal view mode, using left mouse button and drag.

A primary mouse button click on any image will display informations about the image. Secondary mouse button will show a context menu.

+

+ The + Keyboard and Mouse Shortcuts + available are listed in the Reference section. +

Pan view recursively visits each folder under the specified folder. This can consume considerable computer resources.

-- 2.20.1