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
a797319b
Commit
a797319b
authored
Apr 13, 2025
by
Roman Alifanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
big fix of dialogues (they broke down from transferring everything to the main loop)
parent
e162eae8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
96 additions
and
119 deletions
+96
-119
main.py
src/settings/main.py
+73
-71
setting.py
src/settings/setting/setting.py
+4
-15
deps_alert_dialog.py
src/settings/widgets/deps_alert_dialog.py
+10
-16
service_dialog.py
src/settings/widgets/service_dialog.py
+9
-17
No files found.
src/settings/main.py
View file @
a797319b
from
gi.repository
import
GLib
from
gi.repository
import
GLib
import
time
import
traceback
import
traceback
from
.module
import
Module
from
.module
import
Module
from
.page
import
Page
from
.page
import
Page
...
@@ -26,8 +25,19 @@ def init_settings_stack(stack, listbox, split_view):
...
@@ -26,8 +25,19 @@ def init_settings_stack(stack, listbox, split_view):
else
:
else
:
print
(
"First init..."
)
print
(
"First init..."
)
for
module_data
in
yaml_data
:
current_module_index
=
0
module
=
Module
(
module_data
)
modules
=
list
(
yaml_data
)
window
=
listbox
.
get_root
()
def
process_next_module
():
nonlocal
current_module_index
if
current_module_index
>=
len
(
modules
):
finalize_processing
()
return
module_data
=
modules
[
current_module_index
]
current_module_index
+=
1
try
:
try
:
deps_results
=
dep_manager
.
verify_deps
(
module_data
.
get
(
'deps'
,
{}))
deps_results
=
dep_manager
.
verify_deps
(
module_data
.
get
(
'deps'
,
{}))
...
@@ -40,77 +50,68 @@ def init_settings_stack(stack, listbox, split_view):
...
@@ -40,77 +50,68 @@ def init_settings_stack(stack, listbox, split_view):
all_conflicts_ok
=
all
(
r
[
'success'
]
for
r
in
conflicts_results
)
all_conflicts_ok
=
all
(
r
[
'success'
]
for
r
in
conflicts_results
)
if
all_deps_ok
and
all_conflicts_ok
:
if
all_deps_ok
and
all_conflicts_ok
:
print
(
"Deps: OK"
)
process_module
(
module_data
)
GLib
.
idle_add
(
process_next_module
)
else
:
else
:
dialog
=
TuneItDepsAlertDialog
()
show_dialog
(
module_data
,
deps_message
,
conflicts_message
)
dialog
.
set_body
(
module_data
[
'name'
])
dialog
.
deps_message_textbuffer
.
set_text
(
f
"{deps_message}
\n
{conflicts_message}"
)
while
True
:
w
=
listbox
.
get_root
()
if
w
.
get_visible
()
and
w
.
get_mapped
():
response
=
dialog
.
user_question
(
w
)
break
time
.
sleep
(
0.1
)
print
(
f
"RESPONSE: {response}"
)
if
response
==
"skip"
:
break
modules_dict
[
module
.
name
]
=
module
for
section_data
in
module_data
.
get
(
'sections'
,
[]):
page_name
=
module
.
get_translation
(
section_data
.
get
(
'page'
,
'Default'
))
module_page_name
=
section_data
.
get
(
'page'
,
'Default'
)
print
(
module_page_name
)
if
page_name
not
in
pages_dict
:
page_info
=
(
module
.
pages
.
get
(
f
"_{module_page_name}"
,
{})
or
module
.
pages
.
get
(
module_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
)
except
Exception
as
e
:
except
Exception
as
e
:
from
..main
import
get_error
handle_error
(
e
,
module_data
)
error
=
get_error
()
GLib
.
idle_add
(
process_next_module
)
full_traceback
=
traceback
.
format_exc
()
e
=
f
"Module '{module.name}' loading error
\n
Error: {e}
\n
Full traceback:
\n
{full_traceback}"
error
(
e
)
pages
=
list
(
pages_dict
.
values
())
def
show_dialog
(
module_data
,
deps_msg
,
conflicts_msg
):
for
page
in
pages
:
dialog
=
TuneItDepsAlertDialog
()
page
.
sort_sections
()
dialog
.
set_body
(
module_data
[
'name'
])
dialog
.
deps_message_textbuffer
.
set_text
(
f
"{deps_msg}
\n
{conflicts_msg}"
)
pages
=
sorted
(
pages
,
key
=
lambda
p
:
p
.
name
)
def
handle_response
(
response
):
if
response
==
"skip"
:
for
page
in
pages
:
GLib
.
idle_add
(
process_next_module
)
page
.
create_stack_page
(
stack
,
listbox
)
else
:
process_module
(
module_data
)
if
not
stack
:
GLib
.
idle_add
(
process_next_module
)
print
(
"Ошибка: settings_pagestack не найден."
)
def
on_row_selected
(
listbox
,
row
):
if
row
:
page_id
=
row
.
props
.
name
print
(
f
"Selected page: {page_id}"
)
visible_child
=
stack
.
get_child_by_name
(
page_id
)
dialog
.
ask_user
(
window
,
handle_response
)
if
visible_child
:
stack
.
set_visible_child
(
visible_child
)
split_view
.
set_show_content
(
True
)
listbox
.
connect
(
"row-selected"
,
on_row_selected
)
def
process_module
(
module_data
):
module
=
Module
(
module_data
)
modules_dict
[
module
.
name
]
=
module
for
section_data
in
module_data
.
get
(
'sections'
,
[]):
page_name
=
module
.
get_translation
(
section_data
.
get
(
'page'
,
'Default'
))
module_page_name
=
section_data
.
get
(
'page'
,
'Default'
)
if
page_name
not
in
pages_dict
:
page_info
=
module
.
pages
.
get
(
f
"_{module_page_name}"
,
{})
or
module
.
pages
.
get
(
module_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
)
def
finalize_processing
():
pages
=
sorted
(
pages_dict
.
values
(),
key
=
lambda
p
:
p
.
name
)
for
page
in
pages
:
page
.
sort_sections
()
page
.
create_stack_page
(
stack
,
listbox
)
if
not
stack
:
print
(
"Ошибка: settings_pagestack не найден."
)
def
on_row_selected
(
listbox
,
row
):
if
row
:
page_id
=
row
.
props
.
name
visible_child
=
stack
.
get_child_by_name
(
page_id
)
if
visible_child
:
stack
.
set_visible_child
(
visible_child
)
split_view
.
set_show_content
(
True
)
listbox
.
connect
(
"row-selected"
,
on_row_selected
)
def
handle_error
(
e
,
module_data
):
from
..main
import
get_error
error
=
get_error
()
full_traceback
=
traceback
.
format_exc
()
error_msg
=
f
"Module '{module_data['name']}' loading error
\n
Error: {e}
\n
Full traceback:
\n
{full_traceback}"
error
(
error_msg
)
GLib
.
idle_add
(
process_next_module
)
\ No newline at end of file
src/settings/setting/setting.py
View file @
a797319b
...
@@ -116,23 +116,12 @@ class Setting:
...
@@ -116,23 +116,12 @@ class Setting:
if
service_stopped
is
False
:
if
service_stopped
is
False
:
from
...main
import
get_main_window
from
...main
import
get_main_window
dialog
=
ServiceNotStartedDialog
()
while
True
:
dialog
.
present
(
get_main_window
())
w
=
get_main_window
()
if
w
.
get_visible
()
and
w
.
get_mapped
():
dialog
=
ServiceNotStartedDialog
()
response
=
dialog
.
user_question
(
get_main_window
())
break
time
.
sleep
(
0.1
)
service_stopped
=
True
return
None
if
response
==
"yes"
:
dialog
.
service_enable_with_restart
()
elif
response
in
(
"no"
,
"close"
):
dialog
.
close
()
service_stopped
=
True
return
None
self
.
widget
=
WidgetFactory
.
create_widget
(
self
)
self
.
widget
=
WidgetFactory
.
create_widget
(
self
)
return
self
.
widget
.
create_row
()
if
self
.
widget
else
None
return
self
.
widget
.
create_row
()
if
self
.
widget
else
None
...
...
src/settings/widgets/deps_alert_dialog.py
View file @
a797319b
from
gi.repository
import
GLib
,
Adw
,
Gtk
from
gi.repository
import
GLib
,
Adw
,
Gtk
from
time
import
sleep
@Gtk.Template
(
resource_path
=
'/ru.ximperlinux.TuneIt/settings/widgets/deps_alert_dialog.ui'
)
@Gtk.Template
(
resource_path
=
'/ru.ximperlinux.TuneIt/settings/widgets/deps_alert_dialog.ui'
)
class
TuneItDepsAlertDialog
(
Adw
.
AlertDialog
):
class
TuneItDepsAlertDialog
(
Adw
.
AlertDialog
):
__gtype_name__
=
"TuneItDepsAlertDialog"
__gtype_name__
=
"TuneItDepsAlertDialog"
deps_message_textbuffer
=
Gtk
.
Template
.
Child
()
deps_message_textbuffer
=
Gtk
.
Template
.
Child
()
response
=
""
def
__init__
(
self
,
**
kwargs
):
super
()
.
__init__
(
**
kwargs
)
self
.
callback
=
None
def
user_question
(
self
,
window
):
def
ask_user
(
self
,
window
,
callback
):
GLib
.
idle_add
(
self
.
present
,
window
)
self
.
callback
=
callback
self
.
present
(
window
)
def
on_response
(
dialog
,
response
):
self
.
connect
(
'response'
,
self
.
on_response
)
self
.
response
=
response
self
.
connect
(
'response'
,
on_response
)
def
on_response
(
self
,
dialog
,
response
):
if
self
.
callback
:
while
True
:
self
.
callback
(
response
)
if
self
.
response
!=
""
:
return
self
.
response
else
:
sleep
(
0.1
)
continue
src/settings/widgets/service_dialog.py
View file @
a797319b
...
@@ -6,9 +6,9 @@ from time import sleep
...
@@ -6,9 +6,9 @@ from time import sleep
from
gi.repository
import
GLib
,
Adw
from
gi.repository
import
GLib
,
Adw
class
ServiceNotStartedDialog
(
Adw
.
AlertDialog
):
class
ServiceNotStartedDialog
(
Adw
.
AlertDialog
):
response
=
""
response
=
""
def
__init__
(
self
):
def
__init__
(
self
):
super
()
.
__init__
()
super
()
.
__init__
()
...
@@ -19,23 +19,15 @@ class ServiceNotStartedDialog(Adw.AlertDialog):
...
@@ -19,23 +19,15 @@ class ServiceNotStartedDialog(Adw.AlertDialog):
self
.
add_response
(
"yes"
,
_
(
"Yes"
))
self
.
add_response
(
"yes"
,
_
(
"Yes"
))
self
.
add_response
(
"no"
,
_
(
"No"
))
self
.
add_response
(
"no"
,
_
(
"No"
))
def
user_question
(
self
,
window
):
GLib
.
idle_add
(
self
.
present
,
window
)
def
on_response
(
dialog
,
response
):
self
.
response
=
response
self
.
connect
(
'response'
,
on_response
)
self
.
connect
(
'response'
,
on_response
)
while
True
:
def
on_response
(
self
,
dialog
,
response
)
:
if
self
.
response
!=
"
"
:
if
response
==
"yes
"
:
return
self
.
response
self
.
service_enable_with_restart
()
else
:
sleep
(
0.1
)
elif
response
in
(
"no"
,
"close"
):
continue
dialog
.
close
()
def
service_status
(
self
):
def
service_status
(
self
):
try
:
try
:
...
...
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