[gnome-photos/gnome-3-12] application: Prioritize relevant rdf:types



commit ce0adfb2cfe3b10c3d2318261664e6010ce8af08
Author: Pranav Kant <pranav913 gmail com>
Date:   Fri Apr 4 03:55:41 2014 +0530

    application: Prioritize relevant rdf:types
    
    Fixes: https://bugzilla.gnome.org/726919

 src/Makefile.am                         |   10 +++
 src/photos-application.c                |   93 +++++++++++++++++++++++++++++++
 src/photos-tracker-extract-priority.xml |   32 +++++++++++
 3 files changed, 135 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index ec6acee..b9d908c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -26,6 +26,8 @@ gnome_photos_service_built_sources = \
        photos-resources.h \
        photos-shell-search-provider2.c \
        photos-shell-search-provider2.h \
+       photos-tracker-extract-priority.c \
+       photos-tracker-extract-priority.h \
        photos-tracker-resources.c \
        photos-tracker-resources.h \
        $(NULL)
@@ -249,6 +251,7 @@ EXTRA_DIST = \
        photos-preview-menu.ui \
        photos-selection-menu.ui \
        photos-gom-miner.xml \
+       photos-tracker-extract-priority.xml \
        photos-tracker-resources.xml \
        photos-dleyna-renderer-device.xml \
        photos-dleyna-renderer-manager.xml \
@@ -485,6 +488,13 @@ photos-shell-search-provider2.h photos-shell-search-provider2.c: org.gnome.Shell
                --interface-prefix org.gnome.Shell. \
                $<
 
+photos-tracker-extract-priority.h photos-tracker-extract-priority.c: photos-tracker-extract-priority.xml
+       $(AM_V_GEN)gdbus-codegen \
+               --c-namespace Tracker \
+               --generate-c-code photos-tracker-extract-priority \
+               --interface-prefix org.freedesktop.Tracker1. \
+               $(srcdir)/photos-tracker-extract-priority.xml
+
 photos-tracker-resources.h photos-tracker-resources.c: photos-tracker-resources.xml
        $(AM_V_GEN)gdbus-codegen \
                --c-namespace Tracker \
