~ubuntu-branches/ubuntu/oneiric/rhythmbox/oneiric

« back to all changes in this revision

Viewing changes to plugins/replaygain/config.py

  • Committer: Bazaar Package Importer
  • Author(s): Rico Tzschichholz
  • Date: 2011-07-29 16:41:38 UTC
  • mto: This revision was merged to the branch mainline in revision 191.
  • Revision ID: james.westby@ubuntu.com-20110729164138-wwicy8nqalm18ck7
Tags: upstream-2.90.1~20110802
ImportĀ upstreamĀ versionĀ 2.90.1~20110802

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- Mode: python; coding: utf-8; tab-width: 8; indent-tabs-mode: t; -*-
 
2
#
 
3
# Copyright (C) 2010 Jonathan Matthew
 
4
#
 
5
# This program is free software; you can redistribute it and/or modify
 
6
# it under the terms of the GNU General Public License as published by
 
7
# the Free Software Foundation; either version 2, or (at your option)
 
8
# any later version.
 
9
#
 
10
# The Rhythmbox authors hereby grant permission for non-GPL compatible
 
11
# GStreamer plugins to be used and distributed together with GStreamer
 
12
# and Rhythmbox. This permission is above and beyond the permissions granted
 
13
# by the GPL license by which Rhythmbox is covered. If you modify this code
 
14
# you may extend this exception to your version of the code, but you are not
 
15
# obligated to do so. If you do not wish to do so, delete this exception
 
16
# statement from your version.
 
17
#
 
18
# This program is distributed in the hope that it will be useful,
 
19
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
20
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
21
# GNU General Public License for more details.
 
22
#
 
23
# You should have received a copy of the GNU General Public License
 
24
# along with this program; if not, write to the Free Software
 
25
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA.
 
26
#
 
27
 
 
28
import rb
 
29
from gi.repository import Gtk, Gio, GObject, PeasGtk
 
30
from gi.repository import RB
 
31
 
 
32
# modes
 
33
REPLAYGAIN_MODE_RADIO = 0
 
34
REPLAYGAIN_MODE_ALBUM = 1
 
35
 
 
36
# number of samples to keep for calculating the average gain
 
37
# to apply for tracks that aren't tagged
 
38
AVERAGE_GAIN_SAMPLES = 10
 
39
 
 
40
class ReplayGainConfig(GObject.Object, PeasGtk.Configurable):
 
41
        __gtype_name__ = 'ReplayGainConfig'
 
42
        object = GObject.property(type=GObject.Object)
 
43
 
 
44
        def do_create_configure_widget(self):
 
45
                self.settings = Gio.Settings("org.gnome.rhythmbox.plugins.replaygain")
 
46
 
 
47
                ui_file = rb.find_plugin_file(self, "replaygain-prefs.ui")
 
48
                self.builder = Gtk.Builder()
 
49
                self.builder.add_from_file(ui_file)
 
50
 
 
51
                content = self.builder.get_object("replaygain-prefs")
 
52
 
 
53
                label = self.builder.get_object("headerlabel")
 
54
                label.set_markup("<b>%s</b>" % label.get_text())
 
55
                label.set_use_markup(True)
 
56
 
 
57
                combo = self.builder.get_object("replaygainmode")
 
58
                combo.props.id_column = 1
 
59
                self.settings.bind("mode", combo, "active-id", Gio.SettingsBindFlags.DEFAULT)
 
60
 
 
61
                preamp = self.builder.get_object("preamp")
 
62
                self.settings.bind("preamp", preamp.props.adjustment, "value", Gio.SettingsBindFlags.GET)
 
63
                preamp.connect("value-changed", self.preamp_changed_cb)
 
64
 
 
65
                preamp.add_mark(-15.0, Gtk.PositionType.BOTTOM, _("-15.0 dB"))
 
66
                preamp.add_mark(0.0, Gtk.PositionType.BOTTOM, _("0.0 dB"))
 
67
                preamp.add_mark(15.0, Gtk.PositionType.BOTTOM, _("15.0 dB"))
 
68
 
 
69
                limiter = self.builder.get_object("limiter")
 
70
                self.settings.bind("limiter", limiter, "active", Gio.SettingsBindFlags.DEFAULT)
 
71
 
 
72
                return content
 
73
 
 
74
        def preamp_changed_cb(self, preamp):
 
75
                RB.settings_delayed_sync(self.settings, self.sync_preamp, preamp)
 
76
 
 
77
        def sync_preamp(self, settings, preamp):
 
78
                v = preamp.get_value()
 
79
                print "preamp gain changed to %f" % v
 
80
                settings['preamp'] = v
 
81
 
 
82
GObject.type_register(ReplayGainConfig)