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
|
||||
"""container.py - classes necessary to contain Terminal widgets"""
|
||||
|
||||
import gobject
|
||||
import gtk
|
||||
|
||||
from util import debug, err
|
||||
|
||||
class Container:
|
||||
class Container():
|
||||
"""Base class for Terminator Containers"""
|
||||
|
||||
immutable = None
|
||||
@ -17,11 +20,27 @@ class Container:
|
||||
'zoomed' : 1,
|
||||
'maximised' : 2 }
|
||||
|
||||
signals = [ {'name': 'group-hoover-needed',
|
||||
'flags': gobject.SIGNAL_RUN_LAST,
|
||||
'return_type': gobject.TYPE_BOOLEAN,
|
||||
'param_types': ()
|
||||
}
|
||||
]
|
||||
|
||||
def __init__(self, configobject):
|
||||
"""Class initialiser"""
|
||||
self.children = []
|
||||
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):
|
||||
"""Return a list of child widgets, if any"""
|
||||
return(self.children)
|
||||
@ -44,6 +63,10 @@ class Container:
|
||||
err('unsplit called from base class. This is a bug')
|
||||
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):
|
||||
"""Handle the closure of a terminal"""
|
||||
if self.state_zoomed != self.states_zoom['normal']:
|
||||
@ -52,7 +75,7 @@ class Container:
|
||||
if not self.remove(widget):
|
||||
return(False)
|
||||
|
||||
self.group_hoover()
|
||||
self.emit('need_group_hoover')
|
||||
return(True)
|
||||
|
||||
def closegroupterms(self, widget):
|
||||
@ -65,7 +88,7 @@ class Container:
|
||||
if term._group == widget._group and not self.remove(term):
|
||||
all_closed = False
|
||||
|
||||
self.group_hoover()
|
||||
self.emit('need_group_hoover')
|
||||
return(all_closed)
|
||||
|
||||
def resizeterm(self, widget, keyname):
|
||||
|
@ -31,6 +31,8 @@ class Window(Container, gtk.Window):
|
||||
"""Class initialiser"""
|
||||
Container.__init__(self, configobject)
|
||||
gtk.Window.__init__(self)
|
||||
gobject.type_register(Window)
|
||||
self.register_signals(Window)
|
||||
|
||||
self.set_property('allow-shrink', True)
|
||||
self.register_callbacks()
|
||||
@ -112,6 +114,7 @@ class Window(Container, gtk.Window):
|
||||
self.set_colormap(colormap)
|
||||
|
||||
CONFIG = {'fullscreen':False, 'maximised':False, 'borderless':False, 'enable_real_transparency':True, 'hidden':False}
|
||||
|
||||
WINDOW = Window(CONFIG)
|
||||
WINDOW.show_all()
|
||||
gtk.main()
|
||||
|
Loading…
Reference in New Issue
Block a user