diff options
-rw-r--r-- | libappstream-glib/as-node-private.h | 2 | ||||
-rw-r--r-- | libappstream-glib/as-node.c | 28 |
2 files changed, 30 insertions, 0 deletions
diff --git a/libappstream-glib/as-node-private.h b/libappstream-glib/as-node-private.h index e72c85b..354ad61 100644 --- a/libappstream-glib/as-node-private.h +++ b/libappstream-glib/as-node-private.h @@ -33,6 +33,8 @@ G_BEGIN_DECLS gchar *as_node_take_data (const GNode *node); gchar *as_node_take_attribute (const GNode *node, const gchar *key); +void as_node_set_name (GNode *node, + const gchar *name); void as_node_set_data (GNode *node, const gchar *cdata, gssize cdata_len, diff --git a/libappstream-glib/as-node.c b/libappstream-glib/as-node.c index df82545..23c71be 100644 --- a/libappstream-glib/as-node.c +++ b/libappstream-glib/as-node.c @@ -780,6 +780,34 @@ as_node_get_name (const GNode *node) } /** + * as_node_set_name: (skip) + * @node: a #GNode + * @name: the new name + * + * Sets the node name, e.g. "body" + * + * Since: 0.1.4 + **/ +void +as_node_set_name (GNode *node, const gchar *name) +{ + AsNodeData *data; + + g_return_if_fail (node != NULL); + + if (node->data == NULL) + return; + data = node->data; + if (data == NULL) + return; + + /* overwrite */ + g_free (data->name); + data->name = NULL; + as_node_data_set_name (data, name); +} + +/** * as_node_get_data: * @node: a #GNode * |