Search vor name in library.
This commit is contained in:
@@ -296,6 +296,13 @@ class Application:
|
||||
self.precon_icons[icon_name] = icon
|
||||
return icon
|
||||
|
||||
def filter_lib_func(self, model, iter, data):
|
||||
filter_text = self.ui.get_object("searchLibEntry").get_text()
|
||||
if filter_text == "":
|
||||
return True
|
||||
else:
|
||||
return filter_text.lower() in model[iter][1].lower()
|
||||
|
||||
|
||||
def main():
|
||||
win = Application()
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
<object class="GtkEntryCompletion" id="tagCompleter">
|
||||
<property name="model">tagStore</property>
|
||||
<property name="text_column">0</property>
|
||||
<property name="inline_selection">True</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText"/>
|
||||
<attributes>
|
||||
@@ -203,6 +202,7 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="vexpand">False</property>
|
||||
<property name="spacing">2</property>
|
||||
<child>
|
||||
<object class="GtkSearchEntry" id="searchLibEntry">
|
||||
<property name="visible">True</property>
|
||||
@@ -211,6 +211,7 @@
|
||||
<property name="primary_icon_activatable">False</property>
|
||||
<property name="primary_icon_sensitive">False</property>
|
||||
<property name="placeholder_text" translatable="yes">Search Library</property>
|
||||
<signal name="changed" handler="do_refilter_library" object="libraryContainer" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
@@ -219,11 +220,19 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="tagCardCombo">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="has_entry">True</property>
|
||||
<child internal-child="entry">
|
||||
<object class="GtkEntry" id="tagCardEntry">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="caps_lock_warning">False</property>
|
||||
<property name="placeholder_text" translatable="yes">Tag selected cards</property>
|
||||
<property name="completion">tagCompleter</property>
|
||||
<signal name="activate" handler="do_tag_cards" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
||||
@@ -177,6 +177,10 @@ class Handlers:
|
||||
self.app.remove_tag(tag)
|
||||
self.app.current_page.emit('show')
|
||||
|
||||
def do_refilter_library(self, container):
|
||||
# Access Card View inside of container
|
||||
container.get_child().filter.refilter()
|
||||
|
||||
# Handlers for TreeViews etc. wich have been not added by Glade
|
||||
|
||||
# ----------------Search-----------------
|
||||
|
||||
@@ -10,6 +10,7 @@ def init_library_view(app):
|
||||
card_list = cardlist.CardList(True, app)
|
||||
card_list.set_name("libScroller")
|
||||
card_list.list.connect("row-activated", app.handlers.on_library_card_selected)
|
||||
card_list.filter.set_visible_func(app.filter_lib_func)
|
||||
container.add(card_list)
|
||||
container.add_overlay(app.ui.get_object("noResults"))
|
||||
container.show_all()
|
||||
@@ -24,6 +25,9 @@ def reload_library(app, tag=None):
|
||||
else:
|
||||
lib = app.get_tagged_cards(tag)
|
||||
reload_tag_list(app, tag)
|
||||
tag_combo = app.ui.get_object("tagCardCombo")
|
||||
tag_combo.set_model(app.ui.get_object("tagStore"))
|
||||
|
||||
card_tree = app.ui.get_object("libraryContainer").get_child()
|
||||
if lib:
|
||||
app.ui.get_object("noResults").set_visible(False)
|
||||
@@ -58,3 +62,4 @@ def tag_cards(card_list, tag, app):
|
||||
for card in card_list.values():
|
||||
if not app.tags[tag].__contains__(card.multiverse_id):
|
||||
app.tag_card(card, tag)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user