[grilo-plugins] bookmarks: Also save thumbnail URL
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo-plugins] bookmarks: Also save thumbnail URL
- Date: Wed, 7 May 2014 16:18:20 +0000 (UTC)
commit a3898a8767b10185a6fb7076671aa319d54acd8f
Author: Bastien Nocera <hadess hadess net>
Date: Tue Mar 25 10:10:10 2014 +0100
bookmarks: Also save thumbnail URL
https://bugzilla.gnome.org/show_bug.cgi?id=673912
src/bookmarks/bookmarks-resource.c | 20 ++++++++++++++++++++
src/bookmarks/grl-bookmarks.c | 17 ++++++++++++++++-
2 files changed, 36 insertions(+), 1 deletions(-)
---
diff --git a/src/bookmarks/bookmarks-resource.c b/src/bookmarks/bookmarks-resource.c
index 8f0d554..734be13 100644
--- a/src/bookmarks/bookmarks-resource.c
+++ b/src/bookmarks/bookmarks-resource.c
@@ -34,6 +34,7 @@ struct _BookmarksResourcePrivate
char *date;
char *mime;
char *desc;
+ char *thumbnail_url;
};
enum
@@ -47,6 +48,7 @@ enum
PROP_DATE,
PROP_MIME,
PROP_DESC,
+ PROP_THUMBNAIL_URL,
LAST_PROP
};
@@ -62,6 +64,7 @@ bookmarks_resource_finalize (GObject *object)
g_free (priv->date);
g_free (priv->mime);
g_free (priv->desc);
+ g_free (priv->thumbnail_url);
G_OBJECT_CLASS(bookmarks_resource_parent_class)->finalize(object);
}
@@ -99,6 +102,9 @@ bookmarks_resource_get_property (GObject *object,
case PROP_DESC:
g_value_set_string(value, resource->priv->desc);
break;
+ case PROP_THUMBNAIL_URL:
+ g_value_set_string(value, resource->priv->thumbnail_url);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
}
@@ -142,6 +148,10 @@ bookmarks_resource_set_property (GObject *object,
g_free (resource->priv->desc);
resource->priv->desc = g_value_dup_string (value);
break;
+ case PROP_THUMBNAIL_URL:
+ g_free (resource->priv->thumbnail_url);
+ resource->priv->thumbnail_url = g_value_dup_string (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
}
@@ -237,6 +247,16 @@ bookmarks_resource_class_init (BookmarksResourceClass *klass)
G_PARAM_READWRITE);
g_object_class_install_property(object_class, PROP_DESC,
specs[PROP_DESC]);
+ specs[PROP_THUMBNAIL_URL] =
+ g_param_spec_string("thumbnail-url",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, PROP_THUMBNAIL_URL,
+ specs[PROP_THUMBNAIL_URL]);
+ gom_resource_class_set_property_new_in_version(resource_class,
+ "thumbnail-url", 2);
}
static void
diff --git a/src/bookmarks/grl-bookmarks.c b/src/bookmarks/grl-bookmarks.c
index c550a9a..27b8854 100644
--- a/src/bookmarks/grl-bookmarks.c
+++ b/src/bookmarks/grl-bookmarks.c
@@ -245,7 +245,7 @@ grl_bookmarks_source_init (GrlBookmarksSource *source)
source->priv->repository = gom_repository_new (source->priv->adapter);
object_types = g_list_prepend(NULL, GINT_TO_POINTER(BOOKMARKS_TYPE_RESOURCE));
- gom_repository_automatic_migrate_async (source->priv->repository, 1, object_types, migrate_cb, source);
+ gom_repository_automatic_migrate_async (source->priv->repository, 2, object_types, migrate_cb, source);
g_list_free(object_types);
}
@@ -302,6 +302,7 @@ build_media_from_resource (GrlMedia *content,
gchar *desc;
gchar *date;
gchar *mime;
+ gchar *thumb;
guint type;
if (content) {
@@ -316,6 +317,7 @@ build_media_from_resource (GrlMedia *content,
"date", &date,
"mime", &mime,
"type", &type,
+ "thumbnail-url", &thumb,
NULL);
if (!media) {
@@ -353,11 +355,16 @@ build_media_from_resource (GrlMedia *content,
}
}
+ if (thumb) {
+ grl_media_set_thumbnail (media, thumb);
+ }
+
g_free (title);
g_free (url);
g_free (desc);
g_free (date);
g_free (mime);
+ g_free (thumb);
return media;
}
@@ -621,6 +628,7 @@ store_bookmark (GrlBookmarksSource *bookmarks_source,
const gchar *title;
const gchar *url;
const gchar *desc;
+ const gchar *thumb;
GTimeVal now;
gint64 parent_id;
const gchar *mime;
@@ -635,6 +643,7 @@ store_bookmark (GrlBookmarksSource *bookmarks_source,
title = grl_media_get_title (bookmark);
url = grl_media_get_url (bookmark);
+ thumb = grl_media_get_thumbnail (bookmark);
desc = grl_media_get_description (bookmark);
mime = grl_media_get_mime (bookmark);
g_get_current_time (&now);
@@ -690,6 +699,11 @@ store_bookmark (GrlBookmarksSource *bookmarks_source,
*keylist = g_list_remove (*keylist,
GRLKEYID_TO_POINTER (GRL_METADATA_KEY_DESCRIPTION));
}
+ if (thumb) {
+ g_object_set (G_OBJECT (resource), "thumbnail-url", desc, NULL);
+ *keylist = g_list_remove (*keylist,
+ GRLKEYID_TO_POINTER (GRL_METADATA_KEY_THUMBNAIL));
+ }
ret = gom_resource_save_sync (resource, &local_error);
if (!ret) {
@@ -731,6 +745,7 @@ grl_bookmarks_source_supported_keys (GrlSource *source)
GRL_METADATA_KEY_URL,
GRL_METADATA_KEY_CHILDCOUNT,
GRL_METADATA_KEY_DESCRIPTION,
+ GRL_METADATA_KEY_THUMBNAIL,
GRL_BOOKMARKS_KEY_BOOKMARK_TIME,
NULL);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]