Fix #597: Help file search
authorColin Clark <colin.clark@cclark.uk>
Wed, 16 May 2018 18:22:12 +0000 (19:22 +0100)
committerColin Clark <colin.clark@cclark.uk>
Wed, 16 May 2018 18:22:12 +0000 (19:22 +0100)
https://github.com/BestImageViewer/geeqie/issues/597

Only on-line help files are searched.
Search engine defined in Preferences/General.
Local help files are not searched.

14 files changed:
doc/docbook/GuideMainWindowMenus.xml
doc/docbook/GuideOptionsGeneral.xml
src/layout_util.c
src/main.h
src/options.c
src/options.h
src/preferences.c
src/rcfile.c
src/window.c
src/window.h
web/help/GuideImageMarks.html
web/help/GuideMainWindowMenus.html
web/help/GuideOptionsBehavior.html
web/help/GuideOptionsGeneral.html

index 24c22d1..ff883ba 100644 (file)
           <para>Opens the Geeqie user manual in a new browser window.</para>\r
         </listitem>\r
       </varlistentry>\r
+      <varlistentry>\r
+        <term>\r
+          <menuchoice>\r
+            <guimenu>On-line help search</guimenu>\r
+          </menuchoice>\r
+        </term>\r
+        <listitem>\r
+          <para>\r
+            Use a web browser to search Geeqie's on-line help files. The search engine used is defined in\r
+            <link linkend="OnLineHelpSearch">Preferences General</link>\r
+            .\r
+          </para>\r
+        </listitem>\r
+      </varlistentry>\r
       <varlistentry>\r
         <term>\r
           <menuchoice>\r
index 4d492b3..328b819 100644 (file)
     </note>\r
     <variablelist />\r
   </section>\r
+  <section id="OnLineHelpSearch">\r
+    <title>On-line help search</title>\r
+    <para>\r
+      An internet search engine may be used to search the help files on Geeqie's website. The string used to conduct the search is defined here. In most cases it will be in one of two formats:\r
+      <para />\r
+      <code>https://www.search-engine.com/search?q=site:geeqie.org/help</code>\r
+      <para />\r
+      <code>https://www.search-engine.com/?q=site:geeqie.org/help'</code>\r
+    </para>\r
+    <variablelist />\r
+  </section>\r
 </section>\r
index 9f0c68e..7c9d013 100644 (file)
@@ -1125,6 +1125,14 @@ static void layout_menu_help_cb(GtkAction *action, gpointer data)
        help_window_show("index.html");
 }
 
