update ui

parent 9d857475
......@@ -17,7 +17,7 @@
#
# SPDX-License-Identifier: AGPL-3.0-or-later
from gi.repository import Gtk, Adw
from gi.repository import Gtk, Adw, GObject
import gettext
gettext.textdomain('eepm-play-gui')
......@@ -83,10 +83,15 @@ class LogDialog(Adw.Dialog):
@Gtk.Template(resource_path='/ru/eepm/PlayGUI/ui/window.ui')
class EepmPlayGuiWindow(Adw.ApplicationWindow):
__gtype_name__ = 'EepmPlayGuiWindow'
is_loading = GObject.Property(type=bool, default=True)
search_entry = Gtk.Template.Child()
search_toggle_button = Gtk.Template.Child()
main_stack = Gtk.Template.Child()
search_dropdown = Gtk.Template.Child()
loading_spinner = Gtk.Template.Child()
choice_listbox = Gtk.Template.Child()
apply_button = Gtk.Template.Child()
......@@ -96,6 +101,9 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
self.checkboxes = None
self.apply_button.connect("activated", self.on_apply_clicked)
self.connect("notify::is-loading", self.on_is_loading_changed)
self.search_toggle_button.connect("notify::active", self.on_search_toggle_button_clicked)
self.search_entry.connect("search-changed", self.on_search_changed)
self.search_dropdown.connect("notify::selected", self.on_filter_changed)
......@@ -105,14 +113,13 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
self.dialog = LogDialog(win=self)
self.update_ui()
def show_loading_spinner(self):
self.loading_spinner.set_visible(True)
self.choice_listbox.set_visible(False) # Скрыть группу настроек во время загрузки
def hide_loading_spinner(self):
self.loading_spinner.set_visible(False)
self.choice_listbox.set_visible(True)
def on_search_toggle_button_clicked (self, obj, _pspec):
if not self.search_toggle_button.props.active:
self.search_entry.props.text = ""
def on_is_loading_changed (self, obj, _pspec):
self.main_stack.props.visible_child_name = "loading" if self.props.is_loading else "main"
def on_applications_loaded(self, applications, error=None):
if error:
......@@ -124,7 +131,7 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
self.installed_apps = None
self.applications = None
self.show_loading_spinner() # Show loading again for installed apps
self.props.is_loading = True
self.update_button_status()
......@@ -143,7 +150,7 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
self.add_application_row(app)
self.choice_listbox.invalidate_filter()
self.hide_loading_spinner()
self.props.is_loading = False
def clear_choice_listbox(self):
self.choice_listbox.remove_all()
......@@ -218,7 +225,7 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
def on_apply_clicked(self, button):
commands = None
self.show_loading_spinner() # Показать сообщение о загрузке перед выполнением команды
self.props.is_loading = True # Показать сообщение о загрузке перед выполнением команды
to_install, to_remove = self.get_install_remove_lists()
commands = self.build_commands(to_install, to_remove)
......
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