[rhythmbox] artdisplay: fix local cover art search for smb shares



commit e483e429693c925567817b6f2d823f403189915e
Author: Jonathan Matthew <jonathan d14n org>
Date:   Sun Nov 29 18:30:56 2009 +1000

    artdisplay: fix local cover art search for smb shares
    
    Two problems here: gvfs won't do async file enumeration unless the
    enumerator is created asynchronously, and the gvfs smb backend doesn't
    do standard::fast-content-type or access::can-read, so we switch to
    standard::content-type instead, and assume files are readable if
    access::can-read is missing.

 .../artdisplay/LocalCoverArtSearchGIO.py           |   23 +++++++++++++++----
 1 files changed, 18 insertions(+), 5 deletions(-)
---
diff --git a/plugins/artdisplay/artdisplay/LocalCoverArtSearchGIO.py b/plugins/artdisplay/artdisplay/LocalCoverArtSearchGIO.py
index dd34325..25b2ace 100644
--- a/plugins/artdisplay/artdisplay/LocalCoverArtSearchGIO.py
+++ b/plugins/artdisplay/artdisplay/LocalCoverArtSearchGIO.py
@@ -62,15 +62,29 @@ class LocalCoverArtSearch:
 				return
 
 			for f in files:
-				ct = f.get_attribute_string("standard::fast-content-type")
-				if ct.startswith("image/") and f.get_attribute_boolean("access::can-read"):
-					results.append(f.get_name())	# hm
+				ct = f.get_attribute_string("standard::content-type")
+				# assume readable unless told otherwise
+				readable = True
+				if f.has_attribute("access::can-read"):
+					readable = f.get_attribute_boolean("access::can-read")
+				if ct is not None and ct.startswith("image/") and readable:
+					results.append(f.get_name())
 
 			fileenum.next_files_async(ITEMS_PER_NOTIFICATION, callback = self._enum_dir_cb, user_data=(results, on_search_completed_cb, entry, args))
 		except Exception, e:
 			print "okay, probably done: %s" % e
 			on_search_completed_cb(self, entry, results, *args)
 
+
+	def _enum_children_cb(self, parent, result, (on_search_completed_cb, entry, args)):
+		try:
+			enumfiles = parent.enumerate_children_finish(result)
+			enumfiles.next_files_async(ITEMS_PER_NOTIFICATION, callback = self._enum_dir_cb, user_data=([], on_search_completed_cb, entry, args))
+		except Exception, e:
+			print "okay, probably done: %s" % e
+			on_search_completed_cb(self, entry, [], *args)
+
+
 	def search (self, db, entry, is_playing, on_search_completed_cb, *args):
 
 		self.file = gio.File(entry.get_playback_uri())
@@ -84,8 +98,7 @@ class LocalCoverArtSearch:
 
 		print 'searching for local art for %s' % (self.file.get_uri())
 		parent = self.file.get_parent()
-		enumfiles = parent.enumerate_children(attributes="standard::fast-content-type,access::can-read,standard::name")
-		enumfiles.next_files_async(ITEMS_PER_NOTIFICATION, callback = self._enum_dir_cb, user_data=([], on_search_completed_cb, entry, args))
+		enumfiles = parent.enumerate_children_async(attributes="standard::content-type,access::can-read,standard::name", callback = self._enum_children_cb, user_data=(on_search_completed_cb, entry, args))
 
 	def search_next (self):
 		return False



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]