+static void layout_menu_help_search_cb(GtkAction *action, gpointer data)
+{
+       LayoutWindow *lw = data;
+
+       layout_exit_fullscreen(lw);
+       help_search_window_show();
+}
+
 static void layout_menu_help_keys_cb(GtkAction *action, gpointer data)
 {
        LayoutWindow *lw = data;
@@ -1886,6 +1894,7 @@ static GtkActionEntry menu_entries[] = {
   { "SlideShowSlower", GTK_STOCK_FILE, N_("Slower"),           "<control>KP_Subtract",                 N_("Slower"),                   CB(layout_menu_slideshow_slower_cb) },
   { "Refresh",         GTK_STOCK_REFRESH,      N_("_Refresh"),                         "R",                    N_("Refresh"),                          CB(layout_menu_refresh_cb) },
   { "HelpContents",    GTK_STOCK_HELP,         N_("_Contents"),                        "F1",                   N_("Contents"),                         CB(layout_menu_help_cb) },
+  { "HelpSearch",      NULL,           N_("On-line help search"),                      NULL,                   N_("On-line help search"),                              CB(layout_menu_help_search_cb) },
   { "HelpShortcuts",   NULL,                   N_("_Keyboard shortcuts"),              NULL,                   N_("Keyboard shortcuts"),               CB(layout_menu_help_keys_cb) },
   { "HelpKbd",         NULL,                   N_("_Keyboard map"),                    NULL,                   N_("Keyboard map"),                     CB(layout_menu_kbd_map_cb) },
   { "HelpNotes",       NULL,                   N_("_Release notes"),                   NULL,                   N_("Release notes"),                    CB(layout_menu_notes_cb) },
@@ -2189,6 +2198,7 @@ static const gchar *menu_ui_description =
 "    <menu action='HelpMenu'>"
 "      <separator/>"
 "      <menuitem action='HelpContents'/>"
+"      <menuitem action='HelpSearch'/>"
 "      <menuitem action='HelpShortcuts'/>"
 "      <menuitem action='HelpKbd'/>"
 "      <menuitem action='HelpNotes'/>"
index 120f528..c892ad4 100644 (file)
 #define DESKTOP_FILE_TEMPLATE GQ_APP_DIR "/template.desktop"
 
 #define TIMEZONE_DATABASE "timezone21.bin"
+
+#define HELP_SEARCH_ENGINE "https://duckduckgo.com/?q=site:geeqie.org/help "
 /*
  *----------------------------------------------------------------------------
  * main.c
index 689d81a..99cb2c0 100644 (file)
@@ -220,6 +220,8 @@ void setup_default_options(ConfOptions *options)
                {
                options->marks_tooltips[i] = g_strdup_printf("%s%d", _("Mark "), i + 1);
                }
+
+       options->help_search_engine = g_strdup(HELP_SEARCH_ENGINE);
 }
 
 void copy_layout_options(LayoutOptions *dest, const LayoutOptions *src)
index 0415c5c..7ae033f 100644 (file)
@@ -64,6 +64,8 @@ struct _ConfOptions
        gboolean marks_save;            // save marks on exit
        gchar *marks_tooltips[FILEDATA_MARKS_SIZE];
 
+       gchar *help_search_engine;
+
        /* info sidebar component heights */
        struct {
                gint height;
index 1d908aa..fda2322 100644 (file)
@@ -131,6 +131,7 @@ static GtkWidget *color_profile_input_name_entry[COLOR_PROFILE_INPUTS];
 static GtkWidget *color_profile_screen_file_entry;
 
 static GtkWidget *sidecar_ext_entry;
+static GtkWidget *help_search_engine_entry;
 
 
 #define CONFIG_WINDOW_DEF_WIDTH                700
@@ -408,6 +409,7 @@ static void config_window_apply(void)
        options->info_rating.height = c_options->info_rating.height;
 
        options->marks_save = c_options->marks_save;
+       config_entry_to_option(help_search_engine_entry, &options->help_search_engine, NULL);
 
 #ifdef DEBUG
        set_debug_level(debug_c);
@@ -1583,6 +1585,19 @@ static void cache_local_cb(GtkWidget *widget, gpointer data)
                }
 }
 
+static void help_search_engine_entry_icon_cb(GtkEntry *entry, GtkEntryIconPosition pos,
+                                                                       GdkEvent *event, gpointer userdata)
+{
+       if (pos == GTK_ENTRY_ICON_PRIMARY)
+               {
+               gtk_entry_set_text(GTK_ENTRY(userdata), HELP_SEARCH_ENGINE);
+               }
+       else
+               {
+               gtk_entry_set_text(GTK_ENTRY(userdata), "");
+               }
+}
+
 /* general options tab */
 static void config_tab_general(GtkWidget *notebook)
 {
@@ -1698,6 +1713,27 @@ static void config_tab_general(GtkWidget *notebook)
        pref_spin_new_int(hbox, _("Rating:"), NULL,
                                 1, 9999, 1,
                                 options->info_rating.height, &c_options->info_rating.height);
+
+       group = pref_group_new(vbox, FALSE, _("On-line help search engine"), GTK_ORIENTATION_VERTICAL);
+
+       help_search_engine_entry = gtk_entry_new();
+       gtk_entry_set_text(GTK_ENTRY(help_search_engine_entry), options->help_search_engine);
+       gtk_box_pack_start(GTK_BOX(group), help_search_engine_entry, FALSE, FALSE, 0);
+       gtk_widget_show(help_search_engine_entry);
+
+       gtk_widget_set_tooltip_text(help_search_engine_entry, _("The format varies between search engines, e.g the format may be:\nhttps://www.search_engine.com/search?q=site:geeqie.org/help\nhttps://www.search_engine.com/?q=site:geeqie.org/help"));
+
+       gtk_entry_set_icon_from_stock(GTK_ENTRY(help_search_engine_entry),
+                                               GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR);
+       gtk_entry_set_icon_tooltip_text (GTK_ENTRY(help_search_engine_entry),
+                                               GTK_ENTRY_ICON_SECONDARY, _("Clear"));
+       gtk_entry_set_icon_from_stock(GTK_ENTRY(help_search_engine_entry),
+                                               GTK_ENTRY_ICON_PRIMARY, GTK_STOCK_REVERT_TO_SAVED);
+       gtk_entry_set_icon_tooltip_text (GTK_ENTRY(help_search_engine_entry),
+                                               GTK_ENTRY_ICON_PRIMARY, _("Default"));
+       g_signal_connect(GTK_ENTRY(help_search_engine_entry), "icon-press",
+                                               G_CALLBACK(help_search_engine_entry_icon_cb),
+                                               help_search_engine_entry);
 }
 
 /* image tab */
index 467aef8..1724840 100644 (file)
@@ -344,6 +344,7 @@ static void write_global_attributes(GString *outstr, gint indent)
        WRITE_NL(); WRITE_BOOL(*options, log_window.timer_data);
 
        WRITE_NL(); WRITE_BOOL(*options, marks_save);
+       WRITE_NL(); WRITE_CHAR(*options, help_search_engine);
 
        /* File operations Options */
        WRITE_NL(); WRITE_BOOL(*options, file_ops.enable_in_place_rename);
@@ -669,6 +670,7 @@ static gboolean load_global_params(const gchar **attribute_names, const gchar **
                if (READ_BOOL(*options, log_window.timer_data)) continue;
 
                if (READ_BOOL(*options, marks_save)) continue;
+               if (READ_CHAR(*options, help_search_engine)) continue;
 
                /* Properties dialog options */
                if (READ_CHAR(*options, properties.tabs_order)) continue;
index dd70cb4..0b29112 100644 (file)
@@ -25,6 +25,8 @@
 #include "pixbuf_util.h"
 #include "ui_fileops.h"
 #include "ui_help.h"
+#include "ui_misc.h"
+#include "ui_utildlg.h"
 
 GtkWidget *window_new(GtkWindowType type, const gchar *role, const gchar *icon,
                      const gchar *icon_file, const gchar *subtitle)
@@ -313,4 +315,91 @@ void help_window_show(const gchar *key)
                }
 }
 
