Make the window title update with the terminal title

This commit is contained in:
Chris Jones 2009-09-02 21:10:28 +01:00
parent 187484271c
commit f00c265f4c
3 changed files with 32 additions and 3 deletions

View File

@ -29,6 +29,8 @@ class Terminal(gtk.VBox):
__gsignals__ = {
'close-term': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'title-change': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
(gobject.TYPE_STRING,)),
}
TARGET_TYPE_VTE = 8
@ -39,6 +41,7 @@ class Terminal(gtk.VBox):
searchbar = None
cwd = None
command = None
clipboard = None
matches = None
@ -221,6 +224,10 @@ class Terminal(gtk.VBox):
"""Reconfigure our settings"""
pass
def get_window_title(self):
"""Return the window title"""
return(self.vte.get_window_title() or str(self.command))
def on_group_button_press(self):
"""Handler for the group button"""
pass
@ -252,7 +259,18 @@ class Terminal(gtk.VBox):
pass
def on_vte_title_change(self, vte):
pass
title = self.get_window_title()
if title == self.titlebar.oldtitle:
# Title hasn't changed, don't do anything
return
self.titlebar.oldtitle = title
if self.config['titletips']:
vte.set_property('has-tooltip', True)
vte.set_property('tooltip-text', title)
self.titlebar.set_terminal_title(title)
self.emit('title-change', title)
def on_vte_focus(self, vte):
pass
@ -312,6 +330,7 @@ class Terminal(gtk.VBox):
self.pid = self.vte.fork_command(command=shell, argv=args, envv=[],
loglastlog=login, logwtmp=update_records,
logutmp=update_records, directory=self.cwd)
self.command = shell
self.on_vte_title_change(self.vte)
self.titlebar.update()

View File

@ -10,6 +10,8 @@ import gobject
class Titlebar(gtk.EventBox):
"""Class implementing the Titlebar widget"""
oldtitle = None
def __init__(self):
"""Class initialiser"""
gtk.EventBox.__init__(self)
@ -29,4 +31,8 @@ class Titlebar(gtk.EventBox):
"""Update the displayed terminal size"""
pass
def set_terminal_title(self, title):
"""Update the terminal title"""
pass
gobject.type_register(Titlebar)

View File

@ -45,6 +45,9 @@ class Window(Container, gtk.Window):
self.register_callbacks()
self.apply_config()
self.title = WindowTitle(self)
self.title.update()
def register_callbacks(self):
"""Connect the GTK+ signals we care about"""
self.connect('key-press-event', self.on_key_press)
@ -158,6 +161,7 @@ class Window(Container, gtk.Window):
def add(self, widget):
"""Add a widget to the window by way of gtk.Window.add()"""
widget.connect('close-term', self.closeterm)
widget.connect('title-change', self.title.set_title)
gtk.Window.add(self, widget)
def remove(self, widget):
@ -177,10 +181,10 @@ class WindowTitle(object):
self.window = window
self.forced = False
def set_title(self, newtext):
def set_title(self, widget, text):
"""Set the title"""
if not self.forced:
self.text = newtext
self.text = text
self.update()
def force_title(self, newtext):