[gnome-photos/wip/rishi/collection: 30/31] tracker-controller, tracker-search-controller: Delay SEARCH queries



commit a93a00370ccc959ece269e155dd5800aa4fe1da8
Author: Debarshi Ray <debarshir gnome org>
Date:   Wed Jan 17 20:47:23 2018 +0100

    tracker-controller, tracker-search-controller: Delay SEARCH queries
    
    Currently TrackerSearchController issues an "empty" search query at
    startup. This is wasteful because the SEARCH view isn't shown when the
    MainWindow is presented for the first time. It's only revealed when at
    least one search criterion is specified, which requires a new query to
    fetch the relevant results.

 src/photos-tracker-controller.c        | 17 +++++++++++++++++
 src/photos-tracker-search-controller.c |  5 ++++-
 2 files changed, 21 insertions(+), 1 deletion(-)
---
diff --git a/src/photos-tracker-controller.c b/src/photos-tracker-controller.c
index a1da8f4a..5a99575a 100644
--- a/src/photos-tracker-controller.c
+++ b/src/photos-tracker-controller.c
@@ -52,6 +52,7 @@ struct _PhotosTrackerControllerPrivate
   PhotosQuery *current_query;
   PhotosTrackerQueue *queue;
   PhotosWindowMode mode;
+  gboolean delay_start;
   gboolean is_frozen;
   gboolean is_started;
   gboolean query_queued;
@@ -65,6 +66,7 @@ struct _PhotosTrackerControllerPrivate
 enum
 {
   PROP_0,
+  PROP_DELAY_START,
   PROP_MODE
 };
 
@@ -516,6 +518,10 @@ photos_tracker_controller_set_property (GObject *object, guint prop_id, const GV
 
   switch (prop_id)
     {
+    case PROP_DELAY_START:
+      priv->delay_start = g_value_get_boolean (value);
+      break;
+
     case PROP_MODE:
       priv->mode = (PhotosWindowMode) g_value_get_enum (value);
       break;
@@ -577,6 +583,14 @@ photos_tracker_controller_class_init (PhotosTrackerControllerClass *class)
   object_class->set_property = photos_tracker_controller_set_property;
   object_class->finalize = photos_tracker_controller_finalize;
 
+  g_object_class_install_property (object_class,
+                                   PROP_DELAY_START,
+                                   g_param_spec_boolean ("delay-start",
+                                                         "Delay start",
+                                                         "Don't start issuing queries immediately on 
start-up",
+                                                         FALSE,
+                                                         G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
+
   g_object_class_install_property (object_class,
                                    PROP_MODE,
                                    g_param_spec_enum ("mode",
@@ -637,6 +651,9 @@ photos_tracker_controller_start (PhotosTrackerController *self)
 
   priv = photos_tracker_controller_get_instance_private (self);
 
+  if (priv->delay_start)
+    return;
+
   if (priv->is_started)
     return;
 
diff --git a/src/photos-tracker-search-controller.c b/src/photos-tracker-search-controller.c
index 907b6a05..a0ab7a2d 100644
--- a/src/photos-tracker-search-controller.c
+++ b/src/photos-tracker-search-controller.c
@@ -179,5 +179,8 @@ photos_tracker_search_controller_class_init (PhotosTrackerSearchControllerClass
 PhotosTrackerController *
 photos_tracker_search_controller_dup_singleton (void)
 {
-  return g_object_new (PHOTOS_TYPE_TRACKER_SEARCH_CONTROLLER, "mode", PHOTOS_WINDOW_MODE_SEARCH, NULL);
+  return g_object_new (PHOTOS_TYPE_TRACKER_SEARCH_CONTROLLER,
+                       "delay-start", TRUE,
+                       "mode", PHOTOS_WINDOW_MODE_SEARCH,
+                       NULL);
 }


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