From 3df46d1d8563fd1745fbe3e2db59216d4cb81d79 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Sun, 9 Aug 2009 22:00:43 +0100 Subject: [PATCH] attempt to dodge gobject's inability to do multiple inheritance --- terminatorlib/container.py | 29 ++++++++++++++++++++++++++--- terminatorlib/window.py | 3 +++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/terminatorlib/container.py b/terminatorlib/container.py index 3229704c..d8343ba9 100644 --- a/terminatorlib/container.py +++ b/terminatorlib/container.py @@ -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): diff --git a/terminatorlib/window.py b/terminatorlib/window.py index 1ab30c5b..2ed65f89 100644 --- a/terminatorlib/window.py +++ b/terminatorlib/window.py @@ -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()