[rhythmbox] Port ReplayGain plugin to GI



commit 12e9bc0180b40be9d4108a50061a9e8ef879b8e3
Author: Jonathan Matthew <jonathan d14n org>
Date:   Fri Feb 4 23:14:50 2011 +1000

    Port ReplayGain plugin to GI

 plugins/replaygain/replaygain/__init__.py |    5 +++--
 plugins/replaygain/replaygain/config.py   |   23 ++++++++++++-----------
 plugins/replaygain/replaygain/player.py   |   17 +++++++++--------
 3 files changed, 24 insertions(+), 21 deletions(-)
---
diff --git a/plugins/replaygain/replaygain/__init__.py b/plugins/replaygain/replaygain/__init__.py
index 32563f8..8ad9ebb 100644
--- a/plugins/replaygain/replaygain/__init__.py
+++ b/plugins/replaygain/replaygain/__init__.py
@@ -26,14 +26,15 @@
 #
 
 import rb
+from gi.repository import RB
 
 from config import ReplayGainConfigDialog
 from player import ReplayGainPlayer
 
-class ReplayGainPlugin(rb.Plugin):
+class ReplayGainPlugin(RB.Plugin):
 
 	def __init__ (self):
-		rb.Plugin.__init__ (self)
+		RB.Plugin.__init__ (self)
 		self.config_dialog = None
 
 	def activate (self, shell):
diff --git a/plugins/replaygain/replaygain/config.py b/plugins/replaygain/replaygain/config.py
index adab6aa..e4c2710 100644
--- a/plugins/replaygain/replaygain/config.py
+++ b/plugins/replaygain/replaygain/config.py
@@ -26,9 +26,10 @@
 #
 
 import gobject
-import gtk
-import gconf
-import rhythmdb, rb
+import rb
+from gi.repository import Gtk
+from gi.repository import GConf
+from gi.repository import RB
 
 GCONF_DIR = '/apps/rhythmbox/plugins/replaygain'
 
@@ -46,21 +47,21 @@ REPLAYGAIN_MODE_ALBUM = 1
 # to apply for tracks that aren't tagged
 AVERAGE_GAIN_SAMPLES = 10
 
-class ReplayGainConfigDialog(gtk.Dialog):
+class ReplayGainConfigDialog(Gtk.Dialog):
 	def __init__(self, plugin):
-		gtk.Dialog.__init__(self)
+		Gtk.Dialog.__init__(self)
 		self.set_border_width(12)
 
-		self.gconf = gconf.client_get_default()
+		self.gconf = GConf.Client.get_default()
 
 		ui_file = plugin.find_file("replaygain-prefs.ui")
-		self.builder = gtk.Builder()
+		self.builder = Gtk.Builder()
 		self.builder.add_from_file(ui_file)
 
 		content = self.builder.get_object("replaygain-prefs")
 		self.get_content_area().add(content)
 
-		self.add_action_widget(gtk.Button(stock=gtk.STOCK_CLOSE), 0)
+		self.add_action_widget(Gtk.Button(stock=Gtk.STOCK_CLOSE), 0)
 		self.show_all()
 
 		label = self.builder.get_object("headerlabel")
@@ -75,9 +76,9 @@ class ReplayGainConfigDialog(gtk.Dialog):
 		preamp.set_value(self.gconf.get_float(GCONF_KEYS['preamp']))
 		preamp.connect("value-changed", self.preamp_changed_cb)
 
-		preamp.add_mark(-15.0, gtk.POS_BOTTOM, _("-15.0 dB"))
-		preamp.add_mark(0.0, gtk.POS_BOTTOM, _("0.0 dB"))
-		preamp.add_mark(15.0, gtk.POS_BOTTOM, _("15.0 dB"))
+		preamp.add_mark(-15.0, Gtk.PositionType.BOTTOM, _("-15.0 dB"))
+		preamp.add_mark(0.0, Gtk.PositionType.BOTTOM, _("0.0 dB"))
+		preamp.add_mark(15.0, Gtk.PositionType.BOTTOM, _("15.0 dB"))
 
 		limiter = self.builder.get_object("limiter")
 		limiter.set_active(self.gconf.get_bool(GCONF_KEYS['limiter']))
diff --git a/plugins/replaygain/replaygain/player.py b/plugins/replaygain/replaygain/player.py
index fac3aa7..4106220 100644
--- a/plugins/replaygain/replaygain/player.py
+++ b/plugins/replaygain/replaygain/player.py
@@ -25,11 +25,12 @@
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA.
 #
 
-import gtk
-import gconf
-import gst
 import gobject
-import rhythmdb, rb
+import gst
+
+import rb
+from gi.repository import GConf
+from gi.repository import RB
 
 import config
 
@@ -46,15 +47,15 @@ class ReplayGainPlayer(object):
 
 		if len(missing) > 0:
 			msg = _("The GStreamer elements required for ReplayGain processing are not available. The missing elements are: %s") % ", ".join(missing)
-			rb.error_dialog(shell.props.window, _("ReplayGain GStreamer plugins not available"), msg)
+			RB.error_dialog(shell.props.window, _("ReplayGain GStreamer plugins not available"), msg)
 			raise Exception(msg)
 
 		self.shell_player = shell.props.shell_player
 		self.player = self.shell_player.props.player
-		self.gconf = gconf.client_get_default()
+		self.gconf = GConf.Client.get_default()
 
-		self.gconf.add_dir(config.GCONF_DIR, preload=False)
-		self.gconf.notify_add(config.GCONF_KEYS['limiter'], self.limiter_changed_cb)
+		self.gconf.add_dir(config.GCONF_DIR, GConf.ClientPreloadType.PRELOAD_NONE)
+		self.gconf.notify_add(config.GCONF_KEYS['limiter'], self.limiter_changed_cb, None)
 
 		self.previous_gain = []
 		self.fallback_gain = 0.0



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