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.
20 from gi
.repository
import Gtk
21 from gi
.repository
import Gdk
22 from gi
.repository
import GObject
25 class AbspeakWidget(Gtk
.EventBox
):
28 self
.label
= Gtk
.Label()
30 self
.connect("button-press-event", self
.on_mouse
)
33 def get_style_context(self
):
34 return self
.label
.get_style_context()
36 def on_mouse(self
, widget
, event
):
37 if event
.type == Gdk
.EventType
.BUTTON_PRESS
:
38 if event
.button
== 1 or event
.button
== 2 or event
.button
== 3:
39 context
= self
.get_style_context()
40 context
.remove_class("over_zero")
41 context
.remove_class("is_nan")
43 if event
.button
== 1 or event
.button
== 3:
45 elif event
.button
== 2:
48 if abs(adjust
) < 30: # we better don't adjust more than +- 30 dB
49 self
.emit("volume-adjust", adjust
)
51 def set_peak(self
, peak
):
53 context
= self
.get_style_context()
56 context
.remove_class("over_zero")
57 context
.add_class("is_nan")
58 self
.label
.set_text("NaN")
61 context
.remove_class("is_nan")
64 context
.add_class("over_zero")
66 self
.label
.set_text(text
)
70 "reset", AbspeakWidget
, GObject
.SignalFlags
.RUN_FIRST | GObject
.SignalFlags
.ACTION
, None, []
75 GObject
.SignalFlags
.RUN_FIRST | GObject
.SignalFlags
.ACTION
,