[gthumb] shortcuts: allow to register shortcuts for documentation purposes only



commit 6ece2936ea446effbc78c1860b7199a7f65a468e
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Fri Nov 22 10:16:07 2019 +0100

    shortcuts: allow to register shortcuts for documentation purposes only

 gthumb/gth-shortcut.c         | 22 ++++++++++++++++++----
 gthumb/gth-shortcuts-window.c |  2 +-
 gthumb/gth-window.c           |  3 +++
 gthumb/typedefs.h             |  3 +++
 4 files changed, 25 insertions(+), 5 deletions(-)
---
diff --git a/gthumb/gth-shortcut.c b/gthumb/gth-shortcut.c
index e812da7b..d9b64c4b 100644
--- a/gthumb/gth-shortcut.c
+++ b/gthumb/gth-shortcut.c
@@ -93,9 +93,19 @@ gth_shortcut_set_accelerator (GthShortcut *shortcut,
 
        keyval = 0;
        modifiers = 0;
-       if (accelerator != NULL)
-               gtk_accelerator_parse (accelerator, &keyval, &modifiers);
-       gth_shortcut_set_key (shortcut, keyval, modifiers);
+
+       if ((shortcut->context & GTH_SHORTCUT_CONTEXT_DOC) == 0) {
+               if (accelerator != NULL)
+                       gtk_accelerator_parse (accelerator, &keyval, &modifiers);
+               gth_shortcut_set_key (shortcut, keyval, modifiers);
+       }
+       else {
+               shortcut->keyval = keyval;
+               shortcut->modifiers = modifiers;
+               shortcut->accelerator = g_strdup (accelerator);
+               shortcut->label = g_strdup (accelerator);
+       }
+
 }
 
 
@@ -118,7 +128,8 @@ gboolean
 gth_shortcut_customizable (GthShortcut *shortcut)
 {
        return ((shortcut->context & GTH_SHORTCUT_CONTEXT_FIXED) == 0)
-               && ((shortcut->context & GTH_SHORTCUT_CONTEXT_INTERNAL) == 0);
+               && ((shortcut->context & GTH_SHORTCUT_CONTEXT_INTERNAL) == 0)
+               && ((shortcut->context & GTH_SHORTCUT_CONTEXT_DOC) == 0);
 }
 
 
@@ -245,6 +256,9 @@ gth_shortcuts_write_to_file (GPtrArray  *shortcuts_v,
                if ((shortcut->context & GTH_SHORTCUT_CONTEXT_FIXED) != 0)
                        continue;
 
+               if ((shortcut->context & GTH_SHORTCUT_CONTEXT_DOC) != 0)
+                       continue;
+
                dom_element_append_child (shortcuts,
                        dom_document_create_element (doc, "shortcut",
                                                     "action", shortcut->detailed_action,
diff --git a/gthumb/gth-shortcuts-window.c b/gthumb/gth-shortcuts-window.c
index 62b5eb88..bfb31a1a 100644
--- a/gthumb/gth-shortcuts-window.c
+++ b/gthumb/gth-shortcuts-window.c
@@ -80,7 +80,7 @@ gth_shortcuts_window_new (GthWindow *app_window)
                        if ((shortcut_info->context & context->id) == 0)
                                continue;
 
-                       if (shortcut_info->keyval == 0)
+                       if ((shortcut_info->keyval == 0) && ((shortcut_info->context & 
GTH_SHORTCUT_CONTEXT_DOC) == 0))
                                continue;
 
                        if (g_strcmp0 (shortcut_info->category, last_category) != 0) {
diff --git a/gthumb/gth-window.c b/gthumb/gth-window.c
index f7384533..0d8a3452 100644
--- a/gthumb/gth-window.c
+++ b/gthumb/gth-window.c
@@ -898,6 +898,9 @@ gth_window_activate_shortcut (GthWindow       *window,
                if ((shortcut->context & GTH_SHORTCUT_CONTEXT_INTERNAL) != 0)
                        return FALSE;
 
+               if ((shortcut->context & GTH_SHORTCUT_CONTEXT_DOC) != 0)
+                       return FALSE;
+
                action = g_action_map_lookup_action (G_ACTION_MAP (window), shortcut->action_name);
                if (action != NULL) {
                        g_action_activate (action, shortcut->action_parameter);
diff --git a/gthumb/typedefs.h b/gthumb/typedefs.h
index 784eac98..1fdcb437 100644
--- a/gthumb/typedefs.h
+++ b/gthumb/typedefs.h
@@ -155,6 +155,9 @@ typedef enum /*< skip >*/ {
        /* Shortcut available in slideshows. */
        GTH_SHORTCUT_CONTEXT_SLIDESHOW = 1 << 5,
 
+       /* Entry used for documentation only. */
+       GTH_SHORTCUT_CONTEXT_DOC = 1 << 6,
+
        /* Aggregated values: */
 
        GTH_SHORTCUT_CONTEXT_BROWSER_VIEWER = (GTH_SHORTCUT_CONTEXT_BROWSER | GTH_SHORTCUT_CONTEXT_VIEWER),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]