[rhythmbox] fix the python entry equality check so it actually works here



commit 6130244abce4aa3d65d2321867443c86557ad363
Author: Jonathan Matthew <jonathan d14n org>
Date:   Thu Mar 24 08:39:49 2011 +1000

    fix the python entry equality check so it actually works here

 plugins/artdisplay/artdisplay/__init__.py |   14 +++++++-------
 plugins/context/context/LyricsTab.py      |    2 +-
 plugins/im-status/im-status/__init__.py   |    3 +--
 plugins/rb/__init__.py                    |    6 ++----
 4 files changed, 11 insertions(+), 14 deletions(-)
---
diff --git a/plugins/artdisplay/artdisplay/__init__.py b/plugins/artdisplay/artdisplay/__init__.py
index f36a682..d6709f1 100644
--- a/plugins/artdisplay/artdisplay/__init__.py
+++ b/plugins/artdisplay/artdisplay/__init__.py
@@ -426,8 +426,7 @@ class ArtDisplayPlugin (RB.Plugin):
 		self.set_entry(entry)
 
 	def set_entry (self, entry):
-		db = self.shell.get_property ("db")
-		if rb.entry_equal(db, entry, self.current_entry):
+		if rb.entry_equal(entry, self.current_entry):
 			return
 
 		self.art_widget.set (entry, None, None, None, None, True)
@@ -435,12 +434,12 @@ class ArtDisplayPlugin (RB.Plugin):
 		# Intitates search in the database (which checks art cache, internet etc.)
 		self.current_entry = entry
 		self.current_pixbuf = None
+		db = self.shell.get_property ("db")
 		self.art_db.get_pixbuf(db, entry, True, self.on_get_pixbuf_completed)
 
 	def on_get_pixbuf_completed(self, entry, pixbuf, uri, tooltip_image, tooltip_text):
 		# Set the pixbuf for the entry returned from the art db
-		db = self.shell.get_property ("db")
-		if rb.entry_equal(db, entry, self.current_entry):
+		if rb.entry_equal(entry, self.current_entry):
 			self.current_pixbuf = pixbuf
 
 			if tooltip_image is None:
@@ -456,6 +455,7 @@ class ArtDisplayPlugin (RB.Plugin):
 			# This might be from a playing-changed signal,
 			# in which case consumers won't be ready yet.
 			def idle_emit_art():
+				db = self.shell.get_property ("db")
 				db.emit_entry_extra_metadata_notify (entry, "rb:coverArt", pixbuf)
 				if uri:
 					self.emitting_uri_notify = True
@@ -470,7 +470,7 @@ class ArtDisplayPlugin (RB.Plugin):
 			a[0] = pixbuf
 			self.on_get_pixbuf_completed(entry, pixbuf, uri, tooltip_image, tooltip_text)
 
-		playing = rb.entry_equal(db, entry, self.current_entry)
+		playing = rb.entry_equal(entry, self.current_entry)
 		self.art_db.get_pixbuf(db, entry, playing, callback)
 
 		# If callback was called synchronously we can return a pixmap
@@ -538,11 +538,11 @@ class ArtDisplayPlugin (RB.Plugin):
 
 
 	def cover_art_uri_request (self, db, entry):
-		if rb.entry_equal(db, entry, self.current_entry):
+		if rb.entry_equal(entry, self.current_entry):
 			return self.art_widget.current_uri
 
 	def cover_art_uri_gather (self, db, entry, metadata):
-		if rb.entry_equal(db, entry, self.current_entry) and self.art_widget.current_uri:
+		if rb.entry_equal(entry, self.current_entry) and self.art_widget.current_uri:
 			metadata ['rb:coverArt-uri'] = self.art_widget.current_uri
 
 	def on_set_pixbuf (self, widget, entry, pixbuf):
diff --git a/plugins/context/context/LyricsTab.py b/plugins/context/context/LyricsTab.py
index 5a91567..0774df5 100644
--- a/plugins/context/context/LyricsTab.py
+++ b/plugins/context/context/LyricsTab.py
@@ -143,7 +143,7 @@ class LyricsDataSource (gobject.GObject):
         self.db.connect ('entry-extra-metadata-notify::rb:lyrics', self.lyrics_notify)
 
     def lyrics_notify (self, db, entry, field, metadata):
-        if rb.entry_equal(db, entry, self.entry):
+        if rb.entry_equal(entry, self.entry):
             self.emit ('lyrics-ready', self.entry, metadata)
 
     def fetch_lyrics (self, entry):
diff --git a/plugins/im-status/im-status/__init__.py b/plugins/im-status/im-status/__init__.py
index 7b1e582..861ef89 100644
--- a/plugins/im-status/im-status/__init__.py
+++ b/plugins/im-status/im-status/__init__.py
@@ -120,8 +120,7 @@ class IMStatusPlugin (RB.Plugin):
       self.set_status ()
 
   def set_entry (self, entry):
-    db = self.shell.get_property ("db")
-    if rb.entry_equal(db, entry, self.current_entry):
+    if rb.entry_equal(entry, self.current_entry):
       return
 
     if self.current_entry == None:
diff --git a/plugins/rb/__init__.py b/plugins/rb/__init__.py
index 3fc14d5..13e4f16 100644
--- a/plugins/rb/__init__.py
+++ b/plugins/rb/__init__.py
@@ -35,8 +35,6 @@ import thread
 from gi.repository import RB
 from gi.repository import GConf
 
-import rhythmdb
-
 # rb classes
 from Loader import Loader
 from Loader import ChunkLoader
@@ -63,12 +61,12 @@ def append_plugin_source_path(theme, iconpath):
 		icondir = plugindir + iconpath
 		theme.append_search_path(icondir)
 
-def entry_equal(db, a, b):
+def entry_equal(a, b):
 	if (a is None and b is None):
 		return True
 	if (a is None or b is None):
 		return False
-	return db.entry_get(a, rhythmdb.PROP_LOCATION) == db.entry_get(b, rhythmdb.PROP_LOCATION)
+	return a.get_string(RB.RhythmDBPropType.LOCATION) == b.get_string(RB.RhythmDBPropType.LOCATION)
 
 def get_gconf_string_list(key):
 	gconf = GConf.Client().get_default()



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