def on_get_pixbuf_completed(self, entry, pixbuf, uri, tooltip_image, tooltip_text): # Set the pixbuf for the entry returned from the art db if rb.entry_equal(entry, self.current_entry): self.current_pixbuf = pixbuf if tooltip_image is None: pb = None elif tooltip_image.startswith("/"): pb = GdkPixbuf.Pixbuf.new_from_file(tooltip_image) else: f = rb.find_plugin_file(self, tooltip_image) pb = GdkPixbuf.Pixbuf.new_from_file(f) self.art_widget.set(entry, pixbuf, uri, pb, tooltip_text, False) if pixbuf: # This might be from a playing-changed signal, # in which case consumers won't be ready yet. def idle_emit_art(): shell = self.object db = shell.props.db db.emit_entry_extra_metadata_notify(entry, "rb:coverArt", pixbuf) if uri: self.emitting_uri_notify = True db.emit_entry_extra_metadata_notify( entry, "rb:coverArt-uri", uri) self.emitting_uri_notify = False return False gobject.idle_add(idle_emit_art)
def on_get_pixbuf_completed(self, entry, pixbuf, uri, tooltip_image, tooltip_text): # Set the pixbuf for the entry returned from the art db if rb.entry_equal(entry, self.current_entry): self.current_pixbuf = pixbuf if tooltip_image is None: pb = None elif tooltip_image.startswith("/"): pb = GdkPixbuf.Pixbuf.new_from_file(tooltip_image) else: f = rb.find_plugin_file (self, tooltip_image) pb = GdkPixbuf.Pixbuf.new_from_file(f) self.art_widget.set (entry, pixbuf, uri, pb, tooltip_text, False) if pixbuf: # This might be from a playing-changed signal, # in which case consumers won't be ready yet. def idle_emit_art(): shell = self.object db = shell.props.db db.emit_entry_extra_metadata_notify (entry, "rb:coverArt", pixbuf) if uri: self.emitting_uri_notify = True db.emit_entry_extra_metadata_notify (entry, "rb:coverArt-uri", uri) self.emitting_uri_notify = False return False gobject.idle_add(idle_emit_art)
def art_store_request_cb(self, key, filename, data, entry): if rb.entry_equal(entry, self.current_entry) is False: # track changed while we were searching return if isinstance(data, GdkPixbuf.Pixbuf): self.current_pixbuf = data uri = "file://" + urllib.pathname2url(filename) self.art_widget.set (entry, self.current_pixbuf, uri, None, None, False) else: self.art_widget.set (entry, None, None, None, None, False)
def cover_art_request (self, db, entry): a = [None] def callback(entry, pixbuf, uri, tooltip_image, tooltip_text): a[0] = pixbuf self.on_get_pixbuf_completed(entry, pixbuf, uri, tooltip_image, tooltip_text) 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 return a[0]
def set_entry(self, entry): if rb.entry_equal(entry, self.current_entry): return self.art_widget.set(entry, None, None, None, None, True) self.art_container.show_all() self.current_entry = entry self.current_pixbuf = None if entry is not None: key = entry.create_ext_db_key(RB.RhythmDBPropType.ALBUM) self.art_store.request(key, self.art_store_request_cb, entry)
def set_entry (self, entry): if rb.entry_equal(entry, self.current_entry): return self.art_widget.set (entry, None, None, None, None, True) self.art_container.show_all () # Intitates search in the database (which checks art cache, internet etc.) self.current_entry = entry self.current_pixbuf = None shell = self.object db = shell.props.db self.art_db.get_pixbuf(db, entry, True, self.on_get_pixbuf_completed)
def set_entry (self, entry): if rb.entry_equal(entry, self.current_entry): return if self.current_entry == None: self.save_status () self.current_entry = entry if entry is None: self.restore_status () return self.set_status_from_entry ()
def cover_art_request(self, db, entry): a = [None] def callback(entry, pixbuf, uri, tooltip_image, tooltip_text): a[0] = pixbuf self.on_get_pixbuf_completed(entry, pixbuf, uri, tooltip_image, tooltip_text) 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 return a[0]
def set_entry(self, entry): if rb.entry_equal(entry, self.current_entry): return self.art_widget.set(entry, None, None, None, None, True) self.art_container.show_all() # Intitates search in the database (which checks art cache, internet etc.) self.current_entry = entry self.current_pixbuf = None shell = self.object db = shell.props.db self.art_db.get_pixbuf(db, entry, True, self.on_get_pixbuf_completed)
def set_entry(self, entry): if rb.entry_equal(entry, self.current_entry): return if self.current_entry == None: self.save_status() self.current_entry = entry if entry is None: self.restore_status() return self.set_status_from_entry()
def remove_entry(self, entry): ''' Removes an entry from the album entrie's list. If the removed entry was the last one on the Album, it automatically removes itself from it's tree model. ''' for e in self.entries: if rb.entry_equal(e, entry): self.entries.remove(e) break # if there aren't entries left, remove the album from the model if self.get_track_count() == 0: self.remove_from_model()
def art_store_request_cb(self, *args): # Rhythmbox 3.2 introduced an additional argument, using *args ensures backwards compatibility entry = args[-1] data = args[-2] filename = args[-3] if rb.entry_equal(entry, self.current_entry) is False: # track changed while we were searching return if isinstance(data, GdkPixbuf.Pixbuf): self.current_pixbuf = data uri = "file://" + urllib.request.pathname2url(filename) self.art_widget.set(entry, self.current_pixbuf, uri, None, None, False) else: self.art_widget.set(entry, None, None, None, None, False)
def set_entry(self, entry): if rb.entry_equal(entry, self.entry): return self.entry = entry if entry is None: return self.album = entry.get_string(RB.RhythmDBPropType.ALBUM) self.artist = entry.get_string(RB.RhythmDBPropType.ARTIST) self.title = entry.get_string(RB.RhythmDBPropType.TITLE) self.duration = entry.get_ulong(RB.RhythmDBPropType.DURATION) # sp = self.object.props.shell_player # self.duration = sp.get_playing_song_duration() self.rating = entry.get_double(RB.RhythmDBPropType.RATING) print "Song rating %g" % self.rating db = self.object.get_property("db") if entry.get_entry_type().props.category == RB.RhythmDBEntryCategory.STREAM: if not self.album: self.album = db.entry_request_extra_metadata(entry, STREAM_ALBUM) if not self.artist: self.artist = db.entry_request_extra_metadata(entry, STREAM_ARTIST) if not self.title: self.title = db.entry_request_extra_metadata(entry, STREAM_TITLE) self.set_display()
def cover_art_uri_gather (self, db, entry, metadata): if rb.entry_equal(entry, self.current_entry) and self.art_widget.current_uri: metadata ['rb:coverArt-uri'] = self.art_widget.current_uri
def cover_art_uri_request (self, db, entry): if rb.entry_equal(entry, self.current_entry): return self.art_widget.current_uri
def cover_art_uri_request(self, db, 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(entry, self.current_entry) and self.art_widget.current_uri: metadata['rb:coverArt-uri'] = self.art_widget.current_uri
def lyrics_notify (self, db, entry, field, metadata): if rb.entry_equal(entry, self.entry): self.emit ('lyrics-ready', self.entry, metadata)
def lyrics_notify(self, db, entry, field, metadata): if rb.entry_equal(entry, self.entry): self.emit('lyrics-ready', self.entry, metadata)
def set_entry (self, entry): if rb.entry_equal(entry, self.current_entry): return self.current_entry = entry self.set_status_from_entry ()