Revision: 2108
          http://gtkpod.svn.sourceforge.net/gtkpod/?rev=2108&view=rev
Author:   tmzullinger
Date:     2008-08-20 17:37:32 +0000 (Wed, 20 Aug 2008)

Log Message:
-----------
Update python bindings to work with the new thumbnail API.

This removes sw_get_artwork_thumbnails() and the Thumbnail class from
the python bindings.  The get_pixbuf() function is now in the Photo
class.

Modified Paths:
--------------
    libgpod/trunk/ChangeLog
    libgpod/trunk/bindings/python/examples/save_photos.py
    libgpod/trunk/bindings/python/gpod.i.in
    libgpod/trunk/bindings/python/ipod.py
    libgpod/trunk/bindings/python/tests/tests.py

Modified: libgpod/trunk/ChangeLog
===================================================================
--- libgpod/trunk/ChangeLog     2008-08-20 17:32:10 UTC (rev 2107)
+++ libgpod/trunk/ChangeLog     2008-08-20 17:37:32 UTC (rev 2108)
@@ -1,3 +1,15 @@
+2008-08-09  Todd Zullinger  <tmzullinger at users.sourceforge.net>
+
+       * bindings/python/examples/save_photos.py
+         bindings/python/gpod.i.in
+         bindings/python/ipod.py
+         bindings/python/tests/tests.py:
+         Update python bindings to work with the new thumbnail API.
+
+         This removes sw_get_artwork_thumbnails() and the Thumbnail
+         class from the python bindings.  The get_pixbuf() function
+         is now in the Photo class.
+
 2008-08-09  Paul Richardson  <phantom_sf at users.sourceforge.net>
 
        * Added eclipse project related files to svn:ignore

Modified: libgpod/trunk/bindings/python/examples/save_photos.py
===================================================================
--- libgpod/trunk/bindings/python/examples/save_photos.py       2008-08-20 
17:32:10 UTC (rev 2107)
+++ libgpod/trunk/bindings/python/examples/save_photos.py       2008-08-20 
17:37:32 UTC (rev 2108)
@@ -24,7 +24,7 @@
 
 import gpod
 
-if not hasattr(gpod.Thumbnail, 'get_pixbuf'):
+if not hasattr(gpod.Photo, 'get_pixbuf'):
     print 'Sorry, gpod was built without pixbuf support.'
     raise SystemExit
 
@@ -35,9 +35,7 @@
     print " ", album
     for photo in album:
         print "  ", photo
-        for thumbnail, n in zip(photo.thumbnails,
-                                range(0,len(photo.thumbnails))):
-            print "   ", thumbnail
-            thumbnail.get_pixbuf().save("/tmp/%d-%d.png" % 
(photo['id'],n),"png")
+        for w,h,s in ((0,0,'small'), (-1,-1,'large')):
+            photo.get_pixbuf(w,h).save("/tmp/%d-%s.png" % 
(photo['id'],s),"png")
 
 photodb.close()

Modified: libgpod/trunk/bindings/python/gpod.i.in
===================================================================
--- libgpod/trunk/bindings/python/gpod.i.in     2008-08-20 17:32:10 UTC (rev 
2107)
+++ libgpod/trunk/bindings/python/gpod.i.in     2008-08-20 17:37:32 UTC (rev 
2108)
@@ -82,7 +82,6 @@
 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_photoalbum_members(Itdb_PhotoAlbum *album);
 PyObject* sw_ipod_device_to_dict(Itdb_Device *device);
 void sw__track_extra_destroy (PyObject *data);
@@ -208,18 +207,6 @@
   return list;
  }
 