diff --git a/src/photos-application.c b/src/photos-application.c
index 855ebbb..3826fb3 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -1,5 +1,6 @@
 /*
  * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2014 Pranav Kant
  * Copyright © 2012, 2013, 2014 Red Hat, Inc.
  *
  * This program is free software; you can redistribute it and/or
@@ -50,6 +51,7 @@
 #include "photos-search-provider.h"
 #include "photos-single-item-job.h"
 #include "photos-source-manager.h"
+#include "photos-tracker-extract-priority.h"
 
 
 struct _PhotosApplicationPrivate
@@ -75,6 +77,7 @@ struct _PhotosApplicationPrivate
   PhotosModeController *mode_cntrlr;
   PhotosSearchContextState *state;
   PhotosSearchProvider *search_provider;
+  TrackerExtractPriority *extract_priority;
   guint32 activation_timestamp;
 };
 
@@ -553,6 +556,72 @@ photos_application_stop_miners (PhotosApplication *self)
 
 
 static void
+photos_application_tracker_clear_rdf_types (GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+  PhotosApplication *self = PHOTOS_APPLICATION (user_data);
+  GError *error;
+
+  error = NULL;
+  if (!tracker_extract_priority_call_clear_rdf_types_finish (self->priv->extract_priority, res, &error))
+    {
+      g_warning ("Unable to call ClearRdfTypes: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+ out:
+  g_object_unref (self);
+}
+
+
+static void
+photos_application_tracker_set_rdf_types (GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+  PhotosApplication *self = PHOTOS_APPLICATION (user_data);
+  GError *error;
+
+  error = NULL;
+  if (!tracker_extract_priority_call_set_rdf_types_finish (self->priv->extract_priority, res, &error))
+    {
+      g_warning ("Unable to call SetRdfTypes: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+ out:
+  g_object_unref (self);
+}
+
+
+static void
+photos_application_tracker_extract_priority (GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+  PhotosApplication *self = PHOTOS_APPLICATION (user_data);
+  PhotosApplicationPrivate *priv = self->priv;
+  GError *error;
+  const gchar *const rdf_types[] = {"nfo:Image", NULL};
+
+  error = NULL;
+  priv->extract_priority = tracker_extract_priority_proxy_new_for_bus_finish (res, &error);
+  if (error != NULL)
+    {
+      g_warning ("Unable to create TrackerExtractPriority proxy: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  tracker_extract_priority_call_set_rdf_types (priv->extract_priority,
+                                               rdf_types,
+                                               NULL,
+                                               photos_application_tracker_set_rdf_types,
+                                               g_object_ref (self));
+
+ out:
+  g_object_unref (self);
+}
+
+
+static void
 photos_application_window_mode_changed (PhotosApplication *self, PhotosWindowMode mode, PhotosWindowMode 
old_mode)
 {
   PhotosApplicationPrivate *priv = self->priv;
@@ -636,6 +705,20 @@ photos_application_dbus_unregister (GApplication *application,
 
 
 static void
+photos_application_shutdown (GApplication *application)
+{
+  PhotosApplication *self = PHOTOS_APPLICATION (application);
+
+  tracker_extract_priority_call_clear_rdf_types (self->priv->extract_priority,
+                                                 NULL,
+                                                 photos_application_tracker_clear_rdf_types,
+                                                 g_object_ref (self));
+
+  G_APPLICATION_CLASS (photos_application_parent_class)->shutdown (application);
+}
+
+
+static void
 photos_application_startup (GApplication *application)
 {
   PhotosApplication *self = PHOTOS_APPLICATION (application);
@@ -682,6 +765,14 @@ photos_application_startup (GApplication *application)
                                                          NULL,
                                                          NULL);
 
+  tracker_extract_priority_proxy_new_for_bus (G_BUS_TYPE_SESSION,
+                                              G_DBUS_PROXY_FLAGS_NONE,
+                                              "org.freedesktop.Tracker1.Miner.Extract",
+                                              "/org/freedesktop/Tracker1/Extract/Priority",
+                                              NULL,
+                                              photos_application_tracker_extract_priority,
+                                              g_object_ref (self));
+
   priv->item_mngr = photos_item_manager_dup_singleton ();
 
   /* A dummy reference to keep it alive during the lifetime of the
@@ -815,6 +906,7 @@ photos_application_dispose (GObject *object)
   g_clear_object (&priv->camera_cache);
   g_clear_object (&priv->mode_cntrlr);
   g_clear_object (&priv->search_provider);
+  g_clear_object (&priv->extract_priority);
 
   if (priv->state != NULL)
     {
@@ -862,6 +954,7 @@ photos_application_class_init (PhotosApplicationClass *class)
   application_class->activate = photos_application_activate;
   application_class->dbus_register = photos_application_dbus_register;
   application_class->dbus_unregister = photos_application_dbus_unregister;
+  application_class->shutdown = photos_application_shutdown;
   application_class->startup = photos_application_startup;
 
   /* TODO: Add miners-changed signal */
diff --git a/src/photos-tracker-extract-priority.xml b/src/photos-tracker-extract-priority.xml
new file mode 100644
index 0000000..3e27ce4
--- /dev/null
+++ b/src/photos-tracker-extract-priority.xml
@@ -0,0 +1,32 @@
+<!DOCTYPE node PUBLIC
+"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd";>
+
+<!--
+ Photos - access, organize and share your photos on GNOME
+ Copyright © 2014 Pranav Kant
+
+ 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.
+-->
+
+<node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd";>
+  <interface name="org.freedesktop.Tracker1.Extract.Priority">
+    <method name="ClearRdfTypes" />
+    <method name="SetRdfTypes">
+      <arg name="rdf_types" type="as" direction="in" />
+    </method>
+  </interface>
+</node>


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