Begin adding filter options

This commit is contained in:
heliguy
2023-09-23 02:02:05 -04:00
parent 45e89a858f
commit 45ae32c463
9 changed files with 238 additions and 13 deletions

View File

@@ -10,7 +10,7 @@ class myUtils:
self.user_data_path = self.host_home + "/.var/app/"
self.install_success = True
self.uninstall_success = True
def trashFolder(self, path):
if not os.path.exists(path):
return 1

121
src/filter.blp Normal file
View File

@@ -0,0 +1,121 @@
using Gtk 4.0;
using Adw 1;
template FilterWindow : Adw.Window {
default-width: 500;
default-height: 450;
title: _("Set a Filter");
modal: true;
Adw.ToolbarView main_toolbar_view {
[top]
HeaderBar header_bar {
show-title-buttons: false;
[start]
Button cancel_button {
label: _("Cancel");
}
[end]
Button apply_button {
label: _("Apply");
styles["suggested-action"]
}
}
content:
Adw.ToastOverlay toast_overlay {
Stack main_stack {
Box main_box {
orientation: vertical;
Overlay main_overlay {
ScrolledWindow scrolled_window {
vexpand: true;
Adw.Clamp{
Box outerbox {
orientation: vertical;
ListBox show_runtimes_list {
margin-top: 6;
margin-bottom: 6;
margin-start: 12;
margin-end: 12;
hexpand: true;
valign: start;
selection-mode: none;
styles["boxed-list"]
Adw.ActionRow runtimes_row {
title: _("Show Runtimes");
[suffix]
Box {
valign: center;
Switch runtimes_switch {
}
}
activatable-widget: runtimes_switch;
}
}
// ListBox install_type_list {
// margin-top: 6;
// margin-bottom: 6;
// margin-start: 12;
// margin-end: 12;
// hexpand: true;
// valign: start;
// selection-mode: none;
// styles["boxed-list"]
// Adw.ActionRow user {
// title: _("User wide");
// subtitle: _("Apps only available to you");
// [suffix]
// CheckButton user_check {
// }
// activatable-widget: user_check;
// }
// Adw.ActionRow system {
// title: _("System wide");
// subtitle: _("Apps available to everyone on this system");
// [suffix]
// CheckButton system_check {
// }
// activatable-widget: system_check;
// }
// }
ListBox remotes_list {
margin-top: 6;
margin-bottom: 6;
margin-start: 12;
margin-end: 12;
hexpand: true;
valign: start;
selection-mode: none;
styles["boxed-list"]
}
}
}
}
}
}
Adw.StatusPage no_data {
icon-name: "check-plain-symbolic";
title: _("No Leftover Data");
description: _("There is no leftover user data");
}
}
};
// [bottom]
// ActionBar action_bar {
// [start]
// ToggleButton select_all_button {
// label: _("Select All");
// }
// }
}
}

55
src/filter_window.py Normal file
View File

@@ -0,0 +1,55 @@
from gi.repository import Gtk, Adw, GLib, Gdk, Gio
from .common import myUtils
import subprocess
import os
import pathlib
@Gtk.Template(resource_path="/io/github/heliguy4599/Warehouse/filter.ui")
class FilterWindow(Adw.Window):
__gtype_name__ = "FilterWindow"
cancel_button = Gtk.Template.Child()
apply_button = Gtk.Template.Child()
remotes_list = Gtk.Template.Child()
runtimes_switch = Gtk.Template.Child()
def runtimesHandler(self, switch, state):
print(state)
def generateList(self):
for i in range(len(self.host_remotes)):
name = self.host_remotes[i][0]
title = self.host_remotes[i][1]
install_type = self.host_remotes[i][7]
url = self.host_remotes[i][2]
remote_row = Adw.ActionRow(title=title, subtitle=url)
if title == "-":
remote_row.set_title(name)
self.remotes_list.append(remote_row)
label = Gtk.Label(label=("{} wide").format(install_type))
label.add_css_class("subtitle")
remote_row.add_suffix(label)
row_select = Gtk.CheckButton()
remote_row.add_suffix(row_select)
remote_row.set_activatable_widget(row_select)
def __init__(self, main_window, **kwargs):
super().__init__(**kwargs)
# Create Variables
self.my_utils = myUtils(self)
self.host_remotes = self.my_utils.getHostRemotes()
self.filter_list = "the guh"
# Window Things
self.set_transient_for(main_window)
# Connections
self.apply_button.connect("clicked", lambda *_: main_window.updateFilter(self.filter_list))
self.apply_button.connect("clicked", lambda *_: self.close())
self.cancel_button.connect("clicked", lambda *_: self.close())
self.runtimes_switch.connect("state-set", self.runtimesHandler)
# Calls
self.generateList()

2
src/funnel-symbolic.svg Normal file
View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" height="16px" viewBox="0 0 16 16" width="16px"><path d="m 0 1.007812 h 15 l -6 7 v 6 l -3 2 v -8 z m 0 0"/></svg>

After

Width:  |  Height:  |  Size: 193 B

View File

