[gnome-photos/wip/rishi/manager-model: 3/8] base-manager: Add photos_base_manager_get_{next, previous}_object
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/manager-model: 3/8] base-manager: Add photos_base_manager_get_{next, previous}_object
- Date: Tue, 6 Dec 2016 11:28:22 +0000 (UTC)
commit a9eba16052b9d6fa5005b7c012ad01d84604f421
Author: Debarshi Ray <debarshir gnome org>
Date: Tue Dec 6 10:28:43 2016 +0100
base-manager: Add photos_base_manager_get_{next, previous}_object
src/photos-base-manager.c | 74 +++++++++++++++++++++++++++++++++++++++++++++
src/photos-base-manager.h | 6 ++++
2 files changed, 80 insertions(+), 0 deletions(-)
---
diff --git a/src/photos-base-manager.c b/src/photos-base-manager.c
index e482cef..19db262 100644
--- a/src/photos-base-manager.c
+++ b/src/photos-base-manager.c
@@ -174,6 +174,32 @@ photos_base_manager_default_get_filter (PhotosBaseManager *self, gint flags)
static GObject *
+photos_base_manager_default_get_next_object (PhotosBaseManager *self, GObject *object)
+{
+ PhotosBaseManagerPrivate *priv;
+ GObject *ret_val = NULL;
+ GSequenceIter *iter;
+ PhotosBaseManagerObjectData *object_data;
+ const gchar *id;
+
+ priv = photos_base_manager_get_instance_private (self);
+
+ id = photos_filterable_get_id (PHOTOS_FILTERABLE (object));
+ object_data = g_hash_table_lookup (priv->objects, id);
+ g_return_val_if_fail (object_data != NULL, NULL);
+
+ iter = g_sequence_iter_next (object_data->iter);
+ if (g_sequence_iter_is_end (iter))
+ goto out;
+
+ ret_val = G_OBJECT (g_sequence_get (iter));
+
+ out:
+ return ret_val;
+}
+
+
+static GObject *
photos_base_manager_default_get_object_by_id (PhotosBaseManager *self, const gchar *id)
{
PhotosBaseManagerPrivate *priv;
@@ -193,6 +219,32 @@ photos_base_manager_default_get_object_by_id (PhotosBaseManager *self, const gch
}
+static GObject *
+photos_base_manager_default_get_previous_object (PhotosBaseManager *self, GObject *object)
+{
+ PhotosBaseManagerPrivate *priv;
+ GObject *ret_val = NULL;
+ GSequenceIter *iter;
+ PhotosBaseManagerObjectData *object_data;
+ const gchar *id;
+
+ priv = photos_base_manager_get_instance_private (self);
+
+ id = photos_filterable_get_id (PHOTOS_FILTERABLE (object));
+ object_data = g_hash_table_lookup (priv->objects, id);
+ g_return_val_if_fail (object_data != NULL, NULL);
+
+ iter = g_sequence_iter_prev (object_data->iter);
+ if (g_sequence_iter_compare (iter, object_data->iter) == 0)
+ goto out;
+
+ ret_val = G_OBJECT (g_sequence_get (iter));
+
+ out:
+ return ret_val;
+}
+
+
static gchar *
photos_base_manager_default_get_where (PhotosBaseManager *self, gint flags)
{
@@ -391,7 +443,9 @@ photos_base_manager_class_init (PhotosBaseManagerClass *class)
class->add_object = photos_base_manager_default_add_object;
class->get_active_object = photos_base_manager_default_get_active_object;
class->get_filter = photos_base_manager_default_get_filter;
+ class->get_next_object = photos_base_manager_default_get_next_object;
class->get_object_by_id = photos_base_manager_default_get_object_by_id;
+ class->get_previous_object = photos_base_manager_default_get_previous_object;
class->get_where = photos_base_manager_default_get_where;
class->remove_object_by_id = photos_base_manager_default_remove_object_by_id;
class->set_active_object = photos_base_manager_default_set_active_object;
@@ -607,6 +661,16 @@ photos_base_manager_get_filter (PhotosBaseManager *self, gint flags)
GObject *
+photos_base_manager_get_next_object (PhotosBaseManager *self, GObject *object)
+{
+ g_return_val_if_fail (PHOTOS_IS_BASE_MANAGER (self), NULL);
+ g_return_val_if_fail (PHOTOS_IS_FILTERABLE (object), NULL);
+
+ return PHOTOS_BASE_MANAGER_GET_CLASS (self)->get_next_object (self, object);
+}
+
+
+GObject *
photos_base_manager_get_object_by_id (PhotosBaseManager *self, const gchar *id)
{
g_return_val_if_fail (PHOTOS_IS_BASE_MANAGER (self), NULL);
@@ -630,6 +694,16 @@ photos_base_manager_get_objects_count (PhotosBaseManager *self)
}
+GObject *
+photos_base_manager_get_previous_object (PhotosBaseManager *self, GObject *object)
+{
+ g_return_val_if_fail (PHOTOS_IS_BASE_MANAGER (self), NULL);
+ g_return_val_if_fail (PHOTOS_IS_FILTERABLE (object), NULL);
+
+ return PHOTOS_BASE_MANAGER_GET_CLASS (self)->get_previous_object (self, object);
+}
+
+
const gchar *
photos_base_manager_get_title (PhotosBaseManager *self)
{
diff --git a/src/photos-base-manager.h b/src/photos-base-manager.h
index 3d90472..c442f68 100644
--- a/src/photos-base-manager.h
+++ b/src/photos-base-manager.h
@@ -42,7 +42,9 @@ struct _PhotosBaseManagerClass
void (*add_object) (PhotosBaseManager *self, GObject *object);
GObject *(*get_active_object) (PhotosBaseManager *self);
gchar *(*get_filter) (PhotosBaseManager *self, gint flags);
+ GObject *(*get_next_object) (PhotosBaseManager *self, GObject *object);
GObject *(*get_object_by_id) (PhotosBaseManager *self, const gchar *id);
+ GObject *(*get_previous_object) (PhotosBaseManager *self, GObject *object);
gchar *(*get_where) (PhotosBaseManager *self, gint flags);
void (*remove_object_by_id) (PhotosBaseManager *self, const gchar *id);
gboolean (*set_active_object) (PhotosBaseManager *self, GObject *object);
@@ -68,10 +70,14 @@ gchar *photos_base_manager_get_all_filter (PhotosBaseMana
gchar *photos_base_manager_get_filter (PhotosBaseManager *self, gint flags);
+GObject *photos_base_manager_get_next_object (PhotosBaseManager *self, GObject *object);
+
GObject *photos_base_manager_get_object_by_id (PhotosBaseManager *self, const gchar *id);
guint photos_base_manager_get_objects_count (PhotosBaseManager *self);
+GObject *photos_base_manager_get_previous_object (PhotosBaseManager *self, GObject *object);
+
const gchar *photos_base_manager_get_title (PhotosBaseManager *self);
gchar *photos_base_manager_get_where (PhotosBaseManager *self, gint flags);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]