Make the window title update with the terminal title
This commit is contained in:
parent
187484271c
commit
f00c265f4c
|
@ -29,6 +29,8 @@ class Terminal(gtk.VBox):
|
||||||
|
|
||||||
__gsignals__ = {
|
__gsignals__ = {
|
||||||
'close-term': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
|
'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
|
TARGET_TYPE_VTE = 8
|
||||||
|
@ -39,6 +41,7 @@ class Terminal(gtk.VBox):
|
||||||
searchbar = None
|
searchbar = None
|
||||||
|
|
||||||
cwd = None
|
cwd = None
|
||||||
|
command = None
|
||||||
clipboard = None
|
clipboard = None
|
||||||
|
|
||||||
matches = None
|
matches = None
|
||||||
|
@ -221,6 +224,10 @@ class Terminal(gtk.VBox):
|
||||||
"""Reconfigure our settings"""
|
"""Reconfigure our settings"""
|
||||||
pass
|
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):
|
def on_group_button_press(self):
|
||||||
"""Handler for the group button"""
|
"""Handler for the group button"""
|
||||||
pass
|
pass
|
||||||
|
@ -252,7 +259,18 @@ class Terminal(gtk.VBox):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def on_vte_title_change(self, vte):
|
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):
|
def on_vte_focus(self, vte):
|
||||||
pass
|
pass
|
||||||
|
@ -312,6 +330,7 @@ class Terminal(gtk.VBox):
|
||||||
self.pid = self.vte.fork_command(command=shell, argv=args, envv=[],
|
self.pid = self.vte.fork_command(command=shell, argv=args, envv=[],
|
||||||
loglastlog=login, logwtmp=update_records,
|
loglastlog=login, logwtmp=update_records,
|
||||||
logutmp=update_records, directory=self.cwd)
|
logutmp=update_records, directory=self.cwd)
|
||||||
|
self.command = shell
|
||||||
|
|
||||||
self.on_vte_title_change(self.vte)
|
self.on_vte_title_change(self.vte)
|
||||||
self.titlebar.update()
|
self.titlebar.update()
|
||||||
|
|
|
@ -10,6 +10,8 @@ import gobject
|
||||||
class Titlebar(gtk.EventBox):
|
class Titlebar(gtk.EventBox):
|
||||||
"""Class implementing the Titlebar widget"""
|
"""Class implementing the Titlebar widget"""
|
||||||
|
|
||||||
|
oldtitle = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Class initialiser"""
|
"""Class initialiser"""
|
||||||
gtk.EventBox.__init__(self)
|
gtk.EventBox.__init__(self)
|
||||||
|
@ -29,4 +31,8 @@ class Titlebar(gtk.EventBox):
|
||||||
"""Update the displayed terminal size"""
|
"""Update the displayed terminal size"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def set_terminal_title(self, title):
|
||||||
|
"""Update the terminal title"""
|
||||||
|
pass
|
||||||
|
|
||||||
gobject.type_register(Titlebar)
|
gobject.type_register(Titlebar)
|
||||||
|
|
|
@ -45,6 +45,9 @@ class Window(Container, gtk.Window):
|
||||||
self.register_callbacks()
|
self.register_callbacks()
|
||||||
self.apply_config()
|
self.apply_config()
|
||||||
|
|
||||||
|
self.title = WindowTitle(self)
|
||||||
|
self.title.update()
|
||||||
|
|
||||||
def register_callbacks(self):
|
def register_callbacks(self):
|
||||||
"""Connect the GTK+ signals we care about"""
|
"""Connect the GTK+ signals we care about"""
|
||||||
self.connect('key-press-event', self.on_key_press)
|
self.connect('key-press-event', self.on_key_press)
|
||||||
|
@ -158,6 +161,7 @@ class Window(Container, gtk.Window):
|
||||||
def add(self, widget):
|
def add(self, widget):
|
||||||
"""Add a widget to the window by way of gtk.Window.add()"""
|
"""Add a widget to the window by way of gtk.Window.add()"""
|
||||||
widget.connect('close-term', self.closeterm)
|
widget.connect('close-term', self.closeterm)
|
||||||
|
widget.connect('title-change', self.title.set_title)
|
||||||
gtk.Window.add(self, widget)
|
gtk.Window.add(self, widget)
|
||||||
|
|
||||||
def remove(self, widget):
|
def remove(self, widget):
|
||||||
|
@ -177,10 +181,10 @@ class WindowTitle(object):
|
||||||
self.window = window
|
self.window = window
|
||||||
self.forced = False
|
self.forced = False
|
||||||
|
|
||||||
def set_title(self, newtext):
|
def set_title(self, widget, text):
|
||||||
"""Set the title"""
|
"""Set the title"""
|
||||||
if not self.forced:
|
if not self.forced:
|
||||||
self.text = newtext
|
self.text = text
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
def force_title(self, newtext):
|
def force_title(self, newtext):
|
||||||
|
|
Loading…
Reference in New Issue