[gnome-photos/wip/uajain/de_dup: 58/58] WIP



commit 1257f074b80aa8c098fe89eee9ff10ceee6a3fbe
Author: Umang Jain <mailumangjain gmail com>
Date:   Sat Aug 20 16:00:52 2016 +0530

    WIP
    
    The general idea here is that, for every "window-mode-changed" signal
    emitted, we need to check if remote objects are to be displayed in the
    view or not.
    
    Therefore, there is _mode_specific function implemented. In the future,
    if we retain this approach, we can change photos_tracker_controller_mode_specific
    to be a virtual function. This way we can have a common place if for any view
    something is to handled specifically.
    
    This is just a sketch.

 src/photos-item-manager.c                |   11 +++++++++++
 src/photos-query-builder.c               |   10 ++++++++++
 src/photos-query-builder.h               |    2 ++
 src/photos-tracker-overview-controller.c |   21 +++++++++++++++++++++
 src/photos-tracker-overview-controller.h |    2 ++
 src/photos-view-container.c              |    2 ++
 6 files changed, 48 insertions(+), 0 deletions(-)
---
diff --git a/src/photos-item-manager.c b/src/photos-item-manager.c
index 73fcc73..aa27fab 100644
--- a/src/photos-item-manager.c
+++ b/src/photos-item-manager.c
@@ -830,6 +830,17 @@ photos_item_manager_get_load_state (PhotosItemManager *self)
 
 
 void
+photos_item_manager_hide_remote_objects (PhotosItemManager *self, Glist *list)
+{
+  GList *l;
+  for (l=list; l != NULL; l=l->next)
+    {
+      /*remove object by its id from overview base manager only*/
+      photos_base_manager_remove_object_by_id (self->item_mngr_chldrn[PHOTOS_WINDOW_MODE_OVERVIEW], id);
+    }
+}
+
+void
 photos_item_manager_hide_item (PhotosItemManager *self, PhotosBaseItem *item)
 {
   PhotosItemManagerHiddenItem *hidden_item;
diff --git a/src/photos-query-builder.c b/src/photos-query-builder.c
index 80f82e2..a5a1950 100644
--- a/src/photos-query-builder.c
+++ b/src/photos-query-builder.c
@@ -349,6 +349,16 @@ photos_query_builder_update_mtime_query (PhotosSearchContextState *state, const
 
 
 PhotosQuery *
+photos_query_builder_get_remote_objects_with_related_to (PhotosSearchContextState *state)
+{
+  gchar *sparql;
+
+  sparql = g_strdup_printf ("SELECT ?urn WHERE {?urn a nie:DataObject FILTER BOUND (nie:relatedTo(?urn))}");
+  return photos_query_new (state, sparql);
+}
+
+
+PhotosQuery *
 photos_query_builder_relate_remote_object (PhotosSearchContextState *state, const gchar *remote_urn, const 
gchar *item_urn)
 {
   gchar *sparql;
diff --git a/src/photos-query-builder.h b/src/photos-query-builder.h
index c03c368..f0ecc77 100644
--- a/src/photos-query-builder.h
+++ b/src/photos-query-builder.h
@@ -66,6 +66,8 @@ PhotosQuery  *photos_query_builder_insert_remote_object (PhotosSearchContextStat
 
 PhotosQuery  *photos_query_builder_relate_remote_object (PhotosSearchContextState *state, const gchar 
*remote_urn, const gchar *item_urn);
 
+PhotosQuery *photos_query_builder_get_remote_objects_with_related_to (PhotosSearchContextState *state);
+
 G_END_DECLS
 
 #endif /* PHOTOS_QUERY_BUILDER */
diff --git a/src/photos-tracker-overview-controller.c b/src/photos-tracker-overview-controller.c
index b3d9ffd..1657cc9 100644
--- a/src/photos-tracker-overview-controller.c
+++ b/src/photos-tracker-overview-controller.c
@@ -117,6 +117,27 @@ photos_tracker_overview_controller_init (PhotosTrackerOverviewController *self)
 }
 
 
+void
+photos_tracker_overview_controller_mode_specific (PhotosTrackerOverviewController *self)
+{
+  g_print ("I am in overview doing special things\n");
+  GApplication *app;
+  PhotosSearchContextState *state;
+  PhotosItemManager *item_mngr;
+  PhotosQuery *query;
+  GList *items;
+
+  app = g_application_get_default ();
+  state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));
+
+  query = photos_query_builder_get_remote_objects_with_related_to (state);
+
+  /*Make a GList of remote objects here you obtain from query*/
+  item_mngr = g_object_ref(state->item_mngr);
+  photos_item_manager_hide_remote_objects (PHOTOS_ITEM_MANAGER (item_mngr), GList *remote_items);
+}
+
+
 static void
 photos_tracker_overview_controller_class_init (PhotosTrackerOverviewControllerClass *class)
 {
diff --git a/src/photos-tracker-overview-controller.h b/src/photos-tracker-overview-controller.h
index 542d113..88947a6 100644
--- a/src/photos-tracker-overview-controller.h
+++ b/src/photos-tracker-overview-controller.h
@@ -46,6 +46,8 @@ GType                     photos_tracker_overview_controller_get_type          (
 
 PhotosTrackerController  *photos_tracker_overview_controller_dup_singleton     (void);
 
+void photos_tracker_overview_controller_mode_specific (PhotosTrackerOverviewController *self);
+
 G_END_DECLS
 
 #endif /* PHOTOS_TRACKER_OVERVIEW_CONTROLLER_H */
diff --git a/src/photos-view-container.c b/src/photos-view-container.c
index d9d8133..fa3c370 100644
--- a/src/photos-view-container.c
+++ b/src/photos-view-container.c
@@ -212,6 +212,8 @@ photos_view_container_window_mode_changed (PhotosViewContainer *self,
       || mode == PHOTOS_WINDOW_MODE_OVERVIEW
       || mode == PHOTOS_WINDOW_MODE_SEARCH)
     photos_view_container_connect_view (self);
+  if (mode == PHOTOS_WINDOW_MODE_OVERVIEW)
+       photos_tracker_overview_controller_mode_specific (self->trk_cntrlr);
 }
 
 


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