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.
18 from gi
.repository
import Gtk
19 from gi
.repository
import Gdk
20 from gi
.repository
import Pango
21 from gi
.repository
import GObject
24 class AbspeakWidget(Gtk
.EventBox
):
26 GObject
.GObject
.__init
__(self
)
27 self
.label
= Gtk
.Label()
28 #attrs = Pango.AttrList()
29 #font_attr = Pango.AttrFamily("monospace")
30 #attrs.insert(font_attr)
31 #self.label.set_attributes(attrs)
33 self
.connect("button-press-event", self
.on_mouse
)
36 def on_mouse(self
, widget
, event
):
37 if event
.type == Gdk
.EventType
.BUTTON_PRESS
:
40 elif event
.button
== 2:
42 if abs(adjust
) < 30: # we better don't adjust more than +- 30 dB
43 self
.emit("volume-adjust", adjust
)
45 def set_peak(self
, peak
):
48 self
.modify_bg(Gtk
.StateType
.NORMAL
, Gdk
.Color(int(65535 * 0.7), 0, 0))
49 self
.label
.set_text("NaN")
54 self
.modify_bg(Gtk
.StateType
.NORMAL
, Gdk
.Color(int(65535 * 0.8), int(65535 * 0.3), 0))
57 #self.modify_bg(Gtk.StateType.NORMAL, self.label.style.bg[Gtk.StateType.NORMAL])
59 self
.label
.set_text(text
)
61 GObject
.signal_new("reset", AbspeakWidget
,
62 GObject
.SignalFlags
.RUN_FIRST | GObject
.SignalFlags
.ACTION
, None, [])
63 GObject
.signal_new("volume-adjust", AbspeakWidget
,
64 GObject
.SignalFlags
.RUN_FIRST | GObject
.SignalFlags
.ACTION
, None, [GObject
.TYPE_FLOAT
])