changeset 2757:90ebfd9de43a

Addl fix #220: marks do not persist https://github.com/BestImageViewer/geeqie/issues/220 Additional parameter on search page to find files which have marks set.
author Colin Clark <colin.clark@cclark.uk>
date Fri, 18 May 2018 17:48:12 +0100
parents f2f01d556f51
children de18b5afdd1a
files doc/docbook/GuideImageSearchSearch.xml src/search.c web/help/GuideImageSearchSearch.html
diffstat 3 files changed, 118 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/doc/docbook/GuideImageSearchSearch.xml	Wed May 16 19:22:12 2018 +0100
+++ b/doc/docbook/GuideImageSearchSearch.xml	Fri May 18 17:48:12 2018 +0100
@@ -177,6 +177,16 @@
           </itemizedlist>
         </listitem>
       </varlistentry>
+      <varlistentry>
+        <term>
+          <guilabel>Marks</guilabel>
+        </term>
+        <listitem>
+          The search will match if the file does or does not have a mark attached to it. Refer to
+          <link linkend="GuideImageMarks">Marking Images</link>
+          .
+        </listitem>
+      </varlistentry>
     </variablelist>
     <para />
     <para />
--- a/src/search.c	Wed May 16 19:22:12 2018 +0100
+++ b/src/search.c	Fri May 18 17:48:12 2018 +0100
@@ -55,7 +55,7 @@
 
 
 #define DEF_SEARCH_WIDTH  700
-#define DEF_SEARCH_HEIGHT 450
+#define DEF_SEARCH_HEIGHT 650
 
 #define SEARCH_BUFFER_MATCH_LOAD 20
 #define SEARCH_BUFFER_MATCH_HIT  5
@@ -148,6 +148,8 @@
 	GtkWidget *check_class;
 	GtkWidget *menu_class;
 	GtkWidget *class_type;
+	GtkWidget *marks_type;
+	GtkWidget *menu_marks;
 
 	FileData *search_dir_fd;
 	gboolean   search_path_recurse;
@@ -185,6 +187,7 @@
 	MatchType match_rating;
 	MatchType match_gps;
 	MatchType match_class;
+	MatchType match_marks;
 
 	gboolean match_name_enable;
 	gboolean match_size_enable;
@@ -195,6 +198,7 @@
 	gboolean match_comment_enable;
 	gboolean match_rating_enable;
 	gboolean match_class_enable;
+	gboolean match_marks_enable;
 
 	GList *search_folder_list;
 	GList *search_done_list;
@@ -301,6 +305,11 @@
 	{ N_("is not"),	SEARCH_MATCH_NONE }
 };
 
+static const MatchList text_search_menu_marks[] = {
+	{ N_("is"),	SEARCH_MATCH_EQUAL },
+	{ N_("is not"),	SEARCH_MATCH_NONE }
+};
+
 static GList *search_window_list = NULL;
 
 
@@ -2098,6 +2107,58 @@
 			}
 		}
 
