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 684515 - GTK: Cannot edit some fields at GtkStockItem
GTK: Cannot edit some fields at GtkStockItem
Status: RESOLVED DUPLICATE of bug 652697
Product: pygobject
Classification: Bindings
Component: introspection
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2012-09-21 00:37 UTC by S. Daniel Francis
Modified: 2012-09-21 09:07 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description S. Daniel Francis 2012-09-21 00:37:41 UTC
Just trying to create a StockItem from scratch I got a similar error, now I identified I can't change some fields.
Here you can see the possible bug:

Python 2.7.3 (default, Jul 24 2012, 10:05:38) 
[GCC 4.7.0 20120507 (Red Hat 4.7.0-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from gi.repository import Gtk
>>> add = Gtk.stock_lookup('gtk-add')
>>> add.keyval
0L
>>> add.keyval = 1
>>> add.keyval
1L
>>> add.label
'_Add'
>>> add.label = "other-text"
Traceback (most recent call last):
  • File "<stdin>", line 1 in <module>
RuntimeError: unable to set value for field
>>>
Comment 1 Simon Feltman 2012-09-21 07:18:13 UTC
Confirmed.

Analysis:
pygobject attempts to do the right thing but it comes down to g_field_info_set_field not working for strings, see:
http://developer.gnome.org/gi/stable/gi-GIFieldInfo.html#g-field-info-set-field

Code in: gi/pygi-info.c:_wrap_g_field_info_set_value 

The docs say any field which requires memory management needs a specific setter. This basically cannot work unless one of the following happens:
1. A new method for setting a StockItems label field is created with annotations.
2. An attempt could be made to fix this generically with gi in which fields could be annotated to specify memory management.
3. Hack it using ctypes
Comment 2 Simon Feltman 2012-09-21 09:04:24 UTC
A request was already logged in gtk+ for adding s gtk_stock_item_new function: https://bugzilla.gnome.org/show_bug.cgi?id=652697
Comment 3 Simon Feltman 2012-09-21 09:07:43 UTC
Resolving as there is not anything we can do on the pygobject side of things.

*** This bug has been marked as a duplicate of bug 652697 ***