After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 447966 - Add builder support for GdkPixbuf properties
Add builder support for GdkPixbuf properties
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Class: GtkBuilder
unspecified
Other Linux
: High normal
: ---
Assigned To: GtkBuilder maintainers
GtkBuilder maintainers
Depends on:
Blocks:
 
 
Reported: 2007-06-15 18:05 UTC by Johan (not receiving bugmail) Dahlin
Modified: 2011-02-04 16:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
a patch (3.53 KB, patch)
2007-07-04 05:07 UTC, Matthias Clasen
accepted-commit_now Details | Review
untested pixbuf patch (2.70 KB, patch)
2007-07-04 19:33 UTC, Johan (not receiving bugmail) Dahlin
none Details | Review

Description Johan (not receiving bugmail) Dahlin 2007-06-15 18:05:07 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.
Comment 1 Matthias Clasen 2007-07-04 05:06:55 UTC
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.
Comment 2 Matthias Clasen 2007-07-04 05:07:37 UTC
Created attachment 91160 [details] [review]
a patch
Comment 3 Johan (not receiving bugmail) Dahlin 2007-07-04 11:38:37 UTC
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.
Comment 4 Matthias Clasen 2007-07-04 18:18:50 UTC
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.
Comment 5 Johan (not receiving bugmail) Dahlin 2007-07-04 18:30:05 UTC
(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.
Comment 6 Johan (not receiving bugmail) Dahlin 2007-07-04 19:33:15 UTC
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.
Comment 7 Johan (not receiving bugmail) Dahlin 2007-07-04 19:53:13 UTC
Richard pointed out that a missing image should probably be set if one cannot be found, which makes sense.
Comment 8 Matthias Clasen 2007-07-05 18:30:35 UTC
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.
Comment 9 Matthias Clasen 2007-07-05 18:34:04 UTC
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 ?
Comment 10 Matthias Clasen 2007-07-05 19:51:00 UTC
2007-07-05  Matthias Clasen  <mclasen@redhat.com>

        * gtk/gtkbuilder.c: Support pixbuf properties by specifying
        a filename as the property value.  (#447966)