[gnome-photos] query-builder: Add photos_query_builder_filter_local



commit a158892503c997a91dcc4a0ca9768ee26833d7c5
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue May 1 01:34:06 2012 +0200

    query-builder: Add photos_query_builder_filter_local

 src/Makefile.am            |    2 +
 src/photos-query-builder.c |   76 ++++++++++++++++++++++++++++++++++++++++++++
 src/photos-query-builder.h |   32 ++++++++++++++++++
 3 files changed, 110 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index da3ee54..507e2f1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -50,6 +50,8 @@ gnome_photos_SOURCES = \
 	photos-organize-collection-view.c \
 	photos-organize-collection-view.h \
 	photos-query.h \
+	photos-query-builder.h \
+	photos-query-builder.c \
 	photos-selection-controller.c \
 	photos-selection-controller.h \
 	photos-selection-toolbar.c \
diff --git a/src/photos-query-builder.c b/src/photos-query-builder.c
new file mode 100644
index 0000000..c536003
--- /dev/null
+++ b/src/photos-query-builder.c
@@ -0,0 +1,76 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright  2012 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+
+#include "config.h"
+
+#include <gio/gio.h>
+
+#include "photos-query-builder.h"
+
+
+static gchar *
+photos_query_builder_convert_path_to_uri (const gchar *path)
+{
+  GFile *file;
+  gchar *uri;
+
+  if (path == NULL)
+    return g_strdup ("");
+
+  file = g_file_new_for_path (path);
+  uri = g_file_get_uri (file);
+  g_object_unref (file);
+
+  return uri;
+}
+
+
+gchar *
+photos_query_builder_filter_local (void)
+{
+  GFile *file;
+  gchar *desktop_uri;
+  gchar *documents_uri;
+  gchar *download_uri;
+  gchar *filter;
+  const gchar *path;
+
+  path = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
+  desktop_uri = photos_query_builder_convert_path_to_uri (path);
+
+  path = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
+  documents_uri = photos_query_builder_convert_path_to_uri (path);
+
+  path = g_get_user_special_dir (G_USER_DIRECTORY_DOWNLOAD);
+  download_uri = photos_query_builder_convert_path_to_uri (path);
+
+  filter = g_strdup_printf ("((fn:starts-with (nie:url (?urn), \"%s\"))"
+                            " || (fn:starts-with (nie:url (?urn), \"%s\"))"
+                            " || (fn:starts-with (nie:url (?urn), \"%s\")))",
+                            desktop_uri,
+                            documents_uri,
+                            download_uri);
+  g_free (desktop_uri);
+  g_free (documents_uri);
+  g_free (download_uri);
+
+  return filter;
+}
diff --git a/src/photos-query-builder.h b/src/photos-query-builder.h
new file mode 100644
index 0000000..e8083bd
--- /dev/null
+++ b/src/photos-query-builder.h
@@ -0,0 +1,32 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright  2012 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef PHOTOS_QUERY_BUILDER_H
+#define PHOTOS_QUERY_BUILDER_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+gchar        *photos_query_builder_filter_local        (void);
+
+G_END_DECLS
+
+#endif /* PHOTOS_QUERY_BUILDER */



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