[tracker] tracker-store: Sort classes on startup instead of in Statistics.Get
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] tracker-store: Sort classes on startup instead of in Statistics.Get
- Date: Tue, 11 Jan 2011 10:46:43 +0000 (UTC)
commit 4b4ba89f8b20f7dbf4865554968bdce3939f4fd3
Author: Jürg Billeter <j bitron ch>
Date: Tue Jan 11 11:45:09 2011 +0100
tracker-store: Sort classes on startup instead of in Statistics.Get
src/libtracker-data/tracker-data-manager.c | 4 ++++
src/libtracker-data/tracker-ontologies.c | 15 +++++++++++++++
src/libtracker-data/tracker-ontologies.h | 1 +
src/tracker-store/tracker-statistics.c | 16 ----------------
4 files changed, 20 insertions(+), 16 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index d2783a0..c92600c 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -3808,6 +3808,10 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
tracker_db_manager_set_current_locale ();
}
+ if (!read_only) {
+ tracker_ontologies_sort ();
+ }
+
initialized = TRUE;
g_free (ontologies_dir);
diff --git a/src/libtracker-data/tracker-ontologies.c b/src/libtracker-data/tracker-ontologies.c
index 3643524..b5d58d6 100644
--- a/src/libtracker-data/tracker-ontologies.c
+++ b/src/libtracker-data/tracker-ontologies.c
@@ -685,3 +685,18 @@ tracker_ontologies_get_property_string_gvdb (const gchar *uri,
return result;
}
+
+static gint
+class_sort_func (gconstpointer a,
+ gconstpointer b)
+{
+ return g_strcmp0 (tracker_class_get_name (*((TrackerClass **) a)),
+ tracker_class_get_name (*((TrackerClass **) b)));
+}
+
+void
+tracker_ontologies_sort (void)
+{
+ /* Sort result so it is alphabetical */
+ g_ptr_array_sort (classes, class_sort_func);
+}
diff --git a/src/libtracker-data/tracker-ontologies.h b/src/libtracker-data/tracker-ontologies.h
index efde10b..a0f7668 100644
--- a/src/libtracker-data/tracker-ontologies.h
+++ b/src/libtracker-data/tracker-ontologies.h
@@ -38,6 +38,7 @@ G_BEGIN_DECLS
void tracker_ontologies_init (void);
void tracker_ontologies_shutdown (void);
+void tracker_ontologies_sort (void);
/* Service mechanics */
void tracker_ontologies_add_class (TrackerClass *service);
diff --git a/src/tracker-store/tracker-statistics.c b/src/tracker-store/tracker-statistics.c
index c497328..d44d57d 100644
--- a/src/tracker-store/tracker-statistics.c
+++ b/src/tracker-store/tracker-statistics.c
@@ -56,19 +56,6 @@ tracker_statistics_new (void)
return g_object_new (TRACKER_TYPE_STATISTICS, NULL);
}
-static gint
-cache_sort_func (gconstpointer a,
- gconstpointer b)
-{
- const GStrv *strv_a = (GStrv *) a;
- const GStrv *strv_b = (GStrv *) b;
-
- g_return_val_if_fail (strv_a != NULL, 0);
- g_return_val_if_fail (strv_b != NULL, 0);
-
- return g_strcmp0 (*strv_a[0], *strv_b[0]);
-}
-
void
tracker_statistics_get (TrackerStatistics *object,
DBusGMethodInvocation *context,
@@ -103,9 +90,6 @@ tracker_statistics_get (TrackerStatistics *object,
g_ptr_array_add (values, strv);
}
- /* Sort result so it is alphabetical */
- g_ptr_array_sort (values, cache_sort_func);
-
tracker_dbus_request_end (request, NULL);
dbus_g_method_return (context, values);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]