Always set some sort of title; if vte's title is None, use the command the terminal is running.

Add an option to spawn a telnet instance to the local debug server in a tab.  newtab() and splitaxis() now support a command argument for this.
This commit is contained in:
Thomas Hurst 2008-08-07 21:34:47 +01:00
parent 6a14445c74
commit 4c0e500c7b
4 changed files with 39 additions and 22 deletions

View File

@ -152,7 +152,8 @@ See the following bug report for more details:
import threading import threading
gtk.gdk.threads_init() gtk.gdk.threads_init()
debugserver.spawn(locals()) (debugthread, debugsvr) = debugserver.spawn(locals())
term.debugaddress = debugsvr.server_address
gtk.main() gtk.main()

View File

@ -139,7 +139,7 @@ class TerminatorConsole(code.InteractiveConsole):
data = self.server.socketio.read(1) data = self.server.socketio.read(1)
ddbg('raw_input: char=%s' % repr(data)) ddbg('raw_input: char=%s' % repr(data))
if data == LF or data == '\006': if data == LF or data == '\006':
buf = self.parse_telnet(buf + data).lstrip() buf = self.parse_telnet(buf + data)
if buf != '': if buf != '':
return buf return buf
elif data == '\004' or data == '': # ^D elif data == '\004' or data == '': # ^D

View File

@ -95,6 +95,7 @@ class Terminator:
self._maximised = False self._maximised = False
self._fullscreen = False self._fullscreen = False
self._f11_modifier = False self._f11_modifier = False
self.debugaddress = None
self.term_list = [] self.term_list = []
stores = [] stores = []
stores.append (config.TerminatorConfValuestoreRC ()) stores.append (config.TerminatorConfValuestoreRC ())
@ -448,13 +449,13 @@ class Terminator:
dbg("[ERROR] unsupported class %s in _notebook_last_term" % child.__class__.__name__) dbg("[ERROR] unsupported class %s in _notebook_last_term" % child.__class__.__name__)
return None return None
def newtab(self,widget, toplevel = False): def newtab(self,widget, toplevel = False, command = None):
if self._zoomed: if self._zoomed:
# We don't want to add a new tab while we are zoomed in on a terminal # We don't want to add a new tab while we are zoomed in on a terminal
dbg ("newtab function called, but Terminator was in zoomed terminal mode.") dbg ("newtab function called, but Terminator was in zoomed terminal mode.")
return return
terminal = TerminatorTerm (self, self.profile, None, widget.get_cwd()) terminal = TerminatorTerm (self, self.profile, command, widget.get_cwd())
#only one term, we don't show the title #only one term, we don't show the title
terminal._titlebox.hide() terminal._titlebox.hide()
if self.conf.extreme_tabs and not toplevel: if self.conf.extreme_tabs and not toplevel:
@ -537,7 +538,7 @@ class Terminator:
self.term_list.insert (index + 1, terminal) self.term_list.insert (index + 1, terminal)
return (True) return (True)
def splitaxis (self, widget, vertical=True): def splitaxis (self, widget, vertical=True, command=None):
""" Split the provided widget on the horizontal or vertical axis. """ """ Split the provided widget on the horizontal or vertical axis. """
if self._zoomed: if self._zoomed:
# We don't want to split the terminal while we are in zoomed mode # We don't want to split the terminal while we are in zoomed mode
@ -546,7 +547,7 @@ class Terminator:
# create a new terminal and parent pane. # create a new terminal and parent pane.
dbg ('SEGBUG: Creating TerminatorTerm') dbg ('SEGBUG: Creating TerminatorTerm')
terminal = TerminatorTerm (self, self.profile, None, widget.get_cwd()) terminal = TerminatorTerm (self, self.profile, command, widget.get_cwd())
dbg ('SEGBUG: Created TerminatorTerm') dbg ('SEGBUG: Created TerminatorTerm')
pos = vertical and "right" or "bottom" pos = vertical and "right" or "bottom"
dbg ('SEGBUG: Position is: %s'%pos) dbg ('SEGBUG: Position is: %s'%pos)

View File

