[gnome-taquin] Do not hardcode help string.



commit e68b535d59eab8a8b6cdb1adb42a62e73ac5308c
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Wed Jul 31 12:51:36 2019 +0200

    Do not hardcode help string.

 src/base-window.vala | 17 +++++++++++------
 src/game-window.vala |  3 ++-
 2 files changed, 13 insertions(+), 7 deletions(-)
---
diff --git a/src/base-window.vala b/src/base-window.vala
index 3d69ec5..6a2fbb9 100644
--- a/src/base-window.vala
+++ b/src/base-window.vala
@@ -295,12 +295,14 @@ private class BaseWindow : AdaptativeWindow, AdaptativeWidget
     * * global callbacks
     \*/
 
+    [CCode (notify = false)] public string help_string_or_empty { private get; protected construct; default 
= ""; }
+
     [GtkCallback]
     protected virtual bool on_key_press_event (Widget widget, Gdk.EventKey event)
     {
-        return _on_key_press_event (widget, event);
+        return _on_key_press_event (widget, event, help_string_or_empty);
     }
-    private static bool _on_key_press_event (Widget widget, Gdk.EventKey event)
+    private static bool _on_key_press_event (Widget widget, Gdk.EventKey event, string help_string_or_empty)
     {
         string name = (!) (Gdk.keyval_name (event.keyval) ?? "");
 
@@ -313,7 +315,7 @@ private class BaseWindow : AdaptativeWindow, AdaptativeWidget
             if ((event.state & Gdk.ModifierType.CONTROL_MASK) != 0)
                 return false;                           // help overlay
             if ((event.state & Gdk.ModifierType.SHIFT_MASK) == 0)
-                return show_application_help (_this);   // fallback on help overlay (TODO test)
+                return show_application_help (_this, help_string_or_empty);   // fallback on help overlay 
(TODO test)
             _this.about ();
             return true;
         }
@@ -323,15 +325,18 @@ private class BaseWindow : AdaptativeWindow, AdaptativeWidget
 
     private void help (/* SimpleAction action, Variant? variant */)
     {
-        show_application_help (this);
+        show_application_help (this, help_string_or_empty);
     }
 
-    private static inline bool show_application_help (BaseWindow _this)
+    private static inline bool show_application_help (BaseWindow _this, string help_string_or_empty)
     {
+        if (help_string_or_empty == "")
+            return false;
+
         bool success;
         try
         {
-            show_uri (_this.get_screen (), "help:gnome-taquin", get_current_event_time ());
+            show_uri (_this.get_screen (), help_string_or_empty, get_current_event_time ());
             success = true;
         }
         catch (Error e)
diff --git a/src/game-window.vala b/src/game-window.vala
index 9cda7bc..e6d4e55 100644
--- a/src/game-window.vala
+++ b/src/game-window.vala
@@ -47,7 +47,8 @@ private class GameWindow : BaseWindow, AdaptativeWidget
         Object (nta_headerbar               : (NightTimeAwareHeaderBar) _headerbar,
                 base_view                   : (BaseView) _game_view,
                 window_title                : Taquin.PROGRAM_NAME,
-                specific_css_class_or_empty : "");
+                specific_css_class_or_empty : "",
+                help_string_or_empty        : "help:gnome-taquin");
 
         headerbar = _headerbar;
         game_view = _game_view;


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