[gnome-photos/wip/uajain/de_dup: 3/4] tracker-controller: Get remote objects cursor
- From: Umang Jain <uajain src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/uajain/de_dup: 3/4] tracker-controller: Get remote objects cursor
- Date: Sat, 20 Aug 2016 20:18:33 +0000 (UTC)
commit 102782cc74754b785078f15321bb9d3f4da337bd
Author: Umang Jain <mailumangjain gmail com>
Date: Sat Aug 20 22:32:46 2016 +0530
tracker-controller: Get remote objects cursor
Check if there are more remote objects inserted in
tracker's database and pass the cursor to item-manager
so that it can hide it in the overview mode.
src/photos-tracker-controller.c | 47 +++++++++++++++++++++++++++++++++++++++
1 files changed, 47 insertions(+), 0 deletions(-)
---
diff --git a/src/photos-tracker-controller.c b/src/photos-tracker-controller.c
index bfb766b..47be734 100644
--- a/src/photos-tracker-controller.c
+++ b/src/photos-tracker-controller.c
@@ -328,6 +328,31 @@ photos_tracker_controller_source_object_added_removed (PhotosTrackerController *
static void
+photos_tracker_controller_get_remote_objects_cursor (GObject *source_object, GAsyncResult *res, gpointer
user_data)
+{
+ PhotosTrackerController *self = PHOTOS_TRACKER_CONTROLLER (user_data);
+ PhotosTrackerControllerPrivate *priv;
+ TrackerSparqlConnection *connection = TRACKER_SPARQL_CONNECTION (source_object);
+ GError *error;
+ TrackerSparqlCursor *cursor;
+
+ priv = photos_tracker_controller_get_instance_private (self);
+
+ error = NULL;
+ cursor = tracker_sparql_connection_query_finish (connection, res, &error);
+ if (error != NULL)
+ {
+ photos_tracker_controller_query_finished (self, error);
+ g_error_free (error);
+ return;
+ }
+
+ photos_item_manager_hide_remote_objects (PHOTOS_ITEM_MANAGER (priv->item_mngr), cursor);
+ g_object_unref (cursor);
+}
+
+
+static void
photos_tracker_controller_window_mode_changed (PhotosTrackerController *self,
PhotosWindowMode mode,
PhotosWindowMode old_mode)
@@ -338,6 +363,28 @@ photos_tracker_controller_window_mode_changed (PhotosTrackerController *self,
if (priv->refresh_pending && mode == priv->mode)
photos_tracker_controller_refresh_for_source (self);
+
+ if (mode == PHOTOS_WINDOW_MODE_OVERVIEW)
+ {
+ /* We would need something better here to know if the item_mngr is ready to hide remote objects
+ * The problem is: window-mode-changed is also emitted at startup of application so hiding remote
+ * objects before item_mngr is ready with it's items, gives segfault.
+ *
+ * May be : write a logic to detect this kind of state ?
+ */
+ if (!photos_tracker_controller_get_query_status (self))
+ {
+ PhotosQuery *query = photos_query_builder_get_remote_objects_with_related_to (state);
+ photos_tracker_queue_select (priv->queue,
+ query->sparql,
+ NULL,
+ photos_tracker_controller_get_remote_objects_cursor,
+ g_object_ref (self),
+ g_object_unref);
+ photos_query_free (query);
+ }
+ }
+
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]