diff options
author | Todd Zullinger <tmz@pobox.com> | 2008-07-08 20:14:33 -0400 |
---|---|---|
committer | Todd Zullinger <tmz@pobox.com> | 2008-07-18 14:07:24 -0400 |
commit | e97c4a62b1d153ba3d3b9bf1721eb4e7ed6398d5 (patch) | |
tree | eac03d1fb29d7c9163d1582f37c4528af465ddec | |
parent | f65a879b0173db372a3ab5b6d9ca8424edbcd0fa (diff) | |
download | libgpod-tmz-python-thumb-api-fix-v1.tar.gz libgpod-tmz-python-thumb-api-fix-v1.tar.xz libgpod-tmz-python-thumb-api-fix-v1.zip |
Fix build of python bindings with new thumbnail APIpython-thumb-api-fix-v1
This just fixes the build. More work needs to be done to properly
adapt the bindings to the new API and make it usable from python.
-rw-r--r-- | bindings/python/gpod.i.in | 19 | ||||
-rw-r--r-- | bindings/python/ipod.py | 17 |
2 files changed, 20 insertions, 16 deletions
diff --git a/bindings/python/gpod.i.in b/bindings/python/gpod.i.in index 4ac7e20..9960002 100644 --- a/bindings/python/gpod.i.in +++ b/bindings/python/gpod.i.in @@ -56,6 +56,7 @@ version = '.'.join(map(str, version_info)) #include "itdb.h" #include "itdb_device.h" #include "itdb_private.h" +#include "itdb_thumb.h" #include <time.h> #include <datetime.h> #ifdef HAVE_GDKPIXBUF @@ -82,7 +83,7 @@ PyObject* sw_get_photoalbums(Itdb_PhotoDB *db); PyObject* sw_get_photoalbum(GList *list, gint index); PyObject* sw_get_photos(Itdb_PhotoDB *db); PyObject* sw_get_photo(GList *list, gint index); -PyObject* sw_get_artwork_thumbnails(Itdb_Artwork *artwork); +PyObject* sw_get_artwork_thumbnails(Itdb_PhotoDB *db, Itdb_Artwork *artwork); PyObject* sw_get_photoalbum_members(Itdb_PhotoAlbum *album); PyObject* sw_ipod_device_to_dict(Itdb_Device *device); void sw__track_extra_destroy (PyObject *data); @@ -208,12 +209,15 @@ SWIGTYPE_p__Itdb_PhotoAlbum, 0)); return list; } - PyObject* sw_get_artwork_thumbnails(Itdb_Artwork *artwork) { + PyObject* sw_get_artwork_thumbnails(Itdb_PhotoDB *db, Itdb_Artwork *artwork) { PyObject *list; gint i; - GList *l; - list = PyList_New(g_list_length(artwork->thumbnails)); - for (l = artwork->thumbnails, i = 0; l; l = l->next, ++i) { + GList *l, *thumbnails; + Itdb_Thumb_Ipod *thumb; + thumb = (Itdb_Thumb_Ipod *)artwork->thumbnail; + thumbnails = itdb_thumb_ipod_to_pixbufs (db->device, thumb); + list = PyList_New(g_list_length(thumbnails)); + for (l = thumbnails, i = 0; l; l = l->next, ++i) { PyList_SET_ITEM(list, i, SWIG_NewPointerObj((void*)(l->data), SWIGTYPE_p__Itdb_Thumb, 0)); } return list; @@ -489,7 +493,8 @@ typedef int gint; #ifdef HAVE_PYGOBJECT %typemap(out) gpointer itdb_artwork_get_pixbuf { $result = pygobject_new((GObject *)$1); - g_object_unref($1); + if ($1) + g_object_unref($1); } %typemap(in) gpointer pixbuf { @@ -515,7 +520,7 @@ PyObject* sw_get_photoalbum(GList *list, gint index); PyObject* sw_get_photos(Itdb_PhotoDB *db); PyObject* sw_get_photo(GList *list, gint index); PyObject* sw_get_photoalbum_members(Itdb_PhotoAlbum *album); -PyObject* sw_get_artwork_thumbnails(Itdb_Artwork *artwork); +PyObject* sw_get_artwork_thumbnails(Itdb_PhotoDB *db, Itdb_Artwork *artwork); PyObject* sw_ipod_device_to_dict(Itdb_Device *device); %include "@top_srcdir@/src/itdb.h" diff --git a/bindings/python/ipod.py b/bindings/python/ipod.py index e5440d2..29a4a9a 100644 --- a/bindings/python/ipod.py +++ b/bindings/python/ipod.py @@ -965,16 +965,19 @@ class Photo: raise KeyError('No such key: %s' % item) def get_thumbnails(self): + db = self._database + if hasattr(self._database, '_itdb'): + db = self._database._itdb return [Thumbnail(proxied_thumbnail=t, ownerobject=self) for t in gpod.sw_get_artwork_thumbnails( - self._photo)] + db, self._photo)] thumbnails = property(get_thumbnails) class Thumbnail: """A thumbnail in an Photo.""" - _proxied_attributes = [k for k in gpod._Itdb_Thumb.__dict__.keys() + _proxied_attributes = [k for k in gpod._Itdb_Artwork.__dict__.keys() if not (k.startswith("_") or k.startswith("reserved"))] def __init__(self, proxied_thumbnail=None, ownerobject=None): @@ -1022,11 +1025,7 @@ class Thumbnail: if pixbuf_support: def get_pixbuf(self): # this deals with coverart and photo albums + device = self.__ownerobject._database.device if hasattr(self.__ownerobject._database,"_itdb"): - return gpod.itdb_artwork_get_pixbuf( - self.__ownerobject._database._itdb.device, - self._thumbnail) - else: - return gpod.itdb_artwork_get_pixbuf( - self.__ownerobject._database.device, - self._thumbnail) + device = self.__ownerobject._database._itdb.device + return gpod.itdb_artwork_get_pixbuf(device, self._thumbnail) |