Example #1
0
                'abcxyz',
                'testing 123',
                'search',
                'search2',
                'searched' ]

            results = []
            for s in stuff_to_search_in:
                if query.lower() in s.lower():
                    results.append(TestSearchResult(self, s + " " + self.__heading))
            consumer.add_results(results)

    def construct_provider():
        return TestSearchProvider()

    search.register_provider_constructor('test1', lambda: TestSearchProvider("A_TestItems"))
    search.enable_search_provider('test1')

    search.register_provider_constructor('test2', lambda: TestSearchProvider("B_TestItems"))
    search.enable_search_provider('test2')

    search.register_provider_constructor('test3', lambda: TestSearchProvider("C_TestItems"))
    search.enable_search_provider('test3')

    search.register_provider_constructor('test4', lambda: TestSearchProvider("D_TestItems"))
    search.enable_search_provider('test4')

    window = gtk.Window()
    window.set_border_width(50) ## to test positioning of results window 
    entry = SearchEntry()
    entry.show()
Example #2
0
    def _on_highlighted(self):
        """Action when user has highlighted the result"""
        pass

    def _on_activated(self):
        """Action when user has activated the result"""
        self.__app.launch()

class AppSearchProvider(search.SearchProvider):    
    def __init__(self, repo):
        super(AppSearchProvider, self).__init__()
        self.__repo = repo

    def get_heading(self):
        return "Applications"

    def __on_search_results(self, applications, category, search_terms, consumer):        
        results = []
        for a in applications:
            results.append(AppSearchResult(self, a))

        if len(results) > 0:
            consumer.add_results(results)
        
    def perform_search(self, query, consumer):
        results = map(lambda a: AppSearchResult(self, a), self.__repo.search_local_fast_sync(query))
        if results:
            consumer.add_results(results)
            
search.register_provider_constructor('apps', lambda: AppSearchProvider(get_apps_repo()))