[gnome-photos] Add a PhotosOrganizeCollectionModel skeleton



commit d614f1ac00eab4b03818de7b47c30e325962acf2
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Apr 27 01:16:30 2012 +0200

    Add a PhotosOrganizeCollectionModel skeleton

 src/Makefile.am                        |    2 +
 src/photos-organize-collection-model.c |  130 ++++++++++++++++++++++++++++++++
 src/photos-organize-collection-model.h |   90 ++++++++++++++++++++++
 3 files changed, 222 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index e6d18fe..65a8318 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -27,6 +27,8 @@ gnome_photos_SOURCES = \
 	photos-mode-controller.h \
 	photos-organize-collection-dialog.c \
 	photos-organize-collection-dialog.h \
+	photos-organize-collection-model.c \
+	photos-organize-collection-model.h \
 	photos-selection-controller.c \
 	photos-selection-controller.h \
 	photos-selection-toolbar.c \
diff --git a/src/photos-organize-collection-model.c b/src/photos-organize-collection-model.c
new file mode 100644
index 0000000..acbc82c
--- /dev/null
+++ b/src/photos-organize-collection-model.c
@@ -0,0 +1,130 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright  2012 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
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+
+#include "config.h"
+
+#include "photos-collection-manager.h"
+#include "photos-organize-collection-model.h"
+
+
+struct _PhotosOrganizeCollectionModelPrivate
+{
+  PhotosBaseManager *manager;
+  gulong coll_added_id;
+  gulong coll_removed_id;
+};
+
+
+G_DEFINE_TYPE (PhotosOrganizeCollectionModel, photos_organize_collection_model, GTK_TYPE_LIST_STORE);
+
+
+static void
+photos_organize_collection_model_item_added (PhotosBaseManager *manager, GObject *item, gpointer user_data)
+{
+}
+
+
+static void
+photos_organize_collection_model_item_removed (PhotosBaseManager *manager, GObject *item, gpointer user_data)
+{
+}
+
+
+static void
+photos_organize_collection_model_dispose (GObject *object)
+{
+  PhotosOrganizeCollectionModel *self = PHOTOS_ORGANIZE_COLLECTION_MODEL (object);
+  PhotosOrganizeCollectionModelPrivate *priv = self->priv;
+
+  if (priv->manager != NULL)
+    {
+      g_object_unref (priv->manager);
+      priv->manager = NULL;
+    }
+
+  G_OBJECT_CLASS (photos_organize_collection_model_parent_class)->dispose (object);
+}
+
+
+static void
+photos_organize_collection_model_init (PhotosOrganizeCollectionModel *self)
+{
+  PhotosOrganizeCollectionModelPrivate *priv;
+  GType columns[] = {G_TYPE_STRING,  /* ID */
+                     G_TYPE_STRING,  /* NAME */
+                     G_TYPE_INT};    /* STATE */
+
+  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+                                            PHOTOS_TYPE_ORGANIZE_COLLECTION_MODEL,
+                                            PhotosOrganizeCollectionModelPrivate);
+  priv = self->priv;
+
+  gtk_list_store_set_column_types (GTK_LIST_STORE (self), sizeof (columns) / sizeof (columns[0]), columns);
+
+  priv->manager = photos_collection_manager_new ();
+  priv->coll_added_id = g_signal_connect (priv->manager,
+                                          "item-added",
+                                          G_CALLBACK (photos_organize_collection_model_item_added),
+                                          self);
+  priv->coll_removed_id = g_signal_connect (priv->manager,
+                                            "item-removed",
+                                            G_CALLBACK (photos_organize_collection_model_item_removed),
+                                            self);
+
+  /* TODO: populate the model */
+}
+
+
+static void
+photos_organize_collection_model_class_init (PhotosOrganizeCollectionModelClass *class)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+  object_class->dispose = photos_organize_collection_model_dispose;
+
+  g_type_class_add_private (class, sizeof (PhotosOrganizeCollectionModelPrivate));
+}
+
+
+GtkListStore *
+photos_organize_collection_model_new (void)
+{
+  return g_object_new (PHOTOS_TYPE_ORGANIZE_COLLECTION_MODEL, NULL);
+}
+
+
+void
+photos_organize_collection_model_destroy (PhotosOrganizeCollectionModel *self)
+{
+  PhotosOrganizeCollectionModelPrivate *priv = self->priv;
+
+  if (priv->coll_added_id != 0)
+    {
+      g_signal_handler_disconnect (priv->manager, priv->coll_added_id);
+      priv->coll_added_id = 0;
+    }
+
+  if (priv->coll_removed_id != 0)
+    {
+      g_signal_handler_disconnect (priv->manager, priv->coll_removed_id);
+      priv->coll_removed_id = 0;
+    }
+}
diff --git a/src/photos-organize-collection-model.h b/src/photos-organize-collection-model.h
new file mode 100644
index 0000000..1c4de92
--- /dev/null
+++ b/src/photos-organize-collection-model.h
@@ -0,0 +1,90 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright  2012 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
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef PHOTOS_ORGANIZE_COLLECTION_MODEL_H
+#define PHOTOS_ORGANIZE_COLLECTION_MODEL_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define PHOTOS_TYPE_ORGANIZE_COLLECTION_MODEL (photos_view_embed_get_type ())
+
+#define PHOTOS_ORGANIZE_COLLECTION_MODEL(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+   PHOTOS_TYPE_ORGANIZE_COLLECTION_MODEL, PhotosOrganizeCollectionModel))
+
+#define PHOTOS_ORGANIZE_COLLECTION_MODEL_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST ((klass), \
+   PHOTOS_TYPE_ORGANIZE_COLLECTION_MODEL, PhotosOrganizeCollectionModelClass))
+
+#define PHOTOS_IS_ORGANIZE_COLLECTION_MODEL(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+   PHOTOS_TYPE_ORGANIZE_COLLECTION_MODEL))
+
+#define PHOTOS_IS_ORGANIZE_COLLECTION_MODEL_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+   PHOTOS_TYPE_ORGANIZE_COLLECTION_MODEL))
+
+#define PHOTOS_ORGANIZE_COLLECTION_MODEL_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+   PHOTOS_TYPE_ORGANIZE_COLLECTION_MODEL, PhotosOrganizeCollectionModelClass))
+
+#define PHOTOS_COLLECTION_PLACEHOLDER_ID "collection-placeholder"
+
+typedef enum
+{
+  PHOTOS_ORGANIZE_MODEL_ID,
+  PHOTOS_ORGANIZE_MODEL_NAME,
+  PHOTOS_ORGANIZE_MODEL_STATE
+} PhotosOrganizeModelColumns;
+
+typedef enum
+{
+  PHOTOS_ORGANIZE_COLLECTION_STATE_NORMAL = 0,
+  PHOTOS_ORGANIZE_COLLECTION_STATE_ACTIVE = 1 << 0,
+  PHOTOS_ORGANIZE_COLLECTION_STATE_INCONSISTENT = 1 << 1,
+  PHOTOS_ORGANIZE_COLLECTION_STATE_HIDDEN = 1 << 2,
+} PhotosOrganizeCollectionState;
+
+typedef struct _PhotosOrganizeCollectionModel        PhotosOrganizeCollectionModel;
+typedef struct _PhotosOrganizeCollectionModelClass   PhotosOrganizeCollectionModelClass;
+typedef struct _PhotosOrganizeCollectionModelPrivate PhotosOrganizeCollectionModelPrivate;
+
+struct _PhotosOrganizeCollectionModel
+{
+  GtkListStore parent_instance;
+  PhotosOrganizeCollectionModelPrivate *priv;
+};
+
+struct _PhotosOrganizeCollectionModelClass
+{
+  GtkListStoreClass parent_class;
+};
+
+GType             photos_organize_collection_model_get_type               (void) G_GNUC_CONST;
+
+GtkListStore     *photos_organize_collection_model_new                    (void);
+
+void              photos_organize_collection_model_destroy                (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]