[gnome-photos] Add PhotosCreateCollectionIconJob



commit 798376e1bbd56bf512c2ba907b4081908f3ba9dc
Author: Debarshi Ray <debarshir gnome org>
Date:   Mon Feb 17 10:35:06 2014 +0100

    Add PhotosCreateCollectionIconJob

 src/Makefile.am                         |    2 +
 src/photos-create-collection-icon-job.c |  166 +++++++++++++++++++++++++++++++
 src/photos-create-collection-icon-job.h |   81 +++++++++++++++
 3 files changed, 249 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index c04376b..c778cc3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -78,6 +78,8 @@ gnome_photos_SOURCES = \
        photos-collection-icon-watcher.h \
        photos-collection-manager.c \
        photos-collection-manager.h \
+       photos-create-collection-icon-job.c \
+       photos-create-collection-icon-job.h \
        photos-create-collection-job.c \
        photos-create-collection-job.h \
        photos-delete-item-job.c \
diff --git a/src/photos-create-collection-icon-job.c b/src/photos-create-collection-icon-job.c
new file mode 100644
index 0000000..1dfe492
--- /dev/null
+++ b/src/photos-create-collection-icon-job.c
@@ -0,0 +1,166 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2014 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.
+ */
+
+/* Based on code from:
+ *   + Documents
+ */
+
+
+#include "config.h"
+
+#include "photos-query.h"
+#include "photos-query-builder.h"
+#include "photos-create-collection-icon-job.h"
+#include "photos-tracker-queue.h"
+
+
+struct _PhotosCreateCollectionIconJobPrivate
+{
+  GIcon *icon;
+  PhotosCreateCollectionIconJobCallback callback;
+  PhotosTrackerQueue *queue;
+  gchar *urn;
+  gpointer user_data;
+};
+
+enum
+{
+  PROP_0,
+  PROP_URN
+};
+
+
+G_DEFINE_TYPE_WITH_PRIVATE (PhotosCreateCollectionIconJob, photos_create_collection_icon_job, G_TYPE_OBJECT);
+
+
+static void
+photos_create_collection_icon_job_emit_callback (PhotosCreateCollectionIconJob *self)
+{
+  PhotosCreateCollectionIconJobPrivate *priv = self->priv;
+
+  if (priv->callback == NULL)
+    return;
+
+  (*priv->callback) (priv->icon, priv->user_data);
+}
+
+
+static void
+photos_create_collection_icon_job_dispose (GObject *object)
+{
+  PhotosCreateCollectionIconJob *self = PHOTOS_CREATE_COLLECTION_ICON_JOB (object);
+  PhotosCreateCollectionIconJobPrivate *priv = self->priv;
+
+  g_clear_object (&priv->icon);
+  g_clear_object (&priv->queue);
+
+  G_OBJECT_CLASS (photos_create_collection_icon_job_parent_class)->dispose (object);
+}
+
+
+static void
+photos_create_collection_icon_job_finalize (GObject *object)
+{
+  PhotosCreateCollectionIconJob *self = PHOTOS_CREATE_COLLECTION_ICON_JOB (object);
+
+  g_free (self->priv->urn);
+
+  G_OBJECT_CLASS (photos_create_collection_icon_job_parent_class)->finalize (object);
+}
+
+
+static void
+photos_create_collection_icon_job_set_property (GObject *object,
+                                                guint prop_id,
+                                                const GValue *value,
+                                                GParamSpec *pspec)
+{
+  PhotosCreateCollectionIconJob *self = PHOTOS_CREATE_COLLECTION_ICON_JOB (object);
+
+  switch (prop_id)
+    {
+    case PROP_URN:
+      self->priv->urn = g_value_dup_string (value);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+
+static void
+photos_create_collection_icon_job_init (PhotosCreateCollectionIconJob *self)
+{
+  PhotosCreateCollectionIconJobPrivate *priv = self->priv;
+
+  self->priv = photos_create_collection_icon_job_get_instance_private (self);
+  priv = self->priv;
+
+  priv->queue = photos_tracker_queue_dup_singleton (NULL, NULL);
+}
+
+
+static void
+photos_create_collection_icon_job_class_init (PhotosCreateCollectionIconJobClass *class)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+  object_class->dispose = photos_create_collection_icon_job_dispose;
+  object_class->finalize = photos_create_collection_icon_job_finalize;
+  object_class->set_property = photos_create_collection_icon_job_set_property;
+
+  g_object_class_install_property (object_class,
+                                   PROP_URN,
+                                   g_param_spec_string ("urn",
+                                                        "Uniform Resource Name",
+                                                        "An unique ID associated with this item",
+                                                        NULL,
+                                                        G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
+}
+
+
+PhotosCreateCollectionIconJob *
+photos_create_collection_icon_job_new (const gchar *urn)
+{
+  return g_object_new (PHOTOS_TYPE_CREATE_COLLECTION_ICON_JOB, "urn", urn, NULL);
+}
+
+
+void
+photos_create_collection_icon_job_run (PhotosCreateCollectionIconJob *self,
+                                       PhotosCreateCollectionIconJobCallback callback,
+                                       gpointer user_data)
+{
+  PhotosCreateCollectionIconJobPrivate *priv = self->priv;
+
+  if (G_UNLIKELY (priv->queue == NULL))
+    {
+      photos_create_collection_icon_job_emit_callback (self);
+      return;
+    }
+
+  priv->callback = callback;
+  priv->user_data = user_data;
+
+  /* TODO: build collection icon query */
+  photos_create_collection_icon_job_emit_callback (self);
+}
diff --git a/src/photos-create-collection-icon-job.h b/src/photos-create-collection-icon-job.h
new file mode 100644
index 0000000..ff4495c
--- /dev/null
+++ b/src/photos-create-collection-icon-job.h
@@ -0,0 +1,81 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2014 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.
+ */
+
+/* Based on code from:
+ *   + Documents
+ */
+
+#ifndef PHOTOS_CREATE_COLLECTION_ICON_JOB_H
+#define PHOTOS_CREATE_COLLECTION_ICON_JOB_H
+
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+#define PHOTOS_TYPE_CREATE_COLLECTION_ICON_JOB (photos_create_collection_icon_job_get_type ())
+
+#define PHOTOS_CREATE_COLLECTION_ICON_JOB(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+   PHOTOS_TYPE_CREATE_COLLECTION_ICON_JOB, PhotosCreateCollectionIconJob))
+
+#define PHOTOS_CREATE_COLLECTION_ICON_JOB_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST ((klass), \
+   PHOTOS_TYPE_CREATE_COLLECTION_ICON_JOB, PhotosCreateCollectionIconJobClass))
+
+#define PHOTOS_IS_CREATE_COLLECTION_ICON_JOB(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+   PHOTOS_TYPE_CREATE_COLLECTION_ICON_JOB))
+
+#define PHOTOS_IS_CREATE_COLLECTION_ICON_JOB_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+   PHOTOS_TYPE_CREATE_COLLECTION_ICON_JOB))
+
+#define PHOTOS_CREATE_COLLECTION_ICON_JOB_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+   PHOTOS_TYPE_CREATE_COLLECTION_ICON_JOB, PhotosCreateCollectionIconJobClass))
+
+typedef void (*PhotosCreateCollectionIconJobCallback) (GIcon *, gpointer);
+
+typedef struct _PhotosCreateCollectionIconJob        PhotosCreateCollectionIconJob;
+typedef struct _PhotosCreateCollectionIconJobClass   PhotosCreateCollectionIconJobClass;
+typedef struct _PhotosCreateCollectionIconJobPrivate PhotosCreateCollectionIconJobPrivate;
+
+struct _PhotosCreateCollectionIconJob
+{
+  GObject parent_instance;
+  PhotosCreateCollectionIconJobPrivate *priv;
+};
+
+struct _PhotosCreateCollectionIconJobClass
+{
+  GObjectClass parent_class;
+};
+
+GType                          photos_create_collection_icon_job_get_type  (void) G_GNUC_CONST;
+
+PhotosCreateCollectionIconJob *photos_create_collection_icon_job_new       (const gchar *urn);
+
+void                           photos_create_collection_icon_job_run (PhotosCreateCollectionIconJob *self,
+                                                                      PhotosCreateCollectionIconJobCallback 
callback,
+                                                                      gpointer user_data);
+
+G_END_DECLS
+
+#endif /* PHOTOS_CREATE_COLLECTION_ICON_JOB_H */


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