Listing all defs in a SVG
Rodney Lorrimar <[email protected]>
| Newsgroups | gmane.comp.gnome.lib.librsvg.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I needed to know if certain layers were present in a SVG for use with
rsvg_handle_render_cairo_sub(). So I implemented
rsvg_handle_get_all_defs(), and it works for me. The patch is below.
Is this function suitable for inclusion in the API? I was thinking the
function could return the defs prepended with '#', because this is the
form expected by rsvg_handle_render_cairo_sub(), but I'm undecided.
Cheers,
Rodney
Index: librsvg.def
===================================================================
--- librsvg.def (revision 1179)
+++ librsvg.def (working copy)
@@ -33,3 +33,4 @@
_rsvg_acquire_xlink_href_resource
_rsvg_register_types
rsvg_pixbuf_from_data_with_size_data
+rsvg_handle_get_all_defs
Index: rsvg-defs.c
===================================================================
--- rsvg-defs.c (revision 1179)
+++ rsvg-defs.c (working copy)
@@ -199,3 +199,25 @@
}
}
+
+/**
+ * rsvg_handle_get_all_defs
+ * @handle: A #RsvgHandle
+ *
+ * Lists the names of all elements of the SVG.
+ *
+ * Returns: a #GList of #gchar* containing all element names in the
+ * SVG. The content of the list is owned by the SVG handle and
+ * should not be modified or freed. Use g_list_free() when done
+ * using the list.
+ *
+ * Since: 2.26
+ */
+GList *
+rsvg_handle_get_all_defs (RsvgHandle *handle)
+{
+ g_return_val_if_fail (handle != NULL, NULL);
+ g_warn_if_fail (handle->priv->is_closed);
+
+ return g_hash_table_get_keys (handle->priv->defs->hash);
+}
Index: rsvg.h
===================================================================
--- rsvg.h (revision 1179)
+++ rsvg.h (working copy)
@@ -127,6 +127,8 @@
RsvgHandle *rsvg_handle_new_from_data (const guint8 * data, gsize data_len, GError ** error);
RsvgHandle *rsvg_handle_new_from_file (const gchar * file_name, GError ** error);
+GList *rsvg_handle_get_all_defs (RsvgHandle * handle);
+
#ifndef RSVG_DISABLE_DEPRECATED
void rsvg_handle_free (RsvgHandle * handle);
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Librsvg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/librsvg-devel
signature.asc
(application/pgp-signature, 197 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEABECAAYFAkj4iJAACgkQbBchLr+YxKfougCZATikJfWSUIrRdTLIrcjV4hYm tukAoIcg+dHCGKkY1KHx2Uo0mdrMazur =mcxy -----END PGP SIGNATURE-----