@@ -49,6 +49,7 @@ class WarehouseApplication(Adw.Application):
self.create_action("refresh-list", self.refresh_list_shortcut, ["<primary>r", "F5"])
self.create_action("show-runtimes", self.show_runtimes_shortcut, ["<primary>t"])
self.create_action("show-remotes-window", self.show_remotes_shortcut, ["<primary>m"])
self.create_action("set-filter", self.filters_shortcut, ["<primary>y"])
self.show_runtimes_stateful = Gio.SimpleAction.new_stateful("show-runtimes", None, GLib.Variant.new_boolean(False))
self.show_runtimes_stateful.connect("activate", self.on_show_runtimes_action)
@@ -66,7 +67,6 @@ class WarehouseApplication(Adw.Application):
self.props.active_window.batch_select_all_handler(select_button)
def manage_data_shortcut(self, widget, _):
#self.props.active_window.orphans_window()
OrphansWindow(self.props.active_window).present()
def refresh_list_shortcut(self, widget, _):
@@ -79,9 +79,9 @@ class WarehouseApplication(Adw.Application):
def show_remotes_shortcut(self, widget, _):
RemotesWindow(self.props.active_window).present()
# def on_manage_data_folders_action(self, widget, _):
# #self.props.active_window.orphans_window()
# OrphansWindow(self.props.active_window).present()
def filters_shortcut(self, widget, _):
window = self.props.active_window
window.filterWindowHandler(window)
def do_activate(self):
"""Called when the application is activated.

View File

@@ -7,6 +7,7 @@ blueprints = custom_target('blueprints',
'gtk/help-overlay.blp',
'window.blp',
'orphans.blp',
'filter.blp',
),
output: '.',
command: [find_program('blueprint-compiler'), 'batch-compile', '@OUTPUT@', '@CURRENT_SOURCE_DIR@', '@INPUT@'],
@@ -46,6 +47,8 @@ warehouse_sources = [
'remotes.py',
'common.py',
'orphans.blp',
'filter_window.py',
'filter.blp'
]
install_data(warehouse_sources, install_dir: moduledir)

View File

@@ -3,6 +3,7 @@
<gresource prefix="/io/github/heliguy4599/Warehouse">
<file preprocess="xml-stripblanks">window.ui</file>
<file preprocess="xml-stripblanks">orphans.ui</file>
<file preprocess="xml-stripblanks">filter.ui</file>
<file preprocess="xml-stripblanks">gtk/help-overlay.ui</file>
</gresource>
<gresource prefix="/io/github/heliguy4599/Warehouse/icons/scalable/actions/">
@@ -14,5 +15,6 @@
<file preprocess="xml-stripblanks">check-plain-symbolic.svg</file>
<file preprocess="xml-stripblanks">paper-filled-symbolic.svg</file>
<file preprocess="xml-stripblanks">plus-large-symbolic.svg</file>
<file preprocess="xml-stripblanks">funnel-symbolic.svg</file>
</gresource>
</gresources>

View File

@@ -32,6 +32,12 @@ template WarehouseWindow : Adw.ApplicationWindow {
icon-name: "selection-mode-symbolic";
tooltip-text: _("Toggle Selection Mode");
}
[end]
Button filter_button {
icon-name: "funnel-symbolic";
tooltip-text: _("Filter Apps List");
}
}
[top]
SearchBar search_bar {
@@ -153,4 +159,4 @@ menu copy_menu {
action: "win.copy-refs";
}
}
}
}

View File

@@ -22,7 +22,7 @@ import subprocess
from gi.repository import Adw, Gdk, Gio, GLib, Gtk
from .properties_window import show_properties_window
#from .orphans_window import show_orphans_window
from .filter_window import FilterWindow
from .common import myUtils
@Gtk.Template(resource_path="/io/github/heliguy4599/Warehouse/window.ui")
@@ -46,6 +46,7 @@ class WarehouseWindow(Adw.ApplicationWindow):
main_box = Gtk.Template.Child()
main_overlay = Gtk.Template.Child()
main_toolbar_view = Gtk.Template.Child()
filter_button = Gtk.Template.Child()
main_progress_bar = Gtk.ProgressBar(visible=False, pulse_step=0.7)
main_progress_bar.add_css_class("osd")
@@ -169,6 +170,18 @@ class WarehouseWindow(Adw.ApplicationWindow):
self.selected_host_flatpak_indexes = []
self.should_select_all = self.batch_select_all_button.get_active()
def get_host_flatpaks():
output = subprocess.run(["flatpak-spawn", "--host", "flatpak", "list", "--columns=all"], capture_output=True, text=True).stdout
lines = output.strip().split("\n")
@@ -180,12 +193,15 @@ class WarehouseWindow(Adw.ApplicationWindow):
return data
self.host_flatpaks = get_host_flatpaks()
if self.host_flatpaks == [[""]]:
self.main_stack.set_visible_child(self.no_flatpaks)
self.search_button.set_visible(False)
self.search_bar.set_visible(False)
self.batch_mode_button.set_visible(False)
return
for index in range(len(self.host_flatpaks)):
app_name = self.host_flatpaks[index][0]
@@ -229,6 +245,13 @@ class WarehouseWindow(Adw.ApplicationWindow):
self.list_of_flatpaks.append(flatpak_row)
if not self.list_of_flatpaks.get_row_at_index(0):
self.main_stack.set_visible_child(self.no_flatpaks)
self.search_button.set_visible(False)
self.search_bar.set_visible(False)
self.batch_mode_button.set_visible(False)
return
def refresh_list_of_flatpaks(self, widget, should_toast):
self.list_of_flatpaks.remove_all()
self.generate_list_of_flatpaks()
@@ -349,6 +372,15 @@ class WarehouseWindow(Adw.ApplicationWindow):
self.clipboard.set(to_copy)
self.toast_overlay.add_toast(Adw.Toast.new(_("Copied selected app refs")))
def filterWindowHandler(self, widget):
filtwin = FilterWindow(self)
filtwin.present()
def updateFilter(self, filter):
self.filter_list = filter
self.refresh_list_of_flatpaks(self, True)
print(self.filter_list)
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.my_utils = myUtils(self)
@@ -372,3 +404,7 @@ class WarehouseWindow(Adw.ApplicationWindow):
self.create_action("copy-ids", self.copyIDs)
self.create_action("copy-refs", self.copyRefs)
self.filter_button.connect("clicked", self.filterWindowHandler)
self.filter_list = ""