@ -478,6 +478,9 @@ text/plain
logutmp = update_records, directory=self.cwd) logutmp = update_records, directory=self.cwd)
dbg ('SEGBUG: Forked command') dbg ('SEGBUG: Forked command')
self.on_vte_title_change(self._vte) # Force an initial update of our titles
if self._pid == -1: if self._pid == -1:
err (_('Unable to start shell: ') + shell) err (_('Unable to start shell: ') + shell)
return (-1) return (-1)
@ -852,7 +855,6 @@ text/plain
item.connect ("activate", lambda menu_item: self.terminator.splitaxis (self, False)) item.connect ("activate", lambda menu_item: self.terminator.splitaxis (self, False))
menu.append (item) menu.append (item)
item = gtk.ImageMenuItem (str_vert) item = gtk.ImageMenuItem (str_vert)
item_image = gtk.Image () item_image = gtk.Image ()
item_image.set_from_icon_name (APP_NAME + '_vert', gtk.ICON_SIZE_MENU) item_image.set_from_icon_name (APP_NAME + '_vert', gtk.ICON_SIZE_MENU)
@ -865,6 +867,12 @@ text/plain
item.connect ("activate", lambda menu_item: self.terminator.newtab (self)) item.connect ("activate", lambda menu_item: self.terminator.newtab (self))
menu.append (item) menu.append (item)
if self.terminator.debugaddress:
item = gtk.MenuItem (_("Open _Debug Tab"))
item.connect ("activate", lambda menu_item: self.terminator.newtab (self, command = "telnet %s" % ' '.join([str(x) for x in self.terminator.debugaddress])))
menu.append (item)
if self.conf.extreme_tabs: if self.conf.extreme_tabs:
item = gtk.MenuItem (_("Open Top Level Tab")) item = gtk.MenuItem (_("Open Top Level Tab"))
item.connect ("activate", lambda menu_item: self.terminator.newtab (self, True)) item.connect ("activate", lambda menu_item: self.terminator.newtab (self, True))
@ -960,18 +968,25 @@ text/plain
radioitem.connect ('activate', self.on_encoding_change, encoding[1]) radioitem.connect ('activate', self.on_encoding_change, encoding[1])
submenu.append (radioitem) submenu.append (radioitem)
def get_vte_window_title(self, vte):
title = vte.get_window_title ()
if title is None:
title = str(self.command)
return title
def on_vte_title_change(self, vte): def on_vte_title_change(self, vte):
title = self.get_vte_window_title(vte)
if self.conf.titletips: if self.conf.titletips:
vte.set_property ("has-tooltip", True) vte.set_property ("has-tooltip", True)
vte.set_property ("tooltip-text", vte.get_window_title ()) vte.set_property ("tooltip-text", title)
#set the title anyhow, titlebars setting only show/hide the label #set the title anyhow, titlebars setting only show/hide the label
self._title.set_text(vte.get_window_title ()) self._title.set_text(title)
self.terminator.set_window_title("%s - %s" % (vte.get_window_title(), APP_NAME.capitalize())) self.terminator.set_window_title("%s - %s" % (title, APP_NAME.capitalize()))
notebookpage = self.terminator.get_first_notebook_page(vte) notebookpage = self.terminator.get_first_notebook_page(vte)
while notebookpage != None: while notebookpage != None:
if notebookpage[0].get_tab_label(notebookpage[1]): if notebookpage[0].get_tab_label(notebookpage[1]):
label = notebookpage[0].get_tab_label(notebookpage[1]) label = notebookpage[0].get_tab_label(notebookpage[1])
label.set_title(vte.get_window_title ()) label.set_title(title)
notebookpage[0].set_tab_label(notebookpage[1], label) notebookpage[0].set_tab_label(notebookpage[1], label)
notebookpage = self.terminator.get_first_notebook_page(notebookpage[0]) notebookpage = self.terminator.get_first_notebook_page(notebookpage[0])
@ -986,15 +1001,15 @@ text/plain
return return
def on_vte_focus(self, vte): def on_vte_focus(self, vte):
if vte.get_window_title (): title = self.get_vte_window_title(vte)
self.terminator.set_window_title("%s - %s" % (vte.get_window_title(), APP_NAME.capitalize())) self.terminator.set_window_title("%s - %s" % (title, APP_NAME.capitalize()))
notebookpage = self.terminator.get_first_notebook_page(vte) notebookpage = self.terminator.get_first_notebook_page(vte)
while notebookpage != None: while notebookpage != None:
if notebookpage[0].get_tab_label(notebookpage[1]): if notebookpage[0].get_tab_label(notebookpage[1]):
label = notebookpage[0].get_tab_label(notebookpage[1]) label = notebookpage[0].get_tab_label(notebookpage[1])
label.set_title(vte.get_window_title ()) label.set_title(title)
notebookpage[0].set_tab_label(notebookpage[1], label) notebookpage[0].set_tab_label(notebookpage[1], label)
notebookpage = self.terminator.get_first_notebook_page(notebookpage[0]) notebookpage = self.terminator.get_first_notebook_page(notebookpage[0])
def destroy(self): def destroy(self):
self._vte.destroy() self._vte.destroy()