Fix up some handling of unzooming and closing terminals while zoomed
This commit is contained in:
parent
7d9575df5f
commit
132daeb447
|
@ -16,12 +16,6 @@ class Container(object):
|
|||
immutable = None
|
||||
children = None
|
||||
config = None
|
||||
state_zoomed = None
|
||||
|
||||
states_zoom = { 'none' : 0,
|
||||
'zoomed' : 1,
|
||||
'maximised' : 2 }
|
||||
|
||||
signals = None
|
||||
cnxids = None
|
||||
|
||||
|
@ -31,7 +25,6 @@ class Container(object):
|
|||
self.signals = []
|
||||
self.cnxids = {}
|
||||
self.config = Config()
|
||||
self.state_zoomed = self.states_zoom['none']
|
||||
|
||||
def register_signals(self, widget):
|
||||
"""Register gobject signals in a way that avoids multiple inheritance"""
|
||||
|
@ -109,9 +102,15 @@ class Container(object):
|
|||
|
||||
def closeterm(self, widget):
|
||||
"""Handle the closure of a terminal"""
|
||||
if self.state_zoomed != self.states_zoom['none']:
|
||||
dbg('closeterm: current zoomed state is: %s' % self.state_zoomed)
|
||||
try:
|
||||
if self.get_property('term_zoomed'):
|
||||
# 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):
|
||||
return(False)
|
||||
|
@ -126,10 +125,14 @@ class Container(object):
|
|||
|
||||
def toggle_zoom(self, widget, fontscale = False):
|
||||
"""Toggle the existing zoom state"""
|
||||
if self.state_zoomed != self.states_zoom['none']:
|
||||
try:
|
||||
if self.get_property('term_zoomed'):
|
||||
self.unzoom(widget)
|
||||
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):
|
||||
"""Zoom a terminal"""
|
||||
|
|
|
@ -85,12 +85,12 @@ class Paned(Container):
|
|||
'split-horiz': self.split_horiz,
|
||||
'split-vert': self.split_vert,
|
||||
'resize-term': self.resizeterm,
|
||||
'zoom': top_window.terminal_zoom}
|
||||
'zoom': top_window.zoom}
|
||||
|
||||
for signal in signals:
|
||||
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)
|
||||
|
||||
widget.grab_focus()
|
||||
|
|
|
@ -173,7 +173,7 @@ class Window(Container, gtk.Window):
|
|||
'title-change': self.title.set_title,
|
||||
'split-horiz': self.split_horiz,
|
||||
'split-vert': self.split_vert,
|
||||
'unzoom': self.terminal_unzoom}
|
||||
'unzoom': self.unzoom}
|
||||
|
||||
for signal in signals:
|
||||
self.connect_child(widget, signal, signals[signal])
|
||||
|
@ -208,7 +208,7 @@ class Window(Container, gtk.Window):
|
|||
|
||||
sibling.spawn_child()
|
||||
|
||||
def terminal_zoom(self, widget, font_scale=True):
|
||||
def zoom(self, widget, font_scale=True):
|
||||
"""Zoom a terminal widget"""
|
||||
children = self.get_children()
|
||||
|
||||
|
@ -233,11 +233,11 @@ class Window(Container, gtk.Window):
|
|||
|
||||
widget.grab_focus()
|
||||
|
||||
def terminal_unzoom(self, widget):
|
||||
def unzoom(self, widget):
|
||||
"""Restore normal terminal layout"""
|
||||
if not self.get_property('term_zoomed'):
|
||||
# We're not zoomed anyway
|
||||
dbg('Window::terminal_unzoom: not zoomed, no-op')
|
||||
dbg('Window::unzoom: not zoomed, no-op')
|
||||
return
|
||||
|
||||
widget = self.zoom_data['widget']
|
||||
|
|
Loading…
Reference in New Issue