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
6838be25
Commit
6838be25
authored
Feb 28, 2025
by
Roman Alifanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init InfoDictWidget
parent
9f3782cc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
101 additions
and
0 deletions
+101
-0
InfoDictWidget.py
src/settings/setting/widgets/InfoDictWidget.py
+99
-0
__init__.py
src/settings/setting/widgets/__init__.py
+2
-0
No files found.
src/settings/setting/widgets/InfoDictWidget.py
0 → 100644
View file @
6838be25
from
gi.repository
import
Adw
,
Gtk
from
.BaseWidget
import
BaseWidget
class
InfoDictWidget
(
BaseWidget
):
def
create_row
(
self
):
main_box
=
Adw
.
PreferencesRow
()
main_box
.
set_activatable
(
False
)
content_box
=
Gtk
.
Box
(
orientation
=
Gtk
.
Orientation
.
VERTICAL
,
margin_top
=
8
,
margin_bottom
=
8
,
margin_start
=
12
,
margin_end
=
12
)
main_box
.
set_child
(
content_box
)
title_label
=
Gtk
.
Label
(
label
=
self
.
setting
.
name
,
halign
=
Gtk
.
Align
.
START
,
margin_bottom
=
6
)
content_box
.
append
(
title_label
)
if
self
.
setting
.
help
:
subtitle_label
=
Gtk
.
Label
(
label
=
self
.
setting
.
help
,
halign
=
Gtk
.
Align
.
START
,
wrap
=
True
,
margin_bottom
=
8
)
subtitle_label
.
add_css_class
(
"dim-label"
)
content_box
.
append
(
subtitle_label
)
self
.
main_list
=
Gtk
.
ListBox
()
self
.
main_list
.
set_selection_mode
(
Gtk
.
SelectionMode
.
NONE
)
self
.
main_list
.
add_css_class
(
'boxed-list'
)
content_box
.
append
(
self
.
main_list
)
self
.
_update_initial_state
()
return
main_box
def
_create_value_label
(
self
,
value
,
level
):
label
=
Gtk
.
Label
(
label
=
str
(
value
),
halign
=
Gtk
.
Align
.
END
,
hexpand
=
True
,
margin_start
=
12
,
margin_end
=
12
*
level
)
label
.
add_css_class
(
'dim-label'
)
return
label
def
_render_value
(
self
,
value
,
container
,
level
=
0
):
if
isinstance
(
value
,
dict
):
self
.
_render_dict
(
value
,
container
,
level
)
elif
isinstance
(
value
,
(
list
,
tuple
)):
self
.
_render_list
(
value
,
container
,
level
)
else
:
container
.
append
(
self
.
_create_value_label
(
value
,
level
))
def
_render_dict
(
self
,
data
,
parent_container
,
level
):
for
key
,
value
in
data
.
items
():
row
=
Adw
.
ActionRow
()
row
.
set_title
(
key
)
row
.
set_activatable
(
False
)
if
isinstance
(
value
,
(
dict
,
list
,
tuple
)):
value_widget
=
Gtk
.
Box
(
orientation
=
Gtk
.
Orientation
.
VERTICAL
)
self
.
_render_value
(
value
,
value_widget
,
level
+
1
)
else
:
value_widget
=
self
.
_create_value_label
(
value
,
level
)
row
.
add_suffix
(
value_widget
)
parent_container
.
append
(
row
)
def
_render_list
(
self
,
data
,
parent_container
,
level
):
for
item
in
data
:
row
=
Adw
.
ActionRow
()
row
.
set_title
(
"•"
)
row
.
set_activatable
(
False
)
if
isinstance
(
item
,
(
dict
,
list
,
tuple
)):
value_widget
=
Gtk
.
Box
(
orientation
=
Gtk
.
Orientation
.
VERTICAL
)
self
.
_render_value
(
item
,
value_widget
,
level
+
1
)
else
:
value_widget
=
self
.
_create_value_label
(
item
,
level
)
row
.
add_suffix
(
value_widget
)
parent_container
.
append
(
row
)
def
_update_initial_state
(
self
):
current_value
=
self
.
setting
.
_get_backend_value
()
or
{}
while
child
:
=
self
.
main_list
.
get_first_child
():
self
.
main_list
.
remove
(
child
)
self
.
_render_value
(
current_value
,
self
.
main_list
,
0
)
def
update_display
(
self
):
self
.
_update_initial_state
()
src/settings/setting/widgets/__init__.py
View file @
6838be25
...
...
@@ -6,6 +6,7 @@ from .NumStepper import NumStepper
from
.FileChooser
import
FileChooser
from
.ButtonWidget
import
ButtonWidget
from
.InfoLabelWidget
import
InfoLabelWidget
from
.InfoDictWidget
import
InfoDictWidget
class
WidgetFactory
:
widget_map
=
{
...
...
@@ -17,6 +18,7 @@ class WidgetFactory:
'number'
:
NumStepper
,
'button'
:
ButtonWidget
,
'info_label'
:
InfoLabelWidget
,
'info_dict'
:
InfoDictWidget
,
}
@staticmethod
...
...
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