Skip to content
This repository was archived by the owner on Jul 23, 2024. It is now read-only.

Commit 3f10e87

Browse files
authored
Move modules to new backend/frontend directories (#668)
# Description This is a yet another refactoring PR (I promise this will be the last _major_ one), this time I based it on a codebase structure used by Bottles project. The new structure should be more readable, and easier to navigate. Also, as a nice small bonus, I've included `struct.md` files inside `frontend/` and `backend/` directories with small descriptions for subdirectories. ## Type of change <!-- What type of change does your pull request introduce? Put an `x` in the box that apply. --> - [x] Refactor - [ ] Bugfix (Change which fixes a issue) - [ ] New feature (Change which adds new functionality) - [ ] Enhancement (Change which slightly improves existing code) - [ ] Breaking change (This change will introduce incompatibility with existing functionality) ## Changelog <!-- This is optional, but highly appreciated. --> - Rename `utils/css.py` to `utils/css_parser.py` and `utils/custom_presets.py` to `utils/preset_downloader.py`, - Move modules to new backend/frontend directories, - Change module name from `utils.py` to `common.py`, - Format some modules for better readability ## Testing - [x] I have tested my changes and verified that they work as expected <!-- Required, your PR won't be accepted if you don't do this step. --> ### How to test the changes Just check if everything is working as expected in every build method (I've tested this PR with manual and Flatpak methods)
2 parents eb2b4a5 + ca9970d commit 3f10e87

Some content is hidden

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

53 files changed

+244
-252
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,5 +431,5 @@ $RECYCLE.BIN/
431431
# The flatpak pip generator (needed for GH-Actions)
432432
flatpak-pip-generator
433433

434-
# Don't include constants.py in VCS since that's a generated file
435-
gradience/constants.py
434+
# Don't include constants.py in VCS since that's a generated file
435+
gradience/backend/constants.py

gradience/Structure.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

gradience/__init__.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +0,0 @@
1-
# __init__.py
2-
#
3-
# Change the look of Adwaita, with ease
4-
# Copyright (C) 2022 Gradience Team
5-
#
6-
# This program is free software: you can redistribute it and/or modify
7-
# it under the terms of the GNU General Public License as published by
8-
# the Free Software Foundation, either version 3 of the License, or
9-
# (at your option) any later version.
10-
#
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.
15-
#
16-
# You should have received a copy of the GNU General Public License
17-
# along with this program. If not, see <https://www.gnu.org/licenses/>.

gradience/backend/__init__.py

Whitespace-only changes.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# css.py
1+
# css_parser.py
22
#
33
# Change the look of Adwaita, with ease
44
# Copyright (C) 2022 Gradience Team
@@ -20,7 +20,7 @@
2020

2121

2222
# Adwaita named palette colors dict
23-
COLORS = [
23+
adw_colors = [
2424
"blue_",
2525
"green_",
2626
"yellow_",
@@ -41,7 +41,7 @@ def parse_css(path):
4141
variables = {}
4242
palette = {}
4343

44-
for color in COLORS:
44+
for color in adw_colors:
4545
palette[color] = {}
4646

4747
with open(path, "r", encoding="utf-8") as sheet:
@@ -51,7 +51,7 @@ def parse_css(path):
5151
if cdefine_match != None: # If @define-color variable declarations were found
5252
palette_part = cdefine_match.__getitem__(1) # Get the second item of the re.Match object
5353
name, color = palette_part.split(" ", 1)[1].split(" ", 1)
54-
for color_name in COLORS:
54+
for color_name in adw_colors:
5555
if name.startswith(color_name): # Palette colors
5656
palette[name[:-1]][name[-1:]] = color[:-1]
5757
break
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
from gi.repository import GLib, Gio, Adw
2222

23-
from gradience.utils.utils import buglog
23+
from gradience.backend.utils.common import buglog
2424

2525

2626
""" Custom exception class """

gradience/backend/meson.build

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
backenddir = 'gradience/backend'
2+
3+
configure_file(
4+
input: 'constants.py.in',
5+
output: 'constants.py',
6+
configuration: configuration_data({
7+
'APP_ID': APPLICATION_ID,
8+
'RELEASE_VER': meson.project_version(),
9+
'VERSION': meson.project_version() + VERSION_SUFFIX,
10+
'BUILD_TYPE': get_option('buildtype'),
11+
'PROJECT_URL': PROJECT_URL,
12+
'BUGTRACKER_URL': BUGTRACKER_URL,
13+
'HELP_URL': HELP_URL,
14+
'TRANSLATE_URL': TRANSLATE_URL,
15+
'PKGDATA_DIR': PKGDATA_DIR,
16+
'LOCALE_DIR': conf.get('LOCALE_DIR'),
17+
}),
18+
install: true,
19+
install_dir: PY_INSTALLDIR.get_install_dir() / backenddir,
20+
)
21+
22+
subdir('models')
23+
subdir('utils')
24+
25+
gradience_sources = [
26+
'__init__.py',
27+
'css_parser.py',
28+
'flatpak_overrides.py',
29+
'preset_downloader.py'
30+
]
31+
PY_INSTALLDIR.install_sources(gradience_sources, subdir: backenddir)

gradience/backend/models/__init__.py

Whitespace-only changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
modelsdir = 'gradience/backend/models'
2+
3+
gradience_sources = [
4+
'__init__.py',
5+
'preset.py',
6+
'repo.py'
7+
]
8+
PY_INSTALLDIR.install_sources(gradience_sources, subdir: modelsdir)

0 commit comments

Comments
 (0)