changeset 2756:f2f01d556f51

Fix #597: Help file search 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.
author Colin Clark <colin.clark@cclark.uk>
date Wed, 16 May 2018 19:22:12 +0100
parents db7fa530da47
children 90ebfd9de43a
files 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
diffstat 14 files changed, 220 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/doc/docbook/GuideMainWindowMenus.xml	Wed May 16 10:04:01 2018 +0100
+++ b/doc/docbook/GuideMainWindowMenus.xml	Wed May 16 19:22:12 2018 +0100
@@ -1445,6 +1445,20 @@
       <varlistentry>
         <term>
           <menuchoice>
+            <guimenu>On-line help search</guimenu>
+          </menuchoice>
+        </term>
+        <listitem>
+          <para>
+            Use a web browser to search Geeqie's on-line help files. The search engine used is defined in
+            <link linkend="OnLineHelpSearch">Preferences General</link>
+            .
+          </para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <menuchoice>
             <guimenu>Keyboard shortcuts</guimenu>
           </menuchoice>
         </term>
--- a/doc/docbook/GuideOptionsGeneral.xml	Wed May 16 10:04:01 2018 +0100
+++ b/doc/docbook/GuideOptionsGeneral.xml	Wed May 16 19:22:12 2018 +0100
@@ -222,4 +222,15 @@
     </note>
     <variablelist />
   </section>
+  <section id="OnLineHelpSearch">
+    <title>On-line help search</title>
+    <para>
+      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:
+      <para />
+      <code>https://www.search-engine.com/search?q=site:geeqie.org/help</code>
+      <para />
+      <code>https://www.search-engine.com/?q=site:geeqie.org/help'</code>
+    </para>
+    <variablelist />
+  </section>
 </section>
--- a/src/layout_util.c	Wed May 16 10:04:01 2018 +0100
+++ b/src/layout_util.c	Wed May 16 19:22:12 2018 +0100
@@ -1125,6 +1125,14 @@
 	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 @@
   { "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 @@
 "    <menu action='HelpMenu'>"
 "      <separator/>"
 "      <menuitem action='HelpContents'/>"
+"      <menuitem action='HelpSearch'/>"
 "      <menuitem action='HelpShortcuts'/>"
 "      <menuitem action='HelpKbd'/>"
 "      <menuitem action='HelpNotes'/>"
--- a/src/main.h	Wed May 16 10:04:01 2018 +0100
+++ b/src/main.h	Wed May 16 19:22:12 2018 +0100
@@ -125,6 +125,8 @@
 #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
--- a/src/options.c	Wed May 16 10:04:01 2018 +0100
+++ b/src/options.c	Wed May 16 19:22:12 2018 +0100
@@ -220,6 +220,8 @@
 		{
 		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)
--- a/src/options.h	Wed May 16 10:04:01 2018 +0100
+++ b/src/options.h	Wed May 16 19:22:12 2018 +0100
@@ -64,6 +64,8 @@
 	gboolean marks_save;		// save marks on exit
 	gchar *marks_tooltips[FILEDATA_MARKS_SIZE];
 
+	gchar *help_search_engine;
+
 	/* info sidebar component heights */
 	struct {
 		gint height;
--- a/src/preferences.c	Wed May 16 10:04:01 2018 +0100
+++ b/src/preferences.c	Wed May 16 19:22:12 2018 +0100
@@ -131,6 +131,7 @@
 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 @@
 	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 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 @@
 	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 */
--- a/src/rcfile.c	Wed May 16 10:04:01 2018 +0100
+++ b/src/rcfile.c	Wed May 16 19:22:12 2018 +0100
@@ -344,6 +344,7 @@
 	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 @@
 		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;
--- a/src/window.c	Wed May 16 10:04:01 2018 +0100
+++ b/src/window.c	Wed May 16 19:22:12 2018 +0100
@@ -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 @@
 		}
 }
 
+/*
+ *-----------------------------------------------------------------------------
+ * 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: */
--- a/src/window.h	Wed May 16 10:04:01 2018 +0100
+++ b/src/window.h	Wed May 16 19:22:12 2018 +0100
@@ -27,7 +27,7 @@
 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: */
--- a/web/help/GuideImageMarks.html	Wed May 16 10:04:01 2018 +0100
+++ b/web/help/GuideImageMarks.html	Wed May 16 19:22:12 2018 +0100
@@ -459,23 +459,30 @@
     <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>
--- a/web/help/GuideMainWindowMenus.html	Wed May 16 10:04:01 2018 +0100
+++ b/web/help/GuideMainWindowMenus.html	Wed May 16 19:22:12 2018 +0100
@@ -732,6 +732,15 @@
           <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>
 <dd>
@@ -984,7 +993,7 @@
           </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">
@@ -1318,6 +1327,16 @@
           <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>
 <dd>
--- a/web/help/GuideOptionsBehavior.html	Wed May 16 10:04:01 2018 +0100
+++ b/web/help/GuideOptionsBehavior.html	Wed May 16 19:22:12 2018 +0100
@@ -574,6 +574,12 @@
           <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>
 <dd>
--- a/web/help/GuideOptionsGeneral.html	Wed May 16 10:04:01 2018 +0100
+++ b/web/help/GuideOptionsGeneral.html	Wed May 16 19:22:12 2018 +0100
@@ -470,6 +470,9 @@
 <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 @@
     </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>