add some more add/remove love to Window
This commit is contained in:
parent
4111a80f7a
commit
93d8118c33
@ -6,6 +6,7 @@
|
|||||||
import gobject
|
import gobject
|
||||||
|
|
||||||
from config import Config
|
from config import Config
|
||||||
|
from util import dbg
|
||||||
|
|
||||||
# pylint: disable-msg=R0921
|
# pylint: disable-msg=R0921
|
||||||
class Container(object):
|
class Container(object):
|
||||||
@ -31,6 +32,7 @@ class Container(object):
|
|||||||
"""Class initialiser"""
|
"""Class initialiser"""
|
||||||
self.children = []
|
self.children = []
|
||||||
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"""
|
||||||
@ -65,13 +67,18 @@ class Container(object):
|
|||||||
"""Default unsplitter. This should be implemented by subclasses"""
|
"""Default unsplitter. This should be implemented by subclasses"""
|
||||||
raise NotImplementedError('unsplit')
|
raise NotImplementedError('unsplit')
|
||||||
|
|
||||||
|
def add(self, widget):
|
||||||
|
"""Add a widget to the container"""
|
||||||
|
raise NotImplementedError('add')
|
||||||
|
|
||||||
def remove(self, widget):
|
def remove(self, widget):
|
||||||
"""Remove a widget from the container"""
|
"""Remove a widget from the container"""
|
||||||
raise NotImplementedError('remove')
|
raise NotImplementedError('remove')
|
||||||
|
|
||||||
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['normal']:
|
if self.state_zoomed != self.states_zoom['none']:
|
||||||
|
dbg('closeterm: current zoomed state is: %s' % self.state_zoomed)
|
||||||
self.unzoom(widget)
|
self.unzoom(widget)
|
||||||
|
|
||||||
if not self.remove(widget):
|
if not self.remove(widget):
|
||||||
@ -86,7 +93,7 @@ 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['normal']:
|
if self.state_zoomed != self.states_zoom['none']:
|
||||||
self.unzoom(widget)
|
self.unzoom(widget)
|
||||||
else:
|
else:
|
||||||
self.zoom(widget, fontscale)
|
self.zoom(widget, fontscale)
|
||||||
|
@ -155,6 +155,16 @@ class Window(Container, gtk.Window):
|
|||||||
if colormap:
|
if colormap:
|
||||||
self.set_colormap(colormap)
|
self.set_colormap(colormap)
|
||||||
|
|
||||||
|
def add(self, widget):
|
||||||
|
"""Add a widget to the window by way of gtk.Window.add()"""
|
||||||
|
widget.connect('close-term', self.closeterm)
|
||||||
|
gtk.Window.add(self, widget)
|
||||||
|
|
||||||
|
def remove(self, widget):
|
||||||
|
"""Remove our child widget by way of gtk.Window.remove()"""
|
||||||
|
gtk.Window.remove(self, widget)
|
||||||
|
self.destroy()
|
||||||
|
|
||||||
class WindowTitle(object):
|
class WindowTitle(object):
|
||||||
"""Class to handle the setting of the window title"""
|
"""Class to handle the setting of the window title"""
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user