Skip to content

Commit f801f22

Browse files
committed
common: Generalize the yaru variants computation
Avoid repeating the same logic in multiple places, but instead refer to the default configuration, and in case adapt in each sub-project
1 parent 55769fe commit f801f22

File tree

7 files changed

+48
-65
lines changed

7 files changed

+48
-65
lines changed

cinnamon-shell/src/meson.build

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,9 @@ cinnamonshell_theme_dir = join_paths(cinnamonshell_default_theme_dir,
33

44
message()
55

6-
variants = [
7-
'light',
8-
'dark',
9-
]
10-
116
DEFAULT_VARIANT = 'light'
127
message(meson.project_build_root())
138

14-
foreach accent: enabled_accent_colors
15-
if enabled_accent_colors.contains(accent)
16-
variants += (get_option('default') ? [accent] : [])
17-
variants += (get_option('dark') ? [ accent + '-dark' ] : [])
18-
endif
19-
endforeach
20-
219
theme_css = []
2210
theme_sources = files(
2311
run_command(
@@ -81,7 +69,11 @@ endforeach
8169
# theme_gresource_xml = files('data/cinnamon-shell-theme.gresource.xml')[0]
8270
# icons_gresource_xml = files('data/cinnamon-shell-icons.gresource.xml')[0]
8371

84-
foreach variant: variants
72+
foreach variant: yaru_flavours
73+
if variant == 'default'
74+
variant = DEFAULT_VARIANT
75+
endif
76+
8577
is_dark = variant == 'dark' or variant.endswith('-dark')
8678
is_variant = variant != DEFAULT_VARIANT
8779
variant_base_name = is_dark ? variant.split('-dark')[0] : variant

common/meson.build

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,29 @@ test('sass-utils',
1212
files('test-sass-utils.scss'),
1313
'/dev/null',
1414
])
15+
16+
yaru_sass_global_paths = ['-I', meson.current_source_dir()]
17+
18+
yaru_flavours = []
19+
20+
available_flavours = [
21+
'default',
22+
'dark',
23+
'mate',
24+
'mate-dark',
25+
]
26+
27+
foreach flavour: available_flavours
28+
if not get_option(flavour)
29+
message('skip flavour ' + flavour)
30+
continue
31+
endif
32+
yaru_flavours += flavour
33+
endforeach
34+
35+
foreach accent: enabled_accent_colors
36+
if enabled_accent_colors.contains(accent)
37+
yaru_flavours += (get_option('default') ? [accent] : [])
38+
yaru_flavours += (get_option('dark') ? [ accent + '-dark' ] : [])
39+
endif
40+
endforeach

gnome-shell/src/meson.build

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,23 @@ styles = [
66
'gnome-shell-high-contrast',
77
]
88

9-
variants = [
10-
'light',
11-
'dark',
12-
]
13-
149
DEFAULT_VARIANT = get_option('gnome-shell-default-variant')
1510
DEFAULT_GDM_VARIANT = get_option('gdm-default-variant')
1611
DEFAULT_HIGH_CONTRAST_VARIANT = get_option('gnome-shell-default-high-contrast-variant')
1712
INCLUDE_HIGH_CONTRAST_VARIANTS = false
1813

19-
foreach accent: enabled_accent_colors
20-
if enabled_accent_colors.contains(accent)
21-
variants += (get_option('default') ? [accent] : [])
22-
variants += (get_option('dark') ? [ accent + '-dark' ] : [])
14+
variants = []
15+
foreach variant : yaru_flavours
16+
if variant == 'default'
17+
variants += DEFAULT_VARIANT
18+
continue
2319
endif
20+
21+
if variant.startswith('mate')
22+
continue
23+
endif
24+
25+
variants += variant
2426
endforeach
2527

2628
if not variants.contains(DEFAULT_VARIANT)

gtk/meson.build

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1 @@
1-
flavours = []
2-
3-
available_flavours = [
4-
'default',
5-
'dark',
6-
'mate',
7-
'mate-dark',
8-
]
9-
10-
foreach flavour: available_flavours
11-
if not get_option(flavour)
12-
message('skip flavour ' + flavour)
13-
continue
14-
endif
15-
flavours += flavour
16-
endforeach
17-
18-
foreach accent: enabled_accent_colors
19-
if enabled_accent_colors.contains(accent)
20-
flavours += (get_option('default') ? [accent] : [])
21-
flavours += (get_option('dark') ? [ accent + '-dark' ] : [])
22-
endif
23-
endforeach
24-
25-
261
subdir('src')

gtk/src/meson.build

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ gtk_versions = [
99
]
1010

1111
gtk_yaru_colors_defs = {}
12-
sass_global_paths = ['-I', meson.project_source_root() / 'common']
1312

14-
foreach flavour: flavours
13+
foreach flavour: yaru_flavours
1514
message('Configuring flavour ' + flavour)
1615
suffix = flavour == 'default' ? '' : '-@0@'.format(flavour)
1716
theme_name = meson.project_name() + suffix
@@ -36,7 +35,7 @@ foreach flavour: flavours
3635
)
3736

3837
accent_color_code = run_command(sassc,
39-
sass_global_paths,
38+
yaru_sass_global_paths,
4039
accent_info_css).stderr().split(' Accent color is ')[1].strip()
4140
assert(accent_color_code.startswith('#'), 'No accent color code found')
4241
endif
@@ -117,7 +116,7 @@ foreach flavour: flavours
117116

118117
# Look for scss files in the variant dir first, otherwise fallback to
119118
# base, default or upstream paths, so using reversed order
120-
scss_paths = sass_global_paths
119+
scss_paths = yaru_sass_global_paths
121120
gtk_scss_dependencies = []
122121
foreach src: sources_priority
123122
scss_paths += ['-I', meson.current_source_dir() / src ]
@@ -236,4 +235,4 @@ foreach flavour: flavours
236235
endforeach
237236
endforeach
238237

239-
meson.add_install_script('post_install.py', get_option('datadir'), meson.project_name(), flavours)
238+
meson.add_install_script('post_install.py', get_option('datadir'), meson.project_name(), yaru_flavours)

icons/meson.build

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,7 @@ PANEL_ONLY_ICONS_CATEGORIES = [
33
'panel',
44
]
55

6-
icon_flavors = [
7-
'default',
8-
'dark',
9-
'mate',
10-
'mate-dark',
11-
]
12-
13-
foreach accent: enabled_accent_colors
14-
icon_flavors += (get_option('default') ? [accent] : [])
15-
icon_flavors += (get_option('dark') ? [ accent + '-dark' ] : [])
16-
endforeach
6+
icon_flavors = yaru_flavours
177

188
fullcolor_path = 'src' / 'fullcolor'
199
xvfb_run = find_program('xvfb-run', required: false)

meson.build

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ gnome = import('gnome')
1010
python = find_program('python3')
1111
sassc = find_program('sassc')
1212

13+
enabled_accent_colors = get_option('accent-colors')
1314
subdir('common')
1415

1516
components = [
@@ -25,8 +26,6 @@ components = [
2526
'cinnamon-shell',
2627
]
2728

28-
enabled_accent_colors = get_option('accent-colors')
29-
3029
foreach component: components
3130
if not get_option(component)
3231
message('skip component ' + component)

0 commit comments

Comments
 (0)