Skip to content

Commit 9b470eb

Browse files
authored
Add gnome-shell theme for mamolinux (#17)
- Copy from yaru - Modify panel to provide different colours in panel
1 parent d3f6eda commit 9b470eb

File tree

221 files changed

+11233
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

221 files changed

+11233
-5
lines changed

Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
SHELL:=/bin/bash
22

3-
all: clean buildthemes buildplankthemes
3+
all: buildthemes buildplankthemes
44

55
buildthemes:
66
@echo "Building desktop themes"
77
python3 generate-themes.py All
8+
@wait
89

910
buildplankthemes:
1011
@echo "Building plank themes"

common/accent-colors.scss.in

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
@function get_accent_color($accent_color, $is_dark: false) {
2+
$color: null;
3+
@if $accent_color == 'default' {
4+
$color: #0e8420;
5+
} @else if $accent_color == 'aqua' {
6+
$color: #6cabcd;
7+
} @else if $accent_color == 'blue' {
8+
$color: #5b73c4;
9+
} @else if $accent_color == 'brown' {
10+
$color: #aa876a;
11+
} @else if $accent_color == 'grey' {
12+
$color: #9d9d9d;
13+
} @else if $accent_color == 'orange' {
14+
$color: #E95420;
15+
} @else if $accent_color == 'pink' {
16+
$color: #c76199;
17+
} @else if $accent_color == 'purple' {
18+
$color: #8c6ec9;
19+
} @else if $accent_color == 'red' {
20+
$color: #DA3450;
21+
} @else if $accent_color == 'sand' {
22+
$color: #c8ac69;
23+
} @else if $accent_color == 'teal' {
24+
$color: #5aaa9a;
25+
} @else {
26+
@error('No known accent color defined!');
27+
}
28+
@debug('Using accent color ' + $accent_color + ': ' + $color);
29+
@return $color;
30+
}
31+
32+
$yaru_is_dark_variant: @yaru_dark_variant@;
33+
$yaru_accent_bg_color: get_accent_color('@yaru_accent_color@', $yaru_is_dark_variant);
34+
$accent_bg_color: $yaru_accent_bg_color;
35+
$accent_color: $yaru_accent_bg_color;
36+
@debug("Accent color is " + $yaru_accent_bg_color);
37+
38+
@import '@yaru_theme_entry_point@'

common/colorize-dummy-svg.py

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/usr/bin/env python3
2+
# Copyright © 2022, Canonical Ltd
3+
#
4+
# This program is free software; you can redistribute it and/or
5+
# modify it under the terms of the GNU Lesser General Public
6+
# License as published by the Free Software Foundation; either
7+
# version 2.1 of the License, or (at your option) any later version.
8+
#
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 GNU
12+
# Lesser General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU Lesser General Public
15+
# License along with this library. If not, see <http://www.gnu.org/licenses/>.
16+
# Authors:
17+
# Marco Trevisan <marco.trevisan@canonical.com>
18+
19+
import argparse
20+
import fnmatch
21+
import os
22+
23+
from glob import glob
24+
25+
# Keep this in sync with yaru-colors-defs.scss, or the input CSS in use.
26+
DUMMY_COLORS = {
27+
'accent-bg-color': '#00ff01',
28+
'accent-active-color': '#00ff02',
29+
'accent-border-color': '#ff0001',
30+
'accent-focused-color': '#0101ff',
31+
'bg-color': '#ffff00',
32+
'border-color': '#ff00ff',
33+
'disabled-bg-color': '#ffff02',
34+
'switch-bg-color': '#ffff01',
35+
'check-bg-color': '#ffff03',
36+
}
37+
38+
def read_colors_replacements(css_file):
39+
colors_replacements = {}
40+
41+
for l in css_file.readlines():
42+
for line in l.split('//')[0].split(';'):
43+
if '-yaru-' not in line:
44+
continue
45+
46+
[named_color, color] = line.split('-yaru-', 1)[-1].split(': ')
47+
colors_replacements[DUMMY_COLORS[named_color]] = color
48+
print(named_color, color, f'(replaces {DUMMY_COLORS[named_color]})')
49+
50+
return colors_replacements
51+
52+
def replace_colors(svg, replacements, output_folder, variant):
53+
with open(svg, 'r') as f:
54+
contents = f.read()
55+
for dummy, color in replacements.items():
56+
contents = contents.replace(dummy, color)
57+
58+
output_folder = os.path.abspath(output_folder)
59+
basename = os.path.basename(svg).rsplit('.', 1)[0]
60+
finalname = f'{basename}-{variant}.svg' if variant else f'{basename}.svg'
61+
output_path = os.path.join(output_folder, finalname)
62+
print(f'Processing {os.path.basename(svg)} => {output_path}')
63+
64+
os.makedirs(output_folder, exist_ok=True)
65+
with open(output_path, 'w') as out:
66+
out.write(contents)
67+
68+
if __name__ == '__main__':
69+
parser = argparse.ArgumentParser()
70+
parser.add_argument('yaru_colors_defs_scss', type=argparse.FileType('r'))
71+
parser.add_argument('--input-file', default=None)
72+
parser.add_argument('--assets-path', default='.')
73+
parser.add_argument('--output-folder', default='.')
74+
parser.add_argument('--variant', default=None)
75+
parser.add_argument('--filter', action='append', default=[])
76+
parser.add_argument('--exclude', action='append', default=[])
77+
78+
args = parser.parse_args()
79+
replacements = read_colors_replacements(args.yaru_colors_defs_scss)
80+
variant = None if args.variant == 'default' else args.variant
81+
82+
if args.input_file:
83+
replace_colors(args.input_file, replacements,
84+
args.output_folder, variant)
85+
else:
86+
for svg in glob(os.path.join(os.path.abspath(args.assets_path), '*.svg')):
87+
if [fl for fl in args.exclude if fnmatch.fnmatch(svg, fl)]:
88+
continue
89+
90+
if args.filter and not [fl for fl in args.filter if fnmatch.fnmatch(svg, fl)]:
91+
continue
92+
93+
replace_colors(svg, replacements, args.output_folder, variant)

common/meson.build

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
colorize_dummy_svg = find_program('colorize-dummy-svg.py')
2+
accent_colors_definitions_scss = meson.project_source_root() / '@0@'.format(files('accent-colors.scss.in')[0])
3+
yaru_colors_defs_scss = meson.project_source_root() / '@0@'.format(files('yaru-colors-defs.scss')[0])
4+
5+
sass_utils_scss = files([
6+
'sass-utils.scss',
7+
])
8+
9+
test('sass-utils',
10+
sassc,
11+
args: [
12+
files('test-sass-utils.scss'),
13+
'/dev/null',
14+
])

common/sass-utils.scss

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
// Copyright © 2022, Canonical Ltd
2+
//
3+
// This program is free software; you can redistribute it and/or
4+
// modify it under the terms of the GNU Lesser General Public
5+
// License as published by the Free Software Foundation; either
6+
// version 2.1 of the License, or (at your option) any later version.
7+
//
8+
// This program is distributed in the hope that it will be useful,
9+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+
// Lesser General Public License for more details.
12+
//
13+
// You should have received a copy of the GNU Lesser General Public
14+
// License along with this library. If not, see <http://www.gnu.org/licenses/>.
15+
// Authors:
16+
// Marco Trevisan <marco.trevisan@canonical.com>
17+
18+
@function str-contains($str, $substring) {
19+
@return str-index($str, $substring) != null;
20+
}
21+
22+
@function str-starts-with($str, $substring) {
23+
@return str-index($str, $substring) == 1;
24+
}
25+
26+
@function str-ends-with($str, $substring) {
27+
$index: str-index($str, $substring);
28+
@if ($index == null) {
29+
@return false;
30+
}
31+
32+
@return ($index + str-length($substring) - 1) == str-length($str);
33+
}
34+
35+
@function str-basename($str, $divider: '/') {
36+
$index: str-index($str, $divider);
37+
38+
@while $index != null {
39+
$str: str-slice($str, $index + 1);
40+
$index: str-index($str, $divider);
41+
}
42+
43+
@return $str;
44+
}
45+
46+
@function str-extension($str) {
47+
$extension: str-basename($str, '.');
48+
@return if($extension == $str, null, $extension);
49+
}
50+
51+
@function str-dirname($str, $divider: '/') {
52+
$str_copy: $str;
53+
$index: str-index($str, $divider);
54+
$last_index: null;
55+
56+
@while $index != null {
57+
$str: str-slice($str, $index + 1);
58+
$last_index: if($last_index, $last_index, 0) + $index;
59+
$index: str-index($str, $divider);
60+
}
61+
62+
@return if($last_index, str-slice($str_copy, 1, $last_index - 1), '.');
63+
}
64+
65+
@function list-length($list) {
66+
$i: 0;
67+
@each $e in $list {
68+
$i: $i + 1;
69+
}
70+
71+
@return $i;
72+
}
73+
74+
@function list-nth($list, $nth) {
75+
$i: 0;
76+
77+
@if $nth < 0 {
78+
$nth: list-length($list) + $nth;
79+
}
80+
81+
@each $e in $list {
82+
@if ($i == $nth) {
83+
@return $e;
84+
}
85+
86+
$i: $i + 1;
87+
}
88+
89+
@return null;
90+
}
91+
92+
@function list-index($list, $item) {
93+
$i: 0;
94+
@each $e in $list {
95+
@if ($e == $item) {
96+
@return $i;
97+
}
98+
99+
$i: $i + 1;
100+
}
101+
102+
@return null;
103+
}

common/test-sass-utils.scss

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
// Copyright © 2022, Canonical Ltd
2+
//
3+
// This program is free software; you can redistribute it and/or
4+
// modify it under the terms of the GNU Lesser General Public
5+
// License as published by the Free Software Foundation; either
6+
// version 2.1 of the License, or (at your option) any later version.
7+
//
8+
// This program is distributed in the hope that it will be useful,
9+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+
// Lesser General Public License for more details.
12+
//
13+
// You should have received a copy of the GNU Lesser General Public
14+
// License along with this library. If not, see <http://www.gnu.org/licenses/>.
15+
// Authors:
16+
// Marco Trevisan <marco.trevisan@canonical.com>
17+
18+
@import 'sass-utils';
19+
20+
@function assert($result, $expected: true) {
21+
@if $result != $expected {
22+
$result: if($result == null, 'null', $result);
23+
$expected: if($expected == null, 'null', $expected);
24+
@error "Assertion failed, expected '" + $expected + "', got '" + $result + "'";
25+
}
26+
27+
@return ''
28+
}
29+
30+
@function test($name, $result, $expected: true) {
31+
@return 'Running test '+$name + assert($result, $expected);
32+
}
33+
34+
@function run-test($function, $expected, $args...) {
35+
@return test($function, $function($args), $expected);
36+
}
37+
38+
@debug test('str-contains Empty', str-contains('', ''));
39+
@debug test('str-contains Empty one', str-contains('', 'foo'), false);
40+
@debug test('str-contains Empty substring', str-contains('foo', ''), true);
41+
@debug test('str-contains Valid', str-contains('foo bar baz', 'bar'), true);
42+
@debug test('str-contains Missing', str-contains('foo bar', 'baz'), false);
43+
44+
@debug test('str-starts-with Empty', str-starts-with('', ''));
45+
@debug test('str-starts-with Empty Both', str-starts-with('foo', ''));
46+
@debug test('str-starts-with Valid', str-starts-with('foobar', 'foo'));
47+
@debug test('str-starts-with Valid full', str-starts-with('foobar', 'foobar'));
48+
@debug test('str-starts-with Invalid', str-starts-with('barfoo', 'foo'), false);
49+
50+
@debug test('str-ends-with Empty', str-ends-with('', ''));
51+
@debug test('str-ends-with Empty Both', str-ends-with('foo', ''), false);
52+
@debug test('str-ends-with Valid', str-ends-with('foobar', 'bar'));
53+
@debug test('str-ends-with Valid full', str-ends-with('foobar', 'foobar'));
54+
@debug test('str-ends-with Invalid', str-ends-with('foobar', 'foo'), false);
55+
56+
@debug test('str-basename, Empty', str-basename(''), '');
57+
@debug test('str-basename, Named', str-basename('foo'), 'foo');
58+
@debug test('str-basename, Valid', str-basename('/foo/bar'), 'bar');
59+
@debug test('str-basename, Valid', str-basename('/foo/bar/baz'), 'baz');
60+
@debug test('str-basename, Valid', str-basename('proto:///foo/bar/baz'), 'baz');
61+
62+
@debug test('str-extension, Empty', str-extension(''), null);
63+
@debug test('str-extension, Named', str-extension('foo'), null);
64+
@debug test('str-extension, Valid', str-extension('/foo.bar'), 'bar');
65+
@debug test('str-extension, Valid', str-extension('/foo/bar.baz'), 'baz');
66+
67+
@debug test('str-dirname, Empty', str-dirname(''), '.');
68+
@debug test('str-dirname, Named', str-dirname('foo'), '.');
69+
@debug test('str-dirname, Valid', str-dirname('/foo/bar'), '/foo');
70+
@debug test('str-dirname, Valid', str-dirname('/foo/bar/baz'), '/foo/bar');
71+
@debug test('str-dirname, Valid', str-dirname('proto:///foo/bar/baz'), 'proto:///foo/bar');
72+
73+
@debug test('list-length, Empty', list-length([]), 0);
74+
@debug test('list-length, One', list-length([1]), 1);
75+
@debug test('list-length, Two', list-length([1, '2']), 2);
76+
77+
@debug test('list-nth, Empty', list-nth([], 0), null);
78+
@debug test('list-nth, Empty', list-nth([], 10), null);
79+
@debug test('list-nth, Empty', list-nth([], -10), null);
80+
@debug test('list-nth, One, valid', list-nth([1], 0), 1);
81+
@debug test('list-nth, One, valid negative', list-nth([1], -1), 1);
82+
@debug test('list-nth, One, invalid', list-nth([1], 3), null);
83+
@debug test('list-nth, One, invalid negative', list-nth([1], -3), null);
84+
@debug test('list-nth, Three, valid', list-nth([1, '2', false], 0), 1);
85+
@debug test('list-nth, Three, valid negative', list-nth([1, '2', false], -1), false);
86+
@debug test('list-nth, Three, valid', list-nth([1, '2', false], 1), '2');
87+
@debug test('list-nth, Three, valid negative', list-nth([1, '2', false], -2), '2');
88+
@debug test('list-nth, Three, valid', list-nth([1, '2', false], 2), false);
89+
@debug test('list-nth, Three, valid negative', list-nth([1, '2', false], -3), 1);
90+
91+
@debug test('list-index, Empty', list-index([], 0), null);
92+
@debug test('list-index, Empty', list-index([], 10), null);
93+
@debug test('list-index, Empty', list-index([], -10), null);
94+
@debug test('list-index, One, valid', list-index([1], 1), 0);
95+
@debug test('list-index, One, invalid', list-index([1], 3), null);
96+
@debug test('list-index, Three, valid', list-index([1, '2', false], 1), 0);
97+
@debug test('list-index, Three, valid', list-index([1, '2', false], '2'), 1);
98+
@debug test('list-index, Three, valid', list-index([1, '2', false], false), 2);

0 commit comments

Comments
 (0)