Merge pull request #494 from Vulcalien/detachable_tabs

Make tabs detachable + minor bugfix
This commit is contained in:
Matt Rose 2021-08-29 18:32:05 -04:00 committed by GitHub
commit a7fcf27b11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View File

@ -37,6 +37,7 @@ class Notebook(Container, Gtk.Notebook):
self.register_signals(Notebook) self.register_signals(Notebook)
self.connect('switch-page', self.deferred_on_tab_switch) self.connect('switch-page', self.deferred_on_tab_switch)
self.connect('scroll-event', self.on_scroll_event) self.connect('scroll-event', self.on_scroll_event)
self.connect('create-window', self.create_window_detach)
self.configure() self.configure()
self.set_can_focus(False) self.set_can_focus(False)
@ -77,6 +78,23 @@ class Notebook(Container, Gtk.Notebook):
# self.modify_style(style) # self.modify_style(style)
self.last_active_term = {} 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): def create_layout(self, layout):
"""Apply layout configuration""" """Apply layout configuration"""
def child_compare(a, b): def child_compare(a, b):
@ -173,6 +191,7 @@ class Notebook(Container, Gtk.Notebook):
sibling.force_set_profile(None, widget.get_profile()) sibling.force_set_profile(None, widget.get_profile())
self.insert_page(container, None, page_num) 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-expand', True)
self.child_set_property(container, 'tab-fill', True) self.child_set_property(container, 'tab-fill', True)
self.set_tab_reorderable(container, True) self.set_tab_reorderable(container, True)
@ -299,6 +318,7 @@ class Notebook(Container, Gtk.Notebook):
dbg('inserting page at position: %s' % tabpos) dbg('inserting page at position: %s' % tabpos)
self.insert_page(widget, None, tabpos) self.insert_page(widget, None, tabpos)
self.set_tab_detachable(widget, True)
if maker.isinstance(widget, 'Terminal'): if maker.isinstance(widget, 'Terminal'):
containers, objects = ([], [widget]) containers, objects = ([], [widget])

View File

@ -299,7 +299,7 @@ class Window(Container, Gtk.Window):
def on_destroy_event(self, widget, data=None): def on_destroy_event(self, widget, data=None):
"""Handle window destruction""" """Handle window destruction"""
dbg('destroying self') dbg('destroying self')
for terminal in self.get_visible_terminals(): for terminal in self.get_terminals():
terminal.close() terminal.close()
self.cnxids.remove_all() self.cnxids.remove_all()
self.terminator.deregister_window(self) self.terminator.deregister_window(self)