def __init__(self, guake): """Constructor of Keyboard, only receives the guake instance to be used in internal methods. """ self.guake = guake self.accel_group = None # see reload_accelerators self.client = gconf.client_get_default() notify_add = self.client.notify_add # Setup global keys self.globalhotkeys = {} globalkeys = ['show_hide'] for key in globalkeys: notify_add(GKEY(key), self.reload_global) self.client.notify(GKEY(key)) # Setup local keys keys = [ 'toggle_fullscreen', 'new_tab', 'close_tab', 'rename_current_tab', 'previous_tab', 'next_tab', 'clipboard_copy', 'clipboard_paste', 'quit', 'zoom_in', 'zoom_out', 'increase_height', 'decrease_height', 'increase_transparency', 'decrease_transparency', 'toggle_transparency', "search_on_web", 'move_tab_left', 'move_tab_right', 'switch_tab1', 'switch_tab2', 'switch_tab3', 'switch_tab4', 'switch_tab5', 'switch_tab6', 'switch_tab7', 'switch_tab8', 'switch_tab9', 'switch_tab10', 'switch_tab_last', 'reset_terminal' ] for key in keys: notify_add(LKEY(key), self.reload_accelerators) self.client.notify(LKEY(key))
# rest of the combo too. SHELLS_FILE = '/etc/shells' # string to show in prefereces dialog for user shell option USER_SHELL_VALUE = _('<user shell>') # translating our types to vte types ERASE_BINDINGS = {'ASCII DEL': 'ascii-delete', 'Escape sequence': 'delete-sequence', 'Control-H': 'ascii-backspace'} HOTKEYS = [ {'label': 'General', 'keys': [{'key': GKEY('show_hide'), 'label': 'Toggle Guake visibility'}, {'key': LKEY('toggle_fullscreen'), 'label': 'Toggle Fullscreen'}, {'key': LKEY('toggle_hide_on_lose_focus'), 'label': 'Toggle Hide on Lose Focus'}, {'key': LKEY('quit'), 'label': 'Quit'}, {'key': LKEY('reset_terminal'), 'label': 'Reset terminal'}, ]}, {'label': 'Tab management', 'keys': [{'key': LKEY('new_tab'), 'label': 'New tab'}, {'key': LKEY('close_tab'), 'label': 'Close tab'}, {'key': LKEY('rename_current_tab'),
def load_accelerators(self): """Reads all gconf paths under /apps/guake/keybindings/local and adds to the main accel_group. """ gets = lambda x: self.client.get_string(LKEY(x)) key, mask = gtk.accelerator_parse(gets('reset_terminal')) if key > 0: self.accel_group.connect_group(key, mask, gtk.ACCEL_VISIBLE, self.guake.accel_reset_terminal) key, mask = gtk.accelerator_parse(gets('quit')) if key > 0: self.accel_group.connect_group(key, mask, gtk.ACCEL_VISIBLE, self.guake.accel_quit) key, mask = gtk.accelerator_parse(gets('new_tab')) if key > 0: self.accel_group.connect_group(key, mask, gtk.ACCEL_VISIBLE, self.guake.accel_add) key, mask = gtk.accelerator_parse(gets('close_tab')) if key > 0: self.accel_group.connect_group(key, mask, gtk.ACCEL_VISIBLE, self.guake.close_tab) key, mask = gtk.accelerator_parse(gets('previous_tab')) if key > 0: self.accel_group.connect_group(key, mask, gtk.ACCEL_VISIBLE, self.guake.accel_prev) key, mask = gtk.accelerator_parse(gets('next_tab')) if key > 0: self.accel_group.connect_group(key, mask, gtk.ACCEL_VISIBLE, self.guake.accel_next) key, mask = gtk.accelerator_parse(gets('move_tab_left')) if key > 0: self.accel_group.connect_group(key, mask, gtk.ACCEL_VISIBLE, self.guake.accel_move_tab_left) key, mask = gtk.accelerator_parse(gets('move_tab_right')) if key > 0: self.accel_group.connect_group(key, mask, gtk.ACCEL_VISIBLE, self.guake.accel_move_tab_right) key, mask = gtk.accelerator_parse(gets('rename_current_tab')) if key > 0: self.accel_group.connect_group(key, mask, gtk.ACCEL_VISIBLE, self.guake.accel_rename_current_tab) key, mask = gtk.accelerator_parse(gets('clipboard_copy')) if key > 0: self.accel_group.connect_group(key, mask, gtk.ACCEL_VISIBLE, self.guake.accel_copy_clipboard) key, mask = gtk.accelerator_parse(gets('clipboard_paste')) if key > 0: self.accel_group.connect_group(key, mask, gtk.ACCEL_VISIBLE, self.guake.accel_paste_clipboard) key, mask = gtk.accelerator_parse(gets('toggle_fullscreen')) if key > 0: self.accel_group.connect_group(key, mask, gtk.ACCEL_VISIBLE, self.guake.accel_toggle_fullscreen) key, mask = gtk.accelerator_parse(gets('toggle_hide_on_lose_focus')) if key > 0: self.accel_group.connect_group( key, mask, gtk.ACCEL_VISIBLE, self.guake.accel_toggle_hide_on_lose_focus) key, mask = gtk.accelerator_parse(gets('zoom_in')) if key > 0: self.accel_group.connect_group(key, mask, gtk.ACCEL_VISIBLE, self.guake.accel_zoom_in) key, mask = gtk.accelerator_parse(gets('zoom_in_alt')) if key > 0: self.accel_group.connect_group(key, mask, gtk.ACCEL_VISIBLE, self.guake.accel_zoom_in) key, mask = gtk.accelerator_parse(gets('zoom_out')) if key > 0: self.accel_group.connect_group(key, mask, gtk.ACCEL_VISIBLE, self.guake.accel_zoom_out) key, mask = gtk.accelerator_parse(gets('increase_height')) if key > 0: self.accel_group.connect_group(key, mask, gtk.ACCEL_VISIBLE, self.guake.accel_increase_height) key, mask = gtk.accelerator_parse(gets('decrease_height')) if key > 0: self.accel_group.connect_group(key, mask, gtk.ACCEL_VISIBLE, self.guake.accel_decrease_height) key, mask = gtk.accelerator_parse(gets('increase_transparency')) if key > 0: self.accel_group.connect_group( key, mask, gtk.ACCEL_VISIBLE, self.guake.accel_increase_transparency) key, mask = gtk.accelerator_parse(gets('decrease_transparency')) if key > 0: self.accel_group.connect_group( key, mask, gtk.ACCEL_VISIBLE, self.guake.accel_decrease_transparency) key, mask = gtk.accelerator_parse(gets('toggle_transparency')) if key > 0: self.accel_group.connect_group( key, mask, gtk.ACCEL_VISIBLE, self.guake.accel_toggle_transparency) for tab in xrange(1, 11): key, mask = gtk.accelerator_parse(gets('switch_tab%d' % tab)) if key > 0: self.accel_group.connect_group( key, mask, gtk.ACCEL_VISIBLE, self.guake.gen_accel_switch_tabN(tab - 1)) key, mask = gtk.accelerator_parse(gets('switch_tab_last')) if key > 0: self.accel_group.connect_group(key, mask, gtk.ACCEL_VISIBLE, self.guake.accel_switch_tab_last) try: key, mask = gtk.accelerator_parse(gets('search_on_web')) if key > 0: self.accel_group.connect_group(key, mask, gtk.ACCEL_VISIBLE, self.guake.search_on_web) except Exception: log.exception("Exception occured")