Start making some navigation work
This commit is contained in:
parent
5dd6ae0154
commit
4284cf67ee
@ -91,6 +91,8 @@ DEFAULTS = {
|
||||
'hide_tabbar' : False,
|
||||
'scroll_tabbar' : False,
|
||||
'alternate_screen_scroll': True,
|
||||
'split_to_group' : False,
|
||||
'autoclean_groups' : True,
|
||||
'keybindings' : {
|
||||
'zoom_in' : '<Ctrl>plus',
|
||||
'zoom_out' : '<Ctrl>minus',
|
||||
|
@ -17,8 +17,6 @@ class Terminator(Borg):
|
||||
config = None
|
||||
keybindings = None
|
||||
|
||||
splittogroup = None
|
||||
autocleangroups = None
|
||||
groupsend = None
|
||||
groupsend_type = {'all':0, 'group':1, 'off':2}
|
||||
|
||||
@ -37,10 +35,6 @@ class Terminator(Borg):
|
||||
self.groups = []
|
||||
if not self.groupsend:
|
||||
self.groupsend = self.groupsend_type['group']
|
||||
if not self.splittogroup:
|
||||
self.splittogroup = False
|
||||
if not self.autocleangroups:
|
||||
self.autocleangroups = True
|
||||
if not self.config:
|
||||
self.config = Config()
|
||||
if not self.keybindings:
|
||||
@ -51,6 +45,7 @@ class Terminator(Borg):
|
||||
"""Register a new terminal widget"""
|
||||
self.terminals.append(terminal)
|
||||
terminal.connect('ungroup-all', self.ungroup_all)
|
||||
terminal.connect('navigate', self.navigate_terminal)
|
||||
|
||||
def deregister_terminal(self, terminal):
|
||||
"""De-register a terminal widget"""
|
||||
@ -63,6 +58,34 @@ class Terminator(Borg):
|
||||
for terminal in self.terminals:
|
||||
terminal.reconfigure()
|
||||
|
||||
def navigate_terminal(self, terminal, direction):
|
||||
"""Nagivate around the terminals"""
|
||||
current = self.terminals.index(terminal)
|
||||
length = len(self.terminals)
|
||||
next = None
|
||||
|
||||
if length <= 1:
|
||||
return
|
||||
|
||||
print "Current term: %d" % current
|
||||
print "Number of terms: %d" % length
|
||||
|
||||
if direction == 'next':
|
||||
next = current + 1
|
||||
if next >= length:
|
||||
next = 0
|
||||
elif direction == 'prev':
|
||||
next = current - 1
|
||||
if next < 0:
|
||||
next = length - 1
|
||||
else:
|
||||
raise NotImplementedError
|
||||
# FIXME: Do the directional navigation
|
||||
|
||||
if next is not None:
|
||||
print "sending focus to term %d" % next
|
||||
self.terminals[next].vte.grab_focus()
|
||||
|
||||
def create_group(self, name):
|
||||
"""Create a new group"""
|
||||
if name not in self.groups:
|
||||
@ -83,7 +106,7 @@ class Terminator(Borg):
|
||||
def group_hoover(self):
|
||||
"""Clean out unused groups"""
|
||||
|
||||
if self.autocleangroups:
|
||||
if self.config['autoclean_groups']:
|
||||
todestroy = []
|
||||
for group in self.groups:
|
||||
for terminal in self.terminals:
|
||||
|
@ -51,6 +51,8 @@ class Terminal(gtk.VBox):
|
||||
'maximise': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
|
||||
'resize-term': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
|
||||
(gobject.TYPE_STRING,)),
|
||||
'navigate': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
|
||||
(gobject.TYPE_STRING,)),
|
||||
}
|
||||
|
||||
TARGET_TYPE_VTE = 8
|
||||
@ -343,12 +345,12 @@ class Terminal(gtk.VBox):
|
||||
menu.append(gtk.MenuItem())
|
||||
|
||||
item = gtk.CheckMenuItem(_('Split to this group'))
|
||||
item.set_active(self.terminator.splittogroup)
|
||||
item.set_active(self.config['split_to_group'])
|
||||
item.connect('toggled', lambda x: self.do_splittogroup_toggle())
|
||||
menu.append(item)
|
||||
|
||||
item = gtk.CheckMenuItem(_('Autoclean groups'))
|
||||
item.set_active(self.terminator.autocleangroups)
|
||||
item.set_active(self.config['autoclean_groups'])
|
||||
item.connect('toggled', lambda x: self.do_autocleangroups_toggle())
|
||||
menu.append(item)
|
||||
|
||||
@ -417,19 +419,16 @@ class Terminal(gtk.VBox):
|
||||
|
||||
def do_splittogroup_toggle(self):
|
||||
"""Toggle the splittogroup mode"""
|
||||
# FIXME: Can we think of a smarter way of doing this than poking?
|
||||
self.terminator.splittogroup = not self.terminator.splittogroup
|
||||
self.config['split_to_group'] = not self.config['split_to_group']
|
||||
|
||||
def do_autocleangroups_toggle(self):
|
||||
"""Toggle the autocleangroups mode"""
|
||||
# FIXME: Can we think of a smarter way of doing this than poking?
|
||||
self.terminator.autocleangroups = not self.terminator.autocleangroups
|
||||
self.config['autoclean_groups'] = not self.config['autoclean_groups']
|
||||
|
||||
def reconfigure(self, widget=None):
|
||||
"""Reconfigure our settings"""
|
||||
dbg('Terminal::reconfigure')
|
||||
if self.cnxid:
|
||||
dbg('Terminal::reconfigure: disconnecting')
|
||||
self.vte.disconnect(self.cnxid)
|
||||
self.cnxid = None
|
||||
|
||||
@ -880,22 +879,22 @@ class Terminal(gtk.VBox):
|
||||
self.terminator.newtab (self, True)
|
||||
|
||||
def key_go_next(self):
|
||||
self.terminator.go_next (self)
|
||||
self.emit('navigate', 'next')
|
||||
|
||||
def key_go_prev(self):
|
||||
self.terminator.go_prev (self)
|
||||
self.emit('navigate', 'prev')
|
||||
|
||||
def key_go_up(self):
|
||||
self.terminator.go_up (self)
|
||||
self.emit('navigate', 'up')
|
||||
|
||||
def key_go_down(self):
|
||||
self.terminator.go_down (self)
|
||||
self.emit('navigate', 'down')
|
||||
|
||||
def key_go_left(self):
|
||||
self.terminator.go_left (self)
|
||||
self.emit('navigate', 'left')
|
||||
|
||||
def key_go_right(self):
|
||||
self.terminator.go_right (self)
|
||||
self.emit('navigate', 'right')
|
||||
|
||||
def key_split_horiz(self):
|
||||
self.emit('split-horiz')
|
||||
|
Loading…
Reference in New Issue
Block a user