* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include "main.h"
#include "search.h"
+#include <sys/types.h>
+
+#include <cmath>
+#include <cstdio>
+#include <cstring>
+#include <ctime>
+
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gdk/gdk.h>
+#include <glib-object.h>
+#include <glib.h>
+#include <gtk/gtk.h>
+
#include "bar-keywords.h"
#include "cache.h"
#include "collect-table.h"
+#include "collect.h"
+#include "compat.h"
+#include "debug.h"
#include "dnd.h"
#include "dupe.h"
#include "editors.h"
#include "filedata.h"
#include "image-load.h"
#include "img-view.h"
+#include "intl.h"
#include "layout-util.h"
+#include "layout.h"
+#include "main-defines.h"
#include "menu.h"
#include "metadata.h"
#include "misc.h"
-#include "pixbuf-util.h"
+#include "options.h"
#include "print.h"
+#include "similar.h"
#include "thumb.h"
+#include "typedefs.h"
#include "ui-bookmark.h"
#include "ui-fileops.h"
#include "ui-menu.h"
#include "ui-misc.h"
#include "ui-tabcomp.h"
#include "ui-tree-edit.h"
+#include "ui-utildlg.h"
#include "uri-utils.h"
#include "utilops.h"
#include "window.h"
-#include <cmath>
-
-#define DEF_SEARCH_WIDTH 700
-#define DEF_SEARCH_HEIGHT 650
+enum {
+ DEF_SEARCH_WIDTH = 700,
+ DEF_SEARCH_HEIGHT = 650
+};
-#define SEARCH_BUFFER_MATCH_LOAD 20
-#define SEARCH_BUFFER_MATCH_HIT 5
-#define SEARCH_BUFFER_MATCH_MISS 1
-#define SEARCH_BUFFER_FLUSH_SIZE 99
+enum {
+ SEARCH_BUFFER_MATCH_LOAD = 20,
+ SEARCH_BUFFER_MATCH_HIT = 5,
+ SEARCH_BUFFER_MATCH_MISS = 1,
+ SEARCH_BUFFER_FLUSH_SIZE = 99
+};
#define FORMAT_CLASS_BROKEN static_cast<FileFormatClass>(FILE_FORMAT_CLASSES + 1)
gchar *search_name;
GRegex *search_name_regex;
gboolean search_name_match_case;
+ gboolean search_name_symbolic_link;
gint64 search_size;
gint64 search_size_end;
gint search_date_y;
{
auto sd = static_cast<SearchData *>(data);
GList *list;
- gdouble latitude, longitude;
+ gdouble latitude;
+ gdouble longitude;
FileData *fd;
if (info == TARGET_URI_LIST)
longitude = metadata_read_GPS_coord(fd, "Xmp.exif.GPSLongitude", 1000);
if (latitude != 1000 && longitude != 1000)
{
- gtk_entry_set_text(GTK_ENTRY(sd->entry_gps_coord),
+ gq_gtk_entry_set_text(GTK_ENTRY(sd->entry_gps_coord),
g_strdup_printf("%lf %lf", latitude, longitude));
}
else
{
- gtk_entry_set_text(GTK_ENTRY(sd->entry_gps_coord), "Image is not geocoded");
+ gq_gtk_entry_set_text(GTK_ENTRY(sd->entry_gps_coord), "Image is not geocoded");
}
}
}
if (info == TARGET_TEXT_PLAIN)
{
- gtk_entry_set_text(GTK_ENTRY(sd->entry_gps_coord),"");
+ gq_gtk_entry_set_text(GTK_ENTRY(sd->entry_gps_coord),"");
}
}
if (list != nullptr)
{
fd = static_cast<FileData *>(list->data);
- gtk_entry_set_text(GTK_ENTRY(sd->path_entry),
+ gq_gtk_entry_set_text(GTK_ENTRY(sd->path_entry),
g_strdup_printf("%s", fd->path));
gtk_widget_set_tooltip_text(GTK_WIDGET(sd->path_entry),g_strdup_printf("%s", fd->path));
}
if (info == TARGET_TEXT_PLAIN)
{
- gtk_entry_set_text(GTK_ENTRY(sd->path_entry),"");
+ gq_gtk_entry_set_text(GTK_ENTRY(sd->path_entry),"");
}
}
if (list != nullptr)
{
fd = static_cast<FileData *>(list->data);
- gtk_entry_set_text(GTK_ENTRY(sd->entry_similarity),
+ gq_gtk_entry_set_text(GTK_ENTRY(sd->entry_similarity),
g_strdup_printf("%s", fd->path));
gtk_widget_set_tooltip_text(GTK_WIDGET(sd->entry_similarity),g_strdup_printf("%s", fd->path));
}
if (info == TARGET_TEXT_PLAIN)
{
- gtk_entry_set_text(GTK_ENTRY(sd->entry_similarity),"");
+ gq_gtk_entry_set_text(GTK_ENTRY(sd->entry_similarity),"");
}
}
*-------------------------------------------------------------------
*/
-#define MATCH_IS_BETWEEN(val, a, b) (b > a ? (val >= a && val <= b) : (val >= b && val <= a))
+#define MATCH_IS_BETWEEN(val, a, b) ((b) > (a) ? ((val) >= (a) && (val) <= (b)) : ((val) >= (b) && (val) <= (a)))
static gboolean search_step_cb(gpointer data);
{
return TRUE;
}
- else
- {
- image_loader_free(sd->img_loader);
- sd->img_loader = nullptr;
- }
+
+ image_loader_free(sd->img_loader);
+ sd->img_loader = nullptr;
}
}
tested = TRUE;
match = FALSE;
- if (sd->match_name == SEARCH_MATCH_NAME_EQUAL)
- {
- if (sd->search_name_match_case)
- {
- match = (strcmp(fd->name, sd->search_name) == 0);
- }
- else
- {
- match = (g_ascii_strcasecmp(fd->name, sd->search_name) == 0);
- }
- }
- else if (sd->match_name == SEARCH_MATCH_NAME_CONTAINS || sd->match_name == SEARCH_MATCH_PATH_CONTAINS)
+ if (!sd->search_name_symbolic_link || (sd->search_name_symbolic_link && islink(fd->path)))
{
- const gchar *fd_name_or_path;
- if (sd->match_name == SEARCH_MATCH_NAME_CONTAINS)
- {
- fd_name_or_path = fd->name;
- }
- else
- {
- fd_name_or_path = fd->path;
- }
- if (sd->search_name_match_case)
+ if (sd->match_name == SEARCH_MATCH_NAME_EQUAL)
{
- match = g_regex_match(sd->search_name_regex, fd_name_or_path, static_cast<GRegexMatchFlags>(0), nullptr);
+ if (sd->search_name_match_case)
+ {
+ match = (strcmp(fd->name, sd->search_name) == 0);
+ }
+ else
+ {
+ match = (g_ascii_strcasecmp(fd->name, sd->search_name) == 0);
+ }
}
- else
+ else if (sd->match_name == SEARCH_MATCH_NAME_CONTAINS || sd->match_name == SEARCH_MATCH_PATH_CONTAINS)
{
- /* sd->search_name is converted in search_start() */
- gchar *haystack = g_utf8_strdown(fd_name_or_path, -1);
- match = g_regex_match(sd->search_name_regex, haystack, static_cast<GRegexMatchFlags>(0), nullptr);
- g_free(haystack);
+ const gchar *fd_name_or_path;
+ if (sd->match_name == SEARCH_MATCH_NAME_CONTAINS)
+ {
+ fd_name_or_path = fd->name;
+ }
+ else
+ {
+ fd_name_or_path = fd->path;
+ }
+ if (sd->search_name_match_case)
+ {
+ match = g_regex_match(sd->search_name_regex, fd_name_or_path, static_cast<GRegexMatchFlags>(0), nullptr);
+ }
+ else
+ {
+ /* sd->search_name is converted in search_start() */
+ gchar *haystack = g_utf8_strdown(fd_name_or_path, -1);
+ match = g_regex_match(sd->search_name_regex, haystack, static_cast<GRegexMatchFlags>(0), nullptr);
+ g_free(haystack);
+ }
}
}
}
#define MILES_EARTH_RADIUS 3959
#define NAUTICAL_MILES_EARTH_RADIUS 3440
- gdouble latitude, longitude, range, conversion;
+ gdouble latitude;
+ gdouble longitude;
+ gdouble range;
+ gdouble conversion;
if (g_strcmp0(gtk_combo_box_text_get_active_text(
GTK_COMBO_BOX_TEXT(sd->units_gps)), _("km")) == 0)
if (sd->match_name_enable) history_combo_append_history(sd->entry_name, nullptr);
g_free(sd->search_name);
- sd->search_name = g_strdup(gtk_entry_get_text(GTK_ENTRY(sd->entry_name)));
+ sd->search_name = g_strdup(gq_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)));
+ sd->search_comment = g_strdup(gq_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)));
+ sd->search_similarity_path = g_strdup(gq_gtk_entry_get_text(GTK_ENTRY(sd->entry_similarity)));
if (sd->match_similarity_enable)
{
if (!isfile(sd->search_similarity_path))
{
if (sd->match_gps != SEARCH_MATCH_NONE)
{
- entry_text = decode_geo_parameters(gtk_entry_get_text(
+ entry_text = decode_geo_parameters(gq_gtk_entry_get_text(
GTK_ENTRY(sd->entry_gps_coord)));
sd->search_lat = 1000;
{
/* search path */
- path = remove_trailing_slash(gtk_entry_get_text(GTK_ENTRY(sd->path_entry)));
+ path = remove_trailing_slash(gq_gtk_entry_get_text(GTK_ENTRY(sd->path_entry)));
if (isdir(path))
{
file_data_unref(sd->search_dir_fd);
}
else if (sd->search_type == SEARCH_MATCH_COLLECTION)
{
- collection = g_strdup(gtk_entry_get_text(GTK_ENTRY(sd->collection_entry)));
+ collection = g_strdup(gq_gtk_entry_get_text(GTK_ENTRY(sd->collection_entry)));
if (is_collection(collection))
{
search_window_get_geometry(sd);
- gtk_widget_destroy(sd->window);
+ gq_gtk_widget_destroy(sd->window);
}
static void search_window_close_cb(GtkWidget *, gpointer data)
gchar *path_noext;
gchar *collection;
- path = g_strdup(gtk_entry_get_text(GTK_ENTRY(fdlg->entry)));
+ path = g_strdup(gq_gtk_entry_get_text(GTK_ENTRY(fdlg->entry)));
path_noext = remove_extension_from_path(path);
collection = g_path_get_basename(path_noext);
- gtk_entry_set_text(GTK_ENTRY(sd->collection_entry), collection);
+ gq_gtk_entry_set_text(GTK_ENTRY(sd->collection_entry), collection);
file_dialog_close(fdlg);
g_free(path);
sd->search_similarity_path = g_strdup(example_file->path);
}
- sd->window = window_new(GTK_WINDOW_TOPLEVEL, "search", nullptr, nullptr, _("Image search"));
+ sd->window = window_new("search", nullptr, nullptr, _("Image search"));
DEBUG_NAME(sd->window);
gtk_window_set_resizable(GTK_WINDOW(sd->window), TRUE);
if (lw && options->save_window_positions)
{
gtk_window_set_default_size(GTK_WINDOW(sd->window), lw->options.search_window.w, lw->options.search_window.h);
- gtk_window_move(GTK_WINDOW(sd->window), lw->options.search_window.x, lw->options.search_window.y);
+ gq_gtk_window_move(GTK_WINDOW(sd->window), lw->options.search_window.x, lw->options.search_window.y);
}
else
{
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, PREF_PAD_GAP);
gtk_container_set_border_width(GTK_CONTAINER(vbox), PREF_PAD_GAP);
- gtk_container_add(GTK_CONTAINER(sd->window), vbox);
+ gq_gtk_container_add(GTK_WIDGET(sd->window), vbox);
gtk_widget_show(vbox);
sd->box_search = pref_box_new(vbox, FALSE, GTK_ORIENTATION_VERTICAL, PREF_PAD_GAP);
sd->collection = pref_box_new(hbox, TRUE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE);
sd->collection_entry = gtk_entry_new();
- gtk_entry_set_text(GTK_ENTRY(sd->collection_entry), "");
+ gq_gtk_entry_set_text(GTK_ENTRY(sd->collection_entry), "");
gq_gtk_box_pack_start(GTK_BOX(sd->collection), sd->collection_entry, TRUE, TRUE, 0);
gtk_widget_show(sd->collection_entry);
gtk_widget_show(combo);
pref_checkbox_new_int(hbox, _("Match case"),
sd->search_name_match_case, &sd->search_name_match_case);
+ pref_checkbox_new_int(hbox, _("Symbolic link"), sd->search_name_symbolic_link, &sd->search_name_symbolic_link);
gtk_widget_set_tooltip_text(GTK_WIDGET(combo), "When set to \"contains\" or \"path contains\", this field uses Perl Compatible Regular Expressions.\ne.g. use \n.*\\.jpg\n and not \n*.jpg\n\nSee the Help file.");
/* Search for file size */
sd->result_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
g_object_unref(store);
- gtk_container_add(GTK_CONTAINER(scrolled), sd->result_view);
+ gq_gtk_container_add(GTK_WIDGET(scrolled), sd->result_view);
gtk_widget_show(sd->result_view);
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(sd->result_view));
sd->label_status = gtk_label_new("");
gtk_widget_set_size_request(sd->label_status, 50, -1);
- gtk_container_add(GTK_CONTAINER(frame), sd->label_status);
+ gq_gtk_container_add(GTK_WIDGET(frame), sd->label_status);
gtk_widget_show(sd->label_status);
sd->label_progress = gtk_progress_bar_new();