+/*
+ *-----------------------------------------------------------------------------
+ * on-line help search dialog
+ *-----------------------------------------------------------------------------
+ */
+
+typedef struct _HelpSearchData HelpSearchData;
+struct _HelpSearchData {
+       GenericDialog *gd;
+       GtkWidget *edit_widget;
+       gchar *text_entry;
+};
+
+static void help_search_window_show_icon_press(GtkEntry *entry, GtkEntryIconPosition pos,
+                                                                       GdkEvent *event, gpointer userdata)
+{
+       HelpSearchData *hsd = userdata;
+
+       g_free(hsd->text_entry);
+       hsd->text_entry = g_strdup("");
+       gtk_entry_set_text(GTK_ENTRY(hsd->edit_widget), hsd->text_entry);
+}
+
+static void help_search_window_ok_cb(GenericDialog *gd, gpointer data)
+{
+       HelpSearchData *hsd = data;
+       gchar *search_command;
+
+       search_command = g_strconcat(options->help_search_engine,
+                                               gtk_entry_get_text(GTK_ENTRY(hsd->edit_widget)),
+                                               NULL);
+       help_browser_run(search_command);
+       g_free(search_command);
+
+       g_free(hsd);
+}
+
+static void help_search_window_cancel_cb(GenericDialog *gd, gpointer data)
+{
+       HelpSearchData *hsd = data;
+
+       g_free(hsd);
+}
+
+void help_search_window_show()
+{
+       HelpSearchData *hsd;
+       GenericDialog *gd;
+       GtkWidget *table;
+       GtkWidget *label1;
+       GtkWidget *label2;
+
+       hsd = g_new0(HelpSearchData, 1);
+       hsd->gd = gd = generic_dialog_new(_("On-line help search"), "help_search",
+                               NULL, TRUE,
+                               help_search_window_cancel_cb, hsd);
+       generic_dialog_add_message(gd, NULL, _("Search the on-line help files.\n"), NULL, FALSE);
+
+       generic_dialog_add_button(gd, GTK_STOCK_OK, NULL,
+                                 help_search_window_ok_cb, TRUE);
+
+       label1 = pref_label_new(GENERIC_DIALOG(gd)->vbox, _("Search engine:"));
+       gtk_misc_set_alignment(GTK_MISC(label1), 0.0, 0.5);
+
+       label2 = pref_label_new(GENERIC_DIALOG(gd)->vbox, options->help_search_engine);
+       gtk_misc_set_alignment(GTK_MISC(label2), 0.0, 0.5);
+       pref_spacer(GENERIC_DIALOG(gd)->vbox, 0);
+
+       table = pref_table_new(gd->vbox, 3, 1, FALSE, TRUE);
+       pref_table_label(table, 0, 0, _("Search terms:"), 1.0);
+       hsd->edit_widget = gtk_entry_new();
+       gtk_widget_set_size_request(hsd->edit_widget, 300, -1);
+       gtk_table_attach_defaults(GTK_TABLE(table), hsd->edit_widget, 1, 2, 0, 1);
+       generic_dialog_attach_default(gd, hsd->edit_widget);
+       gtk_widget_show(hsd->edit_widget);
+
+       gtk_entry_set_icon_from_stock(GTK_ENTRY(hsd->edit_widget),
+                                               GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR);
+       gtk_entry_set_icon_tooltip_text (GTK_ENTRY(hsd->edit_widget),
+                                               GTK_ENTRY_ICON_SECONDARY, _("Clear"));
+       g_signal_connect(GTK_ENTRY(hsd->edit_widget), "icon-press",
+                                               G_CALLBACK(help_search_window_show_icon_press), hsd);
+
+       gtk_widget_grab_focus(hsd->edit_widget);
+
+       gtk_widget_show(gd->dialog);
+}
 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
