Commit 29b0f76b authored by Dom Lachowicz's avatar Dom Lachowicz

document new APIs

parent 6241cae0
......@@ -27,31 +27,59 @@
#include "rsvg.h"
#include "rsvg-private.h"
/**
* rsvg_handle_new_from_data:
* @data: The SVG data
* @data_len: The length of #data, in bytes
* @error: return location for errors
*
* Loads the SVG specified by #data.
*
* Returns: A RsvgHandle or %NULL if an error occurs.
* Since: 2.14
*/
RsvgHandle * rsvg_handle_new_from_data (const guint8 *data,
gsize data_len,
GError **error)
{
RsvgHandle * handle = rsvg_handle_new ();
RsvgHandle * handle;
g_return_val_if_fail(data != NULL, NULL);
g_return_val_if_fail(data_len != NULL, NULL);
if(!handle) {
}
else if(!rsvg_handle_write (handle, data, data_len, error)) {
rsvg_handle_free(handle);
handle = NULL;
} else {
rsvg_handle_close(handle, error);
handle = rsvg_handle_new ();
if(handle) {
if(!rsvg_handle_write (handle, data, data_len, error)) {
rsvg_handle_free(handle);
handle = NULL;
} else {
rsvg_handle_close(handle, error);
}
}
return handle;
}
/**
* rsvg_handle_new_from_file:
* @file_name: The file name to load. If built with gnome-vfs, can be a URI.
* @error: return location for errors
*
* Loads the SVG specified by #file_name.
*
* Returns: A RsvgHandle or %NULL if an error occurs.
* Since: 2.14
*/
RsvgHandle * rsvg_handle_new_from_file (const gchar *file_name,
GError **error)
{
gchar * base_uri;
GByteArray *f;
RsvgHandle * handle;
RsvgHandle * handle = NULL;
g_return_val_if_fail(file_name != NULL, NULL);
base_uri = rsvg_get_base_uri_from_filename(file_name);
f = _rsvg_acquire_xlink_href_resource (file_name, base_uri, error);
......@@ -62,10 +90,6 @@ RsvgHandle * rsvg_handle_new_from_file (const gchar *file_name,
rsvg_handle_set_base_uri (handle, base_uri);
g_byte_array_free (f, TRUE);
}
else
{
handle = NULL;
}
g_free(base_uri);
......
......@@ -641,12 +641,6 @@ rsvg_characters (void *data, const xmlChar *ch, int len)
#warning "libxml version less than 2.6.22. XML entities won't work"
#endif
#if LIBXML_VERSION >= 20621
#define RSVG_ENABLE_ENTITIES
#elif defined(__GNUC__)
#warning "libxml version less than 2.6.22. XML entities won't work"
#endif
static xmlEntityPtr
rsvg_get_entity (void *data, const xmlChar *name)
{
......@@ -818,7 +812,7 @@ rsvg_handle_write_impl (RsvgHandle *handle,
g_propagate_error (error, real_error);
return FALSE;
}*/
return TRUE;
return TRUE;
}
static gboolean
......@@ -1004,6 +998,22 @@ rsvg_handle_new (void)
return handle;
}
/**
* rsvg_handle_new_gz:
* DEPRECATED; only here for API/ABI compatibility. Please use rsvg_handle_new() instead.
*
* Returns: A new #RsvgHandle capable of loading gzipped SVG data, or %NULL if that is not possible
*/
RsvgHandle *
rsvg_handle_new_gz (void)
{
#ifdef HAVE_SVGZ
return rsvg_handle_new ();
#else
return NULL;
#endif
}
typedef struct {
RsvgRender super;
RsvgBbox bbox;
......@@ -1129,6 +1139,13 @@ _rsvg_find_bbox (RsvgHandle *handle)
return output;
}
/**
* rsvg_handle_get_dimensions:
* @handle: A RsvgHandle
* @output: A place to store the SVG's size
*
* Get the SVG's size
*/
void
rsvg_handle_get_dimensions(RsvgHandle * handle, RsvgDimensionData * output)
{
......
......@@ -119,6 +119,17 @@ rsvg_cairo_new_drawing_ctx (cairo_t *cr, RsvgHandle *handle)
return draw;
}
/**
* rsvg_cairo_render_sub:
*
* @cr: A Cairo renderer
* @handle: A RsvgHandle
* @id: An element's id within the SVG, or %NULL to render the whole SVG
*
* Draws a subset of a SVG to a Cairo surface
*
* Since: 2.14
*/
void
rsvg_cairo_render_sub (cairo_t *cr, RsvgHandle *handle, const char * id)
{
......@@ -148,6 +159,16 @@ rsvg_cairo_render_sub (cairo_t *cr, RsvgHandle *handle, const char * id)
rsvg_drawing_ctx_free(draw);
}
/**
* rsvg_cairo_render:
*
* @cr: A Cairo renderer
* @handle: A RsvgHandle
*
* Draws a SVG to a Cairo surface
*
* Since: 2.14
*/
void
rsvg_cairo_render (cairo_t *cr, RsvgHandle *handle)
{
......
......@@ -86,7 +86,6 @@ rsvg_handle_new_from_stdio_file (FILE * f,
return handle;
}
static void
rsvg_cairo_size_callback (int *width,
int *height,
......
......@@ -49,6 +49,19 @@ rsvg_pixmap_destroy (gchar *pixels, gpointer data)
g_free (pixels);
}
/**
* rsvg_handle_get_pixbuf_sub:
* @handle: An #RsvgHandle
* @id: The id of an element inside the SVG, or %NULL to render the whole SVG
*
* Returns the pixbuf loaded by #handle. The pixbuf returned will be reffed, so
* the caller of this function must assume that ref. If insufficient data has
* been read to create the pixbuf, or an error occurred in loading, then %NULL
* will be returned. Note that the pixbuf may not be complete until
* @rsvg_handle_close has been called.
*
* Returns: the pixbuf loaded by #handle, or %NULL.
**/
GdkPixbuf *
rsvg_handle_get_pixbuf_sub (RsvgHandle *handle, const char * id)
{
......@@ -95,7 +108,6 @@ rsvg_handle_get_pixbuf_sub (RsvgHandle *handle, const char * id)
return output;
}
/**
* rsvg_handle_get_pixbuf:
* @handle: An #RsvgHandle
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment