Slight refactoring of each derived Container's add() to handle all the Terminal signals the same way.

This commit is contained in:
Chris Jones 2010-01-24 12:55:03 +00:00
parent 1e348d8573
commit 489bc2cbb6
3 changed files with 34 additions and 27 deletions

View File

@ -102,10 +102,10 @@ class Notebook(Container, gtk.Notebook):
def newtab(self, widget=None):
"""Add a new tab, optionally supplying a child widget"""
maker = Factory()
top_window = get_top_window(self)
if not widget:
maker = Factory()
widget = maker.make('Terminal')
widget.spawn_child()
@ -113,17 +113,16 @@ class Notebook(Container, gtk.Notebook):
'split-horiz': self.split_horiz,
'split-vert': self.split_vert,
'title-change': self.propagate_title_change,
'unzoom': self.unzoom}
'unzoom': self.unzoom,
'tab-change': top_window.tab_change,
'group-all': top_window.group_all,
'ungroup-all': top_window.ungroup_all,
'group-tab': top_window.group_tab,
'ungroup-tab': top_window.ungroup_tab}
maker = Factory()
if maker.isinstance(widget, 'Terminal'):
for signal in signals:
self.connect_child(widget, signal, signals[signal])
self.connect_child(widget, 'tab-change', top_window.tab_change)
self.connect_child(widget, 'group-all', top_window.group_all)
self.connect_child(widget, 'ungroup-all', top_window.ungroup_all)
self.connect_child(widget, 'group-tab', top_window.group_tab)
self.connect_child(widget, 'ungroup-tab', top_window.ungroup_tab)
self.set_tab_reorderable(widget, True)
label = TabLabel(self.window.get_title(), self)

View File

@ -84,19 +84,21 @@ class Paned(Container):
'split-vert': self.split_vert,
'title-change': self.propagate_title_change,
'resize-term': self.resizeterm,
'zoom': top_window.zoom}
'zoom': top_window.zoom,
'tab-change': top_window.tab_change,
'group-all': top_window.group_all,
'ungroup-all': top_window.ungroup_all,
'group-tab': top_window.group_tab,
'ungroup-tab': top_window.ungroup_tab,
'maximise': [top_window.zoom, False]}
for signal in signals:
self.connect_child(widget, signal, signals[signal])
# FIXME: We shouldn't be doing this exact same thing in each
# Container
self.connect_child(widget, 'maximise', top_window.zoom, False)
self.connect_child(widget, 'tab-change', top_window.tab_change)
self.connect_child(widget, 'group-all', top_window.group_all)
self.connect_child(widget, 'ungroup-all', top_window.ungroup_all)
self.connect_child(widget, 'group-tab', top_window.group_tab)
self.connect_child(widget, 'ungroup-tab', top_window.ungroup_tab)
args = []
handler = signals[signal]
if isinstance(handler, list):
args = handler[1:]
handler = handler[0]
self.connect_child(widget, signal, handler, *args)
widget.grab_focus()

View File

@ -152,10 +152,15 @@ class Window(Container, gtk.Window):
return(False)
return(True)
def is_child_notebook(self):
"""Returns True if this Window's child is a Notebook"""
maker = Factory()
return(maker.isinstance(self.get_child(), 'Notebook'))
def tab_new(self):
"""Make a new tab"""
maker = Factory()
if not maker.isinstance(self.get_child(), 'Notebook'):
if not self.is_child_notebook():
notebook = maker.make('Notebook', window=self)
self.get_child().newtab()
@ -217,10 +222,12 @@ class Window(Container, gtk.Window):
def set_hidden(self, value):
"""Set the visibility of the window from the supplied value"""
# FIXME: Implement or drop this
pass
def set_iconified(self, value):
"""Set the minimised state of the window from the value"""
# FIXME: Implement or drop this
pass
def set_real_transparency(self, value=True):
@ -245,17 +252,16 @@ class Window(Container, gtk.Window):
'title-change': self.title.set_title,
'split-horiz': self.split_horiz,
'split-vert': self.split_vert,
'unzoom': self.unzoom}
'unzoom': self.unzoom,
'tab-change': self.tab_change,
'group-all': self.group_all,
'ungroup-all': self.ungroup_all,
'group-tab': self.group_tab,
'ungroup-tab': self.ungroup_tab}
for signal in signals:
self.connect_child(widget, signal, signals[signal])
self.connect_child(widget, 'tab-change', self.tab_change)
self.connect_child(widget, 'group-all', self.group_all)
self.connect_child(widget, 'ungroup-all', self.ungroup_all)
self.connect_child(widget, 'group-tab', self.group_tab)
self.connect_child(widget, 'ungroup-tab', self.ungroup_tab)
widget.grab_focus()
def remove(self, widget):