[PATCH 09/14] tracker: add category support
- From: llandwerlin gmail com
- To: grilo-list gnome org
- Subject: [PATCH 09/14] tracker: add category support
- Date: Mon, 17 Jan 2011 10:18:06 +0000
From: Lionel Landwerlin <lionel g landwerlin linux intel com>
Signed-off-by: Lionel Landwerlin <lionel g landwerlin linux intel com>
---
src/tracker/grl-tracker.c | 73 ++++++++++++++++++++++++++++++++++++--------
1 files changed, 59 insertions(+), 14 deletions(-)
diff --git a/src/tracker/grl-tracker.c b/src/tracker/grl-tracker.c
index aff7efd..f54f16e 100644
--- a/src/tracker/grl-tracker.c
+++ b/src/tracker/grl-tracker.c
@@ -106,6 +106,15 @@ enum {
ORDER BY ASC(nfo:fileName(?urn)) \
OFFSET %i LIMIT %i"
+#define TRACKER_BROWSE_CATEGORY_REQUEST " \
+ SELECT %s \
+ WHERE { \
+ { ?urn a %s } \
+ ?urn tracker:available ?tr \
+ } \
+ ORDER BY DESC(nfo:fileLastModified(?urn)) \
+ OFFSET %i LIMIT %i"
+
#define TRACKER_SEARCH_REQUEST " \
SELECT %s \
WHERE { \
@@ -134,6 +143,7 @@ typedef enum {
typedef enum {
TRACKER_BROWSING_MODE_FLAT,
TRACKER_BROWSING_MODE_DIRECTORY,
+ TRACKER_BROWSING_MODE_CATEGORY,
TRACKER_BROWSING_MODE_INVALID,
} tracker_browsing_mode_t;
@@ -314,7 +324,7 @@ grl_tracker_source_class_init (GrlTrackerSourceClass * klass)
PROP_BROWSING_MODE,
g_param_spec_string ("browsing-mode",
"browsing-mode",
- "Method used to browse a tracker source (flat,directory)",
+ "Method used to browse a tracker source (category,directory,flat)",
"directory",
G_PARAM_READABLE
| G_PARAM_WRITABLE
@@ -330,7 +340,7 @@ grl_tracker_source_init (GrlTrackerSource *source)
{
source->priv = GRL_TRACKER_SOURCE_GET_PRIVATE (source);
- source->priv->browsing_mode = TRACKER_BROWSING_MODE_DIRECTORY;
+ source->priv->browsing_mode = TRACKER_BROWSING_MODE_CATEGORY;
}
static void
@@ -398,14 +408,13 @@ tracker_browsing_mode_to_str (tracker_browsing_mode_t mode)
switch (mode) {
case TRACKER_BROWSING_MODE_FLAT:
return "flat";
-
case TRACKER_BROWSING_MODE_DIRECTORY:
return "directory";
-
+ case TRACKER_BROWSING_MODE_CATEGORY:
+ return "category";
default:
return "invalid";
}
-
return "invalid";
}
@@ -418,6 +427,8 @@ tracker_browsing_mode_from_str (const gchar *str)
return TRACKER_BROWSING_MODE_FLAT;
if (!strcmp (str, "directory"))
return TRACKER_BROWSING_MODE_DIRECTORY;
+ if (!strcmp (str, "category"))
+ return TRACKER_BROWSING_MODE_CATEGORY;
return TRACKER_BROWSING_MODE_INVALID;
}
@@ -1018,6 +1029,7 @@ grl_tracker_source_browse (GrlMediaSource *source,
gchar *sparql_final;
GError *error = NULL;
struct OperationSpec *os;
+ GrlMedia *media;
GRL_DEBUG ("grl_tracker_source_browse");
@@ -1028,20 +1040,53 @@ grl_tracker_source_browse (GrlMediaSource *source,
goto send_error;
}
- sparql_select = get_select_string (source, bs->keys);
- if (priv->browsing_mode == TRACKER_BROWSING_MODE_FLAT) {
- sparql_final = g_strdup_printf (TRACKER_BROWSE_FLAT_REQUEST,
- sparql_select, bs->skip, bs->count);
+ if ((priv->browsing_mode == TRACKER_BROWSING_MODE_CATEGORY) &&
+ (bs->container == NULL || grl_media_get_id (bs->container) == NULL)) {
+ /* Hardcoded categories */
+ media = grl_media_box_new ();
+ grl_media_set_title (media, "Music");
+ grl_media_set_id (media, "nmm:MusicPiece");
+ bs->callback (bs->source, bs->browse_id, media, 2, bs->user_data, NULL);
+
+ media = grl_media_box_new ();
+ grl_media_set_title (media, "Photo");
+ grl_media_set_id (media, "nmm:Photo");
+ bs->callback (bs->source, bs->browse_id, media, 1, bs->user_data, NULL);
+
+ media = grl_media_box_new ();
+ grl_media_set_title (media, "Video");
+ grl_media_set_id (media, "nmm:Video");
+ bs->callback (bs->source, bs->browse_id, media, 0, bs->user_data, NULL);
+ return;
} else {
- if (bs->container == NULL ||
- grl_media_get_id (bs->container) == NULL) {
- sparql_final = g_strdup_printf (TRACKER_BROWSE_DIRECTORY_ROOT_REQUEST,
+ sparql_select = get_select_string (source, bs->keys);
+ switch (priv->browsing_mode) {
+ case TRACKER_BROWSING_MODE_FLAT:
+ sparql_final = g_strdup_printf (TRACKER_BROWSE_FLAT_REQUEST,
sparql_select, bs->skip, bs->count);
- } else {
- sparql_final = g_strdup_printf (TRACKER_BROWSE_DIRECTORY_CONT_REQUEST,
+ break;
+
+ case TRACKER_BROWSING_MODE_INVALID:
+ case TRACKER_BROWSING_MODE_DIRECTORY:
+ default:
+ if (bs->container == NULL ||
+ grl_media_get_id (bs->container) == NULL) {
+ sparql_final = g_strdup_printf (TRACKER_BROWSE_DIRECTORY_ROOT_REQUEST,
+ sparql_select, bs->skip, bs->count);
+ } else {
+ sparql_final = g_strdup_printf (TRACKER_BROWSE_DIRECTORY_CONT_REQUEST,
+ sparql_select,
+ grl_media_get_id (bs->container),
+ bs->skip, bs->count);
+ }
+ break;
+
+ case TRACKER_BROWSING_MODE_CATEGORY:
+ sparql_final = g_strdup_printf (TRACKER_BROWSE_CATEGORY_REQUEST,
sparql_select,
grl_media_get_id (bs->container),
bs->skip, bs->count);
+ break;
}
}
--
1.7.2.3
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]