add searching

This commit is contained in:
heliguy
2024-07-19 12:26:13 -04:00
parent f2246064c0
commit 6a7f770e13
2 changed files with 16 additions and 4 deletions

View File

@@ -81,7 +81,15 @@ class DataSubpage(Gtk.ScrolledWindow):
child.set_focusable(False)
child.row.set_focusable(child.check_button.get_visible())
def __init__(self, title, main_window, **kwargs):
def filter_func(self, box):
search_text = self.parent_page.search_entry.get_text().lower()
box = box.get_child()
return search_text in box.title.lower() or search_text in box.subtitle.lower()
def on_invalidate(self, box):
self.flow_box.invalidate_filter()
def __init__(self, title, parent_page, main_window, **kwargs):
super().__init__(**kwargs)
GLib.idle_add(lambda *_: self.title.set_label(title))
@@ -91,6 +99,7 @@ class DataSubpage(Gtk.ScrolledWindow):
# Extra Object Creation
self.main_window = main_window
self.parent_page = parent_page
self.sort_mode = ""
self.sort_ascend = False
self.total_size = 0
@@ -101,5 +110,7 @@ class DataSubpage(Gtk.ScrolledWindow):
# Apply
self.flow_box.set_sort_func(self.sort_func)
self.flow_box.set_filter_func(self.filter_func)
# Connections
# Connections
parent_page.search_entry.connect("search-changed", self.on_invalidate)

View File

@@ -15,6 +15,7 @@ class UserDataPage(Adw.BreakpointBin):
sidebar_button = gtc()
search_button = gtc()
select_button = gtc()
search_entry = gtc()
stack = gtc()
sort_pop = gtc()
asc = gtc()
@@ -116,8 +117,8 @@ class UserDataPage(Adw.BreakpointBin):
# Extra Object Creation
self.__class__.instance = self
# self.adj = self.scrolled_window.get_vadjustment()
self.adp = DataSubpage(_("Active Data"), main_window)
self.ldp = DataSubpage(_("Leftover Data"), main_window)
self.adp = DataSubpage(_("Active Data"), self, main_window)
self.ldp = DataSubpage(_("Leftover Data"), self, main_window)
self.data_flatpaks = []
self.active_data = []
self.leftover_data = []