[gnome-photos/wip/search: 18/23] application: Implement activate_result
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/search: 18/23] application: Implement activate_result
- Date: Tue, 18 Feb 2014 19:16:43 +0000 (UTC)
commit c7dc908a8a7b74823aa09dc60c5d3dba98e20269
Author: Debarshi Ray <debarshir gnome org>
Date: Tue Feb 18 15:17:46 2014 +0100
application: Implement activate_result
src/photos-application.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 59 insertions(+), 0 deletions(-)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index a41ea6e..82f01a7 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -43,9 +43,11 @@
#include "photos-main-window.h"
#include "photos-mode-controller.h"
#include "photos-properties-dialog.h"
+#include "photos-query.h"
#include "photos-resources.h"
#include "photos-search-controller.h"
#include "photos-search-provider.h"
+#include "photos-single-item-job.h"
#include "photos-source-manager.h"
@@ -173,11 +175,68 @@ photos_application_create_window (PhotosApplication *self)
static void
+photos_application_activate_item (PhotosApplication *self, GObject *item)
+{
+ PhotosApplicationPrivate *priv = self->priv;
+
+ photos_base_manager_set_active_object (priv->item_mngr, item);
+
+ photos_application_create_window (self);
+ photos_mode_controller_set_window_mode (priv->mode_cntrlr, PHOTOS_WINDOW_MODE_PREVIEW);
+ g_application_activate (G_APPLICATION (self));
+
+ /* TODO: Forward the search terms when we exit the preview */
+}
+
+
+static void
+photos_application_activate_query_executed (TrackerSparqlCursor *cursor, gpointer user_data)
+{
+ PhotosApplication *self = PHOTOS_APPLICATION (user_data);
+ PhotosApplicationPrivate *priv = self->priv;
+ GObject *item;
+ const gchar *identifier;
+
+ if (cursor == NULL)
+ goto out;
+
+ photos_item_manager_add_item (PHOTOS_ITEM_MANAGER (priv->item_mngr), cursor);
+
+ identifier = tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_URN, NULL);
+ item = photos_base_manager_get_object_by_id (priv->item_mngr, identifier);
+
+ photos_application_activate_item (self, item);
+
+ out:
+ g_object_unref (self);
+}
+
+
+static void
photos_application_activate_result (PhotosApplication *self,
const gchar *identifier,
const gchar *const *terms,
guint timestamp)
{
+ PhotosApplicationPrivate *priv = self->priv;
+ GObject *item;
+
+ priv->activation_timestamp = timestamp;
+
+ item = photos_base_manager_get_object_by_id (priv->item_mngr, identifier);
+ if (item != NULL)
+ photos_application_activate_item (self, item);
+ else
+ {
+ PhotosSingleItemJob *job;
+
+ job = photos_single_item_job_new (identifier);
+ photos_single_item_job_run (job,
+ PHOTOS_QUERY_FLAGS_UNFILTERED,
+ photos_application_activate_query_executed,
+ g_object_ref (self));
+ g_object_unref (job);
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]