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;
76 button.prefader_meter {
82 button.prefader:hover,
83 button.prefader_meter:hover,
84 button.monitor:checked,
87 button.prefader:checked,
88 button.prefader_meter:checked {
91 background-image: none;
93 button.monitor:hover {
94 background-color: @monitor_bgcolor_hover;
96 button.monitor:checked {
97 background-color: @monitor_bgcolor_checked;
100 background-color: @mute_bgcolor_hover;
102 button.mute:checked {
103 background-color: @mute_bgcolor_checked;
106 background-color: @solo_bgcolor_hover;
108 button.solo:checked {
109 background-color: @solo_bgcolor_checked;
111 button.prefader:hover {
112 background-color: @prefader_bgcolor_hover;
114 button.prefader:checked {
115 background-color: @prefader_bgcolor_checked;
117 button.prefader_meter:hover {
118 background-color: @prefader_bgcolor_hover;
120 button.prefader_meter:checked {
121 background-color: @prefader_bgcolor_checked;
132 .control_group .label,
133 .control_group .mute,
134 .control_group .prefader,
135 .control_group .solo {
140 .control_group .mute:hover,
141 .control_group .solo:hover,
142 .control_group .prefader:hover,
143 .control_group .mute:checked,
144 .control_group .solo:checked,
145 .control_group .prefader:checked {
148 background-image: none;
150 .control_group .mute:hover {
151 background-color: @mute_bgcolor_hover;
153 .control_group .mute:checked {
154 background-color:@mute_bgcolor_checked;
156 .control_group .solo:hover {
157 background-color: @solo_bgcolor_hover;
159 .control_group .solo:checked {
160 background-color: @solo_bgcolor_checked;
162 .control_group .prefader:hover {
163 background-color: @prefader_bgcolor_hover;
165 .control_group .prefader:checked {
166 background-color: @prefader_bgcolor_checked;
173 background-color: #cc4c00;
177 background-color: #b20000;
181 COLOR_TMPL_CSS
= """\
183 background-color: {};
189 def add_css_provider(css
, priority
=Gtk
.STYLE_PROVIDER_PRIORITY_APPLICATION
):
190 css_provider
= Gtk
.CssProvider()
191 css_provider
.load_from_data(css
.encode("utf-8"))
192 context
= Gtk
.StyleContext()
193 screen
= Gdk
.Screen
.get_default()
194 context
.add_provider_for_screen(screen
, css_provider
, priority
)
197 def get_text_color(background_color
):
198 """Calculate the luminance of the given color (GdkRGBA)
199 and return an appropriate text color."""
200 # luminance coefficients taken from section C-9 from
201 # http://www.faqs.org/faqs/graphics/colorspace-faq/
203 background_color
.red
* 0.212671
204 + background_color
.green
* 0.715160
205 + background_color
.blue
* 0.072169
214 def load_css_styles():
215 add_css_provider(DEFAULT_CSS
)
218 def set_background_color(widget
, name
, color
):
219 color_string
= color
.to_string()
220 add_css_provider(COLOR_TMPL_CSS
.format(name
, color_string
, get_text_color(color
)))
221 widget_context
= widget
.get_style_context()
222 widget_context
.add_class(name
)
226 return Gdk
.RGBA(random(), random(), random(), 1)