index 1e218d6..c1c4921 100644 (file)
@@ -27,7 +27,7 @@ void window_set_icon(GtkWidget *window, const gchar *icon, const gchar *file);
 gboolean window_maximized(GtkWidget *window);
 
 void help_window_show(const gchar *key);
-
+void help_search_window_show();
 
 #endif /* WINDOW_H */
 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
index 74d8b54..8ec2f08 100644 (file)
@@ -459,23 +459,30 @@ dd.answer div.label { float: left; }
     <span class="guimenu">Select</span>
     menu gives access to the marks operations of setting, filtering and intersection.
   </p>
-<p class="para block">There are 6 individual marks, any of which can be associated with an image simply by pressing the 1 to 6 keys on the keyboard.</p>
+<p class="para block">There are 10 individual marks, any of which can be associated with an image simply by pressing the 0 to 9 keys on the keyboard, where key 0 represents mark 10.</p>
 <p class="para block">
     If the
     <span class="guimenu">Show Marks</span>
-    menu has been selected, each image will have a set of 6 check-boxes displayed adjacent to it in the file pane in both icon and list mode. In addition a set of 6 check-boxes will be shown at the top of the files pane. Clicking any of these will filter the displayed list.
+    menu has been selected, each image will have a set of 10 check-boxes displayed adjacent to it in the file pane in both icon and list mode. In addition a set of 10 check-boxes will be shown at the top of the files pane. Clicking any of these will filter the displayed list.
   </p>
+<p class="para block">Moving the mouse over any of the check-boxes at the top of the files pane will show mnemonic text for that mark. The text can be modified by right-clicking on the check box.</p>
 <p class="para block">
     If the
     <a class="link" href="GuideMainWindowImagePane.html#InformationandhistogramOverlay" title="Image Overlay">Image Overlay</a>
     is being displayed, the currently set marks for the image are shown. It is not necessary to include an entry into the overlay template for this to happen.
   </p>
 <p class="para block">
-    A keyword can be associated with a single mark by right-clicking on the keyword in the sidebar panel. When a meta-data write operation for a file is triggered either <a class="link" href="GuideMainWindowStatusBar.html#Buttons" title="Buttons">manually</a> or as defined in
+    A keyword can be associated with a single mark by right-clicking on the keyword in the sidebar panel. When a meta-data write operation for a file is triggered either
+    <a class="link" href="GuideMainWindowStatusBar.html#Buttons" title="Buttons">manually</a>
+    or as defined in
     <a class="link" href="GuideOptionsMetadata.html" title="Metadata">Metadata</a>
     , the keyword data indicated by the current set of mark-to-keyword links will be written.
   </p>
-<p class="para block">Neither marks, nor the associations between keywords and marks, are preserved when Geeqie is shut down.</p>
+<p class="para block">
+    The associations between keywords and marks is preserved when Geeqie is shut down. The current setting of marks can also be optionally saved - the setting is in the
+    <a class="link" href="GuideOptionsBehavior.html#Behaviour" title="Behavior">Behavior tab of Preferences</a>
+    .
+  </p>
 <p class="para block"></p>
 <p class="para block"></p>
 </div></div>
