def on_input_key_press_event(self, widget, event): keyval = event.get_keyval() keyname = Gdk.keyval_name(keyval[1]) alt = event.state & Gdk.ModifierType.MOD1_MASK Search.get_instance().on_key_press_event(widget, event, self._get_user_query()) if self.results_nav: if keyname in ('Up', 'ISO_Left_Tab'): self.results_nav.go_up() return True if keyname in ('Down', 'Tab'): self.results_nav.go_down() return True if alt and keyname in ('Return', 'KP_Enter'): self.enter_result_item(alt=True) elif keyname in ('Return', 'KP_Enter'): self.enter_result_item() elif alt and keyname.isdigit() and 0 < int(keyname) < 10: # on Alt+<num> try: self.enter_result_item(int(keyname) - 1) except IndexError: # selected non-existing result item pass elif alt and len(keyname) == 1 and 97 <= ord(keyname) <= 122: # on Alt+<char> try: self.enter_result_item(ord(keyname) - 97 + 9) except IndexError: # selected non-existing result item pass if keyname == 'Escape': self.hide()
def on_input_key_press_event(self, widget, event): keyval = event.get_keyval() keyname = Gdk.keyval_name(keyval[1]) alt = event.state & Gdk.ModifierType.MOD1_MASK Search.get_instance().on_key_press_event(widget, event, self._get_user_query()) if self.results_nav: if keyname == 'Up': self.results_nav.go_up() elif keyname == 'Down': self.results_nav.go_down() elif alt and keyname in ('Return', 'KP_Enter'): self.enter_result_item(alt=True) elif keyname in ('Return', 'KP_Enter'): self.enter_result_item() elif alt and keyname.isdigit() and 0 < int(keyname) < 10: # on Alt+<num> try: self.enter_result_item(int(keyname) - 1) except IndexError: # selected non-existing result item pass elif alt and len(keyname) == 1 and 97 <= ord(keyname) <= 122: # on Alt+<char> try: self.enter_result_item(ord(keyname) - 97 + 9) except IndexError: # selected non-existing result item pass if keyname == 'Escape': self.hide()
def on_input_changed(self, entry): """ Triggered by user input """ Search.get_instance().on_query_change(self._get_user_query())
def search(self, search_mode): return Search([search_mode])