[nautilus] Make recursive file system crawling optional
- From: William Jon McCann <mccann src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] Make recursive file system crawling optional
- Date: Wed, 18 Jul 2012 20:00:42 +0000 (UTC)
commit 9ed93015d2e7954d289a6992e6a26c37c33d171b
Author: William Jon McCann <jmccann redhat com>
Date: Wed Jul 18 15:52:04 2012 -0400
Make recursive file system crawling optional
.../nautilus-search-engine-simple.c | 61 +++++++++++++++++++-
1 files changed, 58 insertions(+), 3 deletions(-)
---
diff --git a/libnautilus-private/nautilus-search-engine-simple.c b/libnautilus-private/nautilus-search-engine-simple.c
index 4ce6e99..6f875ee 100644
--- a/libnautilus-private/nautilus-search-engine-simple.c
+++ b/libnautilus-private/nautilus-search-engine-simple.c
@@ -31,6 +31,11 @@
#define BATCH_SIZE 500
+enum {
+ PROP_RECURSIVE = 1,
+ NUM_PROPERTIES
+};
+
typedef struct {
NautilusSearchEngineSimple *engine;
GCancellable *cancellable;
@@ -42,7 +47,8 @@ typedef struct {
GQueue *directories; /* GFiles */
GHashTable *visited;
-
+
+ gboolean recursive;
gint n_processed_files;
GList *uri_hits;
} SearchThreadData;
@@ -52,10 +58,13 @@ struct NautilusSearchEngineSimpleDetails {
NautilusQuery *query;
SearchThreadData *active_search;
-
+
+ gboolean recursive;
gboolean query_finished;
};
+static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
+
static void nautilus_search_provider_init (NautilusSearchProviderIface *iface);
G_DEFINE_TYPE_WITH_CODE (NautilusSearchEngineSimple,
@@ -269,7 +278,7 @@ visit_directory (GFile *dir, SearchThreadData *data)
send_batch (data);
}
- if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY) {
+ if (data->engine->details->recursive && g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY) {
id = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_ID_FILE);
visited = FALSE;
if (id) {
@@ -386,6 +395,43 @@ nautilus_search_engine_simple_set_query (NautilusSearchProvider *provider,
}
static void
+nautilus_search_engine_simple_set_property (GObject *object,
+ guint arg_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ NautilusSearchEngineSimple *engine;
+
+ engine = NAUTILUS_SEARCH_ENGINE_SIMPLE (object);
+
+ switch (arg_id) {
+ case PROP_RECURSIVE:
+ engine->details->recursive = g_value_get_boolean (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, arg_id, pspec);
+ break;
+ }
+}
+
+static void
+nautilus_search_engine_simple_get_property (GObject *object,
+ guint arg_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ NautilusSearchEngineSimple *engine;
+
+ engine = NAUTILUS_SEARCH_ENGINE_SIMPLE (object);
+
+ switch (arg_id) {
+ case PROP_RECURSIVE:
+ g_value_set_boolean (value, engine->details->recursive);
+ break;
+ }
+}
+
+static void
nautilus_search_provider_init (NautilusSearchProviderIface *iface)
{
iface->set_query = nautilus_search_engine_simple_set_query;
@@ -400,7 +446,16 @@ nautilus_search_engine_simple_class_init (NautilusSearchEngineSimpleClass *class
gobject_class = G_OBJECT_CLASS (class);
gobject_class->finalize = finalize;
+ gobject_class->get_property = nautilus_search_engine_simple_get_property;
+ gobject_class->set_property = nautilus_search_engine_simple_set_property;
+
+ properties[PROP_RECURSIVE] = g_param_spec_boolean ("recursive",
+ "recursive",
+ "recursive",
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_properties (gobject_class, NUM_PROPERTIES, properties);
g_type_class_add_private (class, sizeof (NautilusSearchEngineSimpleDetails));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]