index 3a0e4fa..1d634b4 100644 (file)
@@ -731,6 +731,15 @@ dd.answer div.label { float: left; }
 <dd>
           <p class="para block block-first">Displays marks in the file list</p>
         </dd>
+<dt class="term">
+          <span class="menuchoice"><span class="guimenu">Clear marks</span></span>
+        </dt>
+<dd>
+          <p class="para block block-first">Clear all marks for all images</p>
+          <div class="admonition block warning block-indent"><div class="warning-inner">
+            <p class="para block block-first">Marks that are linked to keywords will also be cleared. This may result in a metadata write operation being triggered.</p>
+          </div></div>
+        </dd>
 <dt class="term">
           <span class="menuchoice"><span class="guimenu">Mark n</span></span>
         </dt>
@@ -984,7 +993,7 @@ dd.answer div.label { float: left; }
           </p>
         </dd>
 <dt class="term">
-          <span class="menuchoice"><span class="guimenu">Thumbnail maintenance</span></span>
+          <span class="menuchoice"><span class="guimenu">Cache maintenance</span></span>
         </dt>
 <dd>
           <p class="para block block-first">
@@ -1317,6 +1326,16 @@ dd.answer div.label { float: left; }
 <dd>
           <p class="para block block-first">Opens the Geeqie user manual in a new browser window.</p>
         </dd>
+<dt class="term">
+          <span class="menuchoice"><span class="guimenu">On-line help search</span></span>
+        </dt>
+<dd>
+          <p class="para block block-first">
+            Use a web browser to search Geeqie's on-line help files. The search engine used is defined in
+            <a class="link" href="GuideOptionsGeneral.html#OnLineHelpSearch" title="On-line help search">Preferences General</a>
+            .
+          </p>
+        </dd>
 <dt class="term">
           <span class="menuchoice"><span class="guimenu">Keyboard shortcuts</span></span>
         </dt>
index 0f5c786..f64f91d 100644 (file)
@@ -573,6 +573,12 @@ dd.answer div.label { float: left; }
 <dd>
           <p class="para block block-first">If selected, a single click will enter a directory, rather than the GTK+ default of a double click.</p>
         </dd>
+<dt class="term">
+          <span class="guilabel">Save marks on exit</span>
+        </dt>
+<dd>
+          <p class="para block block-first">Save all marks that have been set. Note that marks that are linked to a keyword will always be saved irrespective of this setting.</p>
+        </dd>
 <dt class="term">
           <span class="guilabel">Recent folder list maximum size</span>
         </dt>
index ed4610b..6d5e053 100644 (file)
@@ -470,6 +470,9 @@ dd.answer div.label { float: left; }
 <li>
 <span class="label">11.1.4. </span><a class="xref" href="GuideOptionsGeneral.html#InfoSidebar" title="Info Sidebar component heights">Info Sidebar component heights</a>
 </li>
+<li>
+<span class="label">11.1.5. </span><a class="xref" href="GuideOptionsGeneral.html#OnLineHelpSearch" title="On-line help search">On-line help search</a>
+</li>
 </ul></div>
 <div class="division section">
 <a name="PreferencesThumbnails"></a><div class="header"><h2 class="section title"><span class="title"><span class="label">11.1.1. </span>Thumbnails</span></h2></div>
@@ -657,6 +660,17 @@ dd.answer div.label { float: left; }
     </div></div>
 <div class="block list variablelist"><dl class="variablelist"></dl></div>
 </div>
+<div class="division section">
+<a name="OnLineHelpSearch"></a><div class="header"><h2 class="section title"><span class="title"><span class="label">11.1.5. </span>On-line help search</span></h2></div>
+<p class="para block block-first">
+      An internet search engine may be used to search the help files on Geeqie's website. The string used to conduct the search is defined here. In most cases it will be in one of two formats:
+      <p class="para block block-first"></p>
+      <span class="code" dir="ltr">https://www.search-engine.com/search?q=site:geeqie.org/help</span>
+      <p class="para block"></p>
+      <span class="code" dir="ltr">https://www.search-engine.com/?q=site:geeqie.org/help'</span>
+    </p>
+<div class="block list variablelist"><dl class="variablelist"></dl></div>
+</div>
 </div></div>
 <div class="navbar navbar-bottom"><table class="navbar"><tr>
 <td class="navbar-prev"><a class="navbar-prev" href="GuideOptionsGeneral.html" title="General Options">General Options</a></td>