Questions about tailoring libdmapsharing API to benefit GObject introspection
- From: "W. Michael Petullo" <mike flyn org>
- To: gir-devel-list gnome org
- Subject: Questions about tailoring libdmapsharing API to benefit GObject introspection
- Date: Sat, 11 Nov 2017 17:30:44 -0500
I am the maintainer of libdmapsharing, a GObject-based library. I am
just now getting around to adjusting the library's API to better suit
GObject introspection. I am not sure how to process on two things having
to do with object properties.
One of my interfaces, the DAAPRecord, has among its properties two
items: hash, a GLib2 ByteArray/g_param_spec_pointer and mediakind, a
g_param_spec_enum. I am trying to implement an object of this interface in
Python, but I am not sure how to proceed with either of these properties.
(As I mentioned, I am willing to modify the libdmapsharing interface to
facilitate this if necessary.)
I am not sure how to best handle hash. Should I create a box type? It
seems like the should be a straightforward approach to handle a ByteArray.
For mediakind, I get a warning if I try this:
class PyDAAPRecord((GObject.GObject, DAAP.Record, DMAP.Record):
# ...
mediakind = GObject.property(type=GObject.TYPE_INT, default=0)
So, I tried to use DMAP.MediaKind like this:
mediakind = GObject.property(type=DMAP.MediaKind, default=0)
However, this causes:
File "./test-dmap-client-python", line 31, in <module>
class PyDAAPRecord(GObject.GObject, DAAP.Record, DMAP.Record):
File "./test-dmap-client-python", line 51, in PyDAAPRecord
mediakind = GObject.property(type=DMAP.MediaKind , default=0)
File "/usr/lib64/python3.6/site-packages/gi/_propertyhelper.py", line 164, in __init__
self._check_default()
File "/usr/lib64/python3.6/site-packages/gi/_propertyhelper.py", line 315, in _check_default
elif not _gobject.type_is_a(default, ptype):
TypeError: could not get typecode from object
I generate dmap_media_kind_get_type using glib-mkenums, and the function
ends up containing:
GType
dmap_media_kind_get_type (void)
{
static GType etype = 0;
if (etype == 0) {
static const GEnumValue values[] = {
{ DMAP_MEDIA_KIND_MUSIC, "DMAP_MEDIA_KIND_MUSIC", "music" },
{ DMAP_MEDIA_KIND_MOVIE, "DMAP_MEDIA_KIND_MOVIE", "movie" },
{ DMAP_MEDIA_KIND_PODCAST, "DMAP_MEDIA_KIND_PODCAST", "podcast" },
{ DMAP_MEDIA_KIND_TV_SHOW, "DMAP_MEDIA_KIND_TV_SHOW", "tv-show" },
{ 0, NULL, NULL }
};
etype = g_enum_register_static ("DMAPMediaKind", values);
}
return etype;
}
My .gir file contains:
<enumeration name="MediaKind"
glib:type-name="DMAPMediaKind"
glib:get-type="dmap_media_kind_get_type"
c:type="DMAPMediaKind">
<member name="music"
value="1"
c:identifier="DMAP_MEDIA_KIND_MUSIC"
glib:nick="music">
</member>
<member name="movie"
value="2"
c:identifier="DMAP_MEDIA_KIND_MOVIE"
glib:nick="movie">
</member>
<member name="podcast"
value="32"
c:identifier="DMAP_MEDIA_KIND_PODCAST"
glib:nick="podcast">
</member>
<member name="tv_show"
value="64"
c:identifier="DMAP_MEDIA_KIND_TV_SHOW"
glib:nick="tv-show">
</member>
</enumeration>
Any suggestions on either of these?
--
Mike
:wq
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]