attempt to dodge gobject's inability to do multiple inheritance
This commit is contained in:
parent
ea767f4164
commit
3df46d1d85
|
@ -3,9 +3,12 @@
|
||||||
# GPL v2 only
|
# GPL v2 only
|
||||||
"""container.py - classes necessary to contain Terminal widgets"""
|
"""container.py - classes necessary to contain Terminal widgets"""
|
||||||
|
|
||||||
|
import gobject
|
||||||
|
import gtk
|
||||||
|
|
||||||
from util import debug, err
|
from util import debug, err
|
||||||
|
|
||||||
class Container:
|
class Container():
|
||||||
"""Base class for Terminator Containers"""
|
"""Base class for Terminator Containers"""
|
||||||
|
|
||||||
immutable = None
|
immutable = None
|
||||||
|
@ -17,11 +20,27 @@ class Container:
|
||||||
'zoomed' : 1,
|
'zoomed' : 1,
|
||||||
'maximised' : 2 }
|
'maximised' : 2 }
|
||||||
|
|
||||||
|
signals = [ {'name': 'group-hoover-needed',
|
||||||
|
'flags': gobject.SIGNAL_RUN_LAST,
|
||||||
|
'return_type': gobject.TYPE_BOOLEAN,
|
||||||
|
'param_types': ()
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
def __init__(self, configobject):
|
def __init__(self, configobject):
|
||||||
"""Class initialiser"""
|
"""Class initialiser"""
|
||||||
self.children = []
|
self.children = []
|
||||||
self.config = configobject
|
self.config = configobject
|
||||||
|
|
||||||
|
def register_signals(self, object):
|
||||||
|
"""Register gobject signals in a way that avoids multiple inheritance"""
|
||||||
|
for signal in self.signals:
|
||||||
|
gobject.signal_new(signal['name'],
|
||||||
|
object,
|
||||||
|
signal['flags'],
|
||||||
|
signal['return_type'],
|
||||||
|
signal['param_types'])
|
||||||
|
|
||||||
def get_offspring(self):
|
def get_offspring(self):
|
||||||
"""Return a list of child widgets, if any"""
|
"""Return a list of child widgets, if any"""
|
||||||
return(self.children)
|
return(self.children)
|
||||||
|
@ -44,6 +63,10 @@ class Container:
|
||||||
err('unsplit called from base class. This is a bug')
|
err('unsplit called from base class. This is a bug')
|
||||||
return(False)
|
return(False)
|
||||||
|
|
||||||
|
def remove(self, widget):
|
||||||
|
"""Remove a widget from the container"""
|
||||||
|
err('remove called from base class. This is a bug')
|
||||||
|
|
||||||
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['normal']:
|
||||||
|
@ -52,7 +75,7 @@ class Container:
|
||||||
if not self.remove(widget):
|
if not self.remove(widget):
|
||||||
return(False)
|
return(False)
|
||||||
|
|
||||||
self.group_hoover()
|
self.emit('need_group_hoover')
|
||||||
return(True)
|
return(True)
|
||||||
|
|
||||||
def closegroupterms(self, widget):
|
def closegroupterms(self, widget):
|
||||||
|
@ -65,7 +88,7 @@ class Container:
|
||||||
if term._group == widget._group and not self.remove(term):
|
if term._group == widget._group and not self.remove(term):
|
||||||
all_closed = False
|
all_closed = False
|
||||||
|
|
||||||
self.group_hoover()
|
self.emit('need_group_hoover')
|
||||||
return(all_closed)
|
return(all_closed)
|
||||||
|
|
||||||
def resizeterm(self, widget, keyname):
|
def resizeterm(self, widget, keyname):
|
||||||
|
|
|
@ -31,6 +31,8 @@ class Window(Container, gtk.Window):
|
||||||
"""Class initialiser"""
|
"""Class initialiser"""
|
||||||
Container.__init__(self, configobject)
|
Container.__init__(self, configobject)
|
||||||
gtk.Window.__init__(self)
|
gtk.Window.__init__(self)
|
||||||
|
gobject.type_register(Window)
|
||||||
|
self.register_signals(Window)
|
||||||
|
|
||||||
self.set_property('allow-shrink', True)
|
self.set_property('allow-shrink', True)
|
||||||
self.register_callbacks()
|
self.register_callbacks()
|
||||||
|
@ -112,6 +114,7 @@ class Window(Container, gtk.Window):
|
||||||
self.set_colormap(colormap)
|
self.set_colormap(colormap)
|
||||||
|
|
||||||
CONFIG = {'fullscreen':False, 'maximised':False, 'borderless':False, 'enable_real_transparency':True, 'hidden':False}
|
CONFIG = {'fullscreen':False, 'maximised':False, 'borderless':False, 'enable_real_transparency':True, 'hidden':False}
|
||||||
|
|
||||||
WINDOW = Window(CONFIG)
|
WINDOW = Window(CONFIG)
|
||||||
WINDOW.show_all()
|
WINDOW.show_all()
|
||||||
gtk.main()
|
gtk.main()
|
||||||
|
|
Loading…
Reference in New Issue