Model searchbar (WIP)

This commit is contained in:
jeffser 2024-06-29 11:10:31 -06:00
parent bf9042f9aa
commit eae71dae16
4 changed files with 37 additions and 0 deletions

View File

@ -27,6 +27,7 @@
<file alias="icons/scalable/status/step-back-symbolic.svg">icons/step-back-symbolic.svg</file> <file alias="icons/scalable/status/step-back-symbolic.svg">icons/step-back-symbolic.svg</file>
<file alias="icons/scalable/status/step-over-symbolic.svg">icons/step-over-symbolic.svg</file> <file alias="icons/scalable/status/step-over-symbolic.svg">icons/step-over-symbolic.svg</file>
<file alias="icons/scalable/status/share-symbolic.svg">icons/share-symbolic.svg</file> <file alias="icons/scalable/status/share-symbolic.svg">icons/share-symbolic.svg</file>
<file alias="icons/scalable/status/edit-find-symbolic.svg">icons/edit-find-symbolic.svg</file>
<file preprocess="xml-stripblanks">window.ui</file> <file preprocess="xml-stripblanks">window.ui</file>
<file preprocess="xml-stripblanks">gtk/help-overlay.ui</file> <file preprocess="xml-stripblanks">gtk/help-overlay.ui</file>
</gresource> </gresource>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg">
<path d="m 6.5 0 c -3.578125 0 -6.5 2.921875 -6.5 6.5 s 2.921875 6.5 6.5 6.5 c 1.429688 0 2.753906 -0.46875 3.828125 -1.257812 l 2.945313 2.945312 c 0.957031 0.9375 2.363281 -0.5 1.40625 -1.4375 l -2.929688 -2.929688 c 0.785156 -1.074218 1.25 -2.394531 1.25 -3.820312 c 0 -3.578125 -2.921875 -6.5 -6.5 -6.5 z m 0 2 c 2.496094 0 4.5 2.003906 4.5 4.5 s -2.003906 4.5 -4.5 4.5 s -4.5 -2.003906 -4.5 -4.5 s 2.003906 -4.5 4.5 -4.5 z m 0 0" fill="#2e3436"/>
</svg>

After

Width:  |  Height:  |  Size: 590 B

View File

@ -103,6 +103,7 @@ class AlpacaWindow(Adw.ApplicationWindow):
navigation_view_manage_models = Gtk.Template.Child() navigation_view_manage_models = Gtk.Template.Child()
file_preview_open_button = Gtk.Template.Child() file_preview_open_button = Gtk.Template.Child()
secondary_menu_button = Gtk.Template.Child() secondary_menu_button = Gtk.Template.Child()
model_searchbar = Gtk.Template.Child()
manage_models_dialog = Gtk.Template.Child() manage_models_dialog = Gtk.Template.Child()
pulling_model_list_box = Gtk.Template.Child() pulling_model_list_box = Gtk.Template.Child()
@ -376,6 +377,19 @@ class AlpacaWindow(Adw.ApplicationWindow):
def link_button_handler(self, button): def link_button_handler(self, button):
os.system(f'xdg-open "{button.get_name()}"') os.system(f'xdg-open "{button.get_name()}"')
@Gtk.Template.Callback()
def model_search_toggle(self, button):
self.model_searchbar.set_search_mode(button.get_active())
self.pulling_model_list_box.set_visible(not button.get_active() and len(self.pulling_models) > 0)
self.local_model_list_box.set_visible(not button.get_active())
print(button.get_active())
@Gtk.Template.Callback()
def model_search_changed(self, entry):
for i in range(len(self.available_models.keys())):
row = self.available_model_list_box.get_row_at_index(i)
row.set_visible(re.search(entry.get_text(), row.get_title(), re.IGNORECASE))
def check_alphanumeric(self, editable, text, length, position): def check_alphanumeric(self, editable, text, length, position):
new_text = ''.join([char for char in text if char.isalnum() or char in ['-', '_']]) new_text = ''.join([char for char in text if char.isalnum() or char in ['-', '_']])
if new_text != text: editable.stop_emission_by_name("insert-text") if new_text != text: editable.stop_emission_by_name("insert-text")

View File

@ -604,6 +604,24 @@
<property name="menu-model">create_model_menu</property> <property name="menu-model">create_model_menu</property>
</object> </object>
</child> </child>
<child type="start">
<object class="GtkToggleButton" id="model_search_button">
<property name="icon-name">edit-find-symbolic</property>
<property name="tooltip-text" translatable="yes">Search Model</property>
<signal name="clicked" handler="model_search_toggle"/>
</object>
</child>
</object>
</child>
<child type="top">
<object class="GtkSearchBar" id="model_searchbar">
<child>
<object class="GtkSearchEntry" id="searchentry">
<signal name="search-changed" handler="model_search_changed"/>
<property name="search-delay">100</property>
<property name="placeholder-text" translatable="true">Search models</property>
</object>
</child>
</object> </object>
</child> </child>
<property name="content"> <property name="content">