update ui

parent 9d857475
<?xml version='1.0' encoding='UTF-8'?>
<!-- Created with Cambalache 0.92.0 -->
<?xml version="1.0" encoding="UTF-8"?>
<!--
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-name window.ui -->
<requires lib="Adw" version="1.0"/>
<requires lib="gio" version="2.0"/>
<requires lib="gtk" version="4.0"/>
<requires lib="libadwaita" version="1.4"/>
<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">
<property name="top-bar-style">raised</property>
<property name="top-bar-style">1</property>
<child type="top">
<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">
<object class="GtkMenuButton">
<property name="icon-name">open-menu-symbolic</property>
<property name="menu-model">primary_menu</property>
<property name="primary">True</property>
<property name="tooltip-text" translatable="yes">Menu</property>
<object class="GtkButton">
<property name="icon-name">help-about-symbolic</property>
<property name="action-name">app.about</property>
</object>
</child>
</object>
</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>
<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">
<property name="margin-bottom">12</property>
<property name="margin-bottom">4</property>
<property name="margin-end">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>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkBox">
<child>
<object class="GtkSearchEntry" id="search_entry">
<property name="hexpand">True</property>
<property name="hexpand">true</property>
</object>
</child>
<child>
......@@ -52,7 +83,7 @@
</items>
</object>
</property>
<property name="width-request">170</property>
<property name="halign">2</property>
</object>
</child>
<style>
......@@ -60,20 +91,21 @@
</style>
</object>
</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>
</child>
<child>
<property name="content">
<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>
<object class="GtkListBox" id="choice_listbox">
<property name="selection-mode">none</property>
<style>
<class name="boxed-list-separate"/>
</style>
......@@ -82,9 +114,9 @@
</object>
</child>
</object>
</child>
</property>
</object>
</child>
</property>
<child type="bottom">
<object class="AdwClamp">
<property name="margin-bottom">12</property>
......@@ -94,9 +126,9 @@
<property name="maximum-size">360</property>
<child type="center">
<object class="GtkListBox">
<property name="selection-mode">none</property>
<child>
<object class="AdwButtonRow" id="apply_button">
<property name="margin-start">1</property>
<property name="title" translatable="yes">Update applications</property>
<style>
<class name="suggested-action"/>
......@@ -112,8 +144,12 @@
</child>
</object>
</property>
<property name="default-height">489</property>
<property name="default-width">300</property>
</object>
</child>
</object>
</property>
</object>
</child>
</template>
<menu id="primary_menu">
<section>
......
......@@ -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()
......@@ -97,6 +102,9 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
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)
......@@ -106,13 +114,12 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
self.update_ui()
def show_loading_spinner(self):
self.loading_spinner.set_visible(True)
self.choice_listbox.set_visible(False) # Скрыть группу настроек во время загрузки
def on_search_toggle_button_clicked (self, obj, _pspec):
if not self.search_toggle_button.props.active:
self.search_entry.props.text = ""
def hide_loading_spinner(self):
self.loading_spinner.set_visible(False)
self.choice_listbox.set_visible(True)
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