Slight refactoring of each derived Container's add() to handle all the Terminal signals the same way.
This commit is contained in:
parent
1e348d8573
commit
489bc2cbb6
|
@ -102,10 +102,10 @@ class Notebook(Container, gtk.Notebook):
|
||||||
|
|
||||||
def newtab(self, widget=None):
|
def newtab(self, widget=None):
|
||||||
"""Add a new tab, optionally supplying a child widget"""
|
"""Add a new tab, optionally supplying a child widget"""
|
||||||
|
maker = Factory()
|
||||||
top_window = get_top_window(self)
|
top_window = get_top_window(self)
|
||||||
|
|
||||||
if not widget:
|
if not widget:
|
||||||
maker = Factory()
|
|
||||||
widget = maker.make('Terminal')
|
widget = maker.make('Terminal')
|
||||||
widget.spawn_child()
|
widget.spawn_child()
|
||||||
|
|
||||||
|
@ -113,17 +113,16 @@ class Notebook(Container, gtk.Notebook):
|
||||||
'split-horiz': self.split_horiz,
|
'split-horiz': self.split_horiz,
|
||||||
'split-vert': self.split_vert,
|
'split-vert': self.split_vert,
|
||||||
'title-change': self.propagate_title_change,
|
'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'):
|
if maker.isinstance(widget, 'Terminal'):
|
||||||
for signal in signals:
|
for signal in signals:
|
||||||
self.connect_child(widget, signal, signals[signal])
|
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)
|
self.set_tab_reorderable(widget, True)
|
||||||
label = TabLabel(self.window.get_title(), self)
|
label = TabLabel(self.window.get_title(), self)
|
||||||
|
|
|
@ -84,19 +84,21 @@ class Paned(Container):
|
||||||
'split-vert': self.split_vert,
|
'split-vert': self.split_vert,
|
||||||
'title-change': self.propagate_title_change,
|
'title-change': self.propagate_title_change,
|
||||||
'resize-term': self.resizeterm,
|
'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:
|
for signal in signals:
|
||||||
self.connect_child(widget, signal, signals[signal])
|
args = []
|
||||||
|
handler = signals[signal]
|
||||||
# FIXME: We shouldn't be doing this exact same thing in each
|
if isinstance(handler, list):
|
||||||
# Container
|
args = handler[1:]
|
||||||
self.connect_child(widget, 'maximise', top_window.zoom, False)
|
handler = handler[0]
|
||||||
self.connect_child(widget, 'tab-change', top_window.tab_change)
|
self.connect_child(widget, signal, handler, *args)
|
||||||
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)
|
|
||||||
|
|
||||||
widget.grab_focus()
|
widget.grab_focus()
|
||||||
|
|
||||||
|
|
|
@ -152,10 +152,15 @@ class Window(Container, gtk.Window):
|
||||||
return(False)
|
return(False)
|
||||||
return(True)
|
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):
|
def tab_new(self):
|
||||||
"""Make a new tab"""
|
"""Make a new tab"""
|
||||||
maker = Factory()
|
maker = Factory()
|
||||||
if not maker.isinstance(self.get_child(), 'Notebook'):
|
if not self.is_child_notebook():
|
||||||
notebook = maker.make('Notebook', window=self)
|
notebook = maker.make('Notebook', window=self)
|
||||||
self.get_child().newtab()
|
self.get_child().newtab()
|
||||||
|
|
||||||
|
@ -217,10 +222,12 @@ class Window(Container, gtk.Window):
|
||||||
|
|
||||||
def set_hidden(self, value):
|
def set_hidden(self, value):
|
||||||
"""Set the visibility of the window from the supplied value"""
|
"""Set the visibility of the window from the supplied value"""
|
||||||
|
# FIXME: Implement or drop this
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def set_iconified(self, value):
|
def set_iconified(self, value):
|
||||||
"""Set the minimised state of the window from the value"""
|
"""Set the minimised state of the window from the value"""
|
||||||
|
# FIXME: Implement or drop this
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def set_real_transparency(self, value=True):
|
def set_real_transparency(self, value=True):
|
||||||
|
@ -245,17 +252,16 @@ class Window(Container, gtk.Window):
|
||||||
'title-change': self.title.set_title,
|
'title-change': self.title.set_title,
|
||||||
'split-horiz': self.split_horiz,
|
'split-horiz': self.split_horiz,
|
||||||
'split-vert': self.split_vert,
|
'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:
|
for signal in signals:
|
||||||
self.connect_child(widget, signal, signals[signal])
|
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()
|
widget.grab_focus()
|
||||||
|
|
||||||
def remove(self, widget):
|
def remove(self, widget):
|
||||||
|
|
Loading…
Reference in New Issue