Commit 46883aaf authored by Roman Alifanov's avatar Roman Alifanov

label to spinner

parent 8b67a237
......@@ -183,23 +183,27 @@ class MainWindow(Adw.ApplicationWindow):
self.toolbar.add_bottom_bar(bottom_clamp)
# Создание и добавление сообщения о загрузке
self.loading_label = Gtk.Label(label="Загрузка, пожалуйста подождите...")
self.content_box.append(self.loading_label)
self.loading_label.set_visible(False) # Изначально скрыта
self.loading_spinner = Adw.Spinner(
halign="center", valign="center",
width_request=48,
height_request=48
)
self.content_box.append(self.loading_spinner)
self.loading_spinner.set_visible(False) # Изначально скрыта
def show_loading_message(self):
self.loading_label.set_visible(True)
def show_loading_spinner(self):
self.loading_spinner.set_visible(True)
self.preferences_group.set_visible(False) # Скрыть группу настроек во время загрузки
self.loading_count += 1 # Increment loading counter
def hide_loading_message(self):
def hide_loading_spinner(self):
self.loading_count -= 1 # Decrement loading counter
if self.loading_count == 0:
self.loading_label.set_visible(False)
self.loading_spinner.set_visible(False)
self.preferences_group.set_visible(True)
def load_applications(self):
self.show_loading_message()
self.show_loading_spinner()
ApplicationManager.get_available_applications(self.on_applications_loaded)
def on_applications_loaded(self, applications, error=None):
......@@ -208,10 +212,10 @@ class MainWindow(Adw.ApplicationWindow):
else:
self.applications = applications
self.update_ui()
self.hide_loading_message() # Move this to ensure it waits for installation loading too
self.hide_loading_spinner() # Move this to ensure it waits for installation loading too
def update_ui(self):
self.show_loading_message() # Show loading again for installed apps
self.show_loading_spinner() # Show loading again for installed apps
ApplicationManager.get_installed_applications(self.on_installed_apps_loaded)
def on_installed_apps_loaded(self, installed_apps, error=None):
......@@ -225,7 +229,7 @@ class MainWindow(Adw.ApplicationWindow):
for app in self.applications:
self.add_application_row(app)
self.hide_loading_message() # Now only hides after both loads are done
self.hide_loading_spinner() # Now only hides after both loads are done
def clear_preferences_group(self):
self.content_box.remove(self.preferences_group)
......@@ -254,7 +258,7 @@ class MainWindow(Adw.ApplicationWindow):
print(f"{app_name} {'установлен' if active else 'снят'}")
def on_apply_clicked(self, button):
self.show_loading_message() # Показать сообщение о загрузке перед выполнением команды
self.show_loading_spinner() # Показать сообщение о загрузке перед выполнением команды
to_install, to_remove = self.get_install_remove_lists()
commands = self.build_commands(to_install, to_remove)
......@@ -310,7 +314,7 @@ class MainWindow(Adw.ApplicationWindow):
def update_ui_after_log(self):
self.update_ui() # Обновление UI после закрытия диалога
self.hide_loading_message() # Скрыть сообщение о загрузке после закрытия диалога
self.hide_loading_spinner() # Скрыть сообщение о загрузке после закрытия диалога
class MyApp(Adw.Application):
......
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