I am writing a plugin for Rhythmbox, wherein a signal raised is passing in an object of type GArray
. The documentation for GLib Arrays shows me a few methods I am interested in, but am unable to access.
For example, g_array_index can get me the nth item in a GArray, but I am unable to call it. The GArray object doesn't show me any useful methods either.
To see what I mean, do this in a Python console:
from gi.repository.GLib import Array
x = Array()
dir(x)
Here is the output of dir(x)
['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__gtype__', '__hash__', '__info__', '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_free_on_dealloc', 'copy', 'data', 'len']
I see no methods in there read from the array, and nothing about the g_array_index
or any other methods mentioned on the GLib Arrays documentation page. I also tried
for a in x:
print a
And also
list(x)
But I receive an error:
TypeError: 'Array' object is not iterable
Attempting x[0] gives this:
TypeError: 'Array' object does not support indexing
The len
property gives the length of the array as is expected.
The data
property gives this
How can I work with this GLib.Array that I am being passed?
I am running Python 2.7.4