[gnome-photos/wip/rishi/share-point: 2/3] Add PhotosSharePoint



commit d1dc54ee8e452cdbfbed323f3e611f450e8b44b3
Author: Debarshi Ray <debarshir gnome org>
Date:   Wed Jun 29 13:30:53 2016 +0200

    Add PhotosSharePoint

 src/Makefile.am          |    2 +
 src/photos-share-point.c |  209 ++++++++++++++++++++++++++++++++++++++++++++++
 src/photos-share-point.h |   67 +++++++++++++++
 3 files changed, 278 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 0cb21e6..195fdb7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -200,6 +200,8 @@ gnome_photos_SOURCES = \
        photos-set-collection-job.h \
        photos-settings.c \
        photos-settings.h \
+       photos-share-point.c \
+       photos-share-point.h \
        photos-single-item-job.c \
        photos-single-item-job.h \
        photos-source.c \
diff --git a/src/photos-share-point.c b/src/photos-share-point.c
new file mode 100644
index 0000000..e519f46
--- /dev/null
+++ b/src/photos-share-point.c
@@ -0,0 +1,209 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2016 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 <gio/gio.h>
+
+#include "photos-filterable.h"
+#include "photos-share-point.h"
+
+
+struct _PhotosSharePointPrivate
+{
+  PhotosSource *source;
+  gboolean builtin;
+  gchar *id;
+};
+
+enum
+{
+  PROP_0,
+  PROP_BUILTIN,
+  PROP_ID,
+  PROP_NAME,
+};
+
+static void photos_filterable_interface_init (PhotosFilterableInterface *iface);
+
+
+G_DEFINE_ABSTRACT_TYPE_WITH_CODE (PhotosSharePoint, photos_share_point, G_TYPE_OBJECT,
+                                  G_ADD_PRIVATE (PhotosSharePoint)
+                                  G_IMPLEMENT_INTERFACE (PHOTOS_TYPE_FILTERABLE,
+                                                         photos_filterable_interface_init));
+
+
+static const gchar *
+photos_share_point_get_id (PhotosFilterable *filterable)
+{
+  PhotosSharePoint *self = PHOTOS_SHARE_POINT (filterable);
+  PhotosSharePoint *priv;
+
+  priv = photos_share_point_get_instance_private (self);
+  return priv->id;
+}
+
+
+static void
+photos_share_point_dispose (GObject *object)
+{
+  PhotosSharePoint *self = PHOTOS_SHARE_POINT (object);
+  PhotosSharePoint *priv;
+
+  priv = photos_share_point_get_instance_private (self);
+
+  G_OBJECT_CLASS (photos_share_point_parent_class)->dispose (object);
+}
+
+
+static void
+photos_share_point_finalize (GObject *object)
+{
+  PhotosSharePoint *self = PHOTOS_SHARE_POINT (object);
+  PhotosSharePoint *priv;
+
+  priv = photos_share_point_get_instance_private (self);
+
+  g_free (priv->id);
+
+  G_OBJECT_CLASS (photos_share_point_parent_class)->finalize (object);
+}
+
+
+static void
+photos_share_point_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+{
+  PhotosSharePoint *self = PHOTOS_SHARE_POINT (object);
+  PhotosSharePoint *priv;
+
+  priv = photos_share_point_get_instance_private (self);
+
+  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;
+
+    case PROP_SOURCE:
+      g_value_set_object (value, priv->source);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+
+static void
+photos_share_point_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+{
+  PhotosSharePoint *self = PHOTOS_SHARE_POINT (object);
+  PhotosSharePoint *priv;
+
+  priv = photos_share_point_get_instance_private (self);
+
+  switch (prop_id)
+    {
+    case PROP_BUILTIN:
+      priv->builtin = g_value_get_boolean (value);
+      break;
+
+    case PROP_ID:
+      priv->id = g_value_dup_string (value);
+      break;
+
+    case PROP_SOURCE:
+      priv->source = PHOTOS_SOURCE (g_value_dup_object (value));
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+
+static void
+photos_share_point_init (PhotosSharePoint *self)
+{
+}
+
+
+static void
+photos_share_point_class_init (PhotosSharePointClass *class)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+  object_class->dispose = photos_share_point_dispose;
+  object_class->finalize = photos_share_point_finalize;
+  object_class->get_property = photos_share_point_get_property;
+  object_class->set_property = photos_share_point_set_property;
+
+  g_object_class_install_property (object_class,
+                                   PROP_BUILTIN,
+                                   g_param_spec_boolean ("builtin",
+                                                         "",
+                                                         "",
+                                                         FALSE,
+                                                         G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
+
+  g_object_class_install_property (object_class,
+                                   PROP_ID,
+                                   g_param_spec_string ("id",
+                                                        "",
+                                                        "",
+                                                        NULL,
+                                                        G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
+
+  g_object_class_install_property (object_class,
+                                   PROP_SOURCE,
+                                   g_param_spec_object ("source",
+                                                        "PhotosSource instance",
+                                                        "The online source corresponding to this share 
point",
+                                                        PHOTOS_TYPE_SOURCE,
+                                                        G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
+}
+
+
+static void
+photos_filterable_interface_init (PhotosFilterableInterface *iface)
+{
+  iface->get_id = photos_share_point_get_id;
+}
+
+
+PhotosSource *
+photos_share_point_get_source (PhotosSharePoint *self)
+{
+  PhotosSharePoint *priv;
+
+  priv = photos_share_point_get_instance_private (self);
+  return priv->source;
+}
diff --git a/src/photos-share-point.h b/src/photos-share-point.h
new file mode 100644
index 0000000..75f8e70
--- /dev/null
+++ b/src/photos-share-point.h
@@ -0,0 +1,67 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2016 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_SHARE_POINT_H
+#define PHOTOS_SHARE_POINT_H
+
+#include <glib-object.h>
+#include <goa/goa.h>
+
+#include "photos-source.h"
+
+G_BEGIN_DECLS
+
+#define PHOTOS_TYPE_SOURCE (photos_share_point_get_type ())
+
+#define PHOTOS_SHARE_POINT(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+   PHOTOS_TYPE_SOURCE, PhotosSharePoint))
+
+#define PHOTOS_IS_SOURCE(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+   PHOTOS_TYPE_SOURCE))
+
+typedef struct _PhotosSharePoint        PhotosSharePoint;
+typedef struct _PhotosSharePointClass   PhotosSharePointClass;
+typedef struct _PhotosSharePointPrivate PhotosSharePointPrivate;
+
+struct _PhotosSharePoint
+{
+  GObject parent_instance;
+};
+
+struct _PhotosSharePointClass
+{
+  GObjectClass parent_class;
+
+  /* virtual methods */
+};
+
+GType                   photos_share_point_get_type               (void) G_GNUC_CONST;
+
+PhotosSource           *photos_share_point_get_source             (PhotosSharePoint *self);
+
+G_END_DECLS
+
+#endif /* PHOTOS_SHARE_POINT_H */


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