[rhythmbox/gobject-introspection: 22/34] port jamendo plugin to gi, perhaps
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox/gobject-introspection: 22/34] port jamendo plugin to gi, perhaps
- Date: Wed, 14 Jul 2010 05:57:55 +0000 (UTC)
commit d585f49163c7e8bc1772affd648075fa8e628541
Author: Jonathan Matthew <jonathan d14n org>
Date: Tue Jul 13 15:08:02 2010 +1000
port jamendo plugin to gi, perhaps
plugins/jamendo/jamendo/JamendoConfigureDialog.py | 8 ++--
plugins/jamendo/jamendo/JamendoSaxHandler.py | 19 ++++----
plugins/jamendo/jamendo/JamendoSource.py | 53 +++++++++++----------
plugins/jamendo/jamendo/__init__.py | 33 +++++++------
4 files changed, 58 insertions(+), 55 deletions(-)
---
diff --git a/plugins/jamendo/jamendo/JamendoConfigureDialog.py b/plugins/jamendo/jamendo/JamendoConfigureDialog.py
index b6d160e..b4724c9 100644
--- a/plugins/jamendo/jamendo/JamendoConfigureDialog.py
+++ b/plugins/jamendo/jamendo/JamendoConfigureDialog.py
@@ -19,8 +19,8 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
import gobject
-import gtk
-import gconf, gnome
+
+from gi.repository import Gtk, GConf
gconf_keys = { 'format' : '/apps/rhythmbox/plugins/jamendo/format',
'sorting': '/apps/rhythmbox/plugins/jamendo/sorting'
@@ -29,9 +29,9 @@ format_list = ['ogg3', 'mp32']
class JamendoConfigureDialog (object):
def __init__(self, builder_file):
- self.gconf = gconf.client_get_default()
+ self.gconf = GConf.Client.get_default()
- builder = gtk.Builder()
+ builder = Gtk.Builder()
builder.add_from_file(builder_file)
self.dialog = builder.get_object('preferences_dialog')
diff --git a/plugins/jamendo/jamendo/JamendoSaxHandler.py b/plugins/jamendo/jamendo/JamendoSaxHandler.py
index 5818965..40f7b73 100644
--- a/plugins/jamendo/jamendo/JamendoSaxHandler.py
+++ b/plugins/jamendo/jamendo/JamendoSaxHandler.py
@@ -18,10 +18,11 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-import rhythmdb
import xml.sax, xml.sax.handler
import datetime
+from gi.repository import RhythmDB
+
data = {"artist" : ["name"],
"album" : ["name","id","releasedate","id3genre"],
"track" : ["name","id","numalbum","duration","id3genre"]}
@@ -74,17 +75,17 @@ class JamendoSaxHandler(xml.sax.handler.ContentHandler):
entry = self.__db.entry_lookup_by_location (track_url)
if entry == None:
entry = self.__db.entry_new(self.__entry_type, track_url)
- self.__db.set(entry, rhythmdb.PROP_ARTIST, self.__data["artist"]["name"])
- self.__db.set(entry, rhythmdb.PROP_ALBUM, self.__data["album"]["name"])
- self.__db.set(entry, rhythmdb.PROP_TITLE, self.__data["track"]["name"])
- self.__db.set(entry, rhythmdb.PROP_TRACK_NUMBER, int(self.__data["track"]["numalbum"]))
- self.__db.set(entry, rhythmdb.PROP_DATE, date)
- self.__db.set(entry, rhythmdb.PROP_GENRE, albumgenre)
- self.__db.set(entry, rhythmdb.PROP_DURATION, duration)
+ self.__db.set(entry, RhythmDB.PropType.ARTIST, self.__data["artist"]["name"])
+ self.__db.set(entry, RhythmDB.PropType.ALBUM, self.__data["album"]["name"])
+ self.__db.set(entry, RhythmDB.PropType.TITLE, self.__data["track"]["name"])
+ self.__db.set(entry, RhythmDB.PropType.TRACK_NUMBER, int(self.__data["track"]["numalbum"]))
+ self.__db.set(entry, RhythmDB.PropType.DATE, date)
+ self.__db.set(entry, RhythmDB.PropType.GENRE, albumgenre)
+ self.__db.set(entry, RhythmDB.PropType.DURATION, duration)
# slight misuse, but this is far more efficient than having a python dict
# containing this data.
- self.__db.set(entry, rhythmdb.PROP_MUSICBRAINZ_ALBUMID, self.__data["album"]["id"])
+ self.__db.set(entry, RhythmDB.PropType.MUSICBRAINZ_ALBUMID, self.__data["album"]["id"])
if self.__num_tracks % 1000 == 0:
self.__db.commit()
diff --git a/plugins/jamendo/jamendo/JamendoSource.py b/plugins/jamendo/jamendo/JamendoSource.py
index 007063d..1731fa3 100644
--- a/plugins/jamendo/jamendo/JamendoSource.py
+++ b/plugins/jamendo/jamendo/JamendoSource.py
@@ -21,18 +21,19 @@
# Parts from "Magnatune Rhythmbox plugin" (stolen from rhythmbox's MagnatuneSource.py)
# Copyright (C), 2006 Adam Zimmerman <adam_zimmerman sfu ca>
-import rb, rhythmdb
-from JamendoSaxHandler import JamendoSaxHandler
-import JamendoConfigureDialog
-
import os
import gobject
-import gtk
-import gnome, gconf
import xml
import gzip
import datetime
+from gi.repository import Gtk, Gdk, GConf
+from gi.repository import RB, RhythmDB
+import rb
+
+from JamendoSaxHandler import JamendoSaxHandler
+import JamendoConfigureDialog
+
# URIs
jamendo_song_info_uri = "http://img.jamendo.com/data/dbdump_artistalbumtrack.xml.gz"
@@ -52,14 +53,14 @@ ogg3_uri = "http://api.jamendo.com/get2/bittorrent/file/plain/?type=archive&clas
artwork_url = "http://api.jamendo.com/get2/image/album/redirect/?id=%s&imagesize=200"
artist_url = "http://www.jamendo.com/get/artist/id/album/page/plain/"
-class JamendoSource(rb.BrowserSource):
+class JamendoSource(RB.BrowserSource):
__gproperties__ = {
- 'plugin': (rb.Plugin, 'plugin', 'plugin', gobject.PARAM_WRITABLE|gobject.PARAM_CONSTRUCT_ONLY),
+ 'plugin': (RB.Plugin, 'plugin', 'plugin', gobject.PARAM_WRITABLE|gobject.PARAM_CONSTRUCT_ONLY),
}
def __init__(self):
- rb.BrowserSource.__init__(self, name=_("Jamendo"))
+ RB.BrowserSource.__init__(self, name=_("Jamendo"))
# catalogue stuff
self.__db = None
@@ -76,7 +77,7 @@ class JamendoSource(rb.BrowserSource):
self.__catalogue_loader = None
self.__catalogue_check = None
- self.__jamendo_dir = rb.find_user_cache_file("jamendo")
+ self.__jamendo_dir = RB.find_user_cache_file("jamendo")
if os.path.exists(self.__jamendo_dir) is False:
os.makedirs(self.__jamendo_dir, 0700)
@@ -99,7 +100,7 @@ class JamendoSource(rb.BrowserSource):
return False
def do_impl_pack_paned (self, paned):
- self.__paned_box = gtk.VBox(False, 5)
+ self.__paned_box = Gtk.VBox(False, 5)
self.pack_start(self.__paned_box)
self.__paned_box.pack_start(paned)
@@ -138,12 +139,12 @@ class JamendoSource(rb.BrowserSource):
self.__update_id = gobject.timeout_add_seconds(6 * 60 * 60, self.__update_catalogue)
self.__update_catalogue()
- sort_key = gconf.client_get_default().get_string(JamendoConfigureDialog.gconf_keys['sorting'])
+ sort_key = GConf.Client.get_default().get_string(JamendoConfigureDialog.gconf_keys['sorting'])
if not sort_key:
sort_key = "Artist,ascending"
self.get_entry_view().set_sorting_type(sort_key)
- rb.BrowserSource.do_impl_activate (self)
+ RB.BrowserSource.do_impl_activate (self)
def do_impl_delete_thyself(self):
if self.__update_id != 0:
@@ -162,8 +163,8 @@ class JamendoSource(rb.BrowserSource):
self.__catalogue_check.cancel()
self.__catalogue_check = None
- gconf.client_get_default().set_string(JamendoConfigureDialog.gconf_keys['sorting'], self.get_entry_view().get_sorting_type())
- rb.BrowserSource.do_impl_delete_thyself (self)
+ GConf.Client.get_default().set_string(JamendoConfigureDialog.gconf_keys['sorting'], self.get_entry_view().get_sorting_type())
+ RB.BrowserSource.do_impl_delete_thyself (self)
#
@@ -258,7 +259,7 @@ class JamendoSource(rb.BrowserSource):
def __show_loading_screen(self, show):
if self.__info_screen is None:
# load the builder stuff
- builder = gtk.Builder()
+ builder = Gtk.Builder()
builder.add_from_file(self.__plugin.find_file("jamendo-loading.ui"))
self.__info_screen = builder.get_object("jamendo_loading_scrolledwindow")
@@ -283,7 +284,7 @@ class JamendoSource(rb.BrowserSource):
# Download album
def download_album (self):
tracks = self.get_entry_view().get_selected_entries()
- format = gconf.client_get_default().get_string(JamendoConfigureDialog.gconf_keys['format'])
+ format = GConf.Client.get_default().get_string(JamendoConfigureDialog.gconf_keys['format'])
if not format or format not in JamendoConfigureDialog.format_list:
format = 'ogg3'
@@ -291,7 +292,7 @@ class JamendoSource(rb.BrowserSource):
#without any track selected
if len(tracks) == 1:
track = tracks[0]
- albumid = self.__db.entry_get(track, rhythmdb.PROP_MUSICBRAINZ_ALBUMID)
+ albumid = self.__db.entry_get(track, RhythmDB.PropType.MUSICBRAINZ_ALBUMID)
formats = {}
formats["mp32"] = mp32_uri + albumid
@@ -304,10 +305,10 @@ class JamendoSource(rb.BrowserSource):
def __download_p2plink (self, result, albumid):
if result is None:
emsg = _("Error looking up p2plink for album %s on jamendo.com") % (albumid)
- gtk.MessageDialog(None, 0, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, emsg).run()
+ Gtk.MessageDialog(None, 0, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, emsg).run()
return
- gtk.show_uri(self.props.shell.props.window.get_screen(), result, gtk.gdk.CURRENT_TIME)
+ Gtk.show_uri(self.props.shell.props.window.get_screen(), result, Gdk.CURRENT_TIME)
# Donate to Artist
def launch_donate (self):
@@ -318,8 +319,8 @@ class JamendoSource(rb.BrowserSource):
if len(tracks) == 1:
track = tracks[0]
# The Album ID can be used to lookup the artist, and issue a clean redirect.
- albumid = self.__db.entry_get(track, rhythmdb.PROP_MUSICBRAINZ_ALBUMID)
- artist = self.__db.entry_get(track, rhythmdb.PROP_ARTIST)
+ albumid = self.__db.entry_get(track, RhythmDB.PropType.MUSICBRAINZ_ALBUMID)
+ artist = self.__db.entry_get(track, RhythmDB.PropType.ARTIST)
url = artist_url + albumid.__str__() + "/"
l = rb.Loader()
@@ -328,9 +329,9 @@ class JamendoSource(rb.BrowserSource):
def __open_donate (self, result, artist):
if result is None:
emsg = _("Error looking up artist %s on jamendo.com") % (artist)
- gtk.MessageDialog(None, 0, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, emsg).run()
+ Gtk.MessageDialog(None, 0, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, emsg).run()
return
- gtk.show_uri(self.props.shell.props.window.get_screen(), result + "donate/", gtk.gdk.CURRENT_TIME)
+ Gtk.show_uri(self.props.shell.props.window.get_screen(), result + "donate/", Gdk.CURRENT_TIME)
def playing_entry_changed (self, entry):
if not self.__db or not entry:
@@ -342,8 +343,8 @@ class JamendoSource(rb.BrowserSource):
gobject.idle_add(self.emit_cover_art_uri, entry)
def emit_cover_art_uri (self, entry):
- stream = self.__db.entry_get (entry, rhythmdb.PROP_LOCATION)
- albumid = self.__db.entry_get (entry, rhythmdb.PROP_MUSICBRAINZ_ALBUMID)
+ stream = self.__db.entry_get (entry, RhythmDB.PropType.LOCATION)
+ albumid = self.__db.entry_get (entry, RhythmDB.PropType.MUSICBRAINZ_ALBUMID)
url = artwork_url % albumid
self.__db.emit_entry_extra_metadata_notify (entry, "rb:coverArt-uri", str(url))
diff --git a/plugins/jamendo/jamendo/__init__.py b/plugins/jamendo/jamendo/__init__.py
index eea0f75..1fee0b3 100644
--- a/plugins/jamendo/jamendo/__init__.py
+++ b/plugins/jamendo/jamendo/__init__.py
@@ -29,13 +29,14 @@
# Parts from "Magnatune Rhythmbox plugin" (stolen from rhythmbox's __init__.py)
# Copyright (C), 2006 Adam Zimmerman <adam_zimmerman sfu ca>
-import rhythmdb, rb
import gobject
-import gtk
from JamendoSource import JamendoSource
from JamendoConfigureDialog import JamendoConfigureDialog
+from gi.repository import Gtk
+from gi.repository import RB
+
popup_ui = """
<ui>
<popup name="JamendoSourceViewPopup">
@@ -53,13 +54,13 @@ popup_ui = """
"""
-class Jamendo(rb.Plugin):
+class Jamendo(RB.Plugin):
#
# Core methods
#
def __init__(self):
- rb.Plugin.__init__(self)
+ RB.Plugin.__init__(self)
def activate(self, shell):
self.db = shell.get_property("db")
@@ -69,13 +70,13 @@ class Jamendo(rb.Plugin):
self.entry_type.can_sync_metadata = True
self.entry_type.sync_metadata = None
- theme = gtk.icon_theme_get_default()
- rb.append_plugin_source_path(theme, "/icons/")
+ theme = Gtk.icon_theme_get_default()
+ RB.append_plugin_source_path(theme, "/icons/")
- width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_LARGE_TOOLBAR)
- icon = rb.try_load_icon(theme, "jamendo", width, 0)
+ width, height = Gtk.icon_size_lookup(Gtk.IconSize.LARGE_TOOLBAR)
+ icon = RB.try_load_icon(theme, "jamendo", width, 0)
- group = rb.rb_source_group_get_by_name ("stores")
+ group = RB.rb_source_group_get_by_name ("stores") # RB.SourceGroup.get_by_name()?
self.source = gobject.new (JamendoSource,
shell=shell,
entry_type=self.entry_type,
@@ -87,17 +88,17 @@ class Jamendo(rb.Plugin):
# Add button
manager = shell.get_player().get_property('ui-manager')
- action = gtk.Action('JamendoDownloadAlbum', _('_Download Album'),
- _("Download this album using BitTorrent"),
- 'gtk-save')
+ action = Gtk.Action(name='JamendoDownloadAlbum', label=_('_Download Album'),
+ tooltip=_("Download this album using BitTorrent"),
+ stock='gtk-save')
action.connect('activate', lambda a: shell.get_property("selected-source").download_album())
- self.action_group = gtk.ActionGroup('JamendoPluginActions')
+ self.action_group = Gtk.ActionGroup(label='JamendoPluginActions')
self.action_group.add_action(action)
# Add Button for Donate
- action = gtk.Action('JamendoDonateArtist', _('_Donate to Artist'),
- _("Donate Money to this Artist"),
- 'gtk-jump-to')
+ action = Gtk.Action(name='JamendoDonateArtist', label=_('_Donate to Artist'),
+ tooltip=_("Donate Money to this Artist"),
+ stock='gtk-jump-to')
action.connect('activate', lambda a: shell.get_property("selected-source").launch_donate())
self.action_group.add_action(action)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]