[gnome-photos] application: Make use of extensions to run the miners
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] application: Make use of extensions to run the miners
- Date: Wed, 10 Sep 2014 12:31:32 +0000 (UTC)
commit f118846bd56e515d561499d4e357c9fea8079441
Author: Debarshi Ray <debarshir gnome org>
Date: Tue Sep 9 19:48:29 2014 +0200
application: Make use of extensions to run the miners
Fixes: https://bugzilla.gnome.org/731865
src/photos-application.c | 93 ++++++++++++++++++++-------------------
src/photos-base-item.h | 3 +
src/photos-facebook-item.c | 3 +
src/photos-flickr-item.c | 3 +
src/photos-google-item.c | 3 +
src/photos-media-server-item.c | 3 +
6 files changed, 63 insertions(+), 45 deletions(-)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index 71922d4..015e2d6 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -57,6 +57,7 @@
struct _PhotosApplicationPrivate
{
+ GList *miners;
GList *miners_running;
GResource *resource;
GSettings *settings;
@@ -70,10 +71,6 @@ struct _PhotosApplicationPrivate
GSimpleAction *sel_none_action;
GSimpleAction *set_bg_action;
GSimpleAction *remote_display_action;
- GomMiner *facebook_miner;
- GomMiner *flickr_miner;
- GomMiner *google_miner;
- GomMiner *media_server_miner;
GtkWidget *main_window;
PhotosBaseManager *item_mngr;
PhotosCameraCache *camera_cache;
@@ -451,18 +448,17 @@ static void
photos_application_refresh_miners (PhotosApplication *self)
{
PhotosApplicationPrivate *priv = self->priv;
+ GList *l;
- if (photos_source_manager_has_provider_type (PHOTOS_SOURCE_MANAGER (priv->state->src_mngr), "facebook"))
- photos_application_refresh_miner_now (self, priv->facebook_miner);
-
- if (photos_source_manager_has_provider_type (PHOTOS_SOURCE_MANAGER (priv->state->src_mngr), "flickr"))
- photos_application_refresh_miner_now (self, priv->flickr_miner);
-
- if (photos_source_manager_has_provider_type (PHOTOS_SOURCE_MANAGER (priv->state->src_mngr), "google"))
- photos_application_refresh_miner_now (self, priv->google_miner);
+ for (l = priv->miners; l != NULL; l = l->next)
+ {
+ GomMiner *miner = GOM_MINER (l->data);
+ const gchar *provider_type;
- if (photos_source_manager_has_provider_type (PHOTOS_SOURCE_MANAGER (priv->state->src_mngr),
"media_server"))
- photos_application_refresh_miner_now (self, priv->media_server_miner);
+ provider_type = g_object_get_data (G_OBJECT (miner), "provider-type");
+ if (photos_source_manager_has_provider_type (PHOTOS_SOURCE_MANAGER (priv->state->src_mngr),
provider_type))
+ photos_application_refresh_miner_now (self, miner);
+ }
}
@@ -780,6 +776,9 @@ photos_application_startup (GApplication *application)
PhotosApplication *self = PHOTOS_APPLICATION (application);
PhotosApplicationPrivate *priv = self->priv;
GError *error;
+ GIOExtensionPoint *extension_point;
+ GList *extensions;
+ GList *l;
GSimpleAction *action;
GrlRegistry *registry;
GtkSettings *settings;
@@ -815,33 +814,35 @@ photos_application_startup (GApplication *application)
g_signal_connect (settings, "notify::gtk-theme-name", G_CALLBACK (photos_application_theme_changed), NULL);
photos_application_theme_changed (settings);
- priv->facebook_miner = gom_miner_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
- G_DBUS_PROXY_FLAGS_NONE,
- "org.gnome.OnlineMiners.Facebook",
- "/org/gnome/OnlineMiners/Facebook",
- NULL,
- NULL);
-
- priv->flickr_miner = gom_miner_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
- G_DBUS_PROXY_FLAGS_NONE,
- "org.gnome.OnlineMiners.Flickr",
- "/org/gnome/OnlineMiners/Flickr",
- NULL,
- NULL);
-
- priv->google_miner = gom_miner_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
- G_DBUS_PROXY_FLAGS_NONE,
- "org.gnome.OnlineMiners.GData",
- "/org/gnome/OnlineMiners/GData",
- NULL,
- NULL);
-
- priv->media_server_miner = gom_miner_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
- G_DBUS_PROXY_FLAGS_NONE,
- "org.gnome.OnlineMiners.MediaServer",
- "/org/gnome/OnlineMiners/MediaServer",
- NULL,
- NULL);
+ extension_point = g_io_extension_point_lookup (PHOTOS_BASE_ITEM_EXTENSION_POINT_NAME);
+ extensions = g_io_extension_point_get_extensions (extension_point);
+ for (l = extensions; l != NULL; l = l->next)
+ {
+ GIOExtension *extension = (GIOExtension *) l->data;
+ PhotosBaseItemClass *base_item_class;
+
+ base_item_class = PHOTOS_BASE_ITEM_CLASS (g_io_extension_ref_class (extension));
+ if (base_item_class->miner_name != NULL && base_item_class->miner_object_path != NULL)
+ {
+ GomMiner *miner;
+ const gchar *extension_name;
+
+ miner = gom_miner_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+ G_DBUS_PROXY_FLAGS_NONE,
+ base_item_class->miner_name,
+ base_item_class->miner_object_path,
+ NULL,
+ NULL);
+
+ extension_name = g_io_extension_get_name (extension);
+ g_object_set_data_full (G_OBJECT (miner), "provider-type", g_strdup (extension_name), g_free);
+
+ priv->miners = g_list_prepend (priv->miners, g_object_ref (miner));
+ g_object_unref (miner);
+ }
+
+ g_type_class_unref (base_item_class);
+ }
tracker_extract_priority_proxy_new_for_bus (G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_NONE,
@@ -961,6 +962,12 @@ photos_application_dispose (GObject *object)
PhotosApplication *self = PHOTOS_APPLICATION (object);
PhotosApplicationPrivate *priv = self->priv;
+ if (priv->miners != NULL)
+ {
+ g_list_free_full (priv->miners, g_object_unref);
+ priv->miners = NULL;
+ }
+
if (priv->resource != NULL)
{
g_resources_unregister (priv->resource);
@@ -978,10 +985,6 @@ photos_application_dispose (GObject *object)
g_clear_object (&priv->sel_all_action);
g_clear_object (&priv->sel_none_action);
g_clear_object (&priv->set_bg_action);
- g_clear_object (&priv->facebook_miner);
- g_clear_object (&priv->flickr_miner);
- g_clear_object (&priv->google_miner);
- g_clear_object (&priv->media_server_miner);
g_clear_object (&priv->item_mngr);
g_clear_object (&priv->camera_cache);
g_clear_object (&priv->mode_cntrlr);
diff --git a/src/photos-base-item.h b/src/photos-base-item.h
index ba6731c..652ae16 100644
--- a/src/photos-base-item.h
+++ b/src/photos-base-item.h
@@ -69,6 +69,9 @@ struct _PhotosBaseItemClass
{
GObjectClass parent_class;
+ const gchar *miner_name;
+ const gchar *miner_object_path;
+
/* virtual methods */
gboolean (*create_thumbnail) (PhotosBaseItem *self, GCancellable *cancellable, GError **error);
gchar *(*download) (PhotosBaseItem *self, GCancellable *cancellable, GError **error);
diff --git a/src/photos-facebook-item.c b/src/photos-facebook-item.c
index 6e5ab36..3a06595 100644
--- a/src/photos-facebook-item.c
+++ b/src/photos-facebook-item.c
@@ -271,6 +271,9 @@ photos_facebook_item_class_init (PhotosFacebookItemClass *class)
GObjectClass *object_class = G_OBJECT_CLASS (class);
PhotosBaseItemClass *base_item_class = PHOTOS_BASE_ITEM_CLASS (class);
+ base_item_class->miner_name = "org.gnome.OnlineMiners.Facebook";
+ base_item_class->miner_object_path = "/org/gnome/OnlineMiners/Facebook";
+
object_class->constructed = photos_facebook_item_constructed;
object_class->dispose = photos_facebook_item_dispose;
base_item_class->create_thumbnail = photos_facebook_item_create_thumbnail;
diff --git a/src/photos-flickr-item.c b/src/photos-flickr-item.c
index f53a1c6..0061938 100644
--- a/src/photos-flickr-item.c
+++ b/src/photos-flickr-item.c
@@ -373,6 +373,9 @@ photos_flickr_item_class_init (PhotosFlickrItemClass *class)
GObjectClass *object_class = G_OBJECT_CLASS (class);
PhotosBaseItemClass *base_item_class = PHOTOS_BASE_ITEM_CLASS (class);
+ base_item_class->miner_name = "org.gnome.OnlineMiners.Flickr";
+ base_item_class->miner_object_path = "/org/gnome/OnlineMiners/Flickr";
+
object_class->constructed = photos_flickr_item_constructed;
object_class->dispose = photos_flickr_item_dispose;
base_item_class->create_thumbnail = photos_flickr_item_create_thumbnail;
diff --git a/src/photos-google-item.c b/src/photos-google-item.c
index d585a7e..cc7a04f 100644
--- a/src/photos-google-item.c
+++ b/src/photos-google-item.c
@@ -302,6 +302,9 @@ photos_google_item_class_init (PhotosGoogleItemClass *class)
GObjectClass *object_class = G_OBJECT_CLASS (class);
PhotosBaseItemClass *base_item_class = PHOTOS_BASE_ITEM_CLASS (class);
+ base_item_class->miner_name = "org.gnome.OnlineMiners.GData";
+ base_item_class->miner_object_path = "/org/gnome/OnlineMiners/GData";
+
object_class->constructed = photos_google_item_constructed;
object_class->dispose = photos_google_item_dispose;
base_item_class->create_thumbnail = photos_google_item_create_thumbnail;
diff --git a/src/photos-media-server-item.c b/src/photos-media-server-item.c
index f9cd603..d6afb93 100644
--- a/src/photos-media-server-item.c
+++ b/src/photos-media-server-item.c
@@ -182,6 +182,9 @@ photos_media_server_item_class_init (PhotosMediaServerItemClass *class)
GObjectClass *object_class = G_OBJECT_CLASS (class);
PhotosBaseItemClass *base_item_class = PHOTOS_BASE_ITEM_CLASS (class);
+ base_item_class->miner_name = "org.gnome.OnlineMiners.MediaServer";
+ base_item_class->miner_object_path = "/org/gnome/OnlineMiners/MediaServer";
+
object_class->constructed = photos_media_server_item_constructed;
object_class->dispose = photos_media_server_item_dispose;
base_item_class->create_thumbnail = photos_media_server_item_create_thumbnail;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]