Commit 81c63701 authored by Roman Alifanov's avatar Roman Alifanov

temporarily, everything is done in the main loop (except for updates to info…

temporarily, everything is done in the main loop (except for updates to info widgets for a certain period). the final fix for random crashes (I really hope so)
parent d540da37
......@@ -21,9 +21,8 @@ def init_settings_stack(stack, listbox, split_view):
if stack.get_pages():
print("Clear pages...")
GLib.idle_add(listbox.remove_all)
for page in stack.get_pages():
GLib.idle_add(stack.remove, page)
listbox.remove_all()
for page in stack.get_pages(): stack.remove(page)
else:
print("First init...")
......
......@@ -29,7 +29,7 @@ class Page:
print(f"Секция {section.name} не создала виджетов.")
if not_empty:
GLib.idle_add(self.update_ui, stack, listbox, pref_page)
self.update_ui(stack, listbox, pref_page)
else:
print(f"the page {self.name} is empty, ignored")
......
......@@ -43,7 +43,7 @@ class Setting:
self.search_target = setting_data.get('search_target', None)
self.map = setting_data.get('map')
if self.map is None:
if self.search_target is not None:
self.map = SearcherFactory.create(self.search_target).search()
......@@ -66,7 +66,7 @@ class Setting:
self.gtype = self.gtype[0]
else:
self.gtype = self.gtype
self.update_interval = setting_data.get('update_interval', None)
if self.update_interval:
self._start_update_thread()
......@@ -113,10 +113,10 @@ class Setting:
else:
global service_stopped
if service_stopped is False:
from ...main import get_main_window
while True:
w = get_main_window()
if w.get_visible() and w.get_mapped():
......@@ -148,10 +148,10 @@ class Setting:
if self._current_value is None or force is True:
backend = self._get_backend()
value = self.default
if backend:
value = backend.get_value(self.key, self.gtype) or self.default
self._current_value = value
return self._current_value
......@@ -163,7 +163,7 @@ class Setting:
def _set_backend_value(self, value):
backend = self._get_backend()
if backend:
backend.set_value(self.key, convert_by_gvariant(value, self.gtype), self.gtype)
backend.set_value(self.key, value, self.gtype)
self._current_value = value
def _get_backend(self):
......@@ -191,7 +191,6 @@ class Setting:
thread.start()
def _update_widget(self):
if self.widget:
self.widget.update_display()
return False
return False
\ No newline at end of file
......@@ -52,9 +52,7 @@ class TuneitWindow(Adw.ApplicationWindow):
self.update_settings_page()
def update_settings_page(self):
thread = threading.Thread(target=self._update_settings_page)
thread.daemon = True
thread.start()
self._update_settings_page()
def _update_settings_page(self, *args):
"""
......@@ -77,15 +75,15 @@ class TuneitWindow(Adw.ApplicationWindow):
print(error)
self.error_dialog.textbuffer.set_text(str(error))
GLib.idle_add(self.error_dialog.present, self)
self.error_dialog.present(self)
def setting_notify(self, module_name: str, notify: str, seconds: int = 5) -> None:
seconds = 5 if seconds is None else seconds
GLib.idle_add(self.settings_toast_overlay.dismiss_all)
self.settings_toast_overlay.dismiss_all()
toast = Adw.Toast(
title=f"{module_name}: {notify}",
timeout=seconds,
)
GLib.idle_add(self.settings_toast_overlay.add_toast, toast)
\ No newline at end of file
self.settings_toast_overlay.add_toast(toast)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment