mirror of https://github.com/GNOME/gimp.git
Make size loading work properly with new librsvg versions.
2007-05-02 Mukund Sivaraman <muks@mukund.org> * plug-ins/common/svg.c: Make size loading work properly with new librsvg versions. * configure.in: bumped required librsvg version to 2.14. svn path=/trunk/; revision=22382
This commit is contained in:
parent
530a64617a
commit
798f694fce
|
@ -1,3 +1,10 @@
|
|||
2007-05-02 Mukund Sivaraman <muks@mukund.org>
|
||||
|
||||
* plug-ins/common/svg.c: Make size loading work properly with
|
||||
new librsvg versions.
|
||||
|
||||
* configure.in: bumped required librsvg version to 2.14.
|
||||
|
||||
2007-05-02 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/common/poppler.c (load_dialog): set a size request on
|
||||
|
|
|
@ -48,7 +48,7 @@ m4_define([fontconfig_required_version], [2.2.0])
|
|||
m4_define([gtkdoc_required_version], [1.0])
|
||||
m4_define([gtkhtml2_required_version], [2.0.0])
|
||||
m4_define([alsa_required_version], [1.0.0])
|
||||
m4_define([rsvg_required_version], [2.8.0])
|
||||
m4_define([rsvg_required_version], [2.14.0])
|
||||
m4_define([wmf_required_version], [0.2.8])
|
||||
m4_define([pygtk_required_version], [2.10.4])
|
||||
m4_define([poppler_required_version], [0.4.1])
|
||||
|
|
|
@ -470,41 +470,6 @@ load_rsvg_pixbuf (const gchar *filename,
|
|||
|
||||
static GtkWidget *size_label = NULL;
|
||||
|
||||
/* This is the callback used from load_rsvg_size(). */
|
||||
static void
|
||||
load_get_size_callback (gint *width,
|
||||
gint *height,
|
||||
gpointer data)
|
||||
{
|
||||
SvgLoadVals *vals = data;
|
||||
|
||||
if (*width < 1 || *height < 1)
|
||||
{
|
||||
*width = SVG_DEFAULT_SIZE;
|
||||
*height = SVG_DEFAULT_SIZE;
|
||||
|
||||
if (size_label)
|
||||
gtk_label_set_text (GTK_LABEL (size_label),
|
||||
_("SVG file does not\nspecify a size!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (size_label)
|
||||
{
|
||||
gchar *text = g_strdup_printf (_("%d × %d"), *width, *height);
|
||||
|
||||
gtk_label_set_text (GTK_LABEL (size_label), text);
|
||||
g_free (text);
|
||||
}
|
||||
}
|
||||
|
||||
vals->width = *width;
|
||||
vals->height = *height;
|
||||
|
||||
/* cancel loading */
|
||||
vals->resolution = 0.0;
|
||||
}
|
||||
|
||||
/* This function retrieves the pixel size from an SVG file. Parsing
|
||||
* stops after the first chunk that provided the parser with enough
|
||||
* information to determine the size. This is usally the opening
|
||||
|
@ -519,6 +484,7 @@ load_rsvg_size (const gchar *filename,
|
|||
GIOChannel *io;
|
||||
GIOStatus status = G_IO_STATUS_NORMAL;
|
||||
gboolean success = TRUE;
|
||||
gboolean done = FALSE;
|
||||
|
||||
io = g_io_channel_new_file (filename, "r", error);
|
||||
if (!io)
|
||||
|
@ -528,12 +494,14 @@ load_rsvg_size (const gchar *filename,
|
|||
|
||||
handle = load_rsvg_handle_new (vals->resolution, vals->resolution);
|
||||
|
||||
rsvg_handle_set_size_callback (handle, load_get_size_callback, vals, NULL);
|
||||
vals->width = SVG_DEFAULT_SIZE;
|
||||
vals->height = SVG_DEFAULT_SIZE;
|
||||
|
||||
while (success && status != G_IO_STATUS_EOF && vals->resolution > 0.0)
|
||||
while (success && status != G_IO_STATUS_EOF && (! done))
|
||||
{
|
||||
gchar buf[1024];
|
||||
gsize len;
|
||||
gchar buf[1024];
|
||||
gsize len;
|
||||
RsvgDimensionData dim = { 0, 0, 0.0, 0.0 };
|
||||
|
||||
status = g_io_channel_read_chars (io, buf, sizeof (buf), &len, error);
|
||||
|
||||
|
@ -548,12 +516,37 @@ load_rsvg_size (const gchar *filename,
|
|||
case G_IO_STATUS_NORMAL:
|
||||
success = rsvg_handle_write (handle,
|
||||
(const guchar *) buf, len, error);
|
||||
rsvg_handle_get_dimensions (handle, &dim);
|
||||
|
||||
if (dim.width > 0 && dim.height > 0)
|
||||
{
|
||||
vals->width = dim.width;
|
||||
vals->height = dim.height;
|
||||
|
||||
done = TRUE;
|
||||
}
|
||||
break;
|
||||
case G_IO_STATUS_AGAIN:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (size_label)
|
||||
{
|
||||
if (done)
|
||||
{
|
||||
gchar *text = g_strdup_printf (_("%d × %d"),
|
||||
vals->width, vals->height);
|
||||
gtk_label_set_text (GTK_LABEL (size_label), text);
|
||||
g_free (text);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_label_set_text (GTK_LABEL (size_label),
|
||||
_("SVG file does not\nspecify a size!"));
|
||||
}
|
||||
}
|
||||
|
||||
g_io_channel_unref (io);
|
||||
rsvg_handle_free (handle);
|
||||
|
||||
|
|
Loading…
Reference in New Issue