[gnome-photos] base-item: Refactor opening in external application
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] base-item: Refactor opening in external application
- Date: Tue, 23 Jul 2013 12:21:09 +0000 (UTC)
commit 44518382a838dfbb748a20c4831b6927547bc7b0
Author: Debarshi Ray <debarshir gnome org>
Date: Tue Jul 23 13:26:57 2013 +0200
base-item: Refactor opening in external application
We have been using gtk_show_uri to open the URI till now. However this
doesn't work for Flickr because the URI points to a JPEG file, and not
the Flickr page for the particular photo. A virtual method with a
default implementation was added so that we can tweak the behaviour
for Flickr.
src/photos-base-item.c | 28 ++++++++++++++++++----------
src/photos-base-item.h | 1 +
2 files changed, 19 insertions(+), 10 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index d7ebcd8..a232d07 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -274,6 +274,22 @@ photos_base_item_default_set_favorite (PhotosBaseItem *self, gboolean favorite)
static void
+photos_base_item_default_open (PhotosBaseItem *self, GdkScreen *screen, guint32 timestamp)
+{
+ PhotosBaseItemPrivate *priv = self->priv;
+ GError *error;
+
+ error = NULL;
+ gtk_show_uri (screen, priv->uri, timestamp, &error);
+ if (error != NULL)
+ {
+ g_warning ("Unable to show URI %s: %s", priv->uri, error->message);
+ g_error_free (error);
+ }
+}
+
+
+static void
photos_base_item_icon_updated (PhotosBaseItem *self, GIcon *icon)
{
PhotosBaseItemPrivate *priv = self->priv;
@@ -814,6 +830,7 @@ photos_base_item_class_init (PhotosBaseItemClass *class)
object_class->finalize = photos_base_item_finalize;
object_class->get_property = photos_base_item_get_property;
object_class->set_property = photos_base_item_set_property;
+ class->open = photos_base_item_default_open;
class->set_favorite = photos_base_item_default_set_favorite;
class->update_type_description = photos_base_item_update_type_description;
@@ -1052,16 +1069,7 @@ photos_base_item_load_finish (PhotosBaseItem *self, GAsyncResult *res, GError **
void
photos_base_item_open (PhotosBaseItem *self, GdkScreen *screen, guint32 timestamp)
{
- PhotosBaseItemPrivate *priv = self->priv;
- GError *error;
-
- error = NULL;
- gtk_show_uri (screen, self->priv->uri, timestamp, &error);
- if (error != NULL)
- {
- g_warning ("Unable to show URI %s: %s", priv->uri, error->message);
- g_error_free (error);
- }
+ PHOTOS_BASE_ITEM_GET_CLASS (self)->open (self, screen, timestamp);
}
diff --git a/src/photos-base-item.h b/src/photos-base-item.h
index 60fdca6..d44c6eb 100644
--- a/src/photos-base-item.h
+++ b/src/photos-base-item.h
@@ -71,6 +71,7 @@ struct _PhotosBaseItemClass
gboolean (*create_thumbnail) (PhotosBaseItem *self, GCancellable *cancellable, GError **error);
gchar *(*download) (PhotosBaseItem *self, GCancellable *cancellable, GError **error);
const gchar *(*get_source_name) (PhotosBaseItem *self);
+ void (*open) (PhotosBaseItem *self, GdkScreen *screen, guint32 timestamp);
void (*set_favorite) (PhotosBaseItem *self, gboolean favorite);
void (*update_type_description) (PhotosBaseItem *self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]