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
27 background-color: #cc4c00;
31 background-color: #b20000;
34 css_provider = Gtk.CssProvider()
35 css_provider.load_from_data(CSS)
36 context = Gtk.StyleContext()
37 screen = Gdk.Screen.get_default()
38 context.add_provider_for_screen(screen, css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
41 class AbspeakWidget(Gtk.EventBox):
44 self.label = Gtk.Label()
46 self.connect("button-press-event", self.on_mouse)
49 def get_style_context(self):
50 return self.label.get_style_context()
52 def on_mouse(self, widget, event):
53 if event.type == Gdk.EventType.BUTTON_PRESS:
54 if event.button == 1 or event.button == 2 or event.button == 3:
55 context = self.get_style_context()
56 context.remove_class('over_zero')
57 context.remove_class('is_nan')
59 if event.button == 1 or event.button == 3:
61 elif event.button == 2:
64 if abs(adjust) < 30: # we better don't adjust more than +- 30 dB
65 self.emit("volume-adjust", adjust)
67 def set_peak(self, peak):
69 context = self.get_style_context()
72 context.remove_class('over_zero')
73 context.add_class('is_nan')
74 self.label.set_text("NaN")
77 context.remove_class('is_nan')
80 context.add_class('over_zero')
82 self.label.set_text(text)
85 GObject.signal_new("reset", AbspeakWidget,
86 GObject.SignalFlags.RUN_FIRST | GObject.SignalFlags.ACTION, None, [])
87 GObject.signal_new("volume-adjust", AbspeakWidget,
88 GObject.SignalFlags.RUN_FIRST | GObject.SignalFlags.ACTION, None,