[gnome-photos] organize-collection-model: Add the placeholder methods
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] organize-collection-model: Add the placeholder methods
- Date: Fri, 27 Apr 2012 20:18:13 +0000 (UTC)
commit 5affe97ae21397dd9d8ee1e0c47b0e20f1a82edf
Author: Debarshi Ray <debarshir gnome org>
Date: Fri Apr 27 17:31:39 2012 +0200
organize-collection-model: Add the placeholder methods
src/photos-organize-collection-model.c | 70 ++++++++++++++++++++++++++++++++
src/photos-organize-collection-model.h | 6 +++
2 files changed, 76 insertions(+), 0 deletions(-)
---
diff --git a/src/photos-organize-collection-model.c b/src/photos-organize-collection-model.c
index acbc82c..83094c9 100644
--- a/src/photos-organize-collection-model.c
+++ b/src/photos-organize-collection-model.c
@@ -27,6 +27,7 @@
struct _PhotosOrganizeCollectionModelPrivate
{
+ GtkTreeRowReference *placeholder_ref;
PhotosBaseManager *manager;
gulong coll_added_id;
gulong coll_removed_id;
@@ -65,6 +66,17 @@ photos_organize_collection_model_dispose (GObject *object)
static void
+photos_organize_collection_model_finalize (GObject *object)
+{
+ PhotosOrganizeCollectionModel *self = PHOTOS_ORGANIZE_COLLECTION_MODEL (object);
+
+ gtk_tree_row_reference_free (self->priv->placeholder_ref);
+
+ G_OBJECT_CLASS (photos_organize_collection_model_parent_class)->finalize (object);
+}
+
+
+static void
photos_organize_collection_model_init (PhotosOrganizeCollectionModel *self)
{
PhotosOrganizeCollectionModelPrivate *priv;
@@ -99,6 +111,7 @@ photos_organize_collection_model_class_init (PhotosOrganizeCollectionModelClass
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->dispose = photos_organize_collection_model_dispose;
+ object_class->finalize = photos_organize_collection_model_finalize;
g_type_class_add_private (class, sizeof (PhotosOrganizeCollectionModelPrivate));
}
@@ -111,6 +124,31 @@ photos_organize_collection_model_new (void)
}
+GtkTreePath *
+photos_organize_collection_model_add_placeholder (PhotosOrganizeCollectionModel *self)
+{
+ PhotosOrganizeCollectionModelPrivate *priv = self->priv;
+ GtkTreeIter iter;
+ GtkTreePath *placeholder_path;
+
+ photos_organize_collection_model_remove_placeholder (self);
+
+ gtk_list_store_append (GTK_LIST_STORE (self), &iter);
+ gtk_list_store_set (GTK_LIST_STORE (self),
+ &iter,
+ PHOTOS_ORGANIZE_MODEL_ID, PHOTOS_COLLECTION_PLACEHOLDER_ID,
+ PHOTOS_ORGANIZE_MODEL_NAME, "",
+ PHOTOS_ORGANIZE_MODEL_STATE, PHOTOS_ORGANIZE_COLLECTION_STATE_ACTIVE,
+ -1);
+
+ placeholder_path = gtk_tree_model_get_path (GTK_TREE_MODEL (self), &iter);
+ if (placeholder_path != NULL)
+ priv->placeholder_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (self), placeholder_path);
+
+ return placeholder_path;
+}
+
+
void
photos_organize_collection_model_destroy (PhotosOrganizeCollectionModel *self)
{
@@ -128,3 +166,35 @@ photos_organize_collection_model_destroy (PhotosOrganizeCollectionModel *self)
priv->coll_removed_id = 0;
}
}
+
+
+GtkTreePath *
+photos_organize_collection_model_forget_placeholder (PhotosOrganizeCollectionModel *self)
+{
+ PhotosOrganizeCollectionModelPrivate *priv = self->priv;
+ GtkTreePath *path;
+
+ path = gtk_tree_row_reference_get_path (priv->placeholder_ref);
+ gtk_tree_row_reference_free (priv->placeholder_ref);
+ priv->placeholder_ref = NULL;
+ return path;
+}
+
+
+void
+photos_organize_collection_model_remove_placeholder (PhotosOrganizeCollectionModel *self)
+{
+ PhotosOrganizeCollectionModelPrivate *priv = self->priv;
+ GtkTreeIter placeholder_iter;
+ GtkTreePath *placeholder_path;
+
+ if (priv->placeholder_ref == NULL)
+ return;
+
+ placeholder_path = gtk_tree_row_reference_get_path (priv->placeholder_ref);
+ if (gtk_tree_model_get_iter (GTK_TREE_MODEL (self), &placeholder_iter, placeholder_path))
+ gtk_list_store_remove (GTK_LIST_STORE (self), &placeholder_iter);
+
+ gtk_tree_row_reference_free (priv->placeholder_ref);
+ priv->placeholder_ref = NULL;
+}
diff --git a/src/photos-organize-collection-model.h b/src/photos-organize-collection-model.h
index 1c4de92..90abbd1 100644
--- a/src/photos-organize-collection-model.h
+++ b/src/photos-organize-collection-model.h
@@ -83,8 +83,14 @@ GType photos_organize_collection_model_get_type (void)
GtkListStore *photos_organize_collection_model_new (void);
+GtkTreePath *photos_organize_collection_model_add_placeholder (PhotosOrganizeCollectionModel *self);
+
void photos_organize_collection_model_destroy (PhotosOrganizeCollectionModel *self);
+GtkTreePath *photos_organize_collection_model_forget_placeholder (PhotosOrganizeCollectionModel *self);
+
+void photos_organize_collection_model_remove_placeholder (PhotosOrganizeCollectionModel *self);
+
G_END_DECLS
#endif /* PHOTOS_ORGANIZE_COLLECTION_MODEL_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]