update ui

parent 9d857475
<?xml version='1.0' encoding='UTF-8'?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Cambalache 0.92.0 --> <!--
DO NOT EDIT!
This file was @generated by blueprint-compiler. Instead, edit the
corresponding .blp file and regenerate this file with blueprint-compiler.
-->
<interface domain="eepm-play-gui"> <interface domain="eepm-play-gui">
<!-- interface-name window.ui -->
<requires lib="Adw" version="1.0"/>
<requires lib="gio" version="2.0"/>
<requires lib="gtk" version="4.0"/> <requires lib="gtk" version="4.0"/>
<requires lib="libadwaita" version="1.4"/>
<template class="EepmPlayGuiWindow" parent="AdwApplicationWindow"> <template class="EepmPlayGuiWindow" parent="AdwApplicationWindow">
<property name="content"> <property name="default-height">489</property>
<property name="default-width">300</property>
<property name="width-request">360</property>
<property name="height-request">294</property>
<child>
<object class="AdwToolbarView"> <object class="AdwToolbarView">
<property name="top-bar-style">raised</property> <property name="top-bar-style">1</property>
<child type="top"> <child type="top">
<object class="AdwHeaderBar" id="header_bar"> <object class="AdwHeaderBar" id="header_bar">
<child type="start">
<object class="GtkToggleButton" id="search_toggle_button">
<property name="sensitive" bind-source="EepmPlayGuiWindow" bind-property="is-loading" bind-flags="sync-create|invert-boolean"/>
<property name="icon-name">system-search-symbolic</property>
</object>
</child>
<child type="end"> <child type="end">
<object class="GtkMenuButton"> <object class="GtkButton">
<property name="icon-name">open-menu-symbolic</property> <property name="icon-name">help-about-symbolic</property>
<property name="menu-model">primary_menu</property> <property name="action-name">app.about</property>
<property name="primary">True</property>
<property name="tooltip-text" translatable="yes">Menu</property>
</object> </object>
</child> </child>
</object> </object>
</child> </child>
<property name="content">
<object class="GtkStack" id="main_stack">
<property name="transition-type">crossfade</property>
<child>
<object class="GtkStackPage">
<property name="name">loading</property>
<property name="child">
<object class="AdwStatusPage" id="status_page">
<property name="paintable">
<object class="AdwSpinnerPaintable">
<property name="widget">status_page</property>
</object>
</property>
<property name="title" translatable="yes">Getting packages list…</property>
<property name="description" translatable="yes">It could take a while</property>
</object>
</property>
</object>
</child>
<child> <child>
<object class="GtkStackPage">
<property name="name">main</property>
<property name="child">
<object class="AdwToolbarView">
<property name="content">
<object class="AdwToolbarView">
<property name="reveal-top-bars" bind-source="search_toggle_button" bind-property="active" bind-flags="sync-create"/>
<child type="top">
<object class="AdwClamp"> <object class="AdwClamp">
<property name="margin-bottom">12</property> <property name="margin-bottom">4</property>
<property name="margin-end">12</property> <property name="margin-end">12</property>
<property name="margin-start">12</property> <property name="margin-start">12</property>
<property name="margin-top">12</property> <property name="margin-top">4</property>
<property name="maximum-size">420</property> <property name="maximum-size">420</property>
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkBox">
<child> <child>
<object class="GtkSearchEntry" id="search_entry"> <object class="GtkSearchEntry" id="search_entry">
<property name="hexpand">True</property> <property name="hexpand">true</property>
</object> </object>
</child> </child>
<child> <child>
...@@ -52,7 +83,7 @@ ...@@ -52,7 +83,7 @@
</items> </items>
</object> </object>
</property> </property>
<property name="width-request">170</property> <property name="halign">2</property>
</object> </object>
</child> </child>
<style> <style>
...@@ -60,20 +91,21 @@ ...@@ -60,20 +91,21 @@
</style> </style>
</object> </object>
</child> </child>
<child>
<object class="AdwSpinner" id="loading_spinner">
<property name="halign">center</property>
<property name="height-request">48</property>
<property name="valign">center</property>
<property name="visible">False</property>
<property name="width-request">48</property>
</object> </object>
</child> </child>
<child> <property name="content">
<object class="GtkScrolledWindow"> <object class="GtkScrolledWindow">
<property name="vexpand">True</property> <property name="propagate-natural-height">true</property>
<property name="hscrollbar-policy">2</property>
<child>
<object class="AdwClamp">
<property name="margin-bottom">12</property>
<property name="margin-end">12</property>
<property name="margin-start">12</property>
<property name="margin-top">12</property>
<child> <child>
<object class="GtkListBox" id="choice_listbox"> <object class="GtkListBox" id="choice_listbox">
<property name="selection-mode">none</property>
<style> <style>
<class name="boxed-list-separate"/> <class name="boxed-list-separate"/>
</style> </style>
...@@ -82,9 +114,9 @@ ...@@ -82,9 +114,9 @@
</object> </object>
</child> </child>
</object> </object>
</child> </property>
</object> </object>
</child> </property>
<child type="bottom"> <child type="bottom">
<object class="AdwClamp"> <object class="AdwClamp">
<property name="margin-bottom">12</property> <property name="margin-bottom">12</property>
...@@ -94,9 +126,9 @@ ...@@ -94,9 +126,9 @@
<property name="maximum-size">360</property> <property name="maximum-size">360</property>
<child type="center"> <child type="center">
<object class="GtkListBox"> <object class="GtkListBox">
<property name="selection-mode">none</property>
<child> <child>
<object class="AdwButtonRow" id="apply_button"> <object class="AdwButtonRow" id="apply_button">
<property name="margin-start">1</property>
<property name="title" translatable="yes">Update applications</property> <property name="title" translatable="yes">Update applications</property>
<style> <style>
<class name="suggested-action"/> <class name="suggested-action"/>
...@@ -112,8 +144,12 @@ ...@@ -112,8 +144,12 @@
</child> </child>
</object> </object>
</property> </property>
<property name="default-height">489</property> </object>
<property name="default-width">300</property> </child>
</object>
</property>
</object>
</child>
</template> </template>
<menu id="primary_menu"> <menu id="primary_menu">
<section> <section>
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
# #
# SPDX-License-Identifier: AGPL-3.0-or-later # SPDX-License-Identifier: AGPL-3.0-or-later
from gi.repository import Gtk, Adw from gi.repository import Gtk, Adw, GObject
import gettext import gettext
gettext.textdomain('eepm-play-gui') gettext.textdomain('eepm-play-gui')
...@@ -83,10 +83,15 @@ class LogDialog(Adw.Dialog): ...@@ -83,10 +83,15 @@ class LogDialog(Adw.Dialog):
@Gtk.Template(resource_path='/ru/eepm/PlayGUI/ui/window.ui') @Gtk.Template(resource_path='/ru/eepm/PlayGUI/ui/window.ui')
class EepmPlayGuiWindow(Adw.ApplicationWindow): class EepmPlayGuiWindow(Adw.ApplicationWindow):
__gtype_name__ = 'EepmPlayGuiWindow' __gtype_name__ = 'EepmPlayGuiWindow'
is_loading = GObject.Property(type=bool, default=True)
search_entry = Gtk.Template.Child() search_entry = Gtk.Template.Child()
search_toggle_button = Gtk.Template.Child()
main_stack = Gtk.Template.Child()
search_dropdown = Gtk.Template.Child() search_dropdown = Gtk.Template.Child()
loading_spinner = Gtk.Template.Child()
choice_listbox = Gtk.Template.Child() choice_listbox = Gtk.Template.Child()
apply_button = Gtk.Template.Child() apply_button = Gtk.Template.Child()
...@@ -97,6 +102,9 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow): ...@@ -97,6 +102,9 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
self.apply_button.connect("activated", self.on_apply_clicked) 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_entry.connect("search-changed", self.on_search_changed)
self.search_dropdown.connect("notify::selected", self.on_filter_changed) self.search_dropdown.connect("notify::selected", self.on_filter_changed)
...@@ -106,13 +114,12 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow): ...@@ -106,13 +114,12 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
self.update_ui() self.update_ui()
def show_loading_spinner(self): def on_search_toggle_button_clicked (self, obj, _pspec):
self.loading_spinner.set_visible(True) if not self.search_toggle_button.props.active:
self.choice_listbox.set_visible(False) # Скрыть группу настроек во время загрузки self.search_entry.props.text = ""
def hide_loading_spinner(self): def on_is_loading_changed (self, obj, _pspec):
self.loading_spinner.set_visible(False) self.main_stack.props.visible_child_name = "loading" if self.props.is_loading else "main"
self.choice_listbox.set_visible(True)
def on_applications_loaded(self, applications, error=None): def on_applications_loaded(self, applications, error=None):
if error: if error:
...@@ -124,7 +131,7 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow): ...@@ -124,7 +131,7 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
self.installed_apps = None self.installed_apps = None
self.applications = None self.applications = None
self.show_loading_spinner() # Show loading again for installed apps self.props.is_loading = True
self.update_button_status() self.update_button_status()
...@@ -143,7 +150,7 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow): ...@@ -143,7 +150,7 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
self.add_application_row(app) self.add_application_row(app)
self.choice_listbox.invalidate_filter() self.choice_listbox.invalidate_filter()
self.hide_loading_spinner() self.props.is_loading = False
def clear_choice_listbox(self): def clear_choice_listbox(self):
self.choice_listbox.remove_all() self.choice_listbox.remove_all()
...@@ -218,7 +225,7 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow): ...@@ -218,7 +225,7 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
def on_apply_clicked(self, button): def on_apply_clicked(self, button):
commands = None commands = None
self.show_loading_spinner() # Показать сообщение о загрузке перед выполнением команды self.props.is_loading = True # Показать сообщение о загрузке перед выполнением команды
to_install, to_remove = self.get_install_remove_lists() to_install, to_remove = self.get_install_remove_lists()
commands = self.build_commands(to_install, to_remove) 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