- PyObject* sw_get_artwork_thumbnails(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) {
-    PyList_SET_ITEM(list, i, SWIG_NewPointerObj((void*)(l->data), 
SWIGTYPE_p__Itdb_Thumb, 0));
-  }
-  return list;
- }
-
-
 PyObject* sw_get_photoalbum(GList *list, gint index) {
   GList *position;
   if ( (index >= g_list_length(list)) || index < 0 ) {
@@ -489,7 +476,9 @@
 #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 +504,6 @@
 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_ipod_device_to_dict(Itdb_Device *device);
 
 %include "@top_srcdir@/src/itdb.h"

Modified: libgpod/trunk/bindings/python/ipod.py
===================================================================
--- libgpod/trunk/bindings/python/ipod.py       2008-08-20 17:32:10 UTC (rev 
2107)
+++ libgpod/trunk/bindings/python/ipod.py       2008-08-20 17:37:32 UTC (rev 
2108)
@@ -964,69 +964,18 @@
         else:
             raise KeyError('No such key: %s' % item)
 
-    def get_thumbnails(self):
-        return [Thumbnail(proxied_thumbnail=t,
-                          ownerobject=self) for t in 
gpod.sw_get_artwork_thumbnails(
-            self._photo)]
+    if pixbuf_support:
+        def get_pixbuf(self, width=-1, height=-1):
+            """Get a pixbuf from a Photo.
 
-    thumbnails = property(get_thumbnails)
+            width: the width of the pixbuf to retrieve, -1 for the biggest
+            possible size and 0 for the smallest possible size (with no 
scaling)
 
-class Thumbnail:
-    """A thumbnail in an Photo."""
-
-    _proxied_attributes = [k for k in gpod._Itdb_Thumb.__dict__.keys()
-                            if not (k.startswith("_") or 
k.startswith("reserved"))]
-
-    def __init__(self, proxied_thumbnail=None, ownerobject=None):
-        """Create a thumbnail object."""
-
-        if not proxied_thumbnail:
-            raise NotImplemented("Can't create new Thumbnails from scratch, 
create Photos instead")
-
-        self._thumbnail = proxied_thumbnail
-        self.__ownerobject = ownerobject
-
-    def __str__(self):
-        return self.__repr__()
-
-    def __repr__(self):
-        return "<Thumbnail Filename:%s Size:%d Width:%d Height:%d>" % (
-            repr(self['filename']),
-            self['size'],
-            self['width'],
-            self['height'])
-
-    def keys(self):
-        return list(self._proxied_attributes)
-
-    def items(self):
-        return [self[k] for k in self._proxied_attributes]
-
-    def pairs(self):
-        return [(k, self[k]) for k in self._proxied_attributes]
-
-    def __getitem__(self, item):
-        if item in self._proxied_attributes:
-            return getattr(self._thumbnail, item)
-        else:
-            raise KeyError('No such key: %s' % item)
-
-    def __setitem__(self, item, value):
-        if type(value) == types.UnicodeType:
-            value = value.encode('UTF-8','replace')
-        if item in self._proxied_attributes:
-            return setattr(self._thumbnail, item, value)
-        else:
-            raise KeyError('No such key: %s' % item)
-
-    if pixbuf_support:
-        def get_pixbuf(self):
-            # this deals with coverart and photo albums
-            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)
+            height: the height of the pixbuf to retrieve, -1 for the biggest
+            possible size and 0 for the smallest possible size (with no 
scaling)
+            """
+            device = self._database.device
+            if hasattr(self._database,"_itdb"):
+                device = self._database._itdb.device
+            return gpod.itdb_artwork_get_pixbuf(device, self._photo,
+                                                width, height)

Modified: libgpod/trunk/bindings/python/tests/tests.py
===================================================================
--- libgpod/trunk/bindings/python/tests/tests.py        2008-08-20 17:32:10 UTC 
(rev 2107)
+++ libgpod/trunk/bindings/python/tests/tests.py        2008-08-20 17:37:32 UTC 
(rev 2108)
@@ -182,10 +182,5 @@
         for album in self.db.PhotoAlbums:
             [photo for photo in album]
 
-    def testEnumeratePhotosThumbs(self):
-        for album in self.db.PhotoAlbums:
-            for photo in album:
-                [thumb for thumb in photo.thumbnails]            
-                
 if __name__ == '__main__':
     unittest.main()


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to