[tracker/miner-fs-refactor: 49/120] libtracker-miner: Add TrackerFileNotifier::finished



commit d22797424b2a7df164d59fba00e9769dace3da12
Author: Carlos Garnacho <carlos lanedo com>
Date:   Fri Sep 30 12:01:03 2011 +0200

    libtracker-miner: Add TrackerFileNotifier::finished
    
    This signal notifies when have all pending operations finished,
    if anything triggers new operations, a new ::finished signal will
    be emitted after these (i.e. there's no first vs !first index
    difference)

 src/libtracker-miner/tracker-file-notifier.c |   18 +++++++++++++++++-
 src/libtracker-miner/tracker-file-notifier.h |    2 ++
 2 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-file-notifier.c b/src/libtracker-miner/tracker-file-notifier.c
index 5d2f4a6..c196c4b 100644
--- a/src/libtracker-miner/tracker-file-notifier.c
+++ b/src/libtracker-miner/tracker-file-notifier.c
@@ -46,6 +46,7 @@ enum {
 	FILE_MOVED,
 	DIRECTORY_STARTED,
 	DIRECTORY_FINISHED,
+	FINISHED,
 	LAST_SIGNAL
 };
 
@@ -232,7 +233,11 @@ file_notifier_traverse_tree (TrackerFileNotifier *notifier)
 	priv->pending_index_roots = g_list_remove_link (priv->pending_index_roots,
 							priv->pending_index_roots);
 
-	crawl_directories_start (notifier);
+	if (priv->pending_index_roots) {
+		crawl_directories_start (notifier);
+	} else {
+		g_signal_emit (notifier, signals[FINISHED], 0);
+	}
 }
 
 typedef struct {
@@ -473,6 +478,8 @@ crawl_directories_start (TrackerFileNotifier *notifier)
 								priv->pending_index_roots);
 	}
 
+	g_signal_emit (notifier, signals[FINISHED], 0);
+
 	return FALSE;
 }
 
@@ -980,6 +987,15 @@ tracker_file_notifier_class_init (TrackerFileNotifierClass *klass)
 		              G_TYPE_NONE,
 		              5, G_TYPE_FILE, G_TYPE_UINT,
 		              G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT);
+	signals[FINISHED] =
+		g_signal_new ("finished",
+		              G_TYPE_FROM_CLASS (klass),
+		              G_SIGNAL_RUN_LAST,
+		              G_STRUCT_OFFSET (TrackerFileNotifierClass,
+					       finished),
+			      NULL, NULL,
+		              g_cclosure_marshal_VOID__VOID,
+		              G_TYPE_NONE, 0, G_TYPE_NONE);
 
 	g_object_class_install_property (object_class,
 	                                 PROP_INDEXING_TREE,
diff --git a/src/libtracker-miner/tracker-file-notifier.h b/src/libtracker-miner/tracker-file-notifier.h
index e2145d5..5383255 100644
--- a/src/libtracker-miner/tracker-file-notifier.h
+++ b/src/libtracker-miner/tracker-file-notifier.h
@@ -69,6 +69,8 @@ struct _TrackerFileNotifierClass {
 	                             guint                directories_ignored,
 	                             guint                files_found,
 	                             guint                files_ignored);
+
+	void (* finished)           (TrackerFileNotifier *notifier);
 };
 
 GType         tracker_file_notifier_get_type      (void) G_GNUC_CONST;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]