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): ...@@ -21,9 +21,8 @@ def init_settings_stack(stack, listbox, split_view):
if stack.get_pages(): if stack.get_pages():
print("Clear pages...") print("Clear pages...")
GLib.idle_add(listbox.remove_all) listbox.remove_all()
for page in stack.get_pages(): for page in stack.get_pages(): stack.remove(page)
GLib.idle_add(stack.remove, page)
else: else:
print("First init...") print("First init...")
......
...@@ -29,7 +29,7 @@ class Page: ...@@ -29,7 +29,7 @@ class Page:
print(f"Секция {section.name} не создала виджетов.") print(f"Секция {section.name} не создала виджетов.")
if not_empty: if not_empty:
GLib.idle_add(self.update_ui, stack, listbox, pref_page) self.update_ui(stack, listbox, pref_page)
else: else:
print(f"the page {self.name} is empty, ignored") print(f"the page {self.name} is empty, ignored")
......
...@@ -43,7 +43,7 @@ class Setting: ...@@ -43,7 +43,7 @@ class Setting:
self.search_target = setting_data.get('search_target', None) self.search_target = setting_data.get('search_target', None)
self.map = setting_data.get('map') self.map = setting_data.get('map')
if self.map is None: if self.map is None:
if self.search_target is not None: if self.search_target is not None:
self.map = SearcherFactory.create(self.search_target).search() self.map = SearcherFactory.create(self.search_target).search()
...@@ -66,7 +66,7 @@ class Setting: ...@@ -66,7 +66,7 @@ class Setting:
self.gtype = self.gtype[0] self.gtype = self.gtype[0]
else: else:
self.gtype = self.gtype self.gtype = self.gtype
self.update_interval = setting_data.get('update_interval', None) self.update_interval = setting_data.get('update_interval', None)
if self.update_interval: if self.update_interval:
self._start_update_thread() self._start_update_thread()
...@@ -113,10 +113,10 @@ class Setting: ...@@ -113,10 +113,10 @@ class Setting:
else: else:
global service_stopped global service_stopped
if service_stopped is False: if service_stopped is False:
from ...main import get_main_window from ...main import get_main_window
while True: while True:
w = get_main_window() w = get_main_window()
if w.get_visible() and w.get_mapped(): if w.get_visible() and w.get_mapped():
...@@ -148,10 +148,10 @@ class Setting: ...@@ -148,10 +148,10 @@ class Setting:
if self._current_value is None or force is True: if self._current_value is None or force is True:
backend = self._get_backend() backend = self._get_backend()
value = self.default value = self.default
if backend: if backend:
value = backend.get_value(self.key, self.gtype) or self.default value = backend.get_value(self.key, self.gtype) or self.default
self._current_value = value self._current_value = value
return self._current_value return self._current_value
...@@ -163,7 +163,7 @@ class Setting: ...@@ -163,7 +163,7 @@ class Setting:
def _set_backend_value(self, value): def _set_backend_value(self, value):
backend = self._get_backend() backend = self._get_backend()
if 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 self._current_value = value
def _get_backend(self): def _get_backend(self):
...@@ -191,7 +191,6 @@ class Setting: ...@@ -191,7 +191,6 @@ class Setting:
thread.start() thread.start()
def _update_widget(self): def _update_widget(self):
if self.widget: if self.widget:
self.widget.update_display() self.widget.update_display()
return False return False
\ No newline at end of file
...@@ -52,9 +52,7 @@ class TuneitWindow(Adw.ApplicationWindow): ...@@ -52,9 +52,7 @@ class TuneitWindow(Adw.ApplicationWindow):
self.update_settings_page() self.update_settings_page()
def update_settings_page(self): def update_settings_page(self):
thread = threading.Thread(target=self._update_settings_page) self._update_settings_page()
thread.daemon = True
thread.start()
def _update_settings_page(self, *args): def _update_settings_page(self, *args):
""" """
...@@ -77,15 +75,15 @@ class TuneitWindow(Adw.ApplicationWindow): ...@@ -77,15 +75,15 @@ class TuneitWindow(Adw.ApplicationWindow):
print(error) print(error)
self.error_dialog.textbuffer.set_text(str(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: def setting_notify(self, module_name: str, notify: str, seconds: int = 5) -> None:
seconds = 5 if seconds is None else seconds 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( toast = Adw.Toast(
title=f"{module_name}: {notify}", title=f"{module_name}: {notify}",
timeout=seconds, timeout=seconds,
) )
GLib.idle_add(self.settings_toast_overlay.add_toast, toast) self.settings_toast_overlay.add_toast(toast)
\ No newline at end of file \ 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