Add layout save and load of last active term for windows without tabs

This commit is contained in:
Stephen Boddy 2013-11-19 12:46:11 +01:00
parent e66a522555
commit 0272c78739
4 changed files with 41 additions and 6 deletions

View File

@ -281,6 +281,9 @@ the %s will also close all terminals within it.') % (reqtype, reqtype))
labels.append(label.get_custom_label()) labels.append(label.get_custom_label())
layout['labels'] = labels layout['labels'] = labels
layout['active_page'] = self.get_current_page() layout['active_page'] = self.get_current_page()
else:
if hasattr(self, 'last_active_term') and self.last_active_term is not None:
layout['last_active_term'] = self.last_active_term
if mytype == 'Window': if mytype == 'Window':
if self.uuid == self.terminator.last_active_window: if self.uuid == self.terminator.last_active_window:

View File

@ -1088,7 +1088,13 @@ class Terminal(gtk.VBox):
self.vte.set_colors(self.fgcolor_active, self.bgcolor, self.vte.set_colors(self.fgcolor_active, self.bgcolor,
self.palette_active) self.palette_active)
self.set_cursor_color() self.set_cursor_color()
if not self.terminator.doing_layout:
self.terminator.last_focused_term = self self.terminator.last_focused_term = self
if self.get_toplevel().is_child_notebook():
# TODO: Will need some code for the tabs active terms to work
self.get_toplevel().last_active_term = None
else:
self.get_toplevel().last_active_term = self.uuid
self.emit('focus-in') self.emit('focus-in')
def on_vte_focus_out(self, _widget, _event): def on_vte_focus_out(self, _widget, _event):

View File

@ -293,14 +293,25 @@ class Terminator(Borg):
"""Layout operations have finished, record that fact""" """Layout operations have finished, record that fact"""
self.doing_layout = False self.doing_layout = False
window_last_active_term_mapping={}
for window in self.windows: for window in self.windows:
if window.uuid == self.last_active_window: # TODO: Will need some code for the tabs active terms to work
window.show() window_last_active_term_mapping[window]=copy.deepcopy(window.last_active_term)
for terminal in self.terminals: for terminal in self.terminals:
if not terminal.pid: if not terminal.pid:
terminal.spawn_child() terminal.spawn_child()
for window in self.windows:
if window.last_active_term:
# TODO: Will need some code for the tabs active terms to work
term = self.find_terminal_by_uuid(window_last_active_term_mapping[window].urn)
term.ensure_visible_and_focussed()
for window in self.windows:
if window.uuid == self.last_active_window:
window.show()
def reconfigure(self): def reconfigure(self):
"""Update configuration for the whole application""" """Update configuration for the whole application"""

View File

@ -5,12 +5,13 @@
import copy import copy
import time import time
import uuid
import pygtk import pygtk
pygtk.require('2.0') pygtk.require('2.0')
import gobject import gobject
import gtk import gtk
from util import dbg, err from util import dbg, err, make_uuid
import util import util
from translation import _ from translation import _
from version import APP_NAME from version import APP_NAME
@ -38,6 +39,7 @@ class Window(Container, gtk.Window):
position = None position = None
ignore_startup_show = None ignore_startup_show = None
set_pos_by_ratio = None set_pos_by_ratio = None
last_active_term = None
zoom_data = None zoom_data = None
@ -239,6 +241,16 @@ class Window(Container, gtk.Window):
def on_focus_in(self, window, event): def on_focus_in(self, window, event):
"""Focus has entered the window""" """Focus has entered the window"""
self.set_urgency_hint(False) self.set_urgency_hint(False)
term = None
if self.is_child_notebook():
# TODO: Will need some code for the tabs active terms to work
pass
else:
if isinstance(self.last_active_term, uuid.UUID):
term = self.terminator.find_terminal_by_uuid(self.last_active_term.urn)
if term:
gobject.idle_add(term.ensure_visible_and_focussed)
if not self.terminator.doing_layout:
self.terminator.last_active_window = self.uuid self.terminator.last_active_window = self.uuid
# FIXME: Cause the terminal titlebars to update here # FIXME: Cause the terminal titlebars to update here
@ -866,6 +878,9 @@ class Window(Container, gtk.Window):
self.get_children()[0].create_layout(child) self.get_children()[0].create_layout(child)
if layout.has_key('last_active_term') and layout['last_active_term'] not in ['', None]:
self.last_active_term = make_uuid(layout['last_active_term'])
if layout.has_key('last_active_window') and layout['last_active_window'] == 'True': if layout.has_key('last_active_window') and layout['last_active_window'] == 'True':
self.terminator.last_active_window = self.uuid self.terminator.last_active_window = self.uuid