[tracker] tracker-miner-fs: Reindex applications on locale change



commit 49f0971f7983aa68d09d9f96d236c1612b78377d
Author: JÃrg Billeter <j bitron ch>
Date:   Tue Aug 30 14:04:32 2011 +0200

    tracker-miner-fs: Reindex applications on locale change
    
    Fixes NB#276858.

 src/miners/fs/tracker-miner-applications.c |   64 ++++++++++++++++++++++------
 src/miners/fs/tracker-miner-applications.h |    1 +
 2 files changed, 51 insertions(+), 14 deletions(-)
---
diff --git a/src/miners/fs/tracker-miner-applications.c b/src/miners/fs/tracker-miner-applications.c
index ee3fe52..d6c6373 100644
--- a/src/miners/fs/tracker-miner-applications.c
+++ b/src/miners/fs/tracker-miner-applications.c
@@ -130,13 +130,9 @@ miner_applications_basedir_add (TrackerMinerFS *fs,
 	g_free (path);
 }
 
-static gboolean
-miner_applications_initable_init (GInitable     *initable,
-                                  GCancellable  *cancellable,
-                                  GError       **error)
+static void
+miner_applications_add_directories (TrackerMinerFS *fs)
 {
-	TrackerMinerFS *fs;
-	GError *inner_error = NULL;
 #ifdef HAVE_MEEGOTOUCH
 	GFile *file;
 	const gchar *path;
@@ -145,14 +141,6 @@ miner_applications_initable_init (GInitable     *initable,
 	const gchar *user_data_dir;
 	gint i;
 
-	fs = TRACKER_MINER_FS (initable);
-
-	/* Chain up parent's initable callback before calling child's one */
-	if (!miner_applications_initable_parent_iface->init (initable, cancellable, &inner_error)) {
-		g_propagate_error (error, inner_error);
-		return FALSE;
-	}
-
 	g_message ("Setting up applications to iterate from XDG system directories");
 
 	/* Add all XDG system and local dirs */
@@ -181,15 +169,63 @@ miner_applications_initable_init (GInitable     *initable,
 	file = g_file_new_for_path (path);
 	tracker_miner_fs_directory_add (fs, file, TRUE);
 	g_object_unref (file);
+#endif /* HAVE_MEEGOTOUCH */
+}
+
+static void
+tracker_locale_notify_cb (TrackerLocaleID id,
+                          gpointer        user_data)
+{
+	TrackerMiner *miner = user_data;
+
+	if (tracker_miner_applications_detect_locale_changed (miner)) {
+		tracker_miner_fs_set_mtime_checking (TRACKER_MINER_FS (miner), TRUE);
+
+		miner_applications_add_directories (TRACKER_MINER_FS (miner));
+	}
+}
+
+static gboolean
+miner_applications_initable_init (GInitable     *initable,
+                                  GCancellable  *cancellable,
+                                  GError       **error)
+{
+	TrackerMinerFS *fs;
+	TrackerMinerApplications *app;
+	GError *inner_error = NULL;
+
+	fs = TRACKER_MINER_FS (initable);
+	app = TRACKER_MINER_APPLICATIONS (initable);
+
+	/* Chain up parent's initable callback before calling child's one */
+	if (!miner_applications_initable_parent_iface->init (initable, cancellable, &inner_error)) {
+		g_propagate_error (error, inner_error);
+		return FALSE;
+	}
+
+	miner_applications_add_directories (fs);
+
+#ifdef HAVE_MEEGOTOUCH
 	tracker_miner_applications_meego_init ();
 #endif /* HAVE_MEEGOTOUCH */
 
+	app->locale_notification_id = tracker_locale_notify_add (TRACKER_LOCALE_LANGUAGE,
+	                                                         tracker_locale_notify_cb,
+	                                                         app,
+	                                                         NULL);
+
 	return TRUE;
 }
 
 static void
 miner_applications_finalize (GObject *object)
 {
+	TrackerMinerApplications *app;
+
+	app = TRACKER_MINER_APPLICATIONS (object);
+
+	tracker_locale_notify_remove (app->locale_notification_id);
+
 #ifdef HAVE_MEEGOTOUCH
 	tracker_miner_applications_meego_shutdown ();
 #endif /* HAVE_MEEGOTOUCH */
diff --git a/src/miners/fs/tracker-miner-applications.h b/src/miners/fs/tracker-miner-applications.h
index 7f7d8a6..acf7ac6 100644
--- a/src/miners/fs/tracker-miner-applications.h
+++ b/src/miners/fs/tracker-miner-applications.h
@@ -36,6 +36,7 @@ typedef struct _TrackerMinerApplicationsClass TrackerMinerApplicationsClass;
 
 struct _TrackerMinerApplications {
 	TrackerMinerFS parent_instance;
+	gpointer locale_notification_id;
 };
 
 struct _TrackerMinerApplicationsClass {



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