def set_search_entry_editable_cb(self, search, event):
search.set_editable(True)
- search.set_text("")
+ text = search.get_text()
+ if text in self.search_names:
+ search.set_text("")
style = self.search.get_style()
style.text[gtk.STATE_NORMAL] = self.get_colormap().alloc_color(HobColors.BLACK, False, False)
search.set_style(style)
def set_search_entry_reset_cb(self, search, event):
page_num = self.get_current_page()
- self.reset_entry(search, page_num)
+ text = search.get_text()
+ if not text:
+ self.reset_entry(search, page_num)
def reset_entry(self, entry, page_num):
style = entry.get_style()
if search.get_editable() == True:
search.set_text("")
search.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY, False)
+ search.grab_focus()
def set_page(self, title):
for child in self.pages:
self.button_box.pack_end(self.back_button, expand=False, fill=False)
def search_entry_changed(self, entry):
- current_tab = self.ins.get_current_page()
- filter = self.pages[current_tab]['filter']
text = entry.get_text()
- filter[PackageListModel.COL_NAME] = text
- self.tables[current_tab].set_model(self.package_model.tree_model(filter, search_data=text))
- if self.package_model.filtered_nb == 0:
- if not self.ins.get_nth_page(current_tab).top_bar:
- self.ins.get_nth_page(current_tab).add_no_result_bar(entry)
- self.ins.get_nth_page(current_tab).top_bar.show()
- self.ins.get_nth_page(current_tab).scroll.hide()
- else:
- if self.ins.get_nth_page(current_tab).top_bar:
- self.ins.get_nth_page(current_tab).top_bar.hide()
- self.ins.get_nth_page(current_tab).scroll.show()
- if entry.get_text() == '':
- entry.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY, False)
- else:
- entry.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY, True)
+ if text not in self.ins.search_names:
+ current_tab = self.ins.get_current_page()
+ filter = self.pages[current_tab]['filter']
+ filter[PackageListModel.COL_NAME] = text
+ self.tables[current_tab].set_model(self.package_model.tree_model(filter, search_data=text))
+ if self.package_model.filtered_nb == 0:
+ if not self.ins.get_nth_page(current_tab).top_bar:
+ self.ins.get_nth_page(current_tab).add_no_result_bar(entry)
+ self.ins.get_nth_page(current_tab).top_bar.show()
+ self.ins.get_nth_page(current_tab).scroll.hide()
+ else:
+ if self.ins.get_nth_page(current_tab).top_bar:
+ self.ins.get_nth_page(current_tab).top_bar.hide()
+ self.ins.get_nth_page(current_tab).scroll.show()
+ if entry.get_text() == '':
+ entry.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY, False)
+ else:
+ entry.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY, True)
def button_click_cb(self, widget, event):
path, col = widget.table_tree.get_cursor()
button_box.pack_end(self.back_button, expand=False, fill=False)
def search_entry_changed(self, entry):
- current_tab = self.ins.get_current_page()
- filter = self.pages[current_tab]['filter']
text = entry.get_text()
- filter[RecipeListModel.COL_NAME] = text
- self.tables[current_tab].set_model(self.recipe_model.tree_model(filter, search_data=text))
- if self.recipe_model.filtered_nb == 0:
- if not self.ins.get_nth_page(current_tab).top_bar:
- self.ins.get_nth_page(current_tab).add_no_result_bar(entry)
- self.ins.get_nth_page(current_tab).top_bar.show()
- self.ins.get_nth_page(current_tab).scroll.hide()
- else:
- if self.ins.get_nth_page(current_tab).top_bar:
- self.ins.get_nth_page(current_tab).top_bar.hide()
- self.ins.get_nth_page(current_tab).scroll.show()
- if entry.get_text() == '':
- entry.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY, False)
- else:
- entry.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY, True)
+ if text not in self.ins.search_names:
+ current_tab = self.ins.get_current_page()
+ filter = self.pages[current_tab]['filter']
+ filter[RecipeListModel.COL_NAME] = text
+ self.tables[current_tab].set_model(self.recipe_model.tree_model(filter, search_data=text))
+ if self.recipe_model.filtered_nb == 0:
+ if not self.ins.get_nth_page(current_tab).top_bar:
+ self.ins.get_nth_page(current_tab).add_no_result_bar(entry)
+ self.ins.get_nth_page(current_tab).top_bar.show()
+ self.ins.get_nth_page(current_tab).scroll.hide()
+ else:
+ if self.ins.get_nth_page(current_tab).top_bar:
+ self.ins.get_nth_page(current_tab).top_bar.hide()
+ self.ins.get_nth_page(current_tab).scroll.show()
+ if entry.get_text() == '':
+ entry.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY, False)
+ else:
+ entry.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY, True)
def button_click_cb(self, widget, event):
path, col = widget.table_tree.get_cursor()