[gnome-photos/wip/uajain/de_dup: 46/58] Add PhotosSharePointOnline



commit 6a2c823d5e53d02728c8e7a90647159f40c6d534
Author: Debarshi Ray <debarshir gnome org>
Date:   Wed Jul 27 18:32:14 2016 +0200

    Add PhotosSharePointOnline
    
    https://bugzilla.gnome.org/show_bug.cgi?id=751181

 src/Makefile.am                 |    2 +
 src/photos-share-point-online.c |  219 +++++++++++++++++++++++++++++++++++++++
 src/photos-share-point-online.h |   50 +++++++++
 3 files changed, 271 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 201a308..297a5ce 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -204,6 +204,8 @@ gnome_photos_SOURCES = \
        photos-settings.h \
        photos-share-point.c \
        photos-share-point.h \
+       photos-share-point-online.c \
+       photos-share-point-online.h \
        photos-single-item-job.c \
        photos-single-item-job.h \
        photos-source.c \
diff --git a/src/photos-share-point-online.c b/src/photos-share-point-online.c
new file mode 100644
index 0000000..ac6105d
--- /dev/null
+++ b/src/photos-share-point-online.c
@@ -0,0 +1,219 @@
+/*
+ * 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 "photos-filterable.h"
+#include "photos-share-point-online.h"
+
+
+struct _PhotosSharePointOnlinePrivate
+{
+  GIcon *icon;
+  PhotosSource *source;
+  gchar *id;
+  gchar *name;
+};
+
+enum
+{
+  PROP_0,
+  PROP_SOURCE,
+};
+
+static void photos_filterable_interface_init (PhotosFilterableInterface *iface);
+
+
+G_DEFINE_ABSTRACT_TYPE_WITH_CODE (PhotosSharePointOnline, photos_share_point_online, PHOTOS_TYPE_SHARE_POINT,
+                                  G_ADD_PRIVATE (PhotosSharePointOnline)
+                                  G_IMPLEMENT_INTERFACE (PHOTOS_TYPE_FILTERABLE, 
photos_filterable_interface_init));
+
+
+static GIcon *
+photos_share_point_online_get_icon (PhotosSharePoint *share_point)
+{
+  PhotosSharePointOnline *self = PHOTOS_SHARE_POINT_ONLINE (share_point);
+  PhotosSharePointOnlinePrivate *priv;
+
+  priv = photos_share_point_online_get_instance_private (self);
+  return priv->icon;
+}
+
+
+static const gchar *
+photos_share_point_online_get_id (PhotosFilterable *filterable)
+{
+  PhotosSharePointOnline *self = PHOTOS_SHARE_POINT_ONLINE (filterable);
+  PhotosSharePointOnlinePrivate *priv;
+
+  priv = photos_share_point_online_get_instance_private (self);
+  return priv->id;
+}
+
+
+static const gchar *
+photos_share_point_online_get_name (PhotosSharePoint *share_point)
+{
+  PhotosSharePointOnline *self = PHOTOS_SHARE_POINT_ONLINE (share_point);
+  PhotosSharePointOnlinePrivate *priv;
+
+  priv = photos_share_point_online_get_instance_private (self);
+  return priv->name;
+}
+
+
+static void
+photos_share_point_online_dispose (GObject *object)
+{
+  PhotosSharePointOnline *self = PHOTOS_SHARE_POINT_ONLINE (object);
+  PhotosSharePointOnlinePrivate *priv;
+
+  priv = photos_share_point_online_get_instance_private (self);
+
+  g_clear_object (&priv->icon);
+  g_clear_object (&priv->source);
+
+  G_OBJECT_CLASS (photos_share_point_online_parent_class)->dispose (object);
+}
+
+
+static void
+photos_share_point_online_finalize (GObject *object)
+{
+  PhotosSharePointOnline *self = PHOTOS_SHARE_POINT_ONLINE (object);
+  PhotosSharePointOnlinePrivate *priv;
+
+  priv = photos_share_point_online_get_instance_private (self);
+
+  g_free (priv->id);
+  g_free (priv->name);
+
+  G_OBJECT_CLASS (photos_share_point_online_parent_class)->finalize (object);
+}
+
+
+static void
+photos_share_point_online_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+{
+  PhotosSharePointOnline *self = PHOTOS_SHARE_POINT_ONLINE (object);
+  PhotosSharePointOnlinePrivate *priv;
+
+  priv = photos_share_point_online_get_instance_private (self);
+
+  switch (prop_id)
+    {
+    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_online_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec 
*pspec)
+{
+  PhotosSharePointOnline *self = PHOTOS_SHARE_POINT_ONLINE (object);
+  PhotosSharePointOnlinePrivate *priv;
+
+  priv = photos_share_point_online_get_instance_private (self);
+
+  switch (prop_id)
+    {
+    case PROP_SOURCE:
+      {
+        GIcon *icon;
+        const gchar *id;
+        const gchar *name;
+
+        priv->source = PHOTOS_SOURCE (g_value_dup_object (value));
+        if (priv->source == NULL)
+          break;
+
+        id = photos_filterable_get_id (PHOTOS_FILTERABLE (priv->source));
+        priv->id = g_strdup (id);
+
+        icon = photos_source_get_icon (priv->source);
+        priv->icon = g_object_ref (icon);
+
+        name = photos_source_get_name (priv->source);
+        priv->name = g_strdup (name);
+        break;
+      }
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+
+static void
+photos_share_point_online_init (PhotosSharePointOnline *self)
+{
+}
+
+
+static void
+photos_share_point_online_class_init (PhotosSharePointOnlineClass *class)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (class);
+  PhotosSharePointClass *share_point_class = PHOTOS_SHARE_POINT_CLASS (class);
+
+  object_class->dispose = photos_share_point_online_dispose;
+  object_class->finalize = photos_share_point_online_finalize;
+  object_class->get_property = photos_share_point_online_get_property;
+  object_class->set_property = photos_share_point_online_set_property;
+  share_point_class->get_icon = photos_share_point_online_get_icon;
+  share_point_class->get_name = photos_share_point_online_get_name;
+
+  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_online_get_id;
+}
+
+
+PhotosSource *
+photos_share_point_online_get_source (PhotosSharePointOnline *self)
+{
+  PhotosSharePointOnlinePrivate *priv;
+
+  priv = photos_share_point_online_get_instance_private (self);
+  return priv->source;
+}
diff --git a/src/photos-share-point-online.h b/src/photos-share-point-online.h
new file mode 100644
index 0000000..f197e69
--- /dev/null
+++ b/src/photos-share-point-online.h
@@ -0,0 +1,50 @@
+/*
+ * 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_ONLINE_H
+#define PHOTOS_SHARE_POINT_ONLINE_H
+
+#include "photos-share-point.h"
+#include "photos-source.h"
+
+G_BEGIN_DECLS
+
+#define PHOTOS_TYPE_SHARE_POINT_ONLINE (photos_share_point_online_get_type ())
+G_DECLARE_DERIVABLE_TYPE (PhotosSharePointOnline,
+                          photos_share_point_online,
+                          PHOTOS, SHARE_POINT_ONLINE,
+                          PhotosSharePoint)
+
+typedef struct _PhotosSharePointOnlinePrivate PhotosSharePointOnlinePrivate;
+
+struct _PhotosSharePointOnlineClass
+{
+  PhotosSharePointClass parent_class;
+};
+
+PhotosSource           *photos_share_point_online_get_source             (PhotosSharePointOnline *self);
+
+G_END_DECLS
+
+#endif /* PHOTOS_SHARE_POINT_ONLINE_H */


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