summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2017-10-09 20:51:43 +0100
committerRichard Hughes <richard@hughsie.com>2017-10-09 20:51:43 +0100
commit65591d8b5f16dcb399f69d33b1f30f4e564aec2f (patch)
tree9c3eca35c76276c6be53c18bb8b13b3546a79597
parenta1481d201d089f9e70a0cf48a0424315e0f6cdaf (diff)
downloadappstream-glib-65591d8b5f16dcb399f69d33b1f30f4e564aec2f.tar.gz
Add as_app_get_screenshot_default()
-rw-r--r--libappstream-glib/as-app.c19
-rw-r--r--libappstream-glib/as-app.h1
-rw-r--r--libappstream-glib/as-self-test.c2
3 files changed, 21 insertions, 1 deletions
diff --git a/libappstream-glib/as-app.c b/libappstream-glib/as-app.c
index 7f19b9b..1ab64d1 100644
--- a/libappstream-glib/as-app.c
+++ b/libappstream-glib/as-app.c
@@ -1238,6 +1238,25 @@ as_app_get_screenshots (AsApp *app)
}
/**
+ * as_app_get_screenshot_default:
+ * @app: a #AsApp instance.
+ *
+ * Gets the default screenshot for the component.
+ *
+ * Returns: (transfer none): a screenshot or %NULL
+ *
+ * Since: 0.7.3
+ **/
+AsScreenshot *
+as_app_get_screenshot_default (AsApp *app)
+{
+ AsAppPrivate *priv = GET_PRIVATE (app);
+ if (priv->screenshots->len == 0)
+ return NULL;
+ return AS_SCREENSHOT (g_ptr_array_index (priv->screenshots, 0));
+}
+
+/**
* as_app_get_reviews:
* @app: a #AsApp instance.
*
diff --git a/libappstream-glib/as-app.h b/libappstream-glib/as-app.h
index 3a40dd9..779fb2f 100644
--- a/libappstream-glib/as-app.h
+++ b/libappstream-glib/as-app.h
@@ -705,6 +705,7 @@ gboolean as_app_to_file (AsApp *app,
GError **error);
AsContentRating *as_app_get_content_rating (AsApp *app,
const gchar *kind);
+AsScreenshot *as_app_get_screenshot_default (AsApp *app);
AsIcon *as_app_get_icon_default (AsApp *app);
AsIcon *as_app_get_icon_for_size (AsApp *app,
guint width,
diff --git a/libappstream-glib/as-self-test.c b/libappstream-glib/as-self-test.c
index d8b4889..f97320b 100644
--- a/libappstream-glib/as-self-test.c
+++ b/libappstream-glib/as-self-test.c
@@ -1996,7 +1996,7 @@ as_test_app_validate_appdata_good_func (void)
/* check screenshots were loaded */
screenshots = as_app_get_screenshots (app);
g_assert_cmpint (screenshots->len, ==, 1);
- ss = g_ptr_array_index (screenshots, 0);
+ ss = as_app_get_screenshot_default (app);
g_assert_cmpint (as_screenshot_get_kind (ss), ==, AS_SCREENSHOT_KIND_DEFAULT);
images = as_screenshot_get_images (ss);
g_assert_cmpint (images->len, ==, 1);