[tracker/miner-userguide] tracker-miner-fs: Use locale specific path targetting for userguides
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/miner-userguide] tracker-miner-fs: Use locale specific path targetting for userguides
- Date: Thu, 24 Nov 2011 12:50:30 +0000 (UTC)
commit e2cdb947a8b8e4020d43dced1469510b4b0cebe7
Author: Martyn Russell <martyn lanedo com>
Date: Thu Nov 24 12:50:10 2011 +0000
tracker-miner-fs: Use locale specific path targetting for userguides
src/miners/fs/tracker-miner-userguides.c | 115 ++++++++++++++++--------------
1 files changed, 62 insertions(+), 53 deletions(-)
---
diff --git a/src/miners/fs/tracker-miner-userguides.c b/src/miners/fs/tracker-miner-userguides.c
index 122fa31..0fd8145 100644
--- a/src/miners/fs/tracker-miner-userguides.c
+++ b/src/miners/fs/tracker-miner-userguides.c
@@ -120,14 +120,66 @@ miner_userguides_basedir_add (TrackerMinerFS *fs,
{
GFile *file;
gchar *path;
+ gboolean index_all_locales = TRUE;
- /* Add $dir/userguide/contents */
- path = g_build_filename (basedir, "userguide", "contents", NULL);
- file = g_file_new_for_path (path);
- g_message (" Adding:'%s'", path);
- tracker_miner_fs_directory_add (fs, file, TRUE);
- g_object_unref (file);
- g_free (path);
+ /* Without MeeGoTouch, we simply index ALL content. */
+#ifdef HAVE_MEEGOTOUCH
+ gchar *locale;
+
+ locale = tracker_miner_meego_get_locale ();
+ if (locale) {
+ /* First we try the "xx_YY" of the current locale */
+ path = g_build_filename (basedir, "userguide", "contents", locale, NULL);
+ file = g_file_new_for_path (path);
+
+ if (g_file_test (path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
+ g_message (" Adding:'%s'", path);
+ tracker_miner_fs_directory_add (fs, file, TRUE);
+ g_object_unref (file);
+ g_free (path);
+
+ index_all_locales = FALSE;
+ } else {
+ gchar *short_locale;
+
+ g_object_unref (file);
+ g_free (path);
+
+ /* Second we try the "xx" of the current locale */
+ short_locale = g_strdup_printf ("%2.2s", locale);
+ path = g_build_filename (basedir, "userguide", "contents", short_locale, NULL);
+ file = g_file_new_for_path (path);
+
+ if (g_file_test (path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
+ g_message (" Adding:'%s'", path);
+ tracker_miner_fs_directory_add (fs, file, TRUE);
+ g_object_unref (file);
+ g_free (path);
+
+ index_all_locales = FALSE;
+ } else {
+ g_object_unref (file);
+ g_free (path);
+
+ g_warning ("Could not find a userguide matching the locale:'%s' or '%s'",
+ locale,
+ short_locale);
+ }
+ }
+ } else {
+ g_warning ("Locale was not set which is unexpected, indexing ALL user guides");
+ }
+#endif /* HAVE_MEEGOTOUCH */
+
+ if (index_all_locales) {
+ /* Add $dir/userguide/contents */
+ path = g_build_filename (basedir, "userguide", "contents", NULL);
+ file = g_file_new_for_path (path);
+ g_message (" Adding:'%s'", path);
+ tracker_miner_fs_directory_add (fs, file, TRUE);
+ g_object_unref (file);
+ g_free (path);
+ }
}
static void
@@ -240,53 +292,10 @@ static gboolean
miner_userguides_check_directory (TrackerMinerFS *fs,
GFile *file)
{
- gboolean retval = FALSE;
- gchar *basename;
-
- /* We want to inspect all the passed dirs and their children except one:
- * $prefix/userguide/contents/images/
- */
- basename = g_file_get_basename (file);
-
- if (strcmp (basename, "images") != 0) {
- g_message (" Ignoring:'%s'", basename);
- retval = TRUE;
- }
-
- /* Without MeeGoTouch, we simply index ALL content. */
-#ifdef HAVE_MEEGOTOUCH
- GFile *parent;
- gchar *parent_basename;
-
- /* We want to ignore all locales which are not the current one:
- * $prefix/userguide/contents/$locale/
+ /* We target specific locale based userguides now, no
+ * filtering needed at this level
*/
- parent = g_file_get_parent (file);
- if (parent) {
- parent_basename = g_file_get_basename (parent);
- } else {
- parent_basename = NULL;
- }
-
- if (parent_basename && strcmp (parent_basename, "contents") == 0) {
- gchar *locale;
-
- locale = tracker_miner_meego_get_locale ();
-
- if (locale && g_ascii_strcasecmp (locale, basename) == 0) {
- g_message (" Ignoring:'%s' (doesn't match locale:'%s')",
- basename, locale);
- retval = TRUE;
- }
-
- g_free (locale);
- }
-
- g_free (parent_basename);
-#endif /* HAVE_MEEGOTOUCH */
- g_free (basename);
-
- return retval;
+ return TRUE;
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]