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
294388a5
Commit
294388a5
authored
Mar 06, 2025
by
Roman Alifanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GSettingsBackend: does not crash if the scheme is not found
parent
3e423c08
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
9 deletions
+24
-9
gsettings.py
src/settings/backends/gsettings.py
+24
-9
No files found.
src/settings/backends/gsettings.py
View file @
294388a5
...
...
@@ -4,36 +4,51 @@ from .base import Backend
class
GSettingsBackend
(
Backend
):
def
_get_schema
(
self
,
schema_name
):
source
=
Gio
.
SettingsSchemaSource
.
get_default
()
if
source
.
lookup
(
schema_name
,
True
)
is
None
:
print
(
f
"[ERROR] Scheme {schema_name} is not installed"
)
return
None
return
Gio
.
Settings
.
new
(
schema_name
)
def
get_value
(
self
,
key
,
gtype
):
schema_name
,
key_name
=
key
.
rsplit
(
'.'
,
1
)
schema
=
Gio
.
Settings
.
new
(
schema_name
)
schema
=
self
.
_get_schema
(
schema_name
)
if
not
schema
:
return
None
print
(
f
"[DEBUG] Получение значения: schema={schema_name}, key={key_name}, gtype={gtype}"
)
try
:
value
=
schema
.
get_value
(
key_name
)
return
value
.
unpack
()
except
Exception
as
e
:
print
(
f
"[ERROR]
Ошибка при получении значения
{key}: {e}"
)
print
(
f
"[ERROR]
Error when getting the value
{key}: {e}"
)
return
None
def
get_range
(
self
,
key
,
gtype
):
schema_name
,
key_name
=
key
.
rsplit
(
'.'
,
1
)
schema
=
Gio
.
Settings
.
new
(
schema_name
)
schema
=
self
.
_get_schema
(
schema_name
)
if
not
schema
:
return
None
print
(
f
"[DEBUG] Получение значения: schema={schema_name}, key={key_name}, gtype={gtype}"
)
try
:
value
=
schema
.
get_range
(
key_name
)
return
value
.
unpack
()[
1
]
except
Exception
as
e
:
print
(
f
"[ERROR]
Ошибка при получении значения
{key}: {e}"
)
print
(
f
"[ERROR]
Error when getting the range
{key}: {e}"
)
return
None
def
set_value
(
self
,
schema_key
,
value
,
gtype
):
schema_name
,
key_name
=
schema_key
.
rsplit
(
'.'
,
1
)
schema
=
Gio
.
Settings
.
new
(
schema_name
)
schema
=
self
.
_get_schema
(
schema_name
)
if
not
schema
:
return
print
(
f
"[DEBUG] Установка значения: schema={schema_name}, key={key_name}, value={value}, gtype={gtype}"
)
try
:
schema
.
set_value
(
key_name
,
GLib
.
Variant
(
gtype
,
value
))
except
Exception
as
e
:
print
(
f
"[ERROR]
Ошибка при установке значения
{schema_key}: {e}"
)
print
(
f
"[ERROR]
Error when setting the value
{schema_key}: {e}"
)
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