summaryrefslogtreecommitdiff
path: root/libappstream-glib/as-image.c
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2014-03-21 20:28:50 +0000
committerRichard Hughes <richard@hughsie.com>2014-08-20 10:01:26 +0100
commitc63ae20cbbfe7e241fca2775f4df05da85335d13 (patch)
treee8f3a00955a29eb6ad285b2d6bf93bdb06c73601 /libappstream-glib/as-image.c
parent451a7489300e19221bb5bed6da182839e2e3ad69 (diff)
downloadappstream-glib-c63ae20cbbfe7e241fca2775f4df05da85335d13.tar.gz
Use libyaml to read DEP-11 metadata
This is optional, but enabled by default. Use --disable-dep11 to remove the libyaml dependancy.
Diffstat (limited to 'libappstream-glib/as-image.c')
-rw-r--r--libappstream-glib/as-image.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/libappstream-glib/as-image.c b/libappstream-glib/as-image.c
index 0c49e19..195e0d3 100644
--- a/libappstream-glib/as-image.c
+++ b/libappstream-glib/as-image.c
@@ -38,6 +38,7 @@
#include "as-image-private.h"
#include "as-node-private.h"
#include "as-utils-private.h"
+#include "as-yaml.h"
typedef struct _AsImagePrivate AsImagePrivate;
struct _AsImagePrivate
@@ -442,6 +443,36 @@ as_image_node_parse (AsImage *image, GNode *node, GError **error)
}
/**
+ * as_image_node_parse_dep11:
+ * @image: a #AsImage instance.
+ * @node: a #GNode.
+ * @error: A #GError or %NULL.
+ *
+ * Populates the object from a DEP-11 node.
+ *
+ * Returns: %TRUE for success
+ *
+ * Since: 0.3.0
+ **/
+gboolean
+as_image_node_parse_dep11 (AsImage *im, GNode *node, GError **error)
+{
+ GNode *n;
+ const gchar *tmp;
+
+ for (n = node->children; n != NULL; n = n->next) {
+ tmp = as_yaml_node_get_key (n);
+ if (g_strcmp0 (tmp, "height") == 0)
+ as_image_set_height (im, as_yaml_node_get_value_as_int (n));
+ else if (g_strcmp0 (tmp, "width") == 0)
+ as_image_set_width (im, as_yaml_node_get_value_as_int (n));
+ else if (g_strcmp0 (tmp, "url") == 0)
+ as_image_set_url (im, as_yaml_node_get_value (n), -1);
+ }
+ return TRUE;
+}
+
+/**
* as_image_load_filename:
* @image: a #AsImage instance.
* @filename: filename to read from