Attach the debug server to the context menu

This commit is contained in:
Chris Jones 2010-03-19 22:16:08 +00:00
parent 837bd3c5d2
commit 16bc247b0e
6 changed files with 23 additions and 10 deletions

View File

@ -69,7 +69,7 @@ if __name__ == '__main__':
gtk.gdk.threads_init() gtk.gdk.threads_init()
(DEBUGTHREAD, DEBUGSVR) = debugserver.spawn(locals()) (DEBUGTHREAD, DEBUGSVR) = debugserver.spawn(locals())
TERMINATOR.debugaddress = DEBUGSVR.server_address TERMINATOR.debug_address = DEBUGSVR.server_address
try: try:
gtk.main() gtk.main()

View File

@ -35,7 +35,7 @@ class Notebook(Container, gtk.Notebook):
child = window.get_child() child = window.get_child()
window.remove(child) window.remove(child)
window.add(self) window.add(self)
self.newtab(child) self.newtab(widget=child)
self.show_all() self.show_all()
@ -124,7 +124,7 @@ class Notebook(Container, gtk.Notebook):
def add(self, widget): def add(self, widget):
"""Add a widget to the container""" """Add a widget to the container"""
self.newtab(widget) self.newtab(widget=widget)
def remove(self, widget): def remove(self, widget):
"""Remove a widget from the container""" """Remove a widget from the container"""
@ -144,14 +144,14 @@ class Notebook(Container, gtk.Notebook):
children.append(self.get_nth_page(page)) children.append(self.get_nth_page(page))
return(children) return(children)
def newtab(self, widget=None): def newtab(self, debugtab=False, widget=None):
"""Add a new tab, optionally supplying a child widget""" """Add a new tab, optionally supplying a child widget"""
maker = Factory() maker = Factory()
top_window = get_top_window(self) top_window = get_top_window(self)
if not widget: if not widget:
widget = maker.make('Terminal') widget = maker.make('Terminal')
widget.spawn_child() widget.spawn_child(debugserver=debugtab)
signals = {'close-term': self.wrapcloseterm, signals = {'close-term': self.wrapcloseterm,
'split-horiz': self.split_horiz, 'split-horiz': self.split_horiz,

View File

@ -51,7 +51,8 @@ class Terminal(gtk.VBox):
(gobject.TYPE_STRING,)), (gobject.TYPE_STRING,)),
'split-vert': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, 'split-vert': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
(gobject.TYPE_STRING,)), (gobject.TYPE_STRING,)),
'tab-new': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()), 'tab-new': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
(gobject.TYPE_BOOLEAN,)),
'tab-top-new': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()), 'tab-top-new': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'focus-in': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()), 'focus-in': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'zoom': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()), 'zoom': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
@ -1044,7 +1045,7 @@ for %s (%s)' % (name, urlplugin.__class__.__name__))
if cwd is not None: if cwd is not None:
self.cwd = cwd self.cwd = cwd
def spawn_child(self, widget=None, respawn=False): def spawn_child(self, widget=None, respawn=False, debugserver=False):
update_records = self.config['update_records'] update_records = self.config['update_records']
login = self.config['login_shell'] login = self.config['login_shell']
args = [] args = []
@ -1069,6 +1070,11 @@ for %s (%s)' % (name, urlplugin.__class__.__name__))
command = self.config['custom_command'] command = self.config['custom_command']
elif self.layout_command: elif self.layout_command:
command = self.layout_command command = self.layout_command
elif debugserver is True:
details = self.terminator.debug_address
dbg('spawning debug session with: %s:%s' % (details[0],
details[1]))
command = 'telnet %s %s' % (details[0], details[1])
if type(command) is list: if type(command) is list:
shell = util.path_lookup(command[0]) shell = util.path_lookup(command[0])

View File

@ -100,9 +100,15 @@ class TerminalPopupMenu(object):
menu.append(item) menu.append(item)
item = gtk.MenuItem(_('Open _Tab')) item = gtk.MenuItem(_('Open _Tab'))
item.connect('activate', lambda x: terminal.emit('tab-new')) item.connect('activate', lambda x: terminal.emit('tab-new', False))
menu.append(item) menu.append(item)
if self.terminator.debug_address or True:
item = gtk.MenuItem(_('Open _Debug Tab'))
item.connect('activate', lambda x:
terminal.emit('tab-new', True))
menu.append(item)
menu.append(gtk.MenuItem()) menu.append(gtk.MenuItem())
item = gtk.ImageMenuItem(gtk.STOCK_CLOSE) item = gtk.ImageMenuItem(gtk.STOCK_CLOSE)

View File

@ -27,6 +27,7 @@ class Terminator(Borg):
origcwd = None origcwd = None
pid_cwd = None pid_cwd = None
gnome_client = None gnome_client = None
debug_address = None
doing_layout = None doing_layout = None

View File

@ -159,12 +159,12 @@ class Window(Container, gtk.Window):
maker = Factory() maker = Factory()
return(maker.isinstance(self.get_child(), 'Notebook')) return(maker.isinstance(self.get_child(), 'Notebook'))
def tab_new(self, widget=None): def tab_new(self, widget=None, debugtab=False):
"""Make a new tab""" """Make a new tab"""
maker = Factory() maker = Factory()
if not self.is_child_notebook(): if not self.is_child_notebook():
notebook = maker.make('Notebook', window=self) notebook = maker.make('Notebook', window=self)
self.get_child().newtab() self.get_child().newtab(debugtab)
def on_delete_event(self, window, event, data=None): def on_delete_event(self, window, event, data=None):
"""Handle a window close request""" """Handle a window close request"""