Commit a5ff3b91 authored by Roman Alifanov's avatar Roman Alifanov

Standardization to the GNOME Application

parent 46883aaf
This diff is collapsed. Click to expand it.
# eepm-play-gui
A description of this project.
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><g color="#000" fill="#2e3436"><path d="M7.188 2.281c-.094.056-.192.125-.29.19L5.566 3.803a1.684 1.684 0 11-2.17 2.17L2.332 7.037c.506-.069 1.017-.136 1.2.026.242.214.139 1.031.155 1.656.213.088.427.171.657.219.04.008.085-.007.125 0 .337-.525.683-1.288 1-1.344.322-.057.905.562 1.406.937a3.67 3.67 0 00.656-.468c-.195-.595-.594-1.369-.437-1.657.158-.29 1.019-.37 1.625-.531.028-.183.062-.371.062-.562 0-.075-.027-.146-.031-.22-.587-.217-1.435-.385-1.562-.687-.128-.302.34-1.021.593-1.593a3.722 3.722 0 00-.593-.532zm3.875 3.25c-.165.475-.305 1.086-.47 1.563-.43.047-.84.14-1.218.312-.38-.322-.787-.773-1.156-1.093a5.562 5.562 0 00-.688.468c.177.46.453 1.001.625 1.469-.298.309-.531.67-.719 1.063-.494 0-1.102-.084-1.593-.094a5.68 5.68 0 00-.219.812c.435.24 1.006.468 1.438.72-.006.093-.032.185-.032.28 0 .333.049.66.125.97-.382.304-.898.63-1.28.937.015.044.04.083.058.127l.613.613c.417-.1.868-.223 1.266-.303.248.343.532.626.875.875-.027.135-.068.283-.104.428.174-.063.34-.155.482-.297l1.432-1.432a1.994 1.994 0 01.533-3.918c.919 0 1.684.623 1.918 1.467l1.338-1.338c.06-.06.11-.124.156-.191-.035-.062-.06-.13-.1-.188.096-.152.205-.31.315-.47.017-.348-.1-.7-.37-.971l-.177-.176c-.28.192-.561.387-.83.555-.345-.233-.746-.383-1.156-.5-.077-.507-.107-1.132-.187-1.625a5.44 5.44 0 00-.875-.063zm-9.247.608c-.087.068-.173.138-.254.205l.014.035z" style="marker:none" overflow="visible"/><path d="M8.707.293a1 1 0 00-1.415 0l-6.999 7a1 1 0 000 1.413l7 7.001a1 1 0 001.415 0l7-7a1 1 0 000-1.413zm-.708 2.121l5.587 5.587L8 13.586 2.414 7.999z" style="line-height:normal;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000;text-transform:none;text-orientation:mixed;shape-padding:0;isolation:auto;mix-blend-mode:normal;marker:none" font-weight="400" font-family="sans-serif" overflow="visible"/></g></svg>
\ No newline at end of file
application_id = 'ru.eepm.PlayGUI'
scalable_dir = 'hicolor' / 'scalable' / 'apps'
install_data(
scalable_dir / ('@0@.svg').format(application_id),
install_dir: get_option('datadir') / 'icons' / scalable_dir
)
symbolic_dir = 'hicolor' / 'symbolic' / 'apps'
install_data(
symbolic_dir / ('@0@-symbolic.svg').format(application_id),
install_dir: get_option('datadir') / 'icons' / symbolic_dir
)
desktop_file = i18n.merge_file(
input: 'ru.eepm.PlayGUI.desktop.in',
output: 'ru.eepm.PlayGUI.desktop',
type: 'desktop',
po_dir: '../po',
install: true,
install_dir: get_option('datadir') / 'applications'
)
desktop_utils = find_program('desktop-file-validate', required: false)
if desktop_utils.found()
test('Validate desktop file', desktop_utils, args: [desktop_file])
endif
appstream_file = i18n.merge_file(
input: 'ru.eepm.PlayGUI.metainfo.xml.in',
output: 'ru.eepm.PlayGUI.metainfo.xml',
po_dir: '../po',
install: true,
install_dir: get_option('datadir') / 'metainfo'
)
appstreamcli = find_program('appstreamcli', required: false, disabler: true)
test('Validate appstream file', appstreamcli,
args: ['validate', '--no-net', '--explain', appstream_file])
install_data('ru.eepm.PlayGUI.gschema.xml',
install_dir: get_option('datadir') / 'glib-2.0' / 'schemas'
)
compile_schemas = find_program('glib-compile-schemas', required: false, disabler: true)
test('Validate schema file',
compile_schemas,
args: ['--strict', '--dry-run', meson.current_source_dir()])
subdir('icons')
[Desktop Entry]
Name=eepm-play-gui
Exec=eepm-play-gui
Icon=ru.eepm.PlayGUI
Terminal=false
Type=Application
Categories=GTK;
StartupNotify=true
<?xml version="1.0" encoding="UTF-8"?>
<schemalist gettext-domain="eepm-play-gui">
<schema id="ru.eepm.PlayGUI" path="/ru/eepm/PlayGUI/">
</schema>
</schemalist>
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>ru.eepm.PlayGUI.desktop</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>AGPL-3.0-or-later</project_license>
<description>
<p>No description</p>
</description>
</component>
Name: eepm-play-gui
Version: 0.1.0
Release: alt1
License: AGPL2
Summary: GUI for epm play
Group: System/Configuration/Packaging
Url: https://gitlab.eterfund.ru/ximper/eepm-play-gui
BuildArch: noarch
Source: %name-%version.tar
BuildRequires(pre): rpm-macros-meson rpm-macros-systemd
BuildRequires(pre): rpm-build-python3
BuildRequires(pre): rpm-build-gir
BuildRequires: libadwaita-gir-devel
BuildRequires: meson
%add_python3_path %_datadir/%name
%description
GUI frontend for install third-party applications using epm play.
%prep
%setup
%build
%meson
%meson_build
%install
%meson_install
%find_lang %name
%files -f %name.lang
%_bindir/%name
%_datadir/%name
%_datadir/glib-2.0/schemas/*.gschema.xml
%_datadir/metainfo/*.metainfo.xml
%_desktopdir/ru.eepm.PlayGUI.desktop
%_iconsdir/hicolor/*/apps/*.svg
%changelog
* Thu Jul 11 2024 Roman Alifanov <ximper@altlinux.ru> 0.1.0-alt1
- initial build
project('eepm-play-gui',
version: '0.1.0',
meson_version: '>= 0.62.0',
default_options: [ 'warning_level=2', 'werror=false', ],
)
i18n = import('i18n')
gnome = import('gnome')
subdir('data')
subdir('src')
subdir('po')
gnome.post_install(
glib_compile_schemas: true,
gtk_update_icon_cache: true,
update_desktop_database: true,
)
data/ru.eepm.PlayGUI.desktop.in
data/ru.eepm.PlayGUI.metainfo.xml.in
data/ru.eepm.PlayGUI.gschema.xml
src/main.py
src/window.py
src/window.ui
i18n.gettext('eepm-play-gui', preset: 'glib')
{
"id" : "ru.eepm.PlayGUI",
"runtime" : "org.gnome.Platform",
"runtime-version" : "47",
"sdk" : "org.gnome.Sdk",
"command" : "eepm-play-gui",
"finish-args" : [
"--share=network",
"--share=ipc",
"--socket=fallback-x11",
"--device=dri",
"--socket=wayland"
],
"cleanup" : [
"/include",
"/lib/pkgconfig",
"/man",
"/share/doc",
"/share/gtk-doc",
"/share/man",
"/share/pkgconfig",
"*.la",
"*.a"
],
"modules" : [
{
"name" : "eepm-play-gui",
"builddir" : true,
"buildsystem" : "meson",
"sources" : [
{
"type" : "git",
"url" : "file:///home/ximper/Projects"
}
]
}
]
}
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/ru/eepm/PlayGUI">
<file preprocess="xml-stripblanks">window.ui</file>
<file preprocess="xml-stripblanks">gtk/help-overlay.ui</file>
</gresource>
</gresources>
#!@PYTHON@
# eepm-play-gui.in
#
# Copyright 2024 Etersoft
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# SPDX-License-Identifier: AGPL-3.0-or-later
import os
import sys
import signal
import locale
import gettext
VERSION = '@VERSION@'
pkgdatadir = '@pkgdatadir@'
localedir = '@localedir@'
sys.path.insert(1, pkgdatadir)
signal.signal(signal.SIGINT, signal.SIG_DFL)
locale.bindtextdomain('eepm-play-gui', localedir)
locale.textdomain('eepm-play-gui')
gettext.install('eepm-play-gui', localedir)
if __name__ == '__main__':
import gi
from gi.repository import Gio
resource = Gio.Resource.load(os.path.join(pkgdatadir, 'eepm-play-gui.gresource'))
resource._register()
from eepm_play_gui import main
sys.exit(main.main(VERSION))
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkShortcutsWindow" id="help_overlay">
<property name="modal">True</property>
<child>
<object class="GtkShortcutsSection">
<property name="section-name">shortcuts</property>
<property name="max-height">10</property>
<child>
<object class="GtkShortcutsGroup">
<property name="title" translatable="yes" context="shortcut window">General</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="title" translatable="yes" context="shortcut window">Show Shortcuts</property>
<property name="action-name">win.show-help-overlay</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="title" translatable="yes" context="shortcut window">Quit</property>
<property name="action-name">app.quit</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>
# main.py
#
# Copyright 2024 Etersoft
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# SPDX-License-Identifier: AGPL-3.0-or-later
import sys
import gi
gi.require_version('Gtk', '4.0')
gi.require_version('Adw', '1')
from gi.repository import Gtk, Gio, Adw
from .window import EepmPlayGuiWindow
class EepmPlayGuiApplication(Adw.Application):
"""The main application singleton class."""
def __init__(self):
super().__init__(application_id='ru.eepm.PlayGUI',
flags=Gio.ApplicationFlags.DEFAULT_FLAGS)
self.create_action('quit', lambda *_: self.quit(), ['<primary>q'])
self.create_action('about', self.on_about_action)
self.create_action('preferences', self.on_preferences_action)
def do_activate(self):
"""Called when the application is activated.
We raise the application's main window, creating it if
necessary.
"""
win = self.props.active_window
if not win:
win = EepmPlayGuiWindow(application=self)
win.present()
def on_about_action(self, widget, _):
"""Callback for the app.about action."""
about = Adw.AboutWindow(transient_for=self.props.active_window,
application_name='eepm-play-gui',
application_icon='ru.eepm.PlayGUI',
developer_name='Unknown',
version='0.1.0',
developers=['Unknown'],
copyright='© 2024 Unknown')
about.present()
def on_preferences_action(self, widget, _):
"""Callback for the app.preferences action."""
print('app.preferences action activated')
def create_action(self, name, callback, shortcuts=None):
"""Add an application action.
Args:
name: the name of the action
callback: the function to be called when the action is
activated
shortcuts: an optional list of accelerators
"""
action = Gio.SimpleAction.new(name, None)
action.connect("activate", callback)
self.add_action(action)
if shortcuts:
self.set_accels_for_action(f"app.{name}", shortcuts)
def main(version):
"""The application's entry point."""
app = EepmPlayGuiApplication()
return app.run(sys.argv)
pkgdatadir = get_option('prefix') / get_option('datadir') / meson.project_name()
moduledir = pkgdatadir / 'eepm_play_gui'
gnome = import('gnome')
gnome.compile_resources('eepm-play-gui',
'eepm-play-gui.gresource.xml',
gresource_bundle: true,
install: true,
install_dir: pkgdatadir,
)
python = import('python')
conf = configuration_data()
conf.set('PYTHON', python.find_installation('python3').full_path())
conf.set('VERSION', meson.project_version())
conf.set('localedir', get_option('prefix') / get_option('localedir'))
conf.set('pkgdatadir', pkgdatadir)
configure_file(
input: 'eepm-play-gui.in',
output: 'eepm-play-gui',
configuration: conf,
install: true,
install_dir: get_option('bindir'),
install_mode: 'r-xr-xr-x'
)
eepm_play_gui_sources = [
'__init__.py',
'main.py',
'window.py',
]
install_data(eepm_play_gui_sources, install_dir: moduledir)
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<!DOCTYPE cambalache-project SYSTEM "cambalache-project.dtd">
<cambalache-project version="0.92.0" target_tk="gtk-4.0">
<ui>
(1,1,"window.ui","window.ui",None,None,None,None,None,None,None)
</ui>
<ui_library>
(1,"Adw","1.0",None),
(1,"gio","2.0",None),
(1,"gtk","4.0",None),
(1,"libadwaita","1.4",None)
</ui_library>
<object>
(1,1,"AdwApplicationWindow","EepmPlayGuiWindow",None,None,None,None,0,None,None),
(1,2,"AdwToolbarView",None,1,None,None,None,0,None,None),
(1,3,"AdwHeaderBar","header_bar",2,None,"top",None,0,None,None),
(1,4,"GtkMenuButton",None,3,None,"end",None,0,None,None),
(1,5,"AdwClamp",None,2,None,None,None,1,None,None),
(1,6,"GtkBox",None,5,None,None,None,0,None,None),
(1,7,"GtkBox",None,6,None,None,None,0,None,None),
(1,8,"GtkSearchEntry","search_entry",7,None,None,None,0,None,None),
(1,9,"GtkDropDown","search_dropdown",7,None,None,None,1,None,None),
(1,10,"GtkStringList",None,9,None,None,None,0,None,None),
(1,11,"GtkScrolledWindow",None,6,None,None,None,2,None,None),
(1,12,"GtkListBox","choice_listbox",11,None,None,None,0,None,None),
(1,13,"AdwSpinner","loading_spinner",6,None,None,None,1,None,None),
(1,14,"AdwClamp",None,2,None,"bottom",None,2,None,None),
(1,15,"GtkListBox",None,14,None,"center",None,0,None,None),
(1,17,"(menu)","primary_menu",None,None,None,None,1,None,None),
(1,18,"(section)",None,17,None,None,None,0,None,None),
(1,19,"(item)",None,18,None,None,None,0,None,None),
(1,20,"(item)",None,18,None,None,None,1,None,None),
(1,21,"(item)",None,18,None,None,None,2,None,None),
(1,22,"AdwButtonRow","apply_button",15,None,None,None,0,None,None)
</object>
<object_property>
(1,1,"AdwApplicationWindow","content",None,0,None,None,None,2,None,None,None,None),
(1,1,"GtkWindow","default-height","300",0,None,None,None,None,None,None,None,None),
(1,1,"GtkWindow","default-width","600",0,None,None,None,None,None,None,None,None),
(1,2,"AdwToolbarView","top-bar-style","raised",0,None,None,None,None,None,None,None,None),
(1,4,"GtkMenuButton","icon-name","open-menu-symbolic",0,None,None,None,None,None,None,None,None),
(1,4,"GtkMenuButton","menu-model","17",0,None,None,None,None,None,None,None,None),
(1,4,"GtkMenuButton","primary","True",0,None,None,None,None,None,None,None,None),
(1,4,"GtkWidget","tooltip-text","Menu",1,None,None,None,None,None,None,None,None),
(1,5,"AdwClamp","maximum-size","360",0,None,None,None,None,None,None,None,None),
(1,5,"GtkWidget","margin-bottom","12",0,None,None,None,None,None,None,None,None),
(1,5,"GtkWidget","margin-end","12",0,None,None,None,None,None,None,None,None),
(1,5,"GtkWidget","margin-start","12",0,None,None,None,None,None,None,None,None),
(1,5,"GtkWidget","margin-top","12",0,None,None,None,None,None,None,None,None),
(1,6,"GtkBox","spacing","12",0,None,None,None,None,None,None,None,None),
(1,6,"GtkOrientable","orientation","vertical",0,None,None,None,None,None,None,None,None),
(1,8,"GtkWidget","hexpand","True",0,None,None,None,None,None,None,None,None),
(1,9,"GtkDropDown","model",None,0,None,None,None,10,None,None,None,None),
(1,11,"GtkWidget","vexpand","True",0,None,None,None,None,None,None,None,None),
(1,13,"GtkWidget","halign","center",0,None,None,None,None,None,None,None,None),
(1,13,"GtkWidget","height-request","48",0,None,None,None,None,None,None,None,None),
(1,13,"GtkWidget","valign","center",0,None,None,None,None,None,None,None,None),
(1,13,"GtkWidget","visible","False",0,None,None,None,None,None,None,None,None),
(1,13,"GtkWidget","width-request","48",0,None,None,None,None,None,None,None,None),
(1,14,"AdwClamp","maximum-size","360",0,None,None,None,None,None,None,None,None),
(1,14,"GtkWidget","margin-bottom","12",0,None,None,None,None,None,None,None,None),
(1,14,"GtkWidget","margin-end","12",0,None,None,None,None,None,None,None,None),
(1,14,"GtkWidget","margin-start","12",0,None,None,None,None,None,None,None,None),
(1,14,"GtkWidget","margin-top","12",0,None,None,None,None,None,None,None,None),
(1,19,"(item)","action","app.preferences",0,None,None,None,None,None,None,None,None),
(1,19,"(item)","label","_Preferences",1,None,None,None,None,None,None,None,None),
(1,20,"(item)","action","win.show-help-overlay",0,None,None,None,None,None,None,None,None),
(1,20,"(item)","label","_Keyboard Shortcuts",1,None,None,None,None,None,None,None,None),
(1,21,"(item)","action","app.about",0,None,None,None,None,None,None,None,None),
(1,21,"(item)","label","_About Eepm-play-gui",1,None,None,None,None,None,None,None,None),
(1,22,"AdwPreferencesRow","title","Apply",None,None,None,None,None,None,None,None,None),
(1,22,"GtkWidget","margin-start","1",None,None,None,None,None,None,None,None,None)
</object_property>
<object_data>
(1,10,"GtkStringList",1,1,None,None,None,None,None,None),
(1,10,"GtkStringList",2,2,"All",1,None,0,None,None),
(1,10,"GtkStringList",2,3,"Installed",1,None,0,None,None),
(1,10,"GtkStringList",2,4,"Uninstalled",1,None,0,None,None),
(1,7,"GtkWidget",1,1,None,None,None,None,None,None),
(1,7,"GtkWidget",2,2,None,1,None,None,None,None),
(1,12,"GtkWidget",1,1,None,None,None,None,None,None),
(1,12,"GtkWidget",2,2,None,1,None,None,None,None),
(1,15,"GtkWidget",1,1,None,None,None,None,None,None),
(1,15,"GtkWidget",2,2,None,1,None,None,None,None),
(1,22,"GtkWidget",1,1,None,None,None,None,None,None),
(1,22,"GtkWidget",2,2,None,1,None,None,None,None)
</object_data>
<object_data_arg>
(1,7,"GtkWidget",2,2,"name","linked"),
(1,12,"GtkWidget",2,2,"name","boxed-list"),
(1,15,"GtkWidget",2,2,"name","boxed-list"),
(1,22,"GtkWidget",2,2,"name","suggested-action")
</object_data_arg>
</cambalache-project>
#!/usr/bin/python3
# window.py
#
# Copyright 2024 Etersoft
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# SPDX-License-Identifier: AGPL-3.0-or-later
import sys
import gi
import subprocess
import threading
gi.require_version('Gtk', '4.0')
gi.require_version('Adw', '1')
from gi.repository import Gtk, Adw, GLib
......@@ -116,91 +131,32 @@ class ApplicationManager:
lines = output.splitlines()[1:]
return [line.split(' - ')[0].strip().split()[0] for line in lines]
class MainWindow(Adw.ApplicationWindow):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.set_title("eepm play gui")
self.toolbar = Adw.ToolbarView()
self.toolbar.add_top_bar(Adw.HeaderBar())
self.set_content(self.toolbar)
# Clamp
content_clamp = Adw.Clamp(
margin_bottom=12,
margin_end=12,
margin_top=12,
margin_start=12,
maximum_size=500
)
self.toolbar.set_content(content_clamp)
# Инициализация основного контейнера
self.box1 = Gtk.Box(
orientation=Gtk.Orientation.VERTICAL
)
content_clamp.set_child(self.box1)
self.create_ui_elements()
self.loading_count = 0 # Track loading operations
self.load_applications()
def create_ui_elements(self):
# Создание скролл-окна
self.scrolled_window = Gtk.ScrolledWindow()
self.scrolled_window.set_vexpand(True)
@Gtk.Template(resource_path='/ru/eepm/PlayGUI/window.ui')
class EepmPlayGuiWindow(Adw.ApplicationWindow):
__gtype_name__ = 'EepmPlayGuiWindow'
# Создание контейнера для содержимого и группы настроек
self.content_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.preferences_group = Adw.PreferencesGroup()
self.content_box.append(self.preferences_group)
loading_spinner = Gtk.Template.Child()
choice_listbox = Gtk.Template.Child()
apply_button = Gtk.Template.Child()
# Добавление скролл-окна в основной контейнер
self.scrolled_window.set_child(self.content_box)
self.box1.append(self.scrolled_window)
bottom_clamp = Adw.Clamp(
margin_bottom=12,
margin_end=12,
margin_top=12,
margin_start=12,
maximum_size=360
)
bottom_listbox = Gtk.ListBox()
bottom_listbox.add_css_class("boxed-list")
bottom_clamp.set_child(bottom_listbox)
# Кнопка применения
apply_button = Adw.ButtonRow(
title="Применить"
)
apply_button.add_css_class("suggested-action")
apply_button.connect("activated", self.on_apply_clicked)
bottom_listbox.append(apply_button)
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.apply_button.connect("activated", self.on_apply_clicked)
self.toolbar.add_bottom_bar(bottom_clamp)
# Создание и добавление сообщения о загрузке
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) # Изначально скрыта
self.loading_count = 0 # Track loading operations
self.load_applications()
def show_loading_spinner(self):
self.loading_spinner.set_visible(True)
self.preferences_group.set_visible(False) # Скрыть группу настроек во время загрузки
self.choice_listbox.set_visible(False) # Скрыть группу настроек во время загрузки
self.loading_count += 1 # Increment loading counter
def hide_loading_spinner(self):
self.loading_count -= 1 # Decrement loading counter
if self.loading_count == 0:
self.loading_spinner.set_visible(False)
self.preferences_group.set_visible(True)
self.choice_listbox.set_visible(True)
def load_applications(self):
self.show_loading_spinner()
......@@ -223,7 +179,7 @@ class MainWindow(Adw.ApplicationWindow):
print(f"Error: {error}")
else:
self.installed_apps = installed_apps
self.clear_preferences_group()
self.clear_choice_listbox()
self.checkboxes = {}
for app in self.applications:
......@@ -231,10 +187,8 @@ class MainWindow(Adw.ApplicationWindow):
self.hide_loading_spinner() # Now only hides after both loads are done
def clear_preferences_group(self):
self.content_box.remove(self.preferences_group)
self.preferences_group = Adw.PreferencesGroup()
self.content_box.append(self.preferences_group)
def clear_choice_listbox(self):
self.choice_listbox.remove_all()
def add_application_row(self, app):
row = Adw.ActionRow(
......@@ -250,7 +204,7 @@ class MainWindow(Adw.ApplicationWindow):
checkbox.connect("toggled", self.on_checkbox_toggled, app['name'])
row.add_suffix(checkbox)
self.preferences_group.add(row)
self.choice_listbox.append(row)
self.checkboxes[app['name']] = checkbox
def on_checkbox_toggled(self, checkbox, app_name):
......@@ -316,25 +270,3 @@ class MainWindow(Adw.ApplicationWindow):
self.update_ui() # Обновление UI после закрытия диалога
self.hide_loading_spinner() # Скрыть сообщение о загрузке после закрытия диалога
class MyApp(Adw.Application):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.connect('activate', self.on_activate)
def on_activate(self, app):
self.win = MainWindow(
application=app,
default_width=600,
default_height=500,
width_request=360,
height_request=294
)
self.win.present()
if __name__ == "__main__":
app = MyApp(application_id="ru.etersoft.EtersoftEpmPlayGUI")
app.run(sys.argv)
<?xml version='1.0' encoding='UTF-8'?>
<!-- Created with Cambalache 0.92.0 -->
<interface>
<!-- 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">
<object class="AdwToolbarView">
<property name="top-bar-style">raised</property>
<child type="top">
<object class="AdwHeaderBar" id="header_bar">
<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>
</child>
</object>
</child>
<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>
<property name="maximum-size">360</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>
</object>
</child>
<child>
<object class="GtkDropDown" id="search_dropdown">
<property name="model">
<object class="GtkStringList">
<items>
<item>All</item>
<item>Installed</item>
<item>Uninstalled</item>
</items>
</object>
</property>
</object>
</child>
<style>
<class name="linked"/>
</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>
<object class="GtkScrolledWindow">
<property name="vexpand">True</property>
<child>
<object class="GtkListBox" id="choice_listbox">
<style>
<class name="boxed-list"/>
</style>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child type="bottom">
<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>
<property name="maximum-size">360</property>
<child type="center">
<object class="GtkListBox">
<child>
<object class="AdwButtonRow" id="apply_button">
<property name="margin-start">1</property>
<property name="title">Apply</property>
<style>
<class name="suggested-action"/>
</style>
</object>
</child>
<style>
<class name="boxed-list"/>
</style>
</object>
</child>
</object>
</child>
</object>
</property>
<property name="default-height">300</property>
<property name="default-width">600</property>
</template>
<menu id="primary_menu">
<section>
<item>
<attribute name="action">app.preferences</attribute>
<attribute name="label" translatable="yes">_Preferences</attribute>
</item>
<item>
<attribute name="action">win.show-help-overlay</attribute>
<attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
</item>
<item>
<attribute name="action">app.about</attribute>
<attribute name="label" translatable="yes">_About Eepm-play-gui</attribute>
</item>
</section>
</menu>
</interface>
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