[gnome-photos] Add PhotosItemManager



commit 4aeeeec4c977543ca5798a4609131dd4b3c3fc2a
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu May 3 14:53:38 2012 +0200

    Add PhotosItemManager

 src/Makefile.am           |    2 +
 src/photos-item-manager.c |  148 +++++++++++++++++++++++++++++++++++++++++++++
 src/photos-item-manager.h |   86 ++++++++++++++++++++++++++
 3 files changed, 236 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 6dfd730..4e2a3b3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -33,6 +33,8 @@ gnome_photos_SOURCES = \
 	photos-base-item.h \
 	photos-collection-manager.c \
 	photos-collection-manager.h \
+	photos-item-manager.c \
+	photos-item-manager.h \
 	photos-item-model.c \
 	photos-item-model.h \
 	photos-view-embed.c \
diff --git a/src/photos-item-manager.c b/src/photos-item-manager.c
new file mode 100644
index 0000000..9b68b36
--- /dev/null
+++ b/src/photos-item-manager.c
@@ -0,0 +1,148 @@
+/*
+ * 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 <glib.h>
+
+#include "photos-item-manager.h"
+#include "photos-item-model.h"
+
+
+struct _PhotosItemManagerPrivate
+{
+  GtkListStore *model;
+};
+
+
+G_DEFINE_TYPE (PhotosItemManager, photos_item_manager, PHOTOS_TYPE_BASE_MANAGER);
+
+
+static GObject *
+photos_item_manager_constructor (GType                  type,
+                                 guint                  n_construct_params,
+                                 GObjectConstructParam *construct_params)
+{
+  static GObject *self = NULL;
+
+  if (self == NULL)
+    {
+      self = G_OBJECT_CLASS (photos_item_manager_parent_class)->constructor (type,
+                                                                             n_construct_params,
+                                                                             construct_params);
+      g_object_add_weak_pointer (self, (gpointer) &self);
+      return self;
+    }
+
+  return g_object_ref (self);
+}
+
+
+static void
+photos_item_manager_dispose (GObject *object)
+{
+  PhotosItemManager *self = PHOTOS_ITEM_MANAGER (object);
+
+  g_clear_object (&self->priv->model);
+
+  G_OBJECT_CLASS (photos_item_manager_parent_class)->dispose (object);
+}
+
+
+static void
+photos_item_manager_init (PhotosItemManager *self)
+{
+  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, PHOTOS_TYPE_ITEM_MANAGER, PhotosItemManagerPrivate);
+  self->priv->model = photos_item_model_new ();
+}
+
+
+static void
+photos_item_manager_class_init (PhotosItemManagerClass *class)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+  object_class->constructor = photos_item_manager_constructor;
+  object_class->dispose = photos_item_manager_dispose;
+
+  g_type_class_add_private (class, sizeof (PhotosItemManagerPrivate));
+}
+
+
+PhotosBaseManager *
+photos_item_manager_new (void)
+{
+  return g_object_new (PHOTOS_TYPE_ITEM_MANAGER, NULL);
+}
+
+
+PhotosBaseItem *
+photos_item_manager_add_item (PhotosItemManager *self, TrackerSparqlCursor *cursor)
+{
+  PhotosBaseItem *item;
+
+  item = photos_item_manager_create_item (self, cursor);
+  photos_base_manager_add_object (PHOTOS_BASE_MANAGER (self), G_OBJECT (item));
+  photos_item_model_item_added (PHOTOS_ITEM_MODEL (self->priv->model), item);
+
+  /* TODO: add to collection_manager */
+}
+
+
+void
+photos_item_manager_clear (PhotosItemManager *self)
+{
+  photos_base_manager_clear (PHOTOS_BASE_MANAGER (self));
+  gtk_list_store_clear (self->priv->model);
+}
+
+
+PhotosBaseItem *
+photos_item_manager_create_item (PhotosItemManager *self, TrackerSparqlCursor *cursor)
+{
+  /* TODO: create local or other items */
+  return NULL;
+}
+
+
+GtkListStore *
+photos_item_manager_get_model (PhotosItemManager *self)
+{
+  return self->priv->model;
+}
+
+
+void
+photos_item_manager_set_active_item (PhotosItemManager *self, PhotosBaseItem *item)
+{
+  if (!photos_base_manager_set_active_object (PHOTOS_BASE_MANAGER (self), G_OBJECT (item)))
+    return;
+
+  if (item != NULL)
+    {
+      GtkRecentManager *recent;
+      const gchar *uri;
+
+      recent = gtk_recent_manager_get_default ();
+      uri = photos_base_item_get_uri (item);
+      gtk_recent_manager_add_item (recent, uri);
+    }
+}
diff --git a/src/photos-item-manager.h b/src/photos-item-manager.h
new file mode 100644
index 0000000..065e031
--- /dev/null
+++ b/src/photos-item-manager.h
@@ -0,0 +1,86 @@
+/*
+ * 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_ITEM_MANAGER_H
+#define PHOTOS_ITEM_MANAGER_H
+
+#include <gtk/gtk.h>
+#include <tracker-sparql.h>
+
+#include "photos-base-item.h"
+#include "photos-base-manager.h"
+
+G_BEGIN_DECLS
+
+#define PHOTOS_TYPE_ITEM_MANAGER (photos_base_manager_get_type ())
+
+#define PHOTOS_ITEM_MANAGER(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+   PHOTOS_TYPE_ITEM_MANAGER, PhotosItemManager))
+
+#define PHOTOS_ITEM_MANAGER_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST ((klass), \
+   PHOTOS_TYPE_ITEM_MANAGER, PhotosItemManagerClass))
+
+#define PHOTOS_IS_ITEM_MANAGER(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+   PHOTOS_TYPE_ITEM_MANAGER))
+
+#define PHOTOS_IS_ITEM_MANAGER_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+   PHOTOS_TYPE_ITEM_MANAGER))
+
+#define PHOTOS_ITEM_MANAGER_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+   PHOTOS_TYPE_ITEM_MANAGER, PhotosItemManagerClass))
+
+typedef struct _PhotosItemManager        PhotosItemManager;
+typedef struct _PhotosItemManagerClass   PhotosItemManagerClass;
+typedef struct _PhotosItemManagerPrivate PhotosItemManagerPrivate;
+
+struct _PhotosItemManager
+{
+  PhotosBaseManager parent_instance;
+  PhotosItemManagerPrivate *priv;
+};
+
+struct _PhotosItemManagerClass
+{
+  PhotosBaseManagerClass parent_class;
+};
+
+GType                     photos_item_manager_get_type           (void) G_GNUC_CONST;
+
+PhotosBaseManager        *photos_item_manager_new                (void);
+
+PhotosBaseItem           *photos_item_manager_add_item           (PhotosItemManager *self,
+                                                                  TrackerSparqlCursor *cursor);
+
+PhotosBaseItem           *photos_item_manager_create_item        (PhotosItemManager *self,
+                                                                  TrackerSparqlCursor *cursor);
+
+GtkListStore             *photos_item_manager_get_model          (PhotosItemManager *self);
+
+void                      photos_item_manager_set_active_item    (PhotosItemManager *self,
+                                                                  PhotosBaseItem *item);
+
+G_END_DECLS
+
+#endif /* PHOTOS_ITEM_MANAGER_H */



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