diff --git a/src/filter.blp b/src/filter.blp
index fcfb7d5..dc238ce 100644
--- a/src/filter.blp
+++ b/src/filter.blp
@@ -34,7 +34,7 @@ template FilterWindow : Adw.Window {
Box outerbox {
orientation: vertical;
- ListBox show_runtimes_list {
+ ListBox install_type_list {
margin-top: 6;
margin-bottom: 6;
margin-start: 12;
@@ -44,8 +44,23 @@ template FilterWindow : Adw.Window {
selection-mode: none;
styles["boxed-list"]
- Adw.SwitchRow runtimes_row {
+ Adw.ActionRow apps_row {
+ title: _("Show Apps");
+
+ Switch apps_switch {
+ valign: center;
+ }
+
+ activatable-widget: apps_switch;
+ }
+ Adw.ActionRow runtimes_row {
title: _("Show Runtimes");
+
+ Switch runtimes_switch {
+ valign: center;
+ }
+
+ activatable-widget: runtimes_switch;
}
}
// ListBox install_type_list {
@@ -79,6 +94,13 @@ template FilterWindow : Adw.Window {
// activatable-widget: system_check;
// }
// }
+ Label header_label {
+ margin-top: 6;
+ margin-bottom: 3;
+ margin-start: 12;
+ halign: start;
+ label: _("Show Flatpaks from these remotes");
+ }
ListBox remotes_list {
margin-top: 6;
margin-bottom: 6;
diff --git a/src/filter_window.py b/src/filter_window.py
index 7e46b63..93c69a2 100644
--- a/src/filter_window.py
+++ b/src/filter_window.py
@@ -11,28 +11,60 @@ class FilterWindow(Adw.Window):
cancel_button = Gtk.Template.Child()
apply_button = Gtk.Template.Child()
remotes_list = Gtk.Template.Child()
- runtimes_row = Gtk.Template.Child()
+ apps_switch = Gtk.Template.Child()
+ runtimes_switch = Gtk.Template.Child()
+ header_label = Gtk.Template.Child()
def key_handler(self, _a, event, _c, _d):
if event == Gdk.KEY_Escape:
self.close()
+ def isListApplicable(self):
+ self.apply_button.set_sensitive(False)
+
+ if self.filter_list[0] == True or self.filter_list[1] == True:
+ if not self.filter_list[3] == []:
+ self.apply_button.set_sensitive(True)
+
+ def appsHandler(self, switch, _a):
+ self.filter_list[0] = switch.get_active()
+ self.isListApplicable()
+
def runtimesHandler(self, switch, _a):
- print(switch.get_active())
+ self.filter_list[1] = switch.get_active()
+ self.isListApplicable()
+
+ def remoteCheckHandler(self, checkbox, install_type, remote):
+ if checkbox.get_active():
+ self.filter_list[2].append(install_type)
+ self.filter_list[3].append(remote)
+ else:
+ self.filter_list[2].remove(install_type)
+ self.filter_list[3].remove(remote)
+
+ self.isListApplicable()
def generateList(self):
+ Gtk.Label.set_markup(self.header_label, ("{}").format(self.header_label.get_label()))
+
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.SwitchRow(title=title, subtitle=url)
+ 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_check = Gtk.CheckButton()
remote_row.add_suffix(label)
+ remote_row.add_suffix(remote_check)
+ remote_row.set_activatable_widget(remote_check)
+
+ remote_check.connect("toggled", self.remoteCheckHandler, install_type, name)
+ remote_check.set_active(True)
def __init__(self, main_window, **kwargs):
super().__init__(**kwargs)
@@ -40,8 +72,9 @@ class FilterWindow(Adw.Window):
# Create Variables
self.my_utils = myUtils(self)
self.host_remotes = self.my_utils.getHostRemotes()
- self.filter_list = "the guh"
+ self.filter_list = [False, False, [], []]
event_controller = Gtk.EventControllerKey()
+ self.app_window = main_window
# Window Things
self.set_transient_for(main_window)
@@ -50,11 +83,23 @@ class FilterWindow(Adw.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 *_: main_window.filter_button.set_active(False))
self.cancel_button.connect("clicked", lambda *_: self.close())
- self.runtimes_row.connect("notify::active", self.runtimesHandler)
+
+ self.apps_switch.connect("state-set", self.appsHandler)
+ self.runtimes_switch.connect("state-set", self.runtimesHandler)
event_controller.connect("key-pressed", self.key_handler)
# Calls
- self.generateList()
+ self.apps_switch.set_active(True)
+ self.set_size_request(260, 230)
+ if not self.host_remotes[0][0] == '':
+ self.generateList()
+ else:
+ self.header_label.set_visible(False)
+ self.remotes_list.set_visible(False)
+ self.filter_list[2] = "all"
+ self.filter_list[3] = "all"
diff --git a/src/gtk/help-overlay.blp b/src/gtk/help-overlay.blp
index bf852fc..6f8afc7 100644
--- a/src/gtk/help-overlay.blp
+++ b/src/gtk/help-overlay.blp
@@ -15,6 +15,11 @@ ShortcutsWindow help_overlay {
action-name: "app.search";
}
+ ShortcutsShortcut {
+ title: C_("shortcut window", "Set a Filter");
+ action-name: "app.set-filter";
+ }
+
ShortcutsShortcut {
title: C_("shortcut window", "Refresh");
action-name: "app.refresh-list";
@@ -29,11 +34,6 @@ ShortcutsWindow help_overlay {
title: C_("shortcut window", "Select All Apps");
action-name: "app.select-all-in-batch-mode";
}
-
- ShortcutsShortcut {
- title: C_("shortcut window", "Show Runtimes");
- action-name: "app.show-runtimes";
- }
}
ShortcutsGroup {
title: C_("shortcut window", "More Functions");
diff --git a/src/main.py b/src/main.py
index 791e5ff..f1a8e6b 100644
--- a/src/main.py
+++ b/src/main.py
@@ -47,13 +47,8 @@ class WarehouseApplication(Adw.Application):
self.create_action("select-all-in-batch-mode", self.select_all_shortcut, ["a"])
self.create_action("manage-data-folders", self.manage_data_shortcut, ["d"])
self.create_action("refresh-list", self.refresh_list_shortcut, ["r", "F5"])
- self.create_action("show-runtimes", self.show_runtimes_shortcut, ["t"])
self.create_action("show-remotes-window", self.show_remotes_shortcut, ["m"])
- self.create_action("set-filter", self.filters_shortcut, ["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)
- self.add_action(self.show_runtimes_stateful)
+ self.create_action("set-filter", self.filters_shortcut, ["t"])
def batch_mode_shortcut(self, widget, _):
button = self.props.active_window.batch_mode_button
@@ -72,10 +67,6 @@ class WarehouseApplication(Adw.Application):
def refresh_list_shortcut(self, widget, _):
self.props.active_window.refresh_list_of_flatpaks(widget, True)
- def show_runtimes_shortcut(self, widget, _):
- window = self.props.active_window
- window.show_runtimes_toggle_handler(window, not window.show_runtimes)
-
def show_remotes_shortcut(self, widget, _):
RemotesWindow(self.props.active_window).present()
@@ -116,11 +107,6 @@ class WarehouseApplication(Adw.Application):
def on_search_action(self, widget, _):
self.props.active_window.search_bar.set_search_mode(not self.props.active_window.search_bar.get_search_mode())
-
- def on_show_runtimes_action(self, widget, _):
- self.show_runtimes_stateful.set_state(GLib.Variant.new_boolean(state := (not self.show_runtimes_stateful.get_property("state").get_boolean())))
- self.props.active_window.show_runtimes_toggle_handler(state)
-
def create_action(self, name, callback, shortcuts=None):
"""Add an application action.
diff --git a/src/window.blp b/src/window.blp
index 381de78..5d6d952 100644
--- a/src/window.blp
+++ b/src/window.blp
@@ -20,18 +20,18 @@ template WarehouseWindow : Adw.ApplicationWindow {
tooltip-text: _("Search for an Installed App");
}
+ [start]
+ ToggleButton filter_button {
+ icon-name: "funnel-symbolic";
+ tooltip-text: _("Filter Apps List");
+ }
+
[end]
MenuButton {
icon-name: "open-menu-symbolic";
tooltip-text: _("Main Menu");
menu-model: primary_menu;
}
-
- [end]
- ToggleButton filter_button {
- icon-name: "funnel-symbolic";
- tooltip-text: _("Filter Apps List");
- }
[end]
ToggleButton batch_mode_button {
@@ -101,7 +101,7 @@ template WarehouseWindow : Adw.ApplicationWindow {
[end]
MenuButton batch_copy_button {
icon-name: "edit-copy-symbolic";
- tooltip-text: _("Copy Selected App IDs");
+ tooltip-text: _("Open Copy Menu");
menu-model: copy_menu;
}
}
@@ -110,10 +110,6 @@ template WarehouseWindow : Adw.ApplicationWindow {
menu primary_menu {
section {
- item {
- label: _("Show Runtimes");
- action: "app.show-runtimes";
- }
item {
label: _("Manage Orphaned Data");
diff --git a/src/window.py b/src/window.py
index 34233db..d822146 100644
--- a/src/window.py
+++ b/src/window.py
@@ -210,11 +210,11 @@ class WarehouseWindow(Adw.ApplicationWindow):
# Setting up filter stuff
- self.show_runtimes = self.filter_list[0]
- self.filter_install_type = self.filter_list[1]
- self.filter_remotes_list = self.filter_list[2]
+ self.show_apps = self.filter_list[0]
+ self.show_runtimes = self.filter_list[1]
+ self.filter_install_type = self.filter_list[2]
+ self.filter_remotes_list = self.filter_list[3]
- print(self.filter_list)
for index in range(len(self.host_flatpaks)):
app_name = self.host_flatpaks[index][0]
app_id = self.host_flatpaks[index][2]
@@ -224,18 +224,16 @@ class WarehouseWindow(Adw.ApplicationWindow):
flatpak_row.set_subtitle(self.host_flatpaks[index][8])
# Check the filter and skip row if it does not meet the filter
+ if (not self.show_apps) and (not "runtime" in self.host_flatpaks[index][12]):
+ continue
+
if (not self.show_runtimes) and "runtime" in self.host_flatpaks[index][12]:
- print("skip runtime", app_id)
continue
if (not 'all' in self.filter_install_type) and (not self.host_flatpaks[index][7] in self.filter_install_type):
- print(self.filter_install_type)
- print("skip install type", app_name)
continue
if (not 'all' in self.filter_remotes_list) and (not self.host_flatpaks[index][6] in self.filter_remotes_list):
- print(self.filter_install_type)
- print("skip remote", app_name)
continue
properties_button = Gtk.Button(icon_name="info-symbolic", valign=Gtk.Align.CENTER, tooltip_text=_("View Properties"))
@@ -265,7 +263,6 @@ class WarehouseWindow(Adw.ApplicationWindow):
self.list_of_flatpaks.append(flatpak_row)
- print(self.list_of_flatpaks.get_row_at_index(0))
windowSetEmpty(self.list_of_flatpaks.get_row_at_index(0))
def refresh_list_of_flatpaks(self, widget, should_toast):
@@ -274,14 +271,6 @@ class WarehouseWindow(Adw.ApplicationWindow):
if should_toast:
self.toast_overlay.add_toast(Adw.Toast.new(_("List refreshed")))
- def show_runtimes_toggle_handler(self, state):
- if state:
- self.show_runtimes = True
- else:
- self.show_runtimes = False
- self.refresh_list_of_flatpaks(None, False)
- self.selected_host_flatpak_indexes.clear()
-
def batch_mode_handler(self, widget):
self.batch_select_all_button.set_active(False)
if widget.get_active():
@@ -390,17 +379,21 @@ class WarehouseWindow(Adw.ApplicationWindow):
def filterWindowHandler(self, widget):
if widget.get_active():
- # filtwin = FilterWindow(self)
- # filtwin.present()
- self.filter_list = [False, ["user"], ["kdeapps"]]
- self.refresh_list_of_flatpaks(self, False)
+ filtwin = FilterWindow(self)
+ filtwin.present()
else:
- self.filter_list = [False, ["all"], ["all"]]
- self.refresh_list_of_flatpaks(self, False)
+ old_list = self.filter_list
+ self.resetFilterList()
+ if old_list != self.filter_list:
+ self.refresh_list_of_flatpaks(self, False)
+ self.toast_overlay.add_toast(Adw.Toast.new(_("Filter reset")))
def filterWindowKeyboardHandler(self, widget):
self.filter_button.set_active(not self.filter_button.get_active())
+ def resetFilterList(self):
+ self.filter_list = [True, False, ["all"], ["all"]]
+
def updateFilter(self, filter):
self.filter_list = filter
self.refresh_list_of_flatpaks(self, False)
@@ -408,7 +401,8 @@ class WarehouseWindow(Adw.ApplicationWindow):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.my_utils = myUtils(self)
- self.filter_list = [False, ["all"], ["all"]]
+ self.filter_list = []
+ self.resetFilterList()
self.list_of_flatpaks.set_filter_func(self.filter_func)
self.set_size_request(0, 230)