Search vor name in library.

This commit is contained in:
luxick
2017-04-17 19:52:28 +02:00
parent 4e83d5a8b8
commit ecac7b7757
4 changed files with 31 additions and 6 deletions

View File

@@ -296,6 +296,13 @@ class Application:
self.precon_icons[icon_name] = icon self.precon_icons[icon_name] = icon
return 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(): def main():
win = Application() win = Application()

View File

@@ -35,7 +35,6 @@
<object class="GtkEntryCompletion" id="tagCompleter"> <object class="GtkEntryCompletion" id="tagCompleter">
<property name="model">tagStore</property> <property name="model">tagStore</property>
<property name="text_column">0</property> <property name="text_column">0</property>
<property name="inline_selection">True</property>
<child> <child>
<object class="GtkCellRendererText"/> <object class="GtkCellRendererText"/>
<attributes> <attributes>
@@ -203,6 +202,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="vexpand">False</property> <property name="vexpand">False</property>
<property name="spacing">2</property>
<child> <child>
<object class="GtkSearchEntry" id="searchLibEntry"> <object class="GtkSearchEntry" id="searchLibEntry">
<property name="visible">True</property> <property name="visible">True</property>
@@ -211,6 +211,7 @@
<property name="primary_icon_activatable">False</property> <property name="primary_icon_activatable">False</property>
<property name="primary_icon_sensitive">False</property> <property name="primary_icon_sensitive">False</property>
<property name="placeholder_text" translatable="yes">Search Library</property> <property name="placeholder_text" translatable="yes">Search Library</property>
<signal name="changed" handler="do_refilter_library" object="libraryContainer" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@@ -219,11 +220,19 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkEntry" id="tagCardEntry"> <object class="GtkComboBoxText" id="tagCardCombo">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">False</property>
<property name="completion">tagCompleter</property> <property name="has_entry">True</property>
<signal name="activate" handler="do_tag_cards" swapped="no"/> <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>
</object>
</child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>

View File

@@ -177,6 +177,10 @@ class Handlers:
self.app.remove_tag(tag) self.app.remove_tag(tag)
self.app.current_page.emit('show') 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 # Handlers for TreeViews etc. wich have been not added by Glade
# ----------------Search----------------- # ----------------Search-----------------

View File

@@ -10,6 +10,7 @@ def init_library_view(app):
card_list = cardlist.CardList(True, app) card_list = cardlist.CardList(True, app)
card_list.set_name("libScroller") card_list.set_name("libScroller")
card_list.list.connect("row-activated", app.handlers.on_library_card_selected) 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(card_list)
container.add_overlay(app.ui.get_object("noResults")) container.add_overlay(app.ui.get_object("noResults"))
container.show_all() container.show_all()
@@ -24,6 +25,9 @@ def reload_library(app, tag=None):
else: else:
lib = app.get_tagged_cards(tag) lib = app.get_tagged_cards(tag)
reload_tag_list(app, 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() card_tree = app.ui.get_object("libraryContainer").get_child()
if lib: if lib:
app.ui.get_object("noResults").set_visible(False) app.ui.get_object("noResults").set_visible(False)
@@ -40,7 +44,7 @@ def add_new_tag(name, app):
def reload_tag_list(app, preserve=False): def reload_tag_list(app, preserve=False):
tree = app.ui.get_object("tagTree") tree = app.ui.get_object("tagTree")
(path, column) = tree.get_cursor() (path, column) = tree.get_cursor()
store = tree.get_model() store = tree.get_model()
store.clear() store.clear()
for tag, ids in app.tags.items(): for tag, ids in app.tags.items():
@@ -58,3 +62,4 @@ def tag_cards(card_list, tag, app):
for card in card_list.values(): for card in card_list.values():
if not app.tags[tag].__contains__(card.multiverse_id): if not app.tags[tag].__contains__(card.multiverse_id):
app.tag_card(card, tag) app.tag_card(card, tag)