1 # This file is part of jack_mixer
3 # Copyright (C) 2006-2009 Nedko Arnaudov <nedko@arnaudov.name>
4 # Copyright (C) 2009-2020 Frederic Peters <fpeters@0d.be> et al.
5 # Copyright (C) 2020-2021 Christopher Arndt <info@chrisarndt>
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.
20 from random
import random
22 import gi
# noqa: F401
23 from gi
.repository
import Gtk
24 from gi
.repository
import Gdk
29 /* Global color definitions */
31 @define-color monitor_bgcolor_hover #C0BFBC;
32 @define-color monitor_bgcolor_checked #9A9996;
33 @define-color mute_bgcolor_hover #FFBC80;
34 @define-color mute_bgcolor_checked #FF7800;
35 @define-color solo_bgcolor_hover #76A28E;
36 @define-color solo_bgcolor_checked #26A269;
37 @define-color prefader_bgcolor_hover #A6C2E4;
38 @define-color prefader_bgcolor_checked #3584E4;
57 border: 1px inset #111;
64 border: 1px inset #111;
66 background-color: #333;
67 background-image: none;
79 button.monitor:checked,
84 background-image: none;
86 button.monitor:hover {
87 background-color: @monitor_bgcolor_hover;
89 button.monitor:checked {
90 background-color: @monitor_bgcolor_checked;
93 background-color: @mute_bgcolor_hover;
96 background-color: @mute_bgcolor_checked;
99 background-color: @solo_bgcolor_hover;
101 button.solo:checked {
102 background-color: @solo_bgcolor_checked;
113 .control_group .label,
114 .control_group .mute,
115 .control_group .prefader,
116 .control_group .solo {
121 .control_group .mute:hover,
122 .control_group .solo:hover,
123 .control_group .prefader:hover,
124 .control_group .mute:checked,
125 .control_group .solo:checked,
126 .control_group .prefader:checked {
129 background-image: none;
131 .control_group .mute:hover {
132 background-color: @mute_bgcolor_hover;
134 .control_group .mute:checked {
135 background-color:@mute_bgcolor_checked;
137 .control_group .solo:hover {
138 background-color: @solo_bgcolor_hover;
140 .control_group .solo:checked {
141 background-color: @solo_bgcolor_checked;
143 .control_group .prefader:hover {
144 background-color: @prefader_bgcolor_hover;
146 .control_group .prefader:checked {
147 background-color: @prefader_bgcolor_checked;
154 background-color: #cc4c00;
158 background-color: #b20000;
162 COLOR_TMPL_CSS
= """\
164 background-color: {};
170 def add_css_provider(css
, priority
=Gtk
.STYLE_PROVIDER_PRIORITY_APPLICATION
):
171 css_provider
= Gtk
.CssProvider()
172 css_provider
.load_from_data(css
.encode("utf-8"))
173 context
= Gtk
.StyleContext()
174 screen
= Gdk
.Screen
.get_default()
175 context
.add_provider_for_screen(screen
, css_provider
, priority
)
178 def get_text_color(background_color
):
179 """Calculate the luminance of the given color (GdkRGBA)
180 and return an appropriate text color."""
181 # luminance coefficients taken from section C-9 from
182 # http://www.faqs.org/faqs/graphics/colorspace-faq/
184 background_color
.red
* 0.212671
185 + background_color
.green
* 0.715160
186 + background_color
.blue
* 0.072169
195 def load_css_styles():
196 add_css_provider(DEFAULT_CSS
)
199 def set_background_color(widget
, name
, color
):
200 color_string
= color
.to_string()
201 add_css_provider(COLOR_TMPL_CSS
.format(name
, color_string
, get_text_color(color
)))
202 widget_context
= widget
.get_style_context()
203 widget_context
.add_class(name
)
207 return Gdk
.RGBA(random(), random(), random(), 1)