[gnome-photos/wip/foo: 5/8] Clean up some queries
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/foo: 5/8] Clean up some queries
- Date: Mon, 8 Apr 2013 23:10:17 +0000 (UTC)
commit 533fee9ab4f9c96be02d15eb60c61e1aef326688
Author: Debarshi Ray <debarshir gnome org>
Date: Mon Apr 8 22:16:00 2013 +0200
Clean up some queries
Get rid of extra parentheses, replace \" with ' and use
g_strdup_printf to improve readability.
src/photos-query-builder.c | 21 ++++++++++++---------
src/photos-search-type-manager.c | 7 +++----
2 files changed, 15 insertions(+), 13 deletions(-)
---
diff --git a/src/photos-query-builder.c b/src/photos-query-builder.c
index af71273..51487b4 100644
--- a/src/photos-query-builder.c
+++ b/src/photos-query-builder.c
@@ -200,11 +200,14 @@ photos_query_builder_create_collection_query (const gchar *name)
tv.tv_usec = 0;
time = g_time_val_to_iso8601 (&tv);
- sparql = g_strconcat ("INSERT { _:res a nfo:DataContainer ; a nie:DataObject ; ",
- "nie:contentLastModified \"", time, "\" ; ",
- "nie:title \"", name, "\" ; ",
- "nao:identifier \"", PHOTOS_QUERY_LOCAL_COLLECTIONS_IDENTIFIER, name, "\" }",
- NULL);
+ sparql = g_strdup_printf ("INSERT { _:res a nfo:DataContainer ; a nie:DataObject ; "
+ "nie:contentLastModified '%s' ; "
+ "nie:title '%s' ; "
+ "nao:identifier '%s%s' }",
+ time,
+ name,
+ PHOTOS_QUERY_LOCAL_COLLECTIONS_IDENTIFIER,
+ name);
g_free (time);
return photos_query_new (sparql);
@@ -398,10 +401,10 @@ photos_query_builder_filter_local (void)
path = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
pictures_uri = photos_query_builder_convert_path_to_uri (path);
- filter = g_strdup_printf ("((fn:contains (nie:url (?urn), \"%s\"))"
- " || (fn:contains (nie:url (?urn), \"%s\"))"
- " || (fn:contains (nie:url (?urn), \"%s\"))"
- " || (fn:starts-with (nao:identifier (?urn), \"%s\")))",
+ filter = g_strdup_printf ("(fn:contains (nie:url (?urn), \"%s\")"
+ " || fn:contains (nie:url (?urn), \"%s\")"
+ " || fn:contains (nie:url (?urn), \"%s\")"
+ " || fn:starts-with (nao:identifier (?urn), \"%s\"))",
desktop_uri,
download_uri,
pictures_uri,
diff --git a/src/photos-search-type-manager.c b/src/photos-search-type-manager.c
index 1a6b9bf..7d96002 100644
--- a/src/photos-search-type-manager.c
+++ b/src/photos-search-type-manager.c
@@ -66,10 +66,9 @@ photos_search_type_manager_init (PhotosSearchTypeManager *self)
photos_base_manager_add_object (PHOTOS_BASE_MANAGER (self), G_OBJECT (search_type));
g_object_unref (search_type);
- filter = g_strconcat ("((fn:contains (rdf:type (?urn), \'nfo#DataContainer\'))"
- " && (fn:starts-with (nao:identifier (?urn), \'",
PHOTOS_QUERY_COLLECTIONS_IDENTIFIER, "\'))"
- ")",
- NULL);
+ filter = g_strdup_printf ("(fn:contains (rdf:type (?urn), 'nfo#DataContainer')"
+ " && fn:starts-with (nao:identifier (?urn), '%s'))",
+ PHOTOS_QUERY_COLLECTIONS_IDENTIFIER);
search_type = photos_search_type_new_with_filter (PHOTOS_SEARCH_TYPE_STOCK_COLLECTIONS, _("Albums"),
filter);
photos_base_manager_add_object (PHOTOS_BASE_MANAGER (self), G_OBJECT (search_type));
g_object_unref (search_type);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]