[rhythmbox/gobject-introspection: 26/34] fix bits and pieces of the artdisplay plugin, almost almost works
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox/gobject-introspection: 26/34] fix bits and pieces of the artdisplay plugin, almost almost works
- Date: Wed, 14 Jul 2010 05:58:15 +0000 (UTC)
commit f649376a2509b70be60537d1c275b7f4e2546996
Author: Jonathan Matthew <jonathan d14n org>
Date: Wed Jul 14 00:21:18 2010 +1000
fix bits and pieces of the artdisplay plugin, almost almost works
gdkpixbuf stuff is busted though.
gdk.drag_dest_set crashes?
plugins/artdisplay/artdisplay/CoverArtDatabase.py | 22 +++++++-----
.../artdisplay/EmbeddedCoverArtSearch.py | 2 +-
.../artdisplay/artdisplay/LastFMCoverArtSearch.py | 8 ++--
.../artdisplay/artdisplay/LocalCoverArtSearch.py | 6 ++--
.../artdisplay/MusicBrainzCoverArtSearch.py | 2 +-
.../artdisplay/artdisplay/PodcastCoverArtSearch.py | 8 +++-
plugins/artdisplay/artdisplay/__init__.py | 38 ++++++++++++--------
7 files changed, 51 insertions(+), 35 deletions(-)
---
diff --git a/plugins/artdisplay/artdisplay/CoverArtDatabase.py b/plugins/artdisplay/artdisplay/CoverArtDatabase.py
index d856613..047bc74 100644
--- a/plugins/artdisplay/artdisplay/CoverArtDatabase.py
+++ b/plugins/artdisplay/artdisplay/CoverArtDatabase.py
@@ -31,6 +31,7 @@ import gio
import gobject
import gi
+import rb
from gi.repository import GdkPixbuf
from gi.repository import RB, RhythmDB
@@ -110,10 +111,10 @@ class TicketSystem:
return False
def get_search_props(db, entry):
- artist = db.entry_get(entry, RhythmDB.PropType.ALBUM_ARTIST)
+ artist = entry.get_string(RhythmDB.PropType.ALBUM_ARTIST)
if artist == "":
- artist = db.entry_get(entry, RhythmDB.PropType.ARTIST)
- album = db.entry_get(entry, RhythmDB.PropType.ALBUM)
+ artist = entry.get_string(RhythmDB.PropType.ARTIST)
+ album = entry.get_string(RhythmDB.PropType.ALBUM)
return (artist, album)
@@ -232,14 +233,15 @@ class CoverArtDatabase (object):
match_entry = self.ticket.find(entry, find_same_search, db)
if match_entry is not None:
print "entry %s matches existing search for %s" % (
- db.entry_get (entry, RhythmDB.PropType.LOCATION),
- db.entry_get (match_entry, RhythmDB.PropType.LOCATION))
+ entry.get_string(RhythmDB.PropType.LOCATION),
+ match_entry.get_string(RhythmDB.PropType.LOCATION))
self.same_search.setdefault (match_entry, []).append(entry)
return
blist = self.read_blist (blist_location)
ticket = self.ticket.get (entry)
for engine, engine_name, engine_remote in self.engines (blist):
+ print "trying %s" % engine_name
plexer.clear ()
engine.search (db, entry, is_playing, plexer.send ())
while True:
@@ -262,10 +264,10 @@ class CoverArtDatabase (object):
else:
uri = engine_uri
- print "found image for %s" % (db.entry_get(entry, RhythmDB.PropType.LOCATION))
+ print "found image for %s" % (entry.get_string(RhythmDB.PropType.LOCATION))
callback (entry, pixbuf, uri, tooltip_image, tooltip_text)
for m in self.same_search.pop(entry, []):
- print "and for same search %s" % (db.entry_get(m, RhythmDB.PropType.LOCATION))
+ print "and for same search %s" % (m.get_string(RhythmDB.PropType.LOCATION))
callback (m, pixbuf, uri, tooltip_image, tooltip_text)
self.write_blist (blist_location, blist)
@@ -302,18 +304,20 @@ class CoverArtDatabase (object):
if self.ticket.bury (ticket):
self.write_blist (blist_location, blist)
self.same_search.pop (entry, None)
+ print "fuckshit"
return
if self.ticket.bury (ticket):
self.write_blist (blist_location, blist)
self.same_search.pop (entry, None)
+ print "shitfuck"
return
if self.ticket.forget (entry, ticket):
- print "didn't find image for %s" % (db.entry_get(entry, RhythmDB.PropType.LOCATION))
+ print "didn't find image for %s" % (entry.get_string(RhythmDB.PropType.LOCATION))
callback (entry, None, None, None, None)
for m in self.same_search.pop (entry, []):
- print "or for same search %s" % (db.entry_get(m, RhythmDB.PropType.LOCATION))
+ print "or for same search %s" % (m.get_string(RhythmDB.PropType.LOCATION))
callback (m, None, None, None, None)
self.write_blist (blist_location, blist)
diff --git a/plugins/artdisplay/artdisplay/EmbeddedCoverArtSearch.py b/plugins/artdisplay/artdisplay/EmbeddedCoverArtSearch.py
index d865fb2..3eee7e5 100644
--- a/plugins/artdisplay/artdisplay/EmbeddedCoverArtSearch.py
+++ b/plugins/artdisplay/artdisplay/EmbeddedCoverArtSearch.py
@@ -86,7 +86,7 @@ class EmbeddedCoverArtSearch (object):
return
# only search local files
- uri = db.entry_get(entry, RhythmDB.PropType.LOCATION)
+ uri = db.entry_get_string(entry, RhythmDB.PropType.LOCATION)
if uri.startswith("file://") is False:
print "not checking for embedded cover art in non-local entry %s" % uri
on_search_completed (self, entry, None, *args)
diff --git a/plugins/artdisplay/artdisplay/LastFMCoverArtSearch.py b/plugins/artdisplay/artdisplay/LastFMCoverArtSearch.py
index d726456..5ab368b 100644
--- a/plugins/artdisplay/artdisplay/LastFMCoverArtSearch.py
+++ b/plugins/artdisplay/artdisplay/LastFMCoverArtSearch.py
@@ -124,17 +124,17 @@ class LastFMCoverArtSearch (object):
callback (self, entry, None, *args)
return
- artist = db.entry_get (entry, RhythmDB.PropType.ALBUM_ARTIST)
+ artist = entry.get_string(RhythmDB.PropType.ALBUM_ARTIST)
if artist == "":
- artist = db.entry_get (entry, RhythmDB.PropType.ARTIST)
+ artist = entry.get_string (RhythmDB.PropType.ARTIST)
if artist == _("Unknown"):
artist = ""
- album = db.entry_get (entry, RhythmDB.PropType.ALBUM)
+ album = entry.get_string (RhythmDB.PropType.ALBUM)
if album == _("Unknown"):
album = ""
- album_mbid = db.entry_get (entry, RhythmDB.PropType.MUSICBRAINZ_ALBUMID)
+ album_mbid = entry.get_string (RhythmDB.PropType.MB_ALBUMID)
if (artist, album, album_mbid) == ("", "", ""):
print "can't search: no artist, album, or album ID"
callback (self, entry, None, *args)
diff --git a/plugins/artdisplay/artdisplay/LocalCoverArtSearch.py b/plugins/artdisplay/artdisplay/LocalCoverArtSearch.py
index f1c9b99..5b5885e 100644
--- a/plugins/artdisplay/artdisplay/LocalCoverArtSearch.py
+++ b/plugins/artdisplay/artdisplay/LocalCoverArtSearch.py
@@ -50,10 +50,10 @@ def shared_prefix_length (a, b):
return l
def get_search_props(db, entry):
- artist = db.entry_get(entry, RhythmDB.PropType.ALBUM_ARTIST)
+ artist = entry.get_string(RhythmDB.PropType.ALBUM_ARTIST)
if artist == "":
- artist = db.entry_get(entry, RhythmDB.PropType.ARTIST)
- album = db.entry_get(entry, RhythmDB.PropType.ALBUM)
+ artist = entry.get_string(RhythmDB.PropType.ARTIST)
+ album = entry.get_string(RhythmDB.PropType.ALBUM)
return (artist, album)
diff --git a/plugins/artdisplay/artdisplay/MusicBrainzCoverArtSearch.py b/plugins/artdisplay/artdisplay/MusicBrainzCoverArtSearch.py
index 1ae9478..bc1a230 100644
--- a/plugins/artdisplay/artdisplay/MusicBrainzCoverArtSearch.py
+++ b/plugins/artdisplay/artdisplay/MusicBrainzCoverArtSearch.py
@@ -75,7 +75,7 @@ class MusicBrainzCoverArtSearch (object):
self.entry = entry
# if we've got an album ID, we can get the album info directly
- album_id = db.entry_get(entry, RhythmDB.PropType.MUSICBRAINZ_ALBUMID)
+ album_id = db.entry_get_string(entry, RhythmDB.PropType.MUSICBRAINZ_ALBUMID)
if album_id != "":
# these sometimes look like full URLs, sometimes not
if album_id.startswith(MUSICBRAINZ_RELEASE_PREFIX):
diff --git a/plugins/artdisplay/artdisplay/PodcastCoverArtSearch.py b/plugins/artdisplay/artdisplay/PodcastCoverArtSearch.py
index bed6d93..9f50597 100644
--- a/plugins/artdisplay/artdisplay/PodcastCoverArtSearch.py
+++ b/plugins/artdisplay/artdisplay/PodcastCoverArtSearch.py
@@ -34,16 +34,20 @@ class PodcastCoverArtSearch (object):
def search (self, db, entry, is_playing, on_search_completed_callback, *args):
# Check if entry is a podcast for performance
+ # FIXME totally doesn't work with GI
+ on_search_completed_callback (self, entry, None, *args)
+ return
+
if entry.get_entry_type() != db.entry_type_get_by_name("podcast-post"):
on_search_completed_callback (self, entry, None, *args)
return
# Retrieve corresponding feed for this entry
- podcast_location = db.entry_get(entry, RhythmDB.PropType.SUBTITLE)
+ podcast_location = entry.get_string(RhythmDB.PropType.SUBTITLE)
podcast_feed_entry = db.entry_lookup_by_location(podcast_location)
# Check for PROP_IMAGE in feed
- image_url = db.entry_get(podcast_feed_entry, RhythmDB.PropType.IMAGE)
+ image_url = podcast_feed_entry.get_string(RhythmDB.PropType.IMAGE)
on_search_completed_callback (self, entry, image_url, *args)
diff --git a/plugins/artdisplay/artdisplay/__init__.py b/plugins/artdisplay/artdisplay/__init__.py
index 57e03f5..9beb32e 100644
--- a/plugins/artdisplay/artdisplay/__init__.py
+++ b/plugins/artdisplay/artdisplay/__init__.py
@@ -32,7 +32,8 @@ from warnings import warn
from CoverArtDatabase import CoverArtDatabase
-from gi.repository import Gtk, GdkPixbuf
+import rb
+from gi.repository import Gtk, Gdk, GdkPixbuf
from gi.repository import RhythmDB, RB
FADE_STEPS = 10
@@ -146,11 +147,12 @@ class FadingImage (Gtk.Misc):
except Exception, e:
warn ("Missing artwork icon not found: %s" % e, Warning)
return
- self.missing_pixbuf = merge_with_background (missing_pixbuf, self.style.bg[Gtk.StateType.NORMAL], False)
+ self.missing_pixbuf = merge_with_background (missing_pixbuf, self.get_style().bg[Gtk.StateType.NORMAL], False)
def do_size_allocate (self, allocation):
old_width = self.allocation.width
- self.allocation = allocation
+ # self.allocation = allocation
+ self.set_allocation(allocation)
if self.resize_id == 0:
self.resize_id = gobject.idle_add (self.after_resize)
@@ -185,7 +187,10 @@ class FadingImage (Gtk.Misc):
draw_pb = self.merged_pixbuf
# center the image if we're wider than we are tall
- x, y, w, h = event.area
+ x = event.expose.area.x
+ y = event.expose.area.y
+ w = event.expose.area.width
+ h = event.expose.area.height # ick
pad = (self.allocation.width - self.size) / 2
left = max (x, pad)
@@ -193,11 +198,11 @@ class FadingImage (Gtk.Misc):
top = y
bottom = min (y + h, self.size)
if right > left and bottom > top:
- event.window.draw_pixbuf (None, draw_pb, left-pad, top, left, top, right - left, bottom - top)
+ Gdk.draw_pixbuf(event.any.window, None, draw_pb, left - pad, top, left, top, right - left, bottom - top, Gdk.RgbDither.NORMAL, 0, 0)
if self.anim:
x, y, w, h = self.anim_rect ()
- event.window.draw_pixbuf (None, self.anim, max (0, -x), max (0, -y), max (0, x), max (0, y), w, h)
+ Gdk.draw_pixbuf(event.any.window.draw_pixbuf, None, self.anim, max (0, -x), max (0, -y), max (0, x), max (0, y), w, h, Gdk.RgbDither.NORMAL, 0, 0)
return False
def anim_rect (self):
@@ -247,7 +252,8 @@ class FadingImage (Gtk.Misc):
self.old_pixbuf = self.render_overlay ()
else:
self.old_pixbuf = None # don't fade
- self.new_pixbuf = merge_with_background (pixbuf, self.style.bg[Gtk.StateType.NORMAL], True)
+
+ self.new_pixbuf = merge_with_background (pixbuf, self.get_style().bg[Gtk.StateType.NORMAL], True)
self.merged_pixbuf = None
self.fade_step = 0.0
self.anim = None
@@ -262,6 +268,7 @@ class FadingImage (Gtk.Misc):
gobject.source_remove (self.anim_id)
self.anim_id = 0
self.queue_resize ()
+
gobject.type_register (FadingImage)
@@ -289,22 +296,23 @@ class ArtDisplayWidget (FadingImage):
def update_dnd_targets (self):
if self.current_entry:
targets = Gtk.TargetList()
- targets.add_image_targets (0, writable=False)
+ targets.add_image_targets (0, False)
targets.add_uri_targets(0)
targets.add_text_targets(0)
- self.drag_dest_set (Gtk.DestDefaults.ALL, targets, Gdk.DragAction.COPY)
+ # Gtk.drag_dest_set (self, Gtk.DestDefaults.ALL, targets.list, Gdk.DragAction.COPY)
else:
- self.drag_dest_unset ()
+ Gtk.drag_dest_unset (self)
targets = Gtk.TargetList()
if self.current_pixbuf:
- targets.add_image_targets(0, writable=True)
+ targets.add_image_targets(0, True)
if self.current_uri:
targets.add_uri_targets(0)
if targets:
- self.drag_source_set (Gdk.ModifierType.BUTTON1_MASK, targets, Gdk.DragAction.COPY)
+ # Gtk.drag_source_set (self, Gdk.ModifierType.BUTTON1_MASK, targets.list, Gdk.DragAction.COPY)
+ pass
else:
- self.drag_source_unset ()
+ Gtk.drag_source_unset (self)
def query_tooltip (self, widget, x, y, keyboard_mode, tooltip):
if (self.tooltip_image, self.tooltip_text) != (None, None):
@@ -379,8 +387,8 @@ class ArtDisplayPlugin (RB.Plugin):
self.art_widget.connect ('get-max-size', self.get_max_art_size)
self.art_widget.connect ('button-press-event', self.on_button_press)
self.art_container = Gtk.VBox ()
- self.art_container.pack_start (self.art_widget, padding=6)
- shell.add_widget (self.art_container, RB.ShellUILocation.SIDEBAR)
+ self.art_container.pack_start (self.art_widget, True, True, 6)
+ shell.add_widget (self.art_container, RB.ShellUILocation.SIDEBAR, False, True)
self.art_db = CoverArtDatabase ()
self.current_entry, self.current_pixbuf = None, None
self.playing_entry_changed (sp, sp.get_playing_entry ())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]