From 16bc247b0eacb8dd387c7d118599c210dadc3377 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Fri, 19 Mar 2010 22:16:08 +0000 Subject: [PATCH] Attach the debug server to the context menu --- terminator | 2 +- terminatorlib/notebook.py | 8 ++++---- terminatorlib/terminal.py | 10 ++++++++-- terminatorlib/terminal_popup_menu.py | 8 +++++++- terminatorlib/terminator.py | 1 + terminatorlib/window.py | 4 ++-- 6 files changed, 23 insertions(+), 10 deletions(-) diff --git a/terminator b/terminator index 8710c9c4..cbf414e5 100755 --- a/terminator +++ b/terminator @@ -69,7 +69,7 @@ if __name__ == '__main__': gtk.gdk.threads_init() (DEBUGTHREAD, DEBUGSVR) = debugserver.spawn(locals()) - TERMINATOR.debugaddress = DEBUGSVR.server_address + TERMINATOR.debug_address = DEBUGSVR.server_address try: gtk.main() diff --git a/terminatorlib/notebook.py b/terminatorlib/notebook.py index ed5fd38c..ef3821bd 100755 --- a/terminatorlib/notebook.py +++ b/terminatorlib/notebook.py @@ -35,7 +35,7 @@ class Notebook(Container, gtk.Notebook): child = window.get_child() window.remove(child) window.add(self) - self.newtab(child) + self.newtab(widget=child) self.show_all() @@ -124,7 +124,7 @@ class Notebook(Container, gtk.Notebook): def add(self, widget): """Add a widget to the container""" - self.newtab(widget) + self.newtab(widget=widget) def remove(self, widget): """Remove a widget from the container""" @@ -144,14 +144,14 @@ class Notebook(Container, gtk.Notebook): children.append(self.get_nth_page(page)) return(children) - def newtab(self, widget=None): + def newtab(self, debugtab=False, widget=None): """Add a new tab, optionally supplying a child widget""" maker = Factory() top_window = get_top_window(self) if not widget: widget = maker.make('Terminal') - widget.spawn_child() + widget.spawn_child(debugserver=debugtab) signals = {'close-term': self.wrapcloseterm, 'split-horiz': self.split_horiz, diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index 9bff6292..de066af9 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -51,7 +51,8 @@ class Terminal(gtk.VBox): (gobject.TYPE_STRING,)), 'split-vert': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (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, ()), 'focus-in': (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: 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'] login = self.config['login_shell'] args = [] @@ -1069,6 +1070,11 @@ for %s (%s)' % (name, urlplugin.__class__.__name__)) command = self.config['custom_command'] elif 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: shell = util.path_lookup(command[0]) diff --git a/terminatorlib/terminal_popup_menu.py b/terminatorlib/terminal_popup_menu.py index 6eab35ec..9c75a6dd 100755 --- a/terminatorlib/terminal_popup_menu.py +++ b/terminatorlib/terminal_popup_menu.py @@ -100,9 +100,15 @@ class TerminalPopupMenu(object): menu.append(item) 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) + 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()) item = gtk.ImageMenuItem(gtk.STOCK_CLOSE) diff --git a/terminatorlib/terminator.py b/terminatorlib/terminator.py index 3c3c88a2..095b59aa 100755 --- a/terminatorlib/terminator.py +++ b/terminatorlib/terminator.py @@ -27,6 +27,7 @@ class Terminator(Borg): origcwd = None pid_cwd = None gnome_client = None + debug_address = None doing_layout = None diff --git a/terminatorlib/window.py b/terminatorlib/window.py index 7c36ad16..5b683199 100755 --- a/terminatorlib/window.py +++ b/terminatorlib/window.py @@ -159,12 +159,12 @@ class Window(Container, gtk.Window): maker = Factory() 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""" maker = Factory() if not self.is_child_notebook(): notebook = maker.make('Notebook', window=self) - self.get_child().newtab() + self.get_child().newtab(debugtab) def on_delete_event(self, window, event, data=None): """Handle a window close request"""