[gnome-photos/wip/rishi/collection: 19/36] Add Filterable::is_search_criterion



commit b164192eae2ab1943f0522981a80d74e397ac22e
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu Jan 11 18:42:28 2018 +0100

    Add Filterable::is_search_criterion
    
    Not every instance of a Filterable implementation is supposed to be
    offered as a search criterion through the Dropdown. So far, this
    distinction was simple - all instances of a certain implemention were
    either offered or not, and determined by Dropdown through the
    corresponding BaseManager.
    
    However, the introduction of GMount-backed PhotosSources demands finer
    control. A GMount-backed Source shouldn't be presented through the
    Dropdown, while other Sources should be.
    
    This method is meant to address that.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=751212

 src/photos-base-item.c          |  8 ++++++++
 src/photos-filterable.c         |  8 ++++++++
 src/photos-filterable.h         |  3 +++
 src/photos-search-match.c       |  8 ++++++++
 src/photos-search-type.c        |  8 ++++++++
 src/photos-share-point-email.c  |  8 ++++++++
 src/photos-share-point-online.c |  8 ++++++++
 src/photos-source.c             | 12 ++++++++++++
 8 files changed, 63 insertions(+)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index e415e7ec..6154bbab 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -678,6 +678,13 @@ photos_base_item_filterable_get_id (PhotosFilterable *filterable)
 }
 
 
+static gboolean
+photos_base_item_filterable_is_search_criterion (PhotosFilterable *filterable)
+{
+  return FALSE;
+}
+
+
 static void
 photos_base_item_icon_updated (PhotosBaseItem *self, GIcon *icon)
 {
@@ -3041,6 +3048,7 @@ static void
 photos_base_item_filterable_iface_init (PhotosFilterableInterface *iface)
 {
   iface->get_id = photos_base_item_filterable_get_id;
+  iface->is_search_criterion = photos_base_item_filterable_is_search_criterion;
 }
 
 
diff --git a/src/photos-filterable.c b/src/photos-filterable.c
index 590bedaf..3bf01c93 100644
--- a/src/photos-filterable.c
+++ b/src/photos-filterable.c
@@ -75,3 +75,11 @@ photos_filterable_get_where (PhotosFilterable *self)
   g_return_val_if_fail (PHOTOS_IS_FILTERABLE (self), NULL);
   return PHOTOS_FILTERABLE_GET_IFACE (self)->get_where (self);
 }
+
+
+gboolean
+photos_filterable_is_search_criterion (PhotosFilterable *self)
+{
+  g_return_val_if_fail (PHOTOS_IS_FILTERABLE (self), FALSE);
+  return PHOTOS_FILTERABLE_GET_IFACE (self)->is_search_criterion (self);
+}
diff --git a/src/photos-filterable.h b/src/photos-filterable.h
index a9ad3780..0bb24f24 100644
--- a/src/photos-filterable.h
+++ b/src/photos-filterable.h
@@ -38,6 +38,7 @@ struct _PhotosFilterableInterface
   gchar *(*get_filter) (PhotosFilterable *self);
   const gchar *(*get_id) (PhotosFilterable *self);
   gchar *(*get_where) (PhotosFilterable *self);
+  gboolean (*is_search_criterion) (PhotosFilterable *self);
 };
 
 gboolean            photos_filterable_get_builtin        (PhotosFilterable *self);
@@ -48,6 +49,8 @@ const gchar        *photos_filterable_get_id             (PhotosFilterable *self
 
 gchar              *photos_filterable_get_where          (PhotosFilterable *self);
 
+gboolean            photos_filterable_is_search_criterion  (PhotosFilterable *self);
+
 G_END_DECLS
 
 #endif /* PHOTOS_FILTERABLE_H */
diff --git a/src/photos-search-match.c b/src/photos-search-match.c
index d96a4f9d..0c4a1a6f 100644
--- a/src/photos-search-match.c
+++ b/src/photos-search-match.c
@@ -77,6 +77,13 @@ photos_search_match_get_id (PhotosFilterable *filterable)
 }
 
 
