Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
eepm-play-gui
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vladimir Vaskov
eepm-play-gui
Commits
8874800c
Commit
8874800c
authored
Sep 30, 2024
by
Roman Alifanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
filters and search bar are now working!
parent
70f3e20d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
+37
-0
window.py
src/window.py
+37
-0
No files found.
src/window.py
View file @
8874800c
...
...
@@ -135,6 +135,8 @@ class ApplicationManager:
@Gtk.Template
(
resource_path
=
'/ru/eepm/PlayGUI/window.ui'
)
class
EepmPlayGuiWindow
(
Adw
.
ApplicationWindow
):
__gtype_name__
=
'EepmPlayGuiWindow'
search_entry
=
Gtk
.
Template
.
Child
()
search_dropdown
=
Gtk
.
Template
.
Child
()
loading_spinner
=
Gtk
.
Template
.
Child
()
choice_listbox
=
Gtk
.
Template
.
Child
()
...
...
@@ -144,6 +146,11 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
super
()
.
__init__
(
**
kwargs
)
self
.
apply_button
.
connect
(
"activated"
,
self
.
on_apply_clicked
)
self
.
search_entry
.
connect
(
"search-changed"
,
self
.
on_search_changed
)
self
.
search_dropdown
.
connect
(
"notify::selected"
,
self
.
on_filter_changed
)
self
.
choice_listbox
.
set_filter_func
(
self
.
listbox_filter_func
)
self
.
loading_count
=
0
# Track loading operations
self
.
load_applications
()
...
...
@@ -173,6 +180,7 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
def
update_ui
(
self
):
self
.
show_loading_spinner
()
# Show loading again for installed apps
ApplicationManager
.
get_installed_applications
(
self
.
on_installed_apps_loaded
)
self
.
choice_listbox
.
invalidate_filter
()
def
on_installed_apps_loaded
(
self
,
installed_apps
,
error
=
None
):
if
error
:
...
...
@@ -210,6 +218,35 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
def
on_checkbox_toggled
(
self
,
checkbox
,
app_name
):
active
=
checkbox
.
get_active
()
print
(
f
"{app_name} {'установлен' if active else 'снят'}"
)
def
on_search_changed
(
self
,
search_entry
):
self
.
choice_listbox
.
invalidate_filter
()
# Обновление фильтра при изменении поиска
def
on_filter_changed
(
self
,
dropdown
,
_pspec
):
self
.
choice_listbox
.
invalidate_filter
()
# Обновление фильтра при изменении фильтра
def
listbox_filter_func
(
self
,
row
):
"""Функция фильтрации для GtkListBox, которая проверяет текст и состояние фильтра"""
search_text
=
self
.
search_entry
.
get_text
()
.
lower
()
filter_option
=
self
.
search_dropdown
.
get_selected
()
# Получение заголовка и подзаголовка строки
title
=
row
.
get_title
()
.
lower
()
if
row
.
get_title
()
else
''
subtitle
=
row
.
get_subtitle
()
.
lower
()
if
row
.
get_subtitle
()
else
''
# Проверка текста поиска (по имени или описанию)
matches_search
=
search_text
in
title
or
search_text
in
subtitle
# Проверка по фильтру: установлено/не установлено в системе
app_name
=
row
.
get_title
()
if
row
.
get_title
()
else
''
is_installed
=
app_name
in
self
.
installed_apps
if
filter_option
==
1
:
# Installed
return
matches_search
and
is_installed
elif
filter_option
==
2
:
# Uninstalled
return
matches_search
and
not
is_installed
else
:
return
matches_search
# All
def
on_apply_clicked
(
self
,
button
):
self
.
show_loading_spinner
()
# Показать сообщение о загрузке перед выполнением команды
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment