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
3938bcd9
Commit
3938bcd9
authored
Feb 26, 2025
by
Roman Alifanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implementation of Info Label Widget and update_interval
parent
3bfbe556
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
6 deletions
+63
-6
setting.py
src/settings/setting/setting.py
+33
-6
InfoLabelWidget.py
src/settings/setting/widgets/InfoLabelWidget.py
+28
-0
__init__.py
src/settings/setting/widgets/__init__.py
+2
-0
No files found.
src/settings/setting/setting.py
View file @
3938bcd9
import
threading
import
time
from
..searcher
import
SearcherFactory
from
.widgets
import
WidgetFactory
from
..backends
import
backend_factory
...
...
@@ -5,6 +7,7 @@ from ..daemon_client import dclient
from
..tools.gvariant
import
convert_by_gvariant
from
..widgets.service_dialog
import
ServiceNotStartedDialog
from
gi.repository
import
GLib
dialog_presented
=
False
...
...
@@ -12,6 +15,8 @@ class Setting:
def
__init__
(
self
,
setting_data
,
module
):
self
.
_
=
module
.
get_translation
self
.
widget
=
None
self
.
name
=
self
.
_
(
setting_data
[
'name'
])
self
.
root
=
setting_data
.
get
(
'root'
,
False
)
...
...
@@ -61,6 +66,10 @@ class Setting:
else
:
self
.
gtype
=
self
.
gtype
self
.
update_interval
=
setting_data
.
get
(
'update_interval'
,
None
)
if
self
.
update_interval
:
self
.
_start_update_thread
()
def
_default_map
(
self
):
if
self
.
type
==
'boolean'
:
# Дефолтная карта для булевых настроек
...
...
@@ -98,8 +107,8 @@ class Setting:
if
self
.
root
is
True
:
print
(
"Root is true"
)
if
dclient
is
not
None
:
widget
=
WidgetFactory
.
create_widget
(
self
)
return
widget
.
create_row
()
if
widget
else
None
self
.
widget
=
WidgetFactory
.
create_widget
(
self
)
return
self
.
widget
.
create_row
()
if
self
.
widget
else
None
else
:
global
dialog_presented
if
dialog_presented
is
False
:
...
...
@@ -111,8 +120,8 @@ class Setting:
dialog_presented
=
True
return
None
widget
=
WidgetFactory
.
create_widget
(
self
)
return
widget
.
create_row
()
if
widget
else
None
self
.
widget
=
WidgetFactory
.
create_widget
(
self
)
return
self
.
widget
.
create_row
()
if
self
.
widget
else
None
def
_get_selected_row_index
(
self
):
current_value
=
self
.
_get_backend_value
()
...
...
@@ -121,8 +130,8 @@ class Setting:
def
_get_default_row_index
(
self
):
return
list
(
self
.
map
.
values
())
.
index
(
self
.
default
)
if
self
.
default
in
self
.
map
.
values
()
else
None
def
_get_backend_value
(
self
):
if
self
.
_current_value
is
None
:
def
_get_backend_value
(
self
,
force
=
False
):
if
self
.
_current_value
is
None
or
force
is
True
:
backend
=
self
.
_get_backend
()
value
=
self
.
default
...
...
@@ -154,3 +163,21 @@ class Setting:
if
not
backend
:
print
(
f
"Бекенд {self.backend} не зарегистрирован."
)
return
backend
def
_start_update_thread
(
self
):
def
update_loop
():
while
True
:
time
.
sleep
(
self
.
update_interval
)
prev_value
=
self
.
_current_value
current_value
=
self
.
_get_backend_value
(
force
=
True
)
if
current_value
!=
prev_value
:
GLib
.
idle_add
(
self
.
_update_widget
)
thread
=
threading
.
Thread
(
target
=
update_loop
,
daemon
=
True
)
thread
.
start
()
def
_update_widget
(
self
):
if
self
.
widget
:
self
.
widget
.
update_display
()
return
False
src/settings/setting/widgets/InfoLabelWidget.py
0 → 100644
View file @
3938bcd9
from
gi.repository
import
Adw
,
Gtk
,
GLib
from
.BaseWidget
import
BaseWidget
class
InfoLabelWidget
(
BaseWidget
):
def
create_row
(
self
):
self
.
row
=
Adw
.
ActionRow
(
title
=
self
.
setting
.
name
,
subtitle
=
self
.
setting
.
help
)
self
.
label
=
Gtk
.
Label
(
valign
=
Gtk
.
Align
.
CENTER
,
halign
=
Gtk
.
Align
.
CENTER
,
)
self
.
label
.
add_css_class
(
"dim-label"
)
control_box
=
Gtk
.
Box
(
spacing
=
6
,
orientation
=
Gtk
.
Orientation
.
HORIZONTAL
)
control_box
.
append
(
self
.
label
)
self
.
row
.
add_suffix
(
control_box
)
self
.
_update_initial_state
()
return
self
.
row
def
_update_initial_state
(
self
):
current_value
=
self
.
setting
.
_get_backend_value
()
print
(
current_value
)
self
.
label
.
set_label
(
current_value
)
def
update_display
(
self
):
self
.
_update_initial_state
()
src/settings/setting/widgets/__init__.py
View file @
3938bcd9
...
...
@@ -5,6 +5,7 @@ from .EntryWidget import EntryWidget
from
.NumStepper
import
NumStepper
from
.FileChooser
import
FileChooser
from
.ButtonWidget
import
ButtonWidget
from
.InfoLabelWidget
import
InfoLabelWidget
class
WidgetFactory
:
widget_map
=
{
...
...
@@ -15,6 +16,7 @@ class WidgetFactory:
'entry'
:
EntryWidget
,
'number'
:
NumStepper
,
'button'
:
ButtonWidget
,
'info_label'
:
InfoLabelWidget
,
}
@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