+	if (match && sd->match_marks_enable)
+		{
+		tested = TRUE;
+		match = FALSE;
+		gint search_marks;
+		gint i;
+		gchar *marks_string;
+
+		if (g_strcmp0(gtk_combo_box_text_get_active_text(
+						GTK_COMBO_BOX_TEXT(sd->marks_type)), _("Any mark")) == 0)
+			{
+			search_marks = -1;
+			}
+		else
+			{
+			for (i = 0; i < FILEDATA_MARKS_SIZE; i++)
+				{
+				marks_string = g_strdup_printf("%s%d", _("Mark "), i + 1);
+				if (g_strcmp0(marks_string, options->marks_tooltips[i]) != 0)
+					{
+					g_free(marks_string);
+					marks_string = g_strdup_printf("%s%d %s", _("Mark "), i + 1,
+													options->marks_tooltips[i]);
+					}
+
+				if (g_strcmp0(gtk_combo_box_text_get_active_text(
+								GTK_COMBO_BOX_TEXT(sd->marks_type)),
+								marks_string) == 0)
+					{
+					search_marks = 1 << i;
+					}
+				g_free(marks_string);
+				}
+			}
+
+		if (sd->match_marks == SEARCH_MATCH_EQUAL)
+			{
+			match = (fd->marks & search_marks);
+			}
+		else
+			{
+			if (search_marks == -1)
+				{
+				match = fd->marks ? FALSE : TRUE;
+				}
+			else
+				{
+				match = (fd->marks & search_marks) ? FALSE : TRUE;
+				}
+			}
+		}
+
 	if (match && sd->match_gps_enable)
 		{
 		/* Calculate the distance the image is from the specified origin.
@@ -2691,6 +2752,13 @@
 	if (!menu_choice_get_match_type(combo, &sd->match_class)) return;
 }
 
+static void menu_choice_marks_cb(GtkWidget *combo, gpointer data)
+{
+	SearchData *sd = data;
+
+	if (!menu_choice_get_match_type(combo, &sd->match_marks)) return;
+}
+
 static void menu_choice_date_cb(GtkWidget *combo, gpointer data)
 {
 	SearchData *sd = data;
@@ -2900,6 +2968,8 @@
 	GtkTreeSelection *selection;
 	GtkWidget *combo;
 	GdkGeometry geometry;
+	gint i;
+	gchar *marks_string;
 
 	sd = g_new0(SearchData, 1);
 
@@ -2921,6 +2991,7 @@
 	sd->match_comment = SEARCH_MATCH_CONTAINS;
 	sd->match_rating = SEARCH_MATCH_EQUAL;
 	sd->match_class = SEARCH_MATCH_EQUAL;
+	sd->match_marks = SEARCH_MATCH_EQUAL;
 
 	sd->match_name_enable = TRUE;
 
@@ -3161,6 +3232,34 @@
 	gtk_combo_box_set_active(GTK_COMBO_BOX(sd->class_type), 0);
 	gtk_widget_show(sd->class_type);
 
+	/* Search for image marks */
+	hbox = menu_choice(sd->box_search, &sd->check_class, &sd->menu_marks,
+			   _("Marks"), &sd->match_marks_enable,
+			   text_search_menu_marks, sizeof(text_search_menu_marks) / sizeof(MatchList),
+			   G_CALLBACK(menu_choice_marks_cb), sd);
+
+	sd->marks_type = gtk_combo_box_text_new();
+	gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(sd->marks_type), _("Any mark"));
+	for (i = 0; i < FILEDATA_MARKS_SIZE; i++)
+		{
+		marks_string = g_strdup_printf("%s%d", _("Mark "), i + 1);
+		if (g_strcmp0(marks_string, options->marks_tooltips[i]) != 0)
+			{
+			g_free(marks_string);
+			marks_string = g_strdup_printf("%s%d %s", _("Mark "), i + 1,
+											options->marks_tooltips[i]);
+			gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(sd->marks_type), marks_string);
+			}
+		else
+			{
+			gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(sd->marks_type), marks_string);
+			}
+		g_free(marks_string);
+		}
+	gtk_box_pack_start(GTK_BOX(hbox), sd->marks_type, FALSE, FALSE, 0);
+	gtk_combo_box_set_active(GTK_COMBO_BOX(sd->marks_type), 0);
+	gtk_widget_show(sd->marks_type);
+
 	/* Done the types of searches */
 
 	scrolled = gtk_scrolled_window_new(NULL, NULL);
--- a/web/help/GuideImageSearchSearch.html	Wed May 16 19:22:12 2018 +0100
+++ b/web/help/GuideImageSearchSearch.html	Fri May 18 17:48:12 2018 +0100
@@ -620,6 +620,14 @@
 <li>Metadata</li>
 </ul></div>
         </dd>
+<dt class="term">
+          <span class="guilabel">Marks</span>
+        </dt>
+<dd>
+          The search will match if the file does or does not have a mark attached to it. Refer to
+          <a class="link" href="GuideImageMarks.html" title="Marking Images">Marking Images</a>
+          .
+        </dd>
 </dl></div>
 <p class="para block"></p>
 <p class="para block"></p>