GNOME Bugzilla – Bug 447966
Add builder support for GdkPixbuf properties
Last modified: 2011-02-04 16:11:01 UTC
GtkBuilder is currently not supporting GdkPixbuf properties, the following needs to be done to solve this properly; * Treat the property value as a filename * Add an API to manipulate the path the filename will be looked up in It might make sense to use something similar to GtkIconTheme here.
Would it be good enough for now to accept absolute filenames as is, and interpret non-absolute filenames relative to either the location of the xml file we are parsing or the cwd if parsing a string ? That would not require api additions.
Created attachment 91160 [details] [review] a patch
Comment on attachment 91160 [details] [review] a patch >Index: gtk/gtkbuilder.c This looks good, it behaves in the same was a libglade does so it shouldn't be any migration costs. We can handle the API additions after branching for 2.14. >- if (G_IS_PARAM_SPEC_OBJECT (pspec)) >+ if (G_IS_PARAM_SPEC_OBJECT (pspec) && >+ (G_PARAM_SPEC_VALUE_TYPE (pspec) != GDK_TYPE_PIXBUF)) This confused me initially; but I realized that it is required if we want to support pixbufs in the same way libglade does, by treating the property values as filenames. One of the reasons I waited to solve this bug was to try to avoid the special casing and use a reference to a GdkPixbuf object instead. However they're not easily constructed using g_object_new if I remember correctly. It think it's at least worth a comment pointing that fact out.
Ah, you could do it that way too, but you would have to special-case it and treat filename, width, height and preserve-aspect-ratio as fake construct-only properties, and call one of the gdk_pixbuf_new functions, g_object_new does not work for this.
(In reply to comment #4) > Ah, you could do it that way too, but you would have to special-case it and > treat filename, width, height and preserve-aspect-ratio as fake construct-only > properties, and call one of the gdk_pixbuf_new functions, g_object_new does not > work for this. > That's just moving the special casing around. What I'd like to see is a way to construct GdkPixbuf only using g_object_new. Perhaps it would be possible to support by implementing gobject_class->constructor and make it return what gdk_pixbuf_new_from_file_at_size returns, similar to what I did in bug 453663.
Created attachment 91202 [details] [review] untested pixbuf patch Something like would be required for GdkPixbuf to work, it's a bit ugly but I don't think there's another way around it without refactoring all the pixbuf loaders.
Richard pointed out that a missing image should probably be set if one cannot be found, which makes sense.
so, I think we probably want to go down the <object class="GdkPixbuf"> route, even if it requires special-casing in the builder for now.
On the other hand, it might need more special-casing that we are willing to do, since we need to fake the properties as well. Would it be possible to go with the simple filename approach now, and still allow to go with separate object construction later ?
2007-07-05 Matthias Clasen <mclasen@redhat.com> * gtk/gtkbuilder.c: Support pixbuf properties by specifying a filename as the property value. (#447966)