[gnome-software/gnome-3-22] Get the screenshot metadata from the GNOME Shell Extension JSON data
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/gnome-3-22] Get the screenshot metadata from the GNOME Shell Extension JSON data
- Date: Tue, 15 Nov 2016 13:21:05 +0000 (UTC)
commit 7ed57e69ec126d61537495b1163c1fa7aa00fc95
Author: Richard Hughes <richard hughsie com>
Date: Mon Nov 14 21:47:19 2016 +0000
Get the screenshot metadata from the GNOME Shell Extension JSON data
Thanks Jasper!!
src/plugins/gs-plugin-shell-extensions.c | 34 ++++++++++++-----------------
1 files changed, 14 insertions(+), 20 deletions(-)
---
diff --git a/src/plugins/gs-plugin-shell-extensions.c b/src/plugins/gs-plugin-shell-extensions.c
index 1b4125a..84fa6b8 100644
--- a/src/plugins/gs-plugin-shell-extensions.c
+++ b/src/plugins/gs-plugin-shell-extensions.c
@@ -31,7 +31,6 @@
/*
* Things we want from the API:
*
- * - Screenshots
* - Size on disk/download
* - Existing review data for each extension?
* - A local icon for an installed shell extension
@@ -446,6 +445,20 @@ gs_plugin_shell_extensions_parse_app (GsPlugin *plugin,
return NULL;
as_app_set_description (app, NULL, desc);
}
+ tmp = json_object_get_string_member (json_app, "screenshot");
+ if (tmp != NULL) {
+ g_autoptr(AsScreenshot) ss = NULL;
+ g_autoptr(AsImage) im = NULL;
+ g_autofree gchar *uri = NULL;
+ uri = g_build_path ("/", SHELL_EXTENSIONS_API_URI, tmp, NULL);
+ im = as_image_new ();
+ as_image_set_kind (im, AS_IMAGE_KIND_SOURCE);
+ as_image_set_url (im, uri);
+ ss = as_screenshot_new ();
+ as_screenshot_set_kind (ss, AS_SCREENSHOT_KIND_DEFAULT);
+ as_screenshot_add_image (ss, im);
+ as_app_add_screenshot (app, ss);
+ }
tmp = json_object_get_string_member (json_app, "name");
if (tmp != NULL)
as_app_set_name (app, NULL, tmp);
@@ -483,25 +496,6 @@ gs_plugin_shell_extensions_parse_app (GsPlugin *plugin,
return NULL;
}
- /* add a screenshot, which curiously isn't in the json */
- pk = json_object_get_int_member (json_app, "pk");
- if (1) {
- g_autoptr(AsScreenshot) ss = NULL;
- g_autoptr(AsImage) im = NULL;
- g_autofree gchar *uri = NULL;
- uri = g_strdup_printf ("%s/static/extension-data/"
- "screenshots/"
- "screenshot_%" G_GINT64_FORMAT ".png",
- SHELL_EXTENSIONS_API_URI, pk);
- im = as_image_new ();
- as_image_set_kind (im, AS_IMAGE_KIND_SOURCE);
- as_image_set_url (im, uri);
- ss = as_screenshot_new ();
- as_screenshot_set_kind (ss, AS_SCREENSHOT_KIND_DEFAULT);
- as_screenshot_add_image (ss, im);
- as_app_add_screenshot (app, ss);
- }
-
/* required to match categories in gnome-software */
as_app_add_category (app, "Addons");
as_app_add_category (app, "ShellExtensions");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]