[rhythmbox/gobject-introspection: 19/34] port artdisplay plugin to gi, maybe
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox/gobject-introspection: 19/34] port artdisplay plugin to gi, maybe
- Date: Wed, 14 Jul 2010 05:57:40 +0000 (UTC)
commit b0cb98628067d6d74de24b2406bf8a2829246754
Author: Jonathan Matthew <jonathan d14n org>
Date: Tue Jul 13 14:39:46 2010 +1000
port artdisplay plugin to gi, maybe
.../artdisplay/artdisplay/AmazonCoverArtSearch.py | 311 --------------------
plugins/artdisplay/artdisplay/CoverArtDatabase.py | 36 ++-
.../artdisplay/EmbeddedCoverArtSearch.py | 12 +-
.../artdisplay/artdisplay/LastFMCoverArtSearch.py | 18 +-
.../artdisplay/artdisplay/LocalCoverArtSearch.py | 12 +-
plugins/artdisplay/artdisplay/Makefile.am | 3 -
.../artdisplay/MusicBrainzCoverArtSearch.py | 5 +-
.../artdisplay/artdisplay/PodcastCoverArtSearch.py | 8 +-
plugins/artdisplay/artdisplay/__init__.py | 78 +++---
9 files changed, 89 insertions(+), 394 deletions(-)
---
diff --git a/plugins/artdisplay/artdisplay/CoverArtDatabase.py b/plugins/artdisplay/artdisplay/CoverArtDatabase.py
index e785e3a..d856613 100644
--- a/plugins/artdisplay/artdisplay/CoverArtDatabase.py
+++ b/plugins/artdisplay/artdisplay/CoverArtDatabase.py
@@ -25,12 +25,14 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-import rhythmdb, rb
import os
-import gtk
-import gio
import itertools
+import gio
import gobject
+import gi
+
+from gi.repository import GdkPixbuf
+from gi.repository import RB, RhythmDB
from PodcastCoverArtSearch import PodcastCoverArtSearch
from MusicBrainzCoverArtSearch import MusicBrainzCoverArtSearch
@@ -44,7 +46,7 @@ ART_SEARCHES_LOCAL = [LocalCoverArtSearch, EmbeddedCoverArtSearch]
ART_SEARCHES_REMOTE = [PodcastCoverArtSearch, LastFMCoverArtSearch, MusicBrainzCoverArtSearch]
OLD_ART_FOLDER = '~/.gnome2/rhythmbox/covers'
-ART_FOLDER = os.path.join(rb.user_cache_dir(), 'covers')
+ART_FOLDER = os.path.join(RB.user_cache_dir(), 'covers')
ART_CACHE_EXTENSION_JPG = 'jpg'
ART_CACHE_EXTENSION_PNG = 'png'
ART_CACHE_EXTENSION_META = 'rb-meta'
@@ -108,10 +110,10 @@ class TicketSystem:
return False
def get_search_props(db, entry):
- artist = db.entry_get(entry, rhythmdb.PROP_ALBUM_ARTIST)
+ artist = db.entry_get(entry, RhythmDB.PropType.ALBUM_ARTIST)
if artist == "":
- artist = db.entry_get(entry, rhythmdb.PROP_ARTIST)
- album = db.entry_get(entry, rhythmdb.PROP_ALBUM)
+ artist = db.entry_get(entry, RhythmDB.PropType.ARTIST)
+ album = db.entry_get(entry, RhythmDB.PropType.ALBUM)
return (artist, album)
@@ -214,7 +216,7 @@ class CoverArtDatabase (object):
# Check local cache
if art_location:
self.ticket.purge (entry)
- pixbuf = gtk.gdk.pixbuf_new_from_file (art_location)
+ pixbuf = GdkPixbuf.Pixbuf.new_from_file (art_location)
(tooltip_image, tooltip_text) = self.read_meta_file (art_location_meta)
art_location_url = "file://" + pathname2url(art_location)
callback (entry, pixbuf, art_location_url, tooltip_image, tooltip_text)
@@ -230,8 +232,8 @@ 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.PROP_LOCATION),
- db.entry_get (match_entry, rhythmdb.PROP_LOCATION))
+ db.entry_get (entry, RhythmDB.PropType.LOCATION),
+ db.entry_get (match_entry, RhythmDB.PropType.LOCATION))
self.same_search.setdefault (match_entry, []).append(entry)
return
@@ -260,10 +262,10 @@ class CoverArtDatabase (object):
else:
uri = engine_uri
- print "found image for %s" % (db.entry_get(entry, rhythmdb.PROP_LOCATION))
+ print "found image for %s" % (db.entry_get(entry, 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.PROP_LOCATION))
+ print "and for same search %s" % (db.entry_get(m, RhythmDB.PropType.LOCATION))
callback (m, pixbuf, uri, tooltip_image, tooltip_text)
self.write_blist (blist_location, blist)
@@ -308,10 +310,10 @@ class CoverArtDatabase (object):
return
if self.ticket.forget (entry, ticket):
- print "didn't find image for %s" % (db.entry_get(entry, rhythmdb.PROP_LOCATION))
+ print "didn't find image for %s" % (db.entry_get(entry, 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.PROP_LOCATION))
+ print "or for same search %s" % (db.entry_get(m, RhythmDB.PropType.LOCATION))
callback (m, None, None, None, None)
self.write_blist (blist_location, blist)
@@ -350,9 +352,11 @@ class CoverArtDatabase (object):
def image_data_load (self, data):
if data and len (data) >= 1000:
- pbl = gtk.gdk.PixbufLoader ()
+ pbl = GdkPixbuf.PixbufLoader ()
try:
- if pbl.write (data) and pbl.close ():
+ # not sure pixbufloader.write works properly..
+ # XXX needs testing.
+ if pbl.write (data, len(data)) and pbl.close ():
return pbl.get_pixbuf ()
except gobject.GError:
pass
diff --git a/plugins/artdisplay/artdisplay/EmbeddedCoverArtSearch.py b/plugins/artdisplay/artdisplay/EmbeddedCoverArtSearch.py
index cffccb5..d865fb2 100644
--- a/plugins/artdisplay/artdisplay/EmbeddedCoverArtSearch.py
+++ b/plugins/artdisplay/artdisplay/EmbeddedCoverArtSearch.py
@@ -24,11 +24,11 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-import rhythmdb
-
import gst
import gobject
-import gtk
+
+from gi.repository import GdkPixbuf
+from gi.repository import RhythmDB
class EmbeddedCoverArtSearch (object):
def __init__ (self):
@@ -42,8 +42,8 @@ class EmbeddedCoverArtSearch (object):
print "got image tag %s" % tag
try:
- loader = gtk.gdk.PixbufLoader()
- if loader.write(taglist[tag]) and loader.close():
+ loader = GdkPixbuf.PixbufLoader()
+ if loader.write(taglist[tag], len(taglist[tag])) and loader.close():
print "successfully extracted pixbuf"
self.got_pixbuf = True
self.callback(self, self.entry, loader.get_pixbuf(), *self.args)
@@ -86,7 +86,7 @@ class EmbeddedCoverArtSearch (object):
return
# only search local files
- uri = db.entry_get(entry, rhythmdb.PROP_LOCATION)
+ uri = db.entry_get(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 36adea2..d726456 100644
--- a/plugins/artdisplay/artdisplay/LastFMCoverArtSearch.py
+++ b/plugins/artdisplay/artdisplay/LastFMCoverArtSearch.py
@@ -27,10 +27,12 @@
import urllib
import xml.dom.minidom as dom
import re
-import gconf
+
+import gi
+from gi.repository import GConf
+from gi.repository import RhythmDB
import rb
-import rhythmdb
# this API key belongs to jonathan d14n org
# and was generated specifically for this use
@@ -54,7 +56,7 @@ DISC_NUMBER_REGEXS = (
USERNAME_GCONF_KEY = "/apps/rhythmbox/audioscrobbler/username"
def user_has_account():
- username = gconf.client_get_default().get_string(USERNAME_GCONF_KEY)
+ username = GConf.Client.get_default().get_string(USERNAME_GCONF_KEY)
return (username is not None and username != "")
class LastFMCoverArtSearch (object):
@@ -122,17 +124,17 @@ class LastFMCoverArtSearch (object):
callback (self, entry, None, *args)
return
- artist = db.entry_get (entry, rhythmdb.PROP_ALBUM_ARTIST)
+ artist = db.entry_get (entry, RhythmDB.PropType.ALBUM_ARTIST)
if artist == "":
- artist = db.entry_get (entry, rhythmdb.PROP_ARTIST)
+ artist = db.entry_get (entry, RhythmDB.PropType.ARTIST)
if artist == _("Unknown"):
artist = ""
- album = db.entry_get (entry, rhythmdb.PROP_ALBUM)
+ album = db.entry_get (entry, RhythmDB.PropType.ALBUM)
if album == _("Unknown"):
album = ""
- album_mbid = db.entry_get (entry, rhythmdb.PROP_MUSICBRAINZ_ALBUMID)
+ album_mbid = db.entry_get (entry, RhythmDB.PropType.MUSICBRAINZ_ALBUMID)
if (artist, album, album_mbid) == ("", "", ""):
print "can't search: no artist, album, or album ID"
callback (self, entry, None, *args)
@@ -161,5 +163,3 @@ class LastFMCoverArtSearch (object):
def get_best_match_urls (self, search_results):
return search_results
-
-
diff --git a/plugins/artdisplay/artdisplay/LocalCoverArtSearch.py b/plugins/artdisplay/artdisplay/LocalCoverArtSearch.py
index 4c710d9..f1c9b99 100644
--- a/plugins/artdisplay/artdisplay/LocalCoverArtSearch.py
+++ b/plugins/artdisplay/artdisplay/LocalCoverArtSearch.py
@@ -26,10 +26,11 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
import os
-import rhythmdb
-import rb
import gobject
import gio
+import gi
+
+from gi.repository import RhythmDB
IMAGE_NAMES = ["cover", "album", "albumart", ".folder", "folder"]
ITEMS_PER_NOTIFICATION = 10
@@ -49,10 +50,10 @@ def shared_prefix_length (a, b):
return l
def get_search_props(db, entry):
- artist = db.entry_get(entry, rhythmdb.PROP_ALBUM_ARTIST)
+ artist = db.entry_get(entry, RhythmDB.PropType.ALBUM_ARTIST)
if artist == "":
- artist = db.entry_get(entry, rhythmdb.PROP_ARTIST)
- album = db.entry_get(entry, rhythmdb.PROP_ALBUM)
+ artist = db.entry_get(entry, RhythmDB.PropType.ARTIST)
+ album = db.entry_get(entry, RhythmDB.PropType.ALBUM)
return (artist, album)
@@ -212,4 +213,3 @@ class LocalCoverArtSearch:
enumfiles.next_files_async(ITEMS_PER_NOTIFICATION, callback = self._save_dir_cb, user_data=(db, entry, parent, pixbuf))
except Exception, e:
print "unable to scan directory %s: %s" % (parent.get_uri(), e)
-
diff --git a/plugins/artdisplay/artdisplay/Makefile.am b/plugins/artdisplay/artdisplay/Makefile.am
index 9725665..0f54dd1 100644
--- a/plugins/artdisplay/artdisplay/Makefile.am
+++ b/plugins/artdisplay/artdisplay/Makefile.am
@@ -9,6 +9,3 @@ plugin_PYTHON = \
CoverArtDatabase.py \
MusicBrainzCoverArtSearch.py \
__init__.py
-
-# the amazon cover art search no longer works
-EXTRA_DIST = AmazonCoverArtSearch.py
diff --git a/plugins/artdisplay/artdisplay/MusicBrainzCoverArtSearch.py b/plugins/artdisplay/artdisplay/MusicBrainzCoverArtSearch.py
index 4583ee0..1ae9478 100644
--- a/plugins/artdisplay/artdisplay/MusicBrainzCoverArtSearch.py
+++ b/plugins/artdisplay/artdisplay/MusicBrainzCoverArtSearch.py
@@ -28,7 +28,8 @@ import urllib
import xml.dom.minidom as dom
import rb
-import rhythmdb
+import gi
+from gi.repository import RhythmDB
# musicbrainz URLs
MUSICBRAINZ_RELEASE_URL = "http://musicbrainz.org/ws/1/release/%s?type=xml"
@@ -74,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.PROP_MUSICBRAINZ_ALBUMID)
+ album_id = db.entry_get(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 673e166..bed6d93 100644
--- a/plugins/artdisplay/artdisplay/PodcastCoverArtSearch.py
+++ b/plugins/artdisplay/artdisplay/PodcastCoverArtSearch.py
@@ -24,7 +24,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-import rhythmdb
+import gi
+from gi.repository import RhythmDB
class PodcastCoverArtSearch (object):
def __init__ (self):
@@ -38,11 +39,11 @@ class PodcastCoverArtSearch (object):
return
# Retrieve corresponding feed for this entry
- podcast_location = db.entry_get(entry, rhythmdb.PROP_SUBTITLE)
+ podcast_location = db.entry_get(entry, 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.PROP_IMAGE)
+ image_url = db.entry_get(podcast_feed_entry, RhythmDB.PropType.IMAGE)
on_search_completed_callback (self, entry, image_url, *args)
@@ -58,4 +59,3 @@ class PodcastCoverArtSearch (object):
def get_best_match_urls (self, search_results):
# Return image URL
return [search_results]
-
diff --git a/plugins/artdisplay/artdisplay/__init__.py b/plugins/artdisplay/artdisplay/__init__.py
index 6faa748..885d397 100644
--- a/plugins/artdisplay/artdisplay/__init__.py
+++ b/plugins/artdisplay/artdisplay/__init__.py
@@ -24,13 +24,16 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-import rhythmdb, rb
-import gtk, gobject
+import gobject
import gio
+import gi
+
from warnings import warn
from CoverArtDatabase import CoverArtDatabase
+from gi.repository import Gtk, GdkPixbuf
+from gi.repository import RhythmDB, RB
FADE_STEPS = 10
FADE_TOTAL_TIME = 1000
@@ -41,7 +44,7 @@ THROBBER = 'process-working'
ASPECT_RATIO_MIN = 0.9
ASPECT_RATIO_MAX = 1.1
-def merge_pixbufs (old_pb, new_pb, reserve_pb, step, width, height, mode=gtk.gdk.INTERP_BILINEAR):
+def merge_pixbufs (old_pb, new_pb, reserve_pb, step, width, height, mode=GdkPixbuf.InterpType.BILINEAR):
if width <= 1 and height <= 1:
return None
if old_pb is None:
@@ -74,15 +77,15 @@ def merge_with_background (pixbuf, bgcolor, pad_if_not_near_square):
if not has_alpha:
return pixbuf
rw, rh, left, top = width, height, 0, 0
- ret = gtk.gdk.Pixbuf (gtk.gdk.COLORSPACE_RGB, False, 8, rw, rh)
+ ret = GdkPixbuf.Pixbuf (GdkPixbuf.Colorspace.RGB, False, 8, rw, rh)
ret.fill (((bgcolor.red & 0xff00) << 16) | ((bgcolor.green & 0xff00) << 8) | (bgcolor.blue & 0xff00) | 0xff)
if has_alpha:
- pixbuf.composite (ret, left, top, width, height, left, top, 1.0, 1.0, gtk.gdk.INTERP_NEAREST, 255)
+ pixbuf.composite (ret, left, top, width, height, left, top, 1.0, 1.0, GdkPixbuf.InterpType.NEAREST, 255)
else:
pixbuf.copy_area (0, 0, width, height, ret, left, top)
return ret
-class FadingImage (gtk.Misc):
+class FadingImage (Gtk.Misc):
__gsignals__ = {
'size-allocate': 'override',
'get-max-size' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_INT, ())
@@ -111,14 +114,14 @@ class FadingImage (gtk.Misc):
def screen_changed (self, widget, old_screen):
if old_screen:
self.icon_theme.disconnect (self.tc_id)
- self.icon_theme = gtk.icon_theme_get_for_screen (self.get_screen ())
+ self.icon_theme = Gtk.IconTheme.get_for_screen (self.get_screen ())
self.tc_id = self.icon_theme.connect ('changed', self.theme_changed)
self.theme_changed (self.icon_theme)
def reload_anim_frames (self):
icon_info = self.icon_theme.lookup_icon (THROBBER, -1, 0)
size = icon_info.get_base_size ()
- icon = gtk.gdk.pixbuf_new_from_file (icon_info.get_filename ())
+ icon = GdkPixbuf.Pixbuf.new_from_file (icon_info.get_filename ())
self.anim_frames = [ # along, then down
icon.subpixbuf (x * size, y * size, size, size)
for y in range (int (icon.props.height / size))
@@ -139,11 +142,11 @@ class FadingImage (gtk.Misc):
missing_pixbuf = self.icon_theme.load_icon (ART_MISSING_ICON, self.size, 0)
except:
try:
- missing_pixbuf = gtk.gdk.pixbuf_new_from_file_at_size (self.missing_image, self.size, self.size)
+ missing_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size (self.missing_image, self.size, self.size)
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.STATE_NORMAL], False)
+ self.missing_pixbuf = merge_with_background (missing_pixbuf, self.style.bg[Gtk.StateType.NORMAL], False)
def do_size_allocate (self, allocation):
old_width = self.allocation.width
@@ -177,7 +180,7 @@ class FadingImage (gtk.Misc):
return False
if self.merged_pixbuf.props.width != self.size:
- draw_pb = self.merged_pixbuf.scale_simple (self.size, self.size, gtk.gdk.INTERP_NEAREST)
+ draw_pb = self.merged_pixbuf.scale_simple (self.size, self.size, GdkPixbuf.InterpType.NEAREST)
else:
draw_pb = self.merged_pixbuf
@@ -198,7 +201,7 @@ class FadingImage (gtk.Misc):
return False
def anim_rect (self):
- return gtk.gdk.Rectangle (
+ return Gdk.Rectangle (
(self.allocation.width - self.anim_size) / 2,
(self.allocation.height - self.anim_size) / 2,
min (self.anim_size, self.allocation.width),
@@ -214,7 +217,7 @@ class FadingImage (gtk.Misc):
if ret and self.anim:
if ret is self.missing_pixbuf: ret = ret.copy ()
x, y, w, h = self.anim_rect ()
- self.anim.composite (ret, max (x, 0), max (y, 0), w, h, x, y, 1, 1, gtk.gdk.INTERP_BILINEAR, 255)
+ self.anim.composite (ret, max (x, 0), max (y, 0), w, h, x, y, 1, 1, GdkPixbuf.InterpTypeBILINEAR, 255)
return ret
def fade_art (self, first_time):
@@ -244,7 +247,7 @@ 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.STATE_NORMAL], True)
+ self.new_pixbuf = merge_with_background (pixbuf, self.style.bg[Gtk.StateType.NORMAL], True)
self.merged_pixbuf = None
self.fade_step = 0.0
self.anim = None
@@ -264,8 +267,8 @@ gobject.type_register (FadingImage)
class ArtDisplayWidget (FadingImage):
__gsignals__ = {
- 'pixbuf-dropped' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (rhythmdb.Entry, gtk.gdk.Pixbuf)),
- 'uri-dropped' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (rhythmdb.Entry, gobject.TYPE_STRING))
+ 'pixbuf-dropped' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (RhythmDB.Entry, GdkPixbuf.Pixbuf)),
+ 'uri-dropped' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (RhythmDB.Entry, gobject.TYPE_STRING))
}
def __init__ (self, missing_image):
@@ -284,23 +287,22 @@ class ArtDisplayWidget (FadingImage):
self.disconnect (self.ddr_id)
def update_dnd_targets (self):
- targets = None
if self.current_entry:
- targets = gtk.target_list_add_image_targets (targets)
- targets = gtk.target_list_add_uri_targets (targets)
- targets = gtk.target_list_add_text_targets (targets)
- if targets:
- self.drag_dest_set (gtk.DEST_DEFAULT_ALL, targets, gtk.gdk.ACTION_COPY)
+ targets = Gtk.TargetList()
+ targets.add_image_targets (0, writable=False)
+ targets.add_uri_targets(0)
+ targets.add_text_targets(0)
+ self.drag_dest_set (Gtk.DestDefaults.ALL, targets, Gdk.DragAction.COPY)
else:
self.drag_dest_unset ()
- targets = None
+ targets = Gtk.TargetList()
if self.current_pixbuf:
- targets = gtk.target_list_add_image_targets (targets, writable=True)
+ targets.add_image_targets(0, writable=True)
if self.current_uri:
- targets = gtk.target_list_add_uri_targets (targets)
+ targets.add_uri_targets(0)
if targets:
- self.drag_source_set (gtk.gdk.BUTTON1_MASK, targets, gtk.gdk.ACTION_COPY)
+ self.drag_source_set (Gdk.ModifierType.BUTTON1_MASK, targets, Gdk.DragAction.COPY)
else:
self.drag_source_unset ()
@@ -351,7 +353,7 @@ class ArtDisplayWidget (FadingImage):
gobject.type_register (ArtDisplayWidget)
-class ArtDisplayPlugin (rb.Plugin):
+class ArtDisplayPlugin (RB.Plugin):
def __init__ (self):
rb.Plugin.__init__ (self)
@@ -376,9 +378,9 @@ class ArtDisplayPlugin (rb.Plugin):
self.art_widget.connect ('uri-dropped', self.on_set_uri)
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 = Gtk.VBox ()
self.art_container.pack_start (self.art_widget, padding=6)
- shell.add_widget (self.art_container, rb.SHELL_UI_LOCATION_SIDEBAR)
+ shell.add_widget (self.art_container, RB.ShellUILocation.SIDEBAR)
self.art_db = CoverArtDatabase ()
self.current_entry, self.current_pixbuf = None, None
self.playing_entry_changed (sp, sp.get_playing_entry ())
@@ -396,7 +398,7 @@ class ArtDisplayPlugin (rb.Plugin):
db.disconnect (id)
self.db_cb_ids = ()
- shell.remove_widget (self.art_container, rb.SHELL_UI_LOCATION_SIDEBAR)
+ shell.remove_widget (self.art_container, RB.ShellUILocation.SIDEBAR)
self.art_widget.disconnect_handlers ()
self.art_widget = None
self.art_db = None
@@ -427,10 +429,10 @@ class ArtDisplayPlugin (rb.Plugin):
if tooltip_image is None:
pb = None
elif tooltip_image.startswith("/"):
- pb = gtk.gdk.pixbuf_new_from_file(tooltip_image)
+ pb = GdkPixbuf.Pixbuf.new_from_file(tooltip_image)
else:
f = self.find_file(tooltip_image)
- pb = gtk.gdk.pixbuf_new_from_file(f)
+ pb = GdkPixbuf.Pixbuf.new_from_file(f)
self.art_widget.set (entry, pixbuf, uri, pb, tooltip_text, False)
if pixbuf:
@@ -461,7 +463,7 @@ class ArtDisplayPlugin (rb.Plugin):
def cover_art_notify (self, db, entry, field, metadata):
if entry != self.current_entry:
return
- if not isinstance (metadata, gtk.gdk.Pixbuf):
+ if not isinstance (metadata, GdkPixbuf.Pixbuf):
return
self.art_db.cancel_get_pixbuf (entry)
if self.current_pixbuf == metadata:
@@ -490,9 +492,9 @@ class ArtDisplayPlugin (rb.Plugin):
uri = str (metadata)
def loader_cb (data):
if data and len (data) >= 1000:
- pbl = gtk.gdk.PixbufLoader ()
+ pbl = GdkPixbuf.PixbufLoader ()
try:
- if pbl.write (data) and pbl.close ():
+ if pbl.write (data, len(data)) and pbl.close ():
pixbuf = pbl.get_pixbuf ()
if pixbuf:
self.art_db.cancel_get_pixbuf (entry)
@@ -529,11 +531,13 @@ class ArtDisplayPlugin (rb.Plugin):
def on_button_press (self, widget, event):
# on double clicks, open the cover image (if there is one) in the default
# image viewer
- if event.type != gtk.gdk._2BUTTON_PRESS or event.button != 1:
+
+ doubleclick = Gdk.EventType.__dict__.get("2BUTTON_PRESS") # tiny bit ugly.
+ if event.type != doubleclick or event.button != 1:
return
if self.art_widget.current_uri is None:
return
f = gio.File(self.art_widget.current_uri)
- gtk.show_uri(self.shell.props.window.get_screen(), f.get_uri(), event.time)
+ Gtk.show_uri(self.shell.props.window.get_screen(), f.get_uri(), event.time)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]