[gnome-photos] Turn the PhotosBaseItem sub-classes into extensions
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] Turn the PhotosBaseItem sub-classes into extensions
- Date: Mon, 23 Jun 2014 13:01:49 +0000 (UTC)
commit 8674918f1cf33553f10a9caef4964ab27b1eff45
Author: Debarshi Ray <debarshir gnome org>
Date: Wed Jun 18 17:44:31 2014 +0200
Turn the PhotosBaseItem sub-classes into extensions
The idea is to reduce the amount of code that has to be sprinkled all
over the place when adding a new content source. Instead, we should be
able specify most of that in the sub-classes of PhotosBaseItem.
This is the first step in that direction.
Fixes: https://bugzilla.gnome.org/731865
src/photos-application.c | 3 +++
src/photos-facebook-item.c | 8 +++++++-
src/photos-flickr-item.c | 8 +++++++-
src/photos-local-item.c | 9 +++++++--
src/photos-utils.c | 39 +++++++++++++++++++++++++++++++++++++++
src/photos-utils.h | 6 ++++++
6 files changed, 69 insertions(+), 4 deletions(-)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index 52e3218..22674c5 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -52,6 +52,7 @@
#include "photos-single-item-job.h"
#include "photos-source-manager.h"
#include "photos-tracker-extract-priority.h"
+#include "photos-utils.h"
struct _PhotosApplicationPrivate
@@ -938,6 +939,8 @@ photos_application_init (PhotosApplication *self)
eog_debug_init ();
+ photos_utils_ensure_builtins ();
+
priv->search_provider = photos_search_provider_new ();
g_signal_connect_swapped (priv->search_provider,
"activate-result",
diff --git a/src/photos-facebook-item.c b/src/photos-facebook-item.c
index 17bbc04..9e6245c 100644
--- a/src/photos-facebook-item.c
+++ b/src/photos-facebook-item.c
@@ -47,7 +47,13 @@ struct _PhotosFacebookItemPrivate
};
-G_DEFINE_TYPE_WITH_PRIVATE (PhotosFacebookItem, photos_facebook_item, PHOTOS_TYPE_BASE_ITEM);
+G_DEFINE_TYPE_WITH_CODE (PhotosFacebookItem, photos_facebook_item, PHOTOS_TYPE_BASE_ITEM,
+ G_ADD_PRIVATE (PhotosFacebookItem)
+ photos_utils_ensure_extension_points ();
+ g_io_extension_point_implement (PHOTOS_BASE_ITEM_EXTENSION_POINT_NAME,
+ g_define_type_id,
+ "facebook",
+ 0));
static GFBGraphPhoto *
diff --git a/src/photos-flickr-item.c b/src/photos-flickr-item.c
index 019d680..51b1b76 100644
--- a/src/photos-flickr-item.c
+++ b/src/photos-flickr-item.c
@@ -47,7 +47,13 @@ struct _PhotosFlickrItemPrivate
};
-G_DEFINE_TYPE_WITH_PRIVATE (PhotosFlickrItem, photos_flickr_item, PHOTOS_TYPE_BASE_ITEM);
+G_DEFINE_TYPE_WITH_CODE (PhotosFlickrItem, photos_flickr_item, PHOTOS_TYPE_BASE_ITEM,
+ G_ADD_PRIVATE (PhotosFlickrItem)
+ photos_utils_ensure_extension_points ();
+ g_io_extension_point_implement (PHOTOS_BASE_ITEM_EXTENSION_POINT_NAME,
+ g_define_type_id,
+ "flickr",
+ 0));
typedef struct _PhotosFlickrItemSyncData PhotosFlickrItemSyncData;
diff --git a/src/photos-local-item.c b/src/photos-local-item.c
index 99604b7..8c8faba 100644
--- a/src/photos-local-item.c
+++ b/src/photos-local-item.c
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2012, 2013 Red Hat, Inc.
+ * Copyright © 2012, 2013, 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
@@ -33,7 +33,12 @@
#include "photos-utils.h"
-G_DEFINE_TYPE (PhotosLocalItem, photos_local_item, PHOTOS_TYPE_BASE_ITEM);
+G_DEFINE_TYPE_WITH_CODE (PhotosLocalItem, photos_local_item, PHOTOS_TYPE_BASE_ITEM,
+ photos_utils_ensure_extension_points ();
+ g_io_extension_point_implement (PHOTOS_BASE_ITEM_EXTENSION_POINT_NAME,
+ g_define_type_id,
+ "local",
+ 0));
static gboolean
diff --git a/src/photos-utils.c b/src/photos-utils.c
index 9c02c6d..7ece6b0 100644
--- a/src/photos-utils.c
+++ b/src/photos-utils.c
@@ -35,6 +35,10 @@
#include <libgd/gd.h>
#include "photos-application.h"
+#include "photos-base-item.h"
+#include "photos-facebook-item.h"
+#include "photos-flickr-item.h"
+#include "photos-local-item.h"
#include "photos-query.h"
#include "photos-tracker-queue.h"
#include "photos-utils.h"
@@ -364,6 +368,41 @@ photos_utils_dot_dir (void)
}
+void
+photos_utils_ensure_builtins (void)
+{
+ static gsize once_init_value = 0;
+
+ photos_utils_ensure_extension_points ();
+
+ if (g_once_init_enter (&once_init_value))
+ {
+ g_type_ensure (PHOTOS_TYPE_FACEBOOK_ITEM);
+ g_type_ensure (PHOTOS_TYPE_FLICKR_ITEM);
+ g_type_ensure (PHOTOS_TYPE_LOCAL_ITEM);
+
+ g_once_init_leave (&once_init_value, 1);
+ }
+}
+
+
+void
+photos_utils_ensure_extension_points (void)
+{
+ static gsize once_init_value = 0;
+
+ if (g_once_init_enter (&once_init_value))
+ {
+ GIOExtensionPoint *extension_point;
+
+ extension_point = g_io_extension_point_register (PHOTOS_BASE_ITEM_EXTENSION_POINT_NAME);
+ g_io_extension_point_set_required_type (extension_point, PHOTOS_TYPE_BASE_ITEM);
+
+ g_once_init_leave (&once_init_value, 1);
+ }
+}
+
+
GQuark
photos_utils_error_quark (void)
{
diff --git a/src/photos-utils.h b/src/photos-utils.h
index 97e6339..42bbee8 100644
--- a/src/photos-utils.h
+++ b/src/photos-utils.h
@@ -39,6 +39,8 @@ G_BEGIN_DECLS
#define PHOTOS_FLASH_OFF (photos_utils_flash_off_quark ())
#define PHOTOS_FLASH_ON (photos_utils_flash_on_quark ())
+#define PHOTOS_BASE_ITEM_EXTENSION_POINT_NAME "photos-base-item"
+
#define PHOTOS_COLLECTION_SCREENSHOT \
"http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#image-category-screenshot"
@@ -54,6 +56,10 @@ GIcon *photos_utils_get_icon_from_cursor (TrackerSparqlCursor *
const gchar *photos_utils_dot_dir (void);
+void photos_utils_ensure_builtins (void);
+
+void photos_utils_ensure_extension_points (void);
+
GQuark photos_utils_error_quark (void);
gchar *photos_utils_filename_strip_extension (const gchar *filename_with_extension);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]