Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tuneit
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ximper Linux
tuneit
Commits
3d351ebd
Commit
3d351ebd
authored
Feb 18, 2025
by
Roman Alifanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changes for easy Integration of a new type of sections
parent
e2d5e8d4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
36 deletions
+29
-36
__init__.py
src/settings/sections/__init__.py
+8
-26
base.py
src/settings/sections/base.py
+7
-0
base_strategy.py
src/settings/sections/base_strategy.py
+0
-3
classic.py
src/settings/sections/classic.py
+14
-7
No files found.
src/settings/sections/__init__.py
View file @
3d351ebd
from
..setting.setting
import
Setting
from
.base_strategy
import
SectionStrategy
from
.classic
import
ClassicSectionStrategy
class
Section
:
def
__init__
(
self
,
section_data
,
strategy
,
module
):
self
.
name
=
module
.
get_translation
(
section_data
[
'name'
])
self
.
weight
=
section_data
.
get
(
'weight'
,
0
)
self
.
page
=
section_data
.
get
(
'page'
)
self
.
settings
=
[
Setting
(
s
,
module
)
for
s
in
section_data
.
get
(
'settings'
,
[])]
self
.
strategy
=
strategy
self
.
module
=
module
self
.
module
.
add_section
(
self
)
def
create_preferences_group
(
self
):
return
self
.
strategy
.
create_preferences_group
(
self
)
from
.classic
import
ClassicSection
class
SectionFactory
:
def
__init__
(
self
):
self
.
s
trategie
s
=
{
'classic'
:
ClassicSection
Strategy
()
,
self
.
s
ection
s
=
{
'classic'
:
ClassicSection
,
}
def
create_section
(
self
,
section_data
,
module
):
section_type
=
section_data
.
get
(
'type'
,
'classic'
)
s
trategy
=
self
.
strategie
s
.
get
(
section_type
)
if
not
s
trategy
:
raise
ValueError
(
f
"
Неизвестный тип секции
: {section_type}"
)
return
Section
(
section_data
,
strategy
,
module
)
s
ection
=
self
.
section
s
.
get
(
section_type
)
if
not
s
ection
:
raise
ValueError
(
f
"
Unknown type of section
: {section_type}"
)
return
section
(
section_data
,
module
)
\ No newline at end of file
src/settings/sections/base.py
0 → 100644
View file @
3d351ebd
class
BaseSection
():
def
__init__
(
self
,
section_data
,
module
):
self
.
name
=
module
.
get_translation
(
section_data
[
'name'
])
self
.
weight
=
section_data
.
get
(
'weight'
,
0
)
self
.
page
=
section_data
.
get
(
'page'
)
\ No newline at end of file
src/settings/sections/base_strategy.py
deleted
100644 → 0
View file @
e2d5e8d4
class
SectionStrategy
:
def
create_preferences_group
(
self
,
section
):
raise
NotImplementedError
(
"Метод create_preferences_group должен быть реализован"
)
src/settings/sections/classic.py
View file @
3d351ebd
from
gi.repository
import
Adw
from
..setting.setting
import
Setting
from
.base
_strategy
import
SectionStrategy
from
.base
import
BaseSection
class
ClassicSection
(
BaseSection
):
def
__init__
(
self
,
section_data
,
module
):
super
()
.
__init__
(
section_data
,
module
)
self
.
settings
=
[
Setting
(
s
,
module
)
for
s
in
section_data
.
get
(
'settings'
,
[])]
self
.
module
=
module
class
ClassicSectionStrategy
(
SectionStrategy
):
def
create_preferences_group
(
self
,
section
):
group
=
Adw
.
PreferencesGroup
(
title
=
section
.
name
,
description
=
section
.
module
.
name
)
self
.
module
.
add_section
(
self
)
def
create_preferences_group
(
self
):
group
=
Adw
.
PreferencesGroup
(
title
=
self
.
name
,
description
=
self
.
module
.
name
)
not_empty
=
False
for
setting
in
se
ction
.
settings
:
for
setting
in
se
lf
.
settings
:
row
=
setting
.
create_row
()
if
row
:
print
(
f
"
Добавление строки для настройки
: {setting.name}"
)
print
(
f
"
Adding a row for setting
: {setting.name}"
)
group
.
add
(
row
)
not_empty
=
True
else
:
print
(
f
"
Не удалось создать строку для настройки
: {setting.name}"
)
print
(
f
"
Failed to create a row for setting
: {setting.name}"
)
if
not_empty
:
return
group
else
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment