[gtk+] cssimage: Store the URI we're loaded from
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] cssimage: Store the URI we're loaded from
- Date: Sat, 2 Feb 2013 00:47:05 +0000 (UTC)
commit 6348ded15d44a7781b6eab7bbc6dfe972b9f87f5
Author: Benjamin Otte <otte redhat com>
Date: Wed Jan 2 15:27:00 2013 +0100
cssimage: Store the URI we're loaded from
I'd like to use it when printing the value, but I haven't found a way to
do that sanely yet, as I'd need to be able to print relative paths for
make check to work (otherwise the srcdir would blow things up). And we
use a GString to output to, so there's no way to attach a base dir to
that.
If anyone has an idea how to achieve that, poke me. Having the real
filename in debug prints sounds like a very good idea to me.
https://bugzilla.gnome.org/show_bug.cgi?id=692934
gtk/gtkcssimageurl.c | 14 +++++++-------
gtk/gtkcssimageurlprivate.h | 1 +
2 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtkcssimageurl.c b/gtk/gtkcssimageurl.c
index 92126d3..2c6dc89 100644
--- a/gtk/gtkcssimageurl.c
+++ b/gtk/gtkcssimageurl.c
@@ -66,21 +66,20 @@ gtk_css_image_url_parse (GtkCssImage *image,
{
GtkCssImageUrl *url = GTK_CSS_IMAGE_URL (image);
GdkPixbuf *pixbuf;
- GFile *file;
cairo_t *cr;
GError *error = NULL;
GFileInputStream *input;
- file = _gtk_css_parser_read_url (parser);
- if (file == NULL)
+ url->file = _gtk_css_parser_read_url (parser);
+ if (url->file == NULL)
return FALSE;
/* We special case resources here so we can use
gdk_pixbuf_new_from_resource, which in turn has some special casing
for GdkPixdata files to avoid duplicating the memory for the pixbufs */
- if (g_file_has_uri_scheme (file, "resource"))
+ if (g_file_has_uri_scheme (url->file, "resource"))
{
- char *uri = g_file_get_uri (file);
+ char *uri = g_file_get_uri (url->file);
char *resource_path = g_uri_unescape_string (uri + strlen ("resource://"), NULL);
pixbuf = gdk_pixbuf_new_from_resource (resource_path, &error);
@@ -89,7 +88,7 @@ gtk_css_image_url_parse (GtkCssImage *image,
}
else
{
- input = g_file_read (file, NULL, &error);
+ input = g_file_read (url->file, NULL, &error);
if (input == NULL)
{
_gtk_css_parser_take_error (parser, error);
@@ -99,7 +98,6 @@ gtk_css_image_url_parse (GtkCssImage *image,
pixbuf = gdk_pixbuf_new_from_stream (G_INPUT_STREAM (input), NULL, &error);
g_object_unref (input);
}
- g_object_unref (file);
if (pixbuf == NULL)
{
@@ -158,6 +156,8 @@ gtk_css_image_url_dispose (GObject *object)
{
GtkCssImageUrl *url = GTK_CSS_IMAGE_URL (object);
+ g_clear_object (&url->file);
+
if (url->surface)
{
cairo_surface_destroy (url->surface);
diff --git a/gtk/gtkcssimageurlprivate.h b/gtk/gtkcssimageurlprivate.h
index c9e4f7d..e2df7f1 100644
--- a/gtk/gtkcssimageurlprivate.h
+++ b/gtk/gtkcssimageurlprivate.h
@@ -38,6 +38,7 @@ struct _GtkCssImageUrl
{
GtkCssImage parent;
+ GFile *file; /* the file we're loading from */
cairo_surface_t *surface; /* the surface we render - guaranteed to be an image surface */
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]