3 # This file is part of jack_mixer
5 # Copyright (C) 2006 Nedko Arnaudov <nedko@arnaudov.name>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; version 2 of the License
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
25 class widget(gtk.EventBox):
27 gtk.EventBox.__init__(self)
28 self.label = gtk.Label()
29 attrs = pango.AttrList()
30 font_attr = pango.AttrFamily("monospace")
31 attrs.insert(font_attr)
32 self.label.set_attributes(attrs)
34 self.connect("button-press-event", self.on_mouse)
35 self.peak = fpconst.NegInf
37 def on_mouse(self, widget, event):
38 if event.type == gtk.gdk.BUTTON_PRESS:
41 elif event.button == 2:
43 if abs(adjust) < 30: # we better don't adjust more than +- 30 dB
44 self.emit("volume-adjust", adjust)
46 def set_peak(self, peak):
48 if fpconst.isNaN(peak):
49 self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(int(65535 * 0.7), 0, 0))
50 self.label.set_text("NaN")
55 self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(int(65535 * 0.8), int(65535 * 0.3), 0))
57 self.modify_bg(gtk.STATE_NORMAL, self.label.style.bg[gtk.STATE_NORMAL])
59 self.label.set_text(text)
61 gobject.signal_new("reset", widget, gobject.SIGNAL_RUN_FIRST | gobject.SIGNAL_ACTION, gobject.TYPE_NONE, [])
62 gobject.signal_new("volume-adjust", widget, gobject.SIGNAL_RUN_FIRST | gobject.SIGNAL_ACTION, gobject.TYPE_NONE, [gobject.TYPE_FLOAT])