600
601
self.action_bar.set_label(label, link_result=self._show_nonapp_pkgs)
602
603
def update_search_help(self):
604
def build_category_path():
605
if not self.apps_category:
607
if not self.apps_subcategory:
608
return self.apps_category.name
609
return u"%s \u25b8 %s"%(self.apps_category.name,self.apps_subcategory.name)
603
610
search = self.searchentry.get_text()
604
611
appstore = self.app_view.get_model()
605
612
if (search and appstore is not None and len(appstore) == 0):
606
613
category = self.get_current_category()
607
614
correction = self.db.get_spelling_correction(search)
615
text = "<b>%s</b>\n\n"%(_('No results for "%s"')%search)
616
option_template = "\t - %s\n\n"
618
text += _('No items match "%s". Suggestions:')%search+"\n\n"
620
text += _('No items in %s match "%s". Suggestions:')%("<b>%s</b>"%build_category_path(), search)+"\n\n"
622
if self.apps_subcategory:
623
parent_model = AppStore(self.cache,
626
self.db.get_query_list_from_search_entry(search,
627
self.apps_category.query),
628
limit=self.get_app_items_limit(),
629
sortmode=self.get_sort_mode(),
630
nonapps_visible = self.nonapps_visible,
631
filter=self.apps_filter,
632
nonblocking_load=False,
634
if parent_model.nr_apps>0:
635
text += option_template%(gettext.ngettext("Try "
636
"<a href=\"search-parent:\">the item "
637
"in %(category)s</a> that matches.", "Try "
638
"<a href=\"search-parent:\">the %(n)d items "
639
"in %(category)s</a> that match.", n=parent_model.nr_apps)%\
640
{'category':self.apps_category.name,'n':parent_model.nr_apps})
641
if self.apps_filter.get_supported_only():
642
unsupported = copy.copy(self.apps_filter)
643
unsupported.set_supported_only(False)
644
unsupported_model = AppStore(self.cache,
647
self.app_view.get_model().search_query,
648
limit=self.get_app_items_limit(),
649
sortmode=self.get_sort_mode(),
650
nonapps_visible = self.nonapps_visible,
652
nonblocking_load=False,
654
if unsupported_model.nr_apps>0:
655
text += option_template%(gettext.ngettext("Try "
656
"<a href=\"search-unsupported:\">the %(amount)d item "
657
"that matches</a> in software not maintained by Canonical.",
658
"Try <a href=\"search-unsupported:\">the %(amount)d items "
659
"that match</a> in software not maintained by Canonical.",unsupported_model.nr_apps)%{'amount':unsupported_model.nr_apps})
609
text = _("Search term not found in current category. "
610
"Do you want to search "
611
"<a href=\"search-all:\">all categories</a> instead?")
612
self.label_app_list_header.set_markup(text)
613
self.label_app_list_header.set_visible(True)
661
text += option_template%_("Try searching in "
662
"<a href=\"search-all:\">all categories</a> instead.")
616
664
ref = "<a href=\"search:%s\">%s</a>" % (correction, correction)
617
text = _("Search term not found. Did you mean: %s?") % ref
618
self.label_app_list_header.set_markup(text)
619
self.label_app_list_header.set_visible(True)
665
text += option_template%_("Check the search is spelled correctly. Did you mean: %s?") % ref
666
text += option_template%gettext.ngettext("Try using a different word.", "Try using fewer words or different words", len(search.split()))
668
self.label_app_list_header.set_markup(text)
669
self.label_app_list_header.set_visible(True)
621
671
# catchall, hide if we don't have anything useful to suggest
622
672
self.label_app_list_header.set_visible(False)