Fix up some handling of unzooming and closing terminals while zoomed

This commit is contained in:
Chris Jones 2009-11-19 23:16:20 -06:00
parent 7d9575df5f
commit 132daeb447
3 changed files with 23 additions and 20 deletions

View File

@ -16,12 +16,6 @@ class Container(object):
immutable = None immutable = None
children = None children = None
config = None config = None
state_zoomed = None
states_zoom = { 'none' : 0,
'zoomed' : 1,
'maximised' : 2 }
signals = None signals = None
cnxids = None cnxids = None
@ -31,7 +25,6 @@ class Container(object):
self.signals = [] self.signals = []
self.cnxids = {} self.cnxids = {}
self.config = Config() self.config = Config()
self.state_zoomed = self.states_zoom['none']
def register_signals(self, widget): def register_signals(self, widget):
"""Register gobject signals in a way that avoids multiple inheritance""" """Register gobject signals in a way that avoids multiple inheritance"""
@ -109,9 +102,15 @@ class Container(object):
def closeterm(self, widget): def closeterm(self, widget):
"""Handle the closure of a terminal""" """Handle the closure of a terminal"""
if self.state_zoomed != self.states_zoom['none']: try:
dbg('closeterm: current zoomed state is: %s' % self.state_zoomed) if self.get_property('term_zoomed'):
self.unzoom(widget) # We're zoomed, so unzoom and then start closing again
dbg('Container::closeterm: terminal zoomed, unzooming')
self.unzoom(widget)
widget.close()
return(True)
except TypeError:
pass
if not self.remove(widget): if not self.remove(widget):
return(False) return(False)
@ -126,10 +125,14 @@ class Container(object):
def toggle_zoom(self, widget, fontscale = False): def toggle_zoom(self, widget, fontscale = False):
"""Toggle the existing zoom state""" """Toggle the existing zoom state"""
if self.state_zoomed != self.states_zoom['none']: try:
self.unzoom(widget) if self.get_property('term_zoomed'):
else: self.unzoom(widget)
self.zoom(widget, fontscale) else:
self.zoom(widget, fontscale)
except TypeError:
err('Container::toggle_zoom: %s is unable to handle zooming, for \
%s' % (self, widget))
def zoom(self, widget, fontscale = False): def zoom(self, widget, fontscale = False):
"""Zoom a terminal""" """Zoom a terminal"""

View File

@ -85,12 +85,12 @@ class Paned(Container):
'split-horiz': self.split_horiz, 'split-horiz': self.split_horiz,
'split-vert': self.split_vert, 'split-vert': self.split_vert,
'resize-term': self.resizeterm, 'resize-term': self.resizeterm,
'zoom': top_window.terminal_zoom} 'zoom': top_window.zoom}
for signal in signals: for signal in signals:
self.connect_child(widget, signal, signals[signal]) self.connect_child(widget, signal, signals[signal])
self.connect_child(widget, 'maximise', top_window.terminal_zoom, self.connect_child(widget, 'maximise', top_window.zoom,
False) False)
widget.grab_focus() widget.grab_focus()

View File

@ -173,7 +173,7 @@ class Window(Container, gtk.Window):
'title-change': self.title.set_title, 'title-change': self.title.set_title,
'split-horiz': self.split_horiz, 'split-horiz': self.split_horiz,
'split-vert': self.split_vert, 'split-vert': self.split_vert,
'unzoom': self.terminal_unzoom} 'unzoom': self.unzoom}
for signal in signals: for signal in signals:
self.connect_child(widget, signal, signals[signal]) self.connect_child(widget, signal, signals[signal])
@ -208,7 +208,7 @@ class Window(Container, gtk.Window):
sibling.spawn_child() sibling.spawn_child()
def terminal_zoom(self, widget, font_scale=True): def zoom(self, widget, font_scale=True):
"""Zoom a terminal widget""" """Zoom a terminal widget"""
children = self.get_children() children = self.get_children()
@ -233,11 +233,11 @@ class Window(Container, gtk.Window):
widget.grab_focus() widget.grab_focus()
def terminal_unzoom(self, widget): def unzoom(self, widget):
"""Restore normal terminal layout""" """Restore normal terminal layout"""
if not self.get_property('term_zoomed'): if not self.get_property('term_zoomed'):
# We're not zoomed anyway # We're not zoomed anyway
dbg('Window::terminal_unzoom: not zoomed, no-op') dbg('Window::unzoom: not zoomed, no-op')
return return
widget = self.zoom_data['widget'] widget = self.zoom_data['widget']