Context-sensitve help
authorColin Clark <colin.clark@cclark.uk>
Mon, 1 Jan 2018 19:12:33 +0000 (19:12 +0000)
committerColin Clark <colin.clark@cclark.uk>
Mon, 1 Jan 2018 19:12:33 +0000 (19:12 +0000)
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
src/advanced_exif.c
src/collect.c
src/dupe.c
src/img-view.c
src/layout_util.c
src/layout_util.h
src/pan-view/pan-view.c
src/search.c
web/help/GuideOtherWindowsPanView.html

index 55ea758..341ea39 100644 (file)
     You can pan the view as you pan an image in normal view mode, using left mouse button and drag.\r
   </para>\r
   <para>A primary mouse button click on any image will display informations about the image. Secondary mouse button will show a context menu.</para>\r
+  <para>\r
+    The\r
+    <link linkend="GuideReferenceKeyboardShortcuts" endterm="titleGuideReferenceKeyboardShortcuts" />\r
+    available are listed in the Reference section.\r
+  </para>\r
   <note>\r
     <para>Pan view recursively visits each folder under the specified folder. This can consume considerable computer resources.</para>\r
   </note>\r
       </varlistentry>\r
     </variablelist>\r
   </section>\r
-</section>
+</section>\r
index 2a8715c..aa7797d 100644 (file)
@@ -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_...
index 94cfab1..33d5285 100644 (file)
@@ -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;
 }
 
index a5b5c83..7de6d7b 100644 (file)
@@ -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;
 }
index 89d5df8..c1d9762 100644 (file)
@@ -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;
 }
index 0f164b5..0e3b01c 100644 (file)
@@ -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("<Actions>/MenuActions/HelpContents", &help_key))
+               {
+               if (help_key.accel_key == event->keyval &&
+                                       (help_key.accel_mods & mask) == (event->state & mask))
+                       {
+                       ret = TRUE;
+                       }
+               }
+
+       return ret;
+}
 
 /*
  *-----------------------------------------------------------------------------
index fc77d84..e887669 100644 (file)
@@ -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: */
index 6010477..e9d57fb 100644 (file)
@@ -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;
 }
index 7ded659..257b0ac 100644 (file)
@@ -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;
 }
index 1b93553..090d062 100644 (file)
@@ -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.
   </p>
 <p class="para block">A primary mouse button click on any image will display informations about the image. Secondary mouse button will show a context menu.</p>
+<p class="para block">
+    The
+    <a class="link" href="GuideReferenceKeyboardShortcuts.html" title="Keyboard and Mouse Shortcuts">Keyboard and Mouse Shortcuts</a>
+    available are listed in the Reference section.
+  </p>
 <div class="admonition block note block-indent"><div class="note-inner">
     <p class="para block block-first">Pan view recursively visits each folder under the specified folder. This can consume considerable computer resources.</p>
   </div></div>