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 517676 - g_themed_icon_new*() do more than call g_object_new().
g_themed_icon_new*() do more than call g_object_new().
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
2.15.x
Other Linux
: Normal normal
: ---
Assigned To: Alexander Larsson
gtkdev
Depends on:
Blocks:
 
 
Reported: 2008-02-20 15:01 UTC by Murray Cumming
Modified: 2008-03-10 16:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
attempt at a patch (8.22 KB, patch)
2008-03-04 00:45 UTC, Samuel Cormier-Iijima
needs-work Details | Review
new patch with docs, property notification and the len parameter added back (8.43 KB, patch)
2008-03-07 18:25 UTC, Samuel Cormier-Iijima
none Details | Review
patch from the right directory (8.45 KB, patch)
2008-03-07 18:28 UTC, Samuel Cormier-Iijima
committed Details | Review

Description Murray Cumming 2008-02-20 15:01:53 UTC
g_themed_icon_new() and g_themed_icon_new_with_fallbacks() do quite a bit more than just call g_object_new():
http://svn.gnome.org/viewvc/glib/trunk/gio/gthemedicon.c?revision=6336&view=markup

Generally, *_new() functions are meant to be just C convenience methods. Language bindings generally just call g_object_new() with the appropriate properties, so they can actually instantiate derived GTypes (allowing them to override default signal handlers and vfuncs).

If it's too difficult to do this via properties then additional g_themed_icon_construct(GThemedIcon* self, ) and g_themed_icon_construct_with_fallbacks(GThemedIcon* self, ) functions would be helpful. These would be called by g_themed_icon_new() and g_themed_icon_new_with_fallbacks().
Comment 1 Matthias Clasen 2008-02-20 16:43:52 UTC
I don't have any objections if someone wants to write a patch for a "names" property. _with_fallbacks() will still have to do some extra work...
Comment 2 Samuel Cormier-Iijima 2008-03-04 00:45:43 UTC
Created attachment 106523 [details] [review]
attempt at a patch

Added three properties "names", "name", and "use-default-fallbacks", which are all construction only, and the last two can only written. I changed g_themed_icon_new_from_names() to only take one parameter (dropped len), requiring the array to be NULL-terminated instead, and updated the only user. However, not sure if this could break anything else...
Comment 3 Matthias Clasen 2008-03-04 06:47:37 UTC
> I changed g_themed_icon_new_from_names() to only take one parameter

Too late for that now, since we are very close to 2.16. What you can do is make the function accept -1 to mean NULL-terminated.


If you make use-default-fallbacks an independent property, the code should do the right thing for the combination of names+use-default-fallbacks, too. The current implementation silently assumes that there is only one name if use-default-fallbacks is true.

The new properties need doc comments and translated nicks and blurbs.
Comment 4 Matthias Clasen 2008-03-04 06:52:22 UTC
Also, g_themed_icon_append_name kinda indicates that names is not construct-only 
- g_themed_icon_append_name needs to emit property change notification at least.

But maybe that function is just a bad idea...it also has interesting implications for the use of g_icon_hash
Comment 5 Alexander Larsson 2008-03-05 15:42:59 UTC
Yeah. I'm not sure g_themed_icon_append_name() was a great idea either. It makes more sense for GIcons to be read only after construction. But it does make some operations easier.
Comment 6 Samuel Cormier-Iijima 2008-03-07 18:25:24 UTC
Created attachment 106800 [details] [review]
new patch with docs, property notification and the len parameter added back

> > I changed g_themed_icon_new_from_names() to only take one parameter
> 
> Too late for that now, since we are very close to 2.16. What you can do is make
> the function accept -1 to mean NULL-terminated.

Changed it back.

> If you make use-default-fallbacks an independent property, the code should do
> the right thing for the combination of names+use-default-fallbacks, too. The
> current implementation silently assumes that there is only one name if
> use-default-fallbacks is true.

I thought that this would be better, unless you want it to check every item in the names list, create the fallbacks and then remove duplicates. I thought that this might be overkill. I added a note in the blurb and comments...
Comment 7 Samuel Cormier-Iijima 2008-03-07 18:28:30 UTC
Created attachment 106801 [details] [review]
patch from the right directory

Sorry, ignore that last one.
Comment 8 Matthias Clasen 2008-03-10 16:08:51 UTC
2008-03-10  Matthias Clasen <mclasen@redhat.com>

        * gthemedicon.c: Add properties to make bindings happy.  (#517676,
        Samuel Cormier-Iijima)