def testSearchDialog(self): '''Test SearchDialog''' from zim.gui.searchdialog import SearchDialog self.ui.notebook = tests.new_notebook() dialog = SearchDialog(self.ui) dialog.query_entry.set_text('Foo') dialog.query_entry.activate() model = dialog.results_treeview.get_model() self.assertTrue(len(model) > 3) self.ui.mainwindow = tests.MockObject() self.ui.mainwindow.pageview = tests.MockObject() col = dialog.results_treeview.get_column(0) dialog.results_treeview.row_activated((0, ), col)
def testResults(self): notebook = self.setUpNotebook(content=tests.FULL_NOTEBOOK) page = None navigation = tests.MockObject() navigation.open_page = lambda page: tests.MockObject() dialog = SearchDialog(None, notebook, page, navigation) dialog.query_entry.set_text('Foo') dialog.query_entry.activate() model = dialog.results_treeview.get_model() self.assertTrue(len(model) > 3) col = dialog.results_treeview.get_column(0) dialog.results_treeview.row_activated(Gtk.TreePath((0,)), col)
def testResultsInSection(self): # Results with "only search in section" enabled notebook = self.setUpNotebook(content=tests.FULL_NOTEBOOK) page = notebook.get_page(Path('TaskList')) navigation = tests.MockObject() navigation.open_page = lambda page: tests.MockObject() dialog = SearchDialog(None, notebook, page, navigation) dialog.namespacecheckbox.set_active(True) dialog.query_entry.set_text('*fix*') dialog.query_entry.activate() model = dialog.results_treeview.get_model() self.assertTrue(len(model) > 1) col = dialog.results_treeview.get_column(0) dialog.results_treeview.row_activated(Gtk.TreePath((0,)), col)
def show_search(self, query=None): '''Menu action to show the L{SearchDialog} @param query: the search query to show ''' from zim.gui.searchdialog import SearchDialog if query is None and hasattr(self.widget, 'pageview'): query = self.widget.pageview.get_selection() # XXX unauthorized access to pageview dialog = SearchDialog(self.widget, self.notebook, self.page, self.navigation) dialog.present() if query is not None: dialog.search(query)
def show_search(self, query=None, focus_results=False): '''Menu action to show the L{SearchDialog} @param query: the search query to show ''' from zim.gui.searchdialog import SearchDialog if query is None and hasattr(self.widget, 'pageview'): query = self.widget.pageview.get_selection() # XXX unauthorized access to pageview dialog = SearchDialog(self.widget, self.notebook, self.page, self.navigation) dialog.present() if query is not None: dialog.search(query) if focus_results: dialog.results_treeview.grab_focus() else: dialog.query_entry.grab_focus() dialog.query_entry.set_position(-1)