Merge pull request #494 from Vulcalien/detachable_tabs
Make tabs detachable + minor bugfix
This commit is contained in:
commit
a7fcf27b11
|
@ -37,6 +37,7 @@ class Notebook(Container, Gtk.Notebook):
|
|||
self.register_signals(Notebook)
|
||||
self.connect('switch-page', self.deferred_on_tab_switch)
|
||||
self.connect('scroll-event', self.on_scroll_event)
|
||||
self.connect('create-window', self.create_window_detach)
|
||||
self.configure()
|
||||
|
||||
self.set_can_focus(False)
|
||||
|
@ -77,6 +78,23 @@ class Notebook(Container, Gtk.Notebook):
|
|||
# self.modify_style(style)
|
||||
self.last_active_term = {}
|
||||
|
||||
def create_window_detach(self, notebook, widget, x, y):
|
||||
"""Create a window to contain a detached tab"""
|
||||
dbg('creating window for detached tab: %s' % widget)
|
||||
maker = Factory()
|
||||
|
||||
window = maker.make('Window')
|
||||
window.move(x, y)
|
||||
size = self.window.get_size()
|
||||
window.resize(size.width, size.height)
|
||||
|
||||
self.detach_tab(widget)
|
||||
self.disconnect_child(widget)
|
||||
self.hoover()
|
||||
window.add(widget)
|
||||
|
||||
window.show_all()
|
||||
|
||||
def create_layout(self, layout):
|
||||
"""Apply layout configuration"""
|
||||
def child_compare(a, b):
|
||||
|
@ -173,6 +191,7 @@ class Notebook(Container, Gtk.Notebook):
|
|||
sibling.force_set_profile(None, widget.get_profile())
|
||||
|
||||
self.insert_page(container, None, page_num)
|
||||
self.set_tab_detachable(container, True)
|
||||
self.child_set_property(container, 'tab-expand', True)
|
||||
self.child_set_property(container, 'tab-fill', True)
|
||||
self.set_tab_reorderable(container, True)
|
||||
|
@ -299,6 +318,7 @@ class Notebook(Container, Gtk.Notebook):
|
|||
|
||||
dbg('inserting page at position: %s' % tabpos)
|
||||
self.insert_page(widget, None, tabpos)
|
||||
self.set_tab_detachable(widget, True)
|
||||
|
||||
if maker.isinstance(widget, 'Terminal'):
|
||||
containers, objects = ([], [widget])
|
||||
|
|
|
@ -299,7 +299,7 @@ class Window(Container, Gtk.Window):
|
|||
def on_destroy_event(self, widget, data=None):
|
||||
"""Handle window destruction"""
|
||||
dbg('destroying self')
|
||||
for terminal in self.get_visible_terminals():
|
||||
for terminal in self.get_terminals():
|
||||
terminal.close()
|
||||
self.cnxids.remove_all()
|
||||
self.terminator.deregister_window(self)
|
||||
|
|
Loading…
Reference in New Issue