GtkWidget *menu_keywords;
GtkWidget *entry_keywords;
+ GtkWidget *check_comment;
+ GtkWidget *menu_comment;
+ GtkWidget *entry_comment;
+
FileData *search_dir_fd;
gint search_path_recurse;
gchar *search_name;
gchar *search_similarity_path;
CacheData *search_similarity_cd;
GList *search_keyword_list;
+ gchar *search_comment;
+ gint search_comment_match_case;
MatchType search_type;
MatchType match_date;
MatchType match_dimensions;
MatchType match_keywords;
+ MatchType match_comment;
gboolean match_name_enable;
gboolean match_size_enable;
gboolean match_dimensions_enable;
gboolean match_similarity_enable;
gboolean match_keywords_enable;
+ gboolean match_comment_enable;
GList *search_folder_list;
GList *search_done_list;
{ N_("exclude"), SEARCH_MATCH_NONE }
};
+static const MatchList text_search_menu_comment[] = {
+ { N_("contains"), SEARCH_MATCH_CONTAINS },
+ { N_("miss"), SEARCH_MATCH_NONE }
+};
+
static GList *search_window_list = NULL;
}
else
{
- match = (sd->match_keywords == SEARCH_MATCH_NONE);
+ match = (sd->match_comment == SEARCH_MATCH_NONE);
+ }
+ }
+
+ if (match && sd->match_comment_enable && sd->search_comment && strlen(sd->search_comment))
+ {
+ gchar *comment;
+
+ tested = TRUE;
+ match = FALSE;
+
+ if (comment_read(fd, NULL, &comment))
+ {
+ if (! sd->search_comment_match_case)
+ {
+ gchar *tmp = g_utf8_strdown(comment, -1);
+ g_free(comment);
+ comment = tmp;
+ }
+
+ if (sd->match_comment == SEARCH_MATCH_CONTAINS)
+ {
+ match = (strstr(comment, sd->search_comment) != NULL);
+ }
+ else if (sd->match_comment == SEARCH_MATCH_NONE)
+ {
+ match = (strstr(comment, sd->search_comment) == NULL);
+ }
+ g_free(comment);
+ }
+ else
+ {
+ match = (sd->match_comment == SEARCH_MATCH_NONE);
}
}
sd->search_name = tmp;
}
+ if (!sd->search_comment_match_case)
+ {
+ /* convert to lowercase here, so that this is only done once per search */
+ gchar *tmp = g_utf8_strdown(sd->search_comment, -1);
+ g_free(sd->search_comment);
+ sd->search_comment = tmp;
+ }
+
sd->search_count = 0;
sd->search_total = 0;
g_free(sd->search_name);
sd->search_name = g_strdup(gtk_entry_get_text(GTK_ENTRY(sd->entry_name)));
+ /* XXX */
+ g_free(sd->search_comment);
+ sd->search_comment = g_strdup(gtk_entry_get_text(GTK_ENTRY(sd->entry_comment)));
+
g_free(sd->search_similarity_path);
sd->search_similarity_path = g_strdup(gtk_entry_get_text(GTK_ENTRY(sd->entry_similarity)));
if (sd->match_similarity_enable)
if (!menu_choice_get_match_type(combo, &sd->match_keywords)) return;
}
+static void menu_choice_comment_cb(GtkWidget *combo, gpointer data)
+{
+ SearchData *sd = data;
+
+ if (!menu_choice_get_match_type(combo, &sd->match_comment)) return;
+}
+
static void menu_choice_spin_cb(GtkAdjustment *adjustment, gpointer data)
{
gint *value = data;
file_data_unref(sd->search_dir_fd);
g_free(sd->search_name);
+ g_free(sd->search_comment);
g_free(sd->search_similarity_path);
string_list_free(sd->search_keyword_list);
sd->search_height_end = 768;
sd->search_name = NULL;
sd->search_name_match_case = FALSE;
+ sd->search_comment = NULL;
+ sd->search_comment_match_case = FALSE;
sd->search_type = SEARCH_MATCH_NONE;
sd->match_date = SEARCH_MATCH_EQUAL;
sd->match_dimensions = SEARCH_MATCH_EQUAL;
sd->match_keywords = SEARCH_MATCH_ALL;
+ sd->match_comment = SEARCH_MATCH_CONTAINS;
sd->match_name_enable = TRUE;
sd->match_size_enable = FALSE;
sd->match_dimensions_enable = FALSE;
sd->match_similarity_enable = FALSE;
sd->match_keywords_enable = FALSE;
+ sd->match_comment_enable = FALSE;
sd->search_similarity = 95;
sd->search_similarity_path = example_file ? g_strdup(example_file->path) : NULL;
sd->check_recurse = pref_checkbox_new_int(hbox2, _("Recurse"),
sd->search_path_recurse, &sd->search_path_recurse);
+ /* Search for file name */
hbox = menu_choice(sd->box_search, &sd->check_name, &sd->menu_name,
_("File name"), &sd->match_name_enable,
text_search_menu_name, sizeof(text_search_menu_name) / sizeof(MatchList),
pref_checkbox_new_int(hbox, _("Match case"),
sd->search_name_match_case, &sd->search_name_match_case);
+ /* Search for file size */
hbox = menu_choice(sd->box_search, &sd->check_size, &sd->menu_size,
_("File size is"), &sd->match_size_enable,
text_search_menu_size, sizeof(text_search_menu_size) / sizeof(MatchList),
sd->spin_size_end = menu_spin(hbox2, 0, 1024*1024*1024, sd->search_size_end,
G_CALLBACK(menu_choice_spin_cb), &sd->search_size_end);
+ /* Search for file date */
hbox = menu_choice(sd->box_search, &sd->check_date, &sd->menu_date,
_("File date is"), &sd->match_date_enable,
text_search_menu_date, sizeof(text_search_menu_date) / sizeof(MatchList),
gtk_box_pack_start(GTK_BOX(hbox2), sd->date_sel_end, FALSE, FALSE, 0);
gtk_widget_show(sd->date_sel_end);
+ /* Search for image dimensions */
hbox = menu_choice(sd->box_search, &sd->check_dimensions, &sd->menu_dimensions,
_("Image dimensions are"), &sd->match_dimensions_enable,
text_search_menu_size, sizeof(text_search_menu_size) / sizeof(MatchList),
sd->spin_height_end = menu_spin(hbox2, 0, 1000000, sd->search_height_end,
G_CALLBACK(menu_choice_spin_cb), &sd->search_height_end);
+ /* Search for image similarity */
hbox = menu_choice(sd->box_search, &sd->check_similarity, NULL,
_("Image content is"), &sd->match_similarity_enable,
NULL, 0, NULL, sd);
gtk_box_pack_start(GTK_BOX(hbox), combo, TRUE, TRUE, 0);
gtk_widget_show(combo);
+ /* Search for image keywords */
hbox = menu_choice(sd->box_search, &sd->check_keywords, &sd->menu_keywords,
_("Keywords"), &sd->match_keywords_enable,
text_search_menu_keyword, sizeof(text_search_menu_keyword) / sizeof(MatchList),
G_CALLBACK(menu_choice_check_cb), sd->entry_keywords);
gtk_widget_show(sd->entry_keywords);
+ /* Search for image comment */
+ hbox = menu_choice(sd->box_search, &sd->check_comment, &sd->menu_comment,
+ _("Comment"), &sd->match_comment_enable,
+ text_search_menu_comment, sizeof(text_search_menu_comment) / sizeof(MatchList),
+ G_CALLBACK(menu_choice_comment_cb), sd);
+ sd->entry_comment = gtk_entry_new();
+ gtk_box_pack_start(GTK_BOX(hbox), sd->entry_comment, TRUE, TRUE, 0);
+ gtk_widget_set_sensitive(sd->entry_comment, sd->match_comment_enable);
+ g_signal_connect(G_OBJECT(sd->check_comment), "toggled",
+ G_CALLBACK(menu_choice_check_cb), sd->entry_comment);
+ gtk_widget_show(sd->entry_comment);
+ pref_checkbox_new_int(hbox, _("Match case"),
+ sd->search_comment_match_case, &sd->search_comment_match_case);
+
+ /* Done the types of searches */
+
scrolled = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),