[gnome-photos] base-manager: Implement process_new_objects
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] base-manager: Implement process_new_objects
- Date: Sun, 8 Dec 2013 02:32:28 +0000 (UTC)
commit e604ce657cd02c5bac183ebee0ac28f73148079c
Author: Debarshi Ray <debarshir gnome org>
Date: Sun Dec 8 02:15:59 2013 +0100
base-manager: Implement process_new_objects
src/photos-base-manager.c | 42 +++++++++++++++++++++++++++++++++++++++++-
src/photos-base-manager.h | 2 ++
src/photos-source.c | 6 +++++-
3 files changed, 48 insertions(+), 2 deletions(-)
---
diff --git a/src/photos-base-manager.c b/src/photos-base-manager.c
index 4fbceac..fd6fd49 100644
--- a/src/photos-base-manager.c
+++ b/src/photos-base-manager.c
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2012 Red Hat, Inc.
+ * Copyright © 2012, 2013 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -287,6 +287,46 @@ photos_base_manager_get_objects_count (PhotosBaseManager *self)
void
+photos_base_manager_process_new_objects (PhotosBaseManager *self, GHashTable *new_objects)
+{
+ GHashTable *old_objects;
+ GHashTableIter iter;
+ GObject *object;
+ const gchar *id;
+
+ old_objects = photos_base_manager_get_objects (self);
+
+ g_hash_table_iter_init (&iter, old_objects);
+ while (g_hash_table_iter_next (&iter, (gpointer *) &id, (gpointer *) &object))
+ {
+ gboolean builtin;
+
+ /* If old objects are not found in the newer hash table, remove
+ * them.
+ */
+ g_object_get (object, "builtin", &builtin, NULL);
+ if (g_hash_table_lookup (new_objects, id) == NULL && !builtin)
+ {
+ g_signal_emit (self, signals[OBJECT_REMOVED], 0, object);
+ g_hash_table_iter_remove (&iter);
+ }
+ }
+
+ g_hash_table_iter_init (&iter, new_objects);
+ while (g_hash_table_iter_next (&iter, (gpointer *) &id, (gpointer *) &object))
+ {
+ /* If new items are not found in the older hash table, add
+ * them.
+ */
+ if (g_hash_table_lookup (old_objects, id) == NULL)
+ photos_base_manager_add_object (self, object);
+ }
+
+ /* TODO: merge existing item properties with new values. */
+}
+
+
+void
photos_base_manager_remove_object (PhotosBaseManager *self, GObject *object)
{
gchar *id;
diff --git a/src/photos-base-manager.h b/src/photos-base-manager.h
index d833929..0f239ff 100644
--- a/src/photos-base-manager.h
+++ b/src/photos-base-manager.h
@@ -91,6 +91,8 @@ GHashTable *photos_base_manager_get_objects (PhotosBaseMana
guint photos_base_manager_get_objects_count (PhotosBaseManager *self);
+void photos_base_manager_process_new_objects (PhotosBaseManager *self, GHashTable
*new_objects);
+
void photos_base_manager_remove_object (PhotosBaseManager *self, GObject *object);
void photos_base_manager_remove_object_by_id (PhotosBaseManager *self, const gchar *id);
diff --git a/src/photos-source.c b/src/photos-source.c
index 34406d3..4d0d251 100644
--- a/src/photos-source.c
+++ b/src/photos-source.c
@@ -123,6 +123,10 @@ photos_source_get_property (GObject *object, guint prop_id, GValue *value, GPara
switch (prop_id)
{
+ case PROP_BUILTIN:
+ g_value_set_boolean (value, priv->builtin);
+ break;
+
case PROP_ID:
g_value_set_string (value, priv->id);
break;
@@ -213,7 +217,7 @@ photos_source_class_init (PhotosSourceClass *class)
"",
"",
FALSE,
- G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_ID,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]