+static gboolean
+photos_search_match_is_search_criterion (PhotosFilterable *filterable)
+{
+  return TRUE;
+}
+
+
 static void
 photos_search_match_finalize (GObject *object)
 {
@@ -186,6 +193,7 @@ photos_search_match_filterable_iface_init (PhotosFilterableInterface *iface)
 {
   iface->get_filter = photos_search_match_get_filter;
   iface->get_id = photos_search_match_get_id;
+  iface->is_search_criterion = photos_search_match_is_search_criterion;
 }
 
 
diff --git a/src/photos-search-type.c b/src/photos-search-type.c
index 853d1627..5a39df00 100644
--- a/src/photos-search-type.c
+++ b/src/photos-search-type.c
@@ -77,6 +77,13 @@ photos_search_type_get_where (PhotosFilterable *iface)
 }
 
 
+static gboolean
+photos_search_type_is_search_criterion (PhotosFilterable *iface)
+{
+  return TRUE;
+}
+
+
 static void
 photos_search_type_finalize (GObject *object)
 {
@@ -198,6 +205,7 @@ photos_search_type_filterable_iface_init (PhotosFilterableInterface *iface)
   iface->get_filter = photos_search_type_get_filter;
   iface->get_id = photos_search_type_get_id;
   iface->get_where = photos_search_type_get_where;
+  iface->is_search_criterion = photos_search_type_is_search_criterion;
 }
 
 
diff --git a/src/photos-share-point-email.c b/src/photos-share-point-email.c
index 4a82448b..c47a2ab9 100644
--- a/src/photos-share-point-email.c
+++ b/src/photos-share-point-email.c
@@ -79,6 +79,13 @@ photos_share_point_email_get_name (PhotosSharePoint *share_point)
 }
 
 
+static gboolean
+photos_share_point_email_is_search_criterion (PhotosFilterable *filterable)
+{
+  return FALSE;
+}
+
+
 static gboolean
 photos_share_point_email_needs_notification (PhotosSharePoint *share_point)
 {
@@ -273,6 +280,7 @@ static void
 photos_share_point_email_filterable_iface_init (PhotosFilterableInterface *iface)
 {
   iface->get_id = photos_share_point_email_get_id;
+  iface->is_search_criterion = photos_share_point_email_is_search_criterion;
 }
 
 
diff --git a/src/photos-share-point-online.c b/src/photos-share-point-online.c
index 3c393160..3d03866b 100644
--- a/src/photos-share-point-online.c
+++ b/src/photos-share-point-online.c
@@ -83,6 +83,13 @@ photos_share_point_online_get_name (PhotosSharePoint *share_point)
 }
 
 
+static gboolean
+photos_share_point_online_is_search_criterion (PhotosFilterable *filterable)
+{
+  return FALSE;
+}
+
+
 static void
 photos_share_point_online_dispose (GObject *object)
 {
@@ -205,6 +212,7 @@ static void
 photos_share_point_online_filterable_iface_init (PhotosFilterableInterface *iface)
 {
   iface->get_id = photos_share_point_online_get_id;
+  iface->is_search_criterion = photos_share_point_online_is_search_criterion;
 }
 
 
diff --git a/src/photos-source.c b/src/photos-source.c
index 2c2584a8..a61d5f6c 100644
--- a/src/photos-source.c
+++ b/src/photos-source.c
@@ -123,6 +123,17 @@ photos_source_get_id (PhotosFilterable *filterable)
 }
 
 
+static gboolean
+photos_source_is_search_criterion (PhotosFilterable *filterable)
+{
+  PhotosSource *self = PHOTOS_SOURCE (filterable);
+  gboolean ret_val;
+
+  ret_val = self->mount == NULL;
+  return ret_val;
+}
+
+
 static void
 photos_source_dispose (GObject *object)
 {
@@ -339,6 +350,7 @@ photos_source_filterable_iface_init (PhotosFilterableInterface *iface)
   iface->get_builtin = photos_source_get_builtin;
   iface->get_filter = photos_source_get_filter;
   iface->get_id = photos_source_get_id;
+  iface->is_search_criterion = photos_source_is_search_criterion;
 }
 
 


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