Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stylesheet gresource #282

Merged
merged 5 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Install Dependencies
run: |
apt update
apt install -y libgee-0.8-dev libglib2.0-dev libgranite-7-dev libgtk-4-dev libadwaita-1-dev meson valac
apt install -y libgee-0.8-dev libglib2.0-dev libgranite-7-dev libgtk-4-dev libadwaita-1-dev meson sassc valac
- name: Build
run: |
meson build -Dexample=true
Expand Down
2 changes: 2 additions & 0 deletions data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ foreach i : icon_sizes
rename: meson.project_name() + '.svg'
)
endforeach

subdir('styles')
5 changes: 5 additions & 0 deletions data/styles/Index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Class constants and common styles
@import '_common.scss';

@import 'SettingsPage.scss';
@import 'SettingsSidebar.scss';
54 changes: 54 additions & 0 deletions data/styles/SettingsPage.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
simplesettingspage {
> scrolledwindow > viewport > box {
padding: rem(12px);
}

.header-area {
margin-bottom: rem(24px);

> image {
-gtk-icon-size: rem(48px);

&:dir(ltr) {
// Match square icon canvas whitespace at 48px
margin-left: rem(-4px);
margin-right: rem(7px);
}

&:dir(rtl) {
margin-left: rem(7px);
margin-right: rem(-4px);
}
}

label.title-2 {
font-weight: 600;
font-size: 2rem;
}

label:not(.title-2) {
font-size: 0.95rem;
opacity: 0.85;
}

switch {
slider {
// Match font size for title
min-height: 2rem;
min-width: 2rem;
}

&:dir(ltr) {
margin-left: rem(12px);
}

&:dir(rtl) {
margin-right: rem(12px);
}
}
}

.buttonbox {
margin-top: rem(24px);
}
}
23 changes: 23 additions & 0 deletions data/styles/SettingsSidebar.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
settingssidebar list {
min-width: rem(200px);

row,
> .title-4 {
padding: rem(6px);
}

row {
overlay {
// IconSize.LARGE + padding
min-width: calc(32px + #{rem(6px)});
}

overlay:dir(ltr) {
margin-right: rem(6px);
}

overlay:dir(rtl) {
margin-left: rem(6px);
}
}
}
17 changes: 17 additions & 0 deletions data/styles/_common.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@function rem($pixels, $text-size: 9pt) {
@if (unitless($pixels)) {
$pixels: $pixels * 1px;
}

@if (unitless($text-size)) {
$text-size: $text-size * 1px;
}

@if ($pixels > 0) {
// Workaround GTK clamping instead of rounding up
@return ($pixels / $text-size * 1rem) + 0.000000001rem;
} @else {
// Workaround GTK clamping instead of rounding up
@return ($pixels / $text-size * 1rem) - 0.000000001rem;
}
}
25 changes: 25 additions & 0 deletions data/styles/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
sassc = find_program('sassc')

sassc_opts = [ '-a', '-M', '-t', 'compact' ]

stylesheet_deps = custom_target(
'Application.scss',
input: 'Index.scss',
output: 'Application.css',
command: [
sassc,
sassc_opts,
'@INPUT@',
'@OUTPUT@',
]
)

stylesheet_resource = gnome.compile_resources(
'styles-resource',
'styles.gresource.xml',
source_dir: [
meson.current_build_dir(),
meson.current_source_dir(),
],
dependencies: stylesheet_deps
)
6 changes: 6 additions & 0 deletions data/styles/styles.gresource.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/io/elementary/settings">
<file compressed="true">Application.css</file>
</gresource>
</gresources>
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ conf_file = configure_file(

plugs_dir = get_option('prefix') / get_option('libdir') / 'switchboard-3'

gnome = import('gnome')
i18n = import('i18n')
pkg = import('pkgconfig')

Expand Down
1 change: 1 addition & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ switchboard_deps = [
]

executable(meson.project_name(),
stylesheet_resource,
switchboard_files,
conf_file,
dependencies: switchboard_deps,
Expand Down