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
8bfc8b32
Commit
8bfc8b32
authored
Feb 14, 2025
by
Roman Alifanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init error dialog
parent
fd20e820
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
126 additions
and
47 deletions
+126
-47
main.py
src/main.py
+3
-0
main.py
src/settings/main.py
+51
-41
error_dialog.blp
src/settings/widgets/error_dialog.blp
+25
-0
error_dialog.py
src/settings/widgets/error_dialog.py
+29
-0
tuneit.gresource.xml
src/tuneit.gresource.xml
+1
-0
window.py
src/window.py
+17
-6
No files found.
src/main.py
View file @
8bfc8b32
...
...
@@ -29,6 +29,9 @@ from .window import TuneitWindow
def
get_main_window
():
return
_application
.
props
.
active_window
def
get_error
():
return
_application
.
props
.
active_window
.
error
class
TuneitApplication
(
Adw
.
Application
):
"""The main application singleton class."""
...
...
src/settings/main.py
View file @
8bfc8b32
import
traceback
from
.module
import
Module
from
.page
import
Page
from
.sections
import
SectionFactory
...
...
@@ -24,54 +25,63 @@ def init_settings_stack(stack, listbox, split_view):
print
(
"First init..."
)
for
module_data
in
yaml_data
:
deps_results
=
dep_manager
.
verify_deps
(
module_data
.
get
(
'deps'
,
{}))
conflicts_results
=
dep_manager
.
verify_conflicts
(
module_data
.
get
(
'conflicts'
,
{}))
deps_message
=
dep_manager
.
format_results
(
deps_results
)
conflicts_message
=
dep_manager
.
format_results
(
conflicts_results
)
all_deps_ok
=
all
(
r
[
'success'
]
for
r
in
deps_results
)
all_conflicts_ok
=
all
(
r
[
'success'
]
for
r
in
conflicts_results
)
if
all_deps_ok
and
all_conflicts_ok
:
print
(
"Deps: OK"
)
else
:
dialog
=
TuneItDepsAlertDialog
()
dialog
.
set_body
(
module_data
[
'name'
])
dialog
.
deps_message_textbuffer
.
set_text
(
f
"{deps_message}
\n
{conflicts_message}"
)
response
=
dialog
.
user_question
(
listbox
.
get_root
())
print
(
f
"RESPONSE: {response}"
)
if
response
==
"skip"
:
break
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'
)
print
(
module_page_name
)
try
:
deps_results
=
dep_manager
.
verify_deps
(
module_data
.
get
(
'deps'
,
{}))
conflicts_results
=
dep_manager
.
verify_conflicts
(
module_data
.
get
(
'conflicts'
,
{}))
if
page_name
not
in
pages_dict
:
deps_message
=
dep_manager
.
format_results
(
deps_results
)
conflicts_message
=
dep_manager
.
format_results
(
conflicts_results
)
page_info
=
(
module
.
pages
.
get
(
f
"_{module_page_name}"
,
{})
or
module
.
pages
.
get
(
module_page_name
,
{})
)
all_deps_ok
=
all
(
r
[
'success'
]
for
r
in
deps_results
)
all_conflicts_ok
=
all
(
r
[
'success'
]
for
r
in
conflicts_results
)
if
all_deps_ok
and
all_conflicts_ok
:
print
(
"Deps: OK"
)
else
:
dialog
=
TuneItDepsAlertDialog
()
dialog
.
set_body
(
module_data
[
'name'
])
page
=
Page
(
name
=
page_name
,
icon
=
page_info
.
get
(
'icon'
),
dialog
.
deps_message_textbuffer
.
set_text
(
f
"{deps_message}
\n
{conflicts_message}"
)
pages_dict
[
page_name
]
=
page
response
=
dialog
.
user_question
(
listbox
.
get_root
())
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
:
from
..main
import
get_error
error
=
get_error
()
full_traceback
=
traceback
.
format_exc
()
e
=
f
"Module '{module.name}' loading error
\n
Error: {e}
\n
Full traceback:
\n
{full_traceback}"
section
=
section_factory
.
create_section
(
section_data
,
module
)
pages_dict
[
page_name
]
.
add_section
(
section
)
error
(
e
)
pages
=
list
(
pages_dict
.
values
())
for
page
in
pages
:
...
...
src/settings/widgets/error_dialog.blp
0 → 100644
View file @
8bfc8b32
using Gtk 4.0;
using Adw 1;
template $TuneItErrorDialog: Adw.AlertDialog {
heading: _("Error in Tune it!");
body: _("You can write in an official telegram chat by applying this log.");
responses [
close: _("Ignore") destructive,
copy: _("Copy the log and go to telegram chat") suggested,
]
close-response: "close";
extra-child: Gtk.ScrolledWindow {
hscrollbar-policy: never;
vscrollbar-policy: automatic;
height-request: 185;
Gtk.TextView{
wrap-mode: word_char;
buffer: Gtk.TextBuffer textbuffer {};
}
};
}
src/settings/widgets/error_dialog.py
0 → 100644
View file @
8bfc8b32
import
webbrowser
from
gi.repository
import
Adw
,
Gtk
,
Gdk
@Gtk.Template
(
resource_path
=
'/ru.ximperlinux.TuneIt/settings/widgets/error_dialog.ui'
)
class
TuneItErrorDialog
(
Adw
.
AlertDialog
):
__gtype_name__
=
"TuneItErrorDialog"
textbuffer
=
Gtk
.
Template
.
Child
()
def
__init__
(
self
,
**
kwargs
):
super
()
.
__init__
(
**
kwargs
)
self
.
connect
(
'response'
,
self
.
on_response
)
def
on_response
(
self
,
_
,
response
):
if
response
==
'copy'
:
self
.
on_copy
()
def
on_copy
(
self
):
self
.
copy_error
()
webbrowser
.
open
(
"https://t.me/tuneit"
)
def
copy_error
(
self
):
display
=
Gdk
.
Display
.
get_default
()
clipboard
=
display
.
get_clipboard
()
clipboard
.
set
(
self
.
textbuffer
.
get_text
(
self
.
textbuffer
.
get_start_iter
(),
self
.
textbuffer
.
get_end_iter
(),
False
))
src/tuneit.gresource.xml
View file @
8bfc8b32
...
...
@@ -4,6 +4,7 @@
<file
preprocess=
"xml-stripblanks"
>
window.ui
</file>
<file
preprocess=
"xml-stripblanks"
>
settings/widgets/panel_row.ui
</file>
<file
preprocess=
"xml-stripblanks"
>
settings/widgets/deps_alert_dialog.ui
</file>
<file
preprocess=
"xml-stripblanks"
>
settings/widgets/error_dialog.ui
</file>
<file
preprocess=
"xml-stripblanks"
>
gtk/help-overlay.ui
</file>
</gresource>
</gresources>
src/window.py
View file @
8bfc8b32
...
...
@@ -17,11 +17,13 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later
import
threading
import
threading
,
traceback
from
gi.repository
import
GObject
,
Adw
,
Gtk
,
GLib
from
.settings.main
import
init_settings_stack
from
.settings.widgets.error_dialog
import
TuneItErrorDialog
@Gtk.Template
(
resource_path
=
'/ru.ximperlinux.TuneIt/window.ui'
)
class
TuneitWindow
(
Adw
.
ApplicationWindow
):
__gtype_name__
=
'TuneitWindow'
...
...
@@ -36,6 +38,8 @@ class TuneitWindow(Adw.ApplicationWindow):
def
__init__
(
self
,
**
kwargs
):
super
()
.
__init__
(
**
kwargs
)
self
.
error_dialog
=
TuneItErrorDialog
()
self
.
connect
(
'settings_page_update'
,
self
.
update_settings_page
)
self
.
update_settings_page
()
...
...
@@ -49,8 +53,15 @@ class TuneitWindow(Adw.ApplicationWindow):
Можно вызвать вот так, благодаря сигналу:
self.settings_pagestack.get_root().emit("settings_page_update")
"""
init_settings_stack
(
self
.
settings_pagestack
,
self
.
settings_listbox
,
self
.
settings_split_view
,
)
try
:
init_settings_stack
(
self
.
settings_pagestack
,
self
.
settings_listbox
,
self
.
settings_split_view
,
)
except
Exception
as
e
:
self
.
error
(
traceback
.
format_exc
())
def
error
(
self
,
error
):
self
.
error_dialog
.
textbuffer
.
set_text
(
str
(
error
))
self
.
error_dialog
.
present
(
self
)
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