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
Vladimir Vaskov
tuneit
Commits
ca2b7a56
Commit
ca2b7a56
authored
Jan 22, 2025
by
Roman Alifanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new module structure
parent
34825230
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
28 deletions
+91
-28
exampleplug.yml
modules/exampleplug/exampleplug.yml
+27
-12
main.py
src/settings/main.py
+64
-16
No files found.
modules/exampleplug/exampleplug.yml
View file @
ca2b7a56
-
name
:
"
Gnome"
icon
:
preferences-desktop-display-symbolic
weight
:
30
pages
:
-
name
:
"
Appearance"
icon
:
preferences-desktop-display-symbolic
-
name
:
"
Date
&
Time"
icon
:
preferences-system-time-symbolic
-
name
:
"
Power"
icon
:
battery-symbolic
-
name
:
"
System"
icon
:
preferences-system-symbolic
sections
:
-
name
:
Themes
type
:
classic
-
name
:
"
Themes"
weight
:
0
page
:
"
Appearance"
settings
:
-
name
:
IconTheme
type
:
entry
...
...
@@ -27,8 +35,9 @@
gtype
:
string
backend
:
gsettings
key
:
org.gnome.desktop.background.picture-options
-
name
:
Clock
-
name
:
"
Clock"
weight
:
10
page
:
"
Date
&
Time"
settings
:
-
name
:
Weekday
type
:
boolean
...
...
@@ -45,16 +54,18 @@
gtype
:
boolean
backend
:
gsettings
key
:
org.gnome.desktop.interface.clock-show-seconds
-
name
:
Battery
-
name
:
"
Battery"
weight
:
10
page
:
"
Power"
settings
:
-
name
:
Show percentage
type
:
boolean
gtype
:
boolean
backend
:
gsettings
key
:
org.gnome.desktop.interface.show-battery-percentage
-
name
:
Performance
-
name
:
"
Performance"
weight
:
20
page
:
"
System"
settings
:
-
name
:
Animations
help
:
Animations can be disabled for performance
...
...
@@ -63,12 +74,14 @@
backend
:
gsettings
key
:
org.gnome.desktop.interface.enable-animations
-
name
:
"
Fonts"
icon
:
font-x-generic-symbolic
weight
:
1
pages
:
-
name
:
"
Appearance"
icon
:
preferences-desktop-display-symbolic
sections
:
-
name
:
Main
type
:
classic
-
name
:
"
Main"
weight
:
0
page
:
"
Appearance"
settings
:
-
name
:
Antialiasing
type
:
choice
...
...
@@ -104,12 +117,14 @@
step
:
0.01
digits
:
2
-
name
:
"
GRUB"
icon
:
system-reboot-symbolic
weight
:
25
pages
:
-
name
:
"
Boot"
icon
:
system-reboot-symbolic
sections
:
-
name
:
Main
type
:
classic
-
name
:
"
Main"
weight
:
0
page
:
"
Boot"
settings
:
-
name
:
Timeout
root
:
true
...
...
src/settings/main.py
View file @
ca2b7a56
...
...
@@ -125,12 +125,33 @@ class Setting:
return
backend
class
Module
:
def
__init__
(
self
,
module_data
):
self
.
name
=
module_data
[
'name'
]
self
.
weight
=
module_data
.
get
(
'weight'
,
0
)
self
.
pages
=
{
page
[
'name'
]:
page
for
page
in
module_data
.
get
(
'pages'
,
[])
}
self
.
sections
=
[]
def
add_section
(
self
,
section
):
self
.
sections
.
append
(
section
)
def
get_sorted_sections
(
self
):
# Сортируем секции по весу
return
sorted
(
self
.
sections
,
key
=
lambda
s
:
s
.
weight
)
class
Section
:
def
__init__
(
self
,
section_data
,
strategy
):
def
__init__
(
self
,
section_data
,
strategy
,
module
):
self
.
name
=
section_data
[
'name'
]
self
.
weight
=
section_data
.
get
(
'weight'
,
0
)
self
.
page
=
section_data
.
get
(
'page'
)
self
.
settings
=
[
Setting
(
s
)
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
)
...
...
@@ -176,21 +197,26 @@ class SectionFactory:
'classic'
:
ClassicSectionStrategy
(),
}
def
create_section
(
self
,
section_data
):
def
create_section
(
self
,
section_data
,
module
):
section_type
=
section_data
.
get
(
'type'
,
'classic'
)
strategy
=
self
.
strategies
.
get
(
section_type
)
if
not
strategy
:
raise
ValueError
(
f
"Неизвестный тип секции: {section_type}"
)
return
Section
(
section_data
,
strategy
)
return
Section
(
section_data
,
strategy
,
module
)
class
Page
:
def
__init__
(
self
,
name
,
icon
=
None
):
self
.
name
=
name
self
.
icon
=
icon
or
"preferences-system"
# Значение по умолчанию
self
.
sections
=
[]
class
Category
:
def
__init__
(
self
,
category_data
,
section_factory
:
SectionFactory
):
self
.
name
=
category_data
[
'name'
]
self
.
icon_name
=
category_data
.
get
(
'icon'
,
'preferences-system'
)
self
.
weight
=
category_data
.
get
(
'weight'
,
0
)
self
.
sections
=
[
section_factory
.
create_section
(
s
)
for
s
in
category_data
.
get
(
'sections'
,
[])]
def
add_section
(
self
,
section
):
self
.
sections
.
append
(
section
)
def
sort_sections
(
self
):
self
.
sections
=
sorted
(
self
.
sections
,
key
=
lambda
s
:
s
.
weight
)
def
create_stack_page
(
self
,
stack
,
listbox
):
box
=
Gtk
.
ScrolledWindow
()
...
...
@@ -217,16 +243,16 @@ class Category:
row
=
TuneItPanelRow
()
row
.
set_name
(
self
.
name
)
row
.
set_title
(
self
.
name
)
row
.
icon_name
=
self
.
icon
_name
row
.
icon_name
=
self
.
icon
listbox
.
append
(
row
)
else
:
print
(
f
"the category {self.name} is empty, ignored"
)
print
(
f
"the page {self.name} is empty, ignored"
)
def
init_settings_stack
(
stack
,
listbox
,
split_view
):
yaml_data
=
load_modules
()
merged_data
=
merge_categories_by_name
(
yaml_data
)
section_factory
=
SectionFactory
()
modules_dict
=
{}
pages_dict
=
{}
if
stack
.
get_pages
():
print
(
"Clear pages..."
)
...
...
@@ -236,10 +262,32 @@ def init_settings_stack(stack, listbox, split_view):
else
:
print
(
"First init..."
)
categories
=
[
Category
(
c
,
section_factory
)
for
c
in
merged_data
]
for
module_data
in
yaml_data
:
module
=
Module
(
module_data
)
modules_dict
[
module
.
name
]
=
module
for
section_data
in
module_data
.
get
(
'sections'
,
[]):
page_name
=
section_data
.
get
(
'page'
,
'Default'
)
if
page_name
not
in
pages_dict
:
page_info
=
module
.
pages
.
get
(
page_name
,
{})
page
=
Page
(
name
=
page_name
,
icon
=
page_info
.
get
(
'icon'
)
)
pages_dict
[
page_name
]
=
page
section
=
section_factory
.
create_section
(
section_data
,
module
)
pages_dict
[
page_name
]
.
add_section
(
section
)
pages
=
list
(
pages_dict
.
values
())
for
page
in
pages
:
page
.
sort_sections
()
pages
=
sorted
(
pages
,
key
=
lambda
p
:
p
.
name
)
for
category
in
categori
es
:
category
.
create_stack_page
(
stack
,
listbox
)
for
page
in
pag
es
:
page
.
create_stack_page
(
stack
,
listbox
)
if
not
stack
:
print
(
"Ошибка: settings_pagestack не найден."
)
...
...
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