add searchbar

The search bar will appear as you type
parent 346e6db9
...@@ -89,6 +89,7 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow): ...@@ -89,6 +89,7 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
is_loading = GObject.Property(type=bool, default=True) is_loading = GObject.Property(type=bool, default=True)
search_entry = Gtk.Template.Child() search_entry = Gtk.Template.Child()
search_bar = Gtk.Template.Child()
search_toggle_button = Gtk.Template.Child() search_toggle_button = Gtk.Template.Child()
main_stack = Gtk.Template.Child() main_stack = Gtk.Template.Child()
search_dropdown = Gtk.Template.Child() search_dropdown = Gtk.Template.Child()
...@@ -103,7 +104,7 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow): ...@@ -103,7 +104,7 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
self.apply_button.connect("activated", self.on_apply_clicked) self.apply_button.connect("activated", self.on_apply_clicked)
self.connect("notify::is-loading", self.on_is_loading_changed) self.connect("notify::is-loading", self.on_is_loading_changed)
self.search_toggle_button.connect("notify::active", self.on_search_toggle_button_clicked) self.search_bar.connect_entry(self.search_entry)
self.search_entry.connect("search-changed", self.on_search_changed) self.search_entry.connect("search-changed", self.on_search_changed)
self.search_dropdown.connect("notify::selected", self.on_filter_changed) self.search_dropdown.connect("notify::selected", self.on_filter_changed)
...@@ -114,10 +115,6 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow): ...@@ -114,10 +115,6 @@ class EepmPlayGuiWindow(Adw.ApplicationWindow):
self.update_ui() self.update_ui()
def on_search_toggle_button_clicked (self, obj, _pspec):
if not self.search_toggle_button.props.active:
self.search_entry.props.text = ""
def on_is_loading_changed (self, obj, _pspec): def on_is_loading_changed (self, obj, _pspec):
self.main_stack.props.visible_child_name = "loading" if self.props.is_loading else "main" self.main_stack.props.visible_child_name = "loading" if self.props.is_loading else "main"
......
...@@ -50,17 +50,20 @@ ...@@ -50,17 +50,20 @@
<property name="child"> <property name="child">
<object class="AdwToolbarView"> <object class="AdwToolbarView">
<property name="content"> <property name="content">
<object class="AdwToolbarView"> <object class="GtkBox" id="main_box">
<property name="reveal-top-bars" bind-source="search_toggle_button" bind-property="active" bind-flags="sync-create"/> <property name="orientation">vertical</property>
<child type="top"> <child>
<object class="AdwClamp"> <object class="AdwClamp">
<property name="margin-bottom">4</property>
<property name="margin-end">12</property>
<property name="margin-start">12</property>
<property name="margin-top">4</property>
<property name="maximum-size">420</property> <property name="maximum-size">420</property>
<child> <child>
<object class="GtkSearchBar" id="search_bar">
<property name="search-mode-enabled" bind-source="search_toggle_button" bind-property="active" bind-flags="sync-create|bidirectional"/>
<property name="key-capture-widget">main_box</property>
<child>
<object class="GtkBox"> <object class="GtkBox">
<style>
<class name="linked"/>
</style>
<child> <child>
<object class="GtkSearchEntry" id="search_entry"> <object class="GtkSearchEntry" id="search_entry">
<property name="hexpand">true</property> <property name="hexpand">true</property>
...@@ -81,14 +84,36 @@ ...@@ -81,14 +84,36 @@
<property name="halign">end</property> <property name="halign">end</property>
</object> </object>
</child> </child>
</object>
</child>
</object>
<!-- <object class="GtkBox">
<child>
</child>
<child>
<object class="GtkDropDown" id="search_dropdown">
<property name="model">
<object class="GtkStringList">
<items>
<item translatable="yes">All</item>
<item translatable="yes">Installed</item>
<item translatable="yes">Uninstalled</item>
<item translatable="yes">Changed</item>
</items>
</object>
</property>
<property name="halign">end</property>
</object>
</child>
<style> <style>
<class name="linked"/> <class name="linked"/>
</style> </style>
</object> </object> -->
</child> </child>
</object> </object>
</child> </child>
<property name="content"> <child>
<object class="GtkScrolledWindow"> <object class="GtkScrolledWindow">
<property name="propagate-natural-height">true</property> <property name="propagate-natural-height">true</property>
<property name="hscrollbar-policy">never</property> <property name="hscrollbar-policy">never</property>
...@@ -109,7 +134,7 @@ ...@@ -109,7 +134,7 @@
</object> </object>
</child> </child>
</object> </object>
</property> </child>
</object> </object>
</property> </property>
<child type="bottom"> <child type="bottom">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment