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