(self, widget, label)
Close a tab
Close a tab
Close a tab
def closetab(self, widget, label):
        """Close a tab"""
        tabnum = None
        try:
            nb = widget.notebook
        except AttributeError:
            err('TabLabel::closetab: called on non-Notebook: %s' % widget)
            return

        for i in range(0, nb.get_n_pages() + 1):
            if label == nb.get_tab_label(nb.get_nth_page(i)):
                tabnum = i
                break

        if tabnum is None:
            err('TabLabel::closetab: %s not in %s. Bailing.' % (label, nb))
            return

        maker = Factory()
        child = nb.get_nth_page(tabnum)

        if maker.isinstance(child, 'Terminal'):
            dbg('Notebook::closetab: child is a single Terminal')
            del nb.last_active_term[child]
            child.close()
            # FIXME: We only do this del and return here to avoid removing the
            # page below, which child.close() implicitly does
            del(label)
            return
        elif maker.isinstance(child, 'Container'):
            dbg('Notebook::closetab: child is a Container')
            result = self.construct_confirm_close(self.window, _('tab'))

            if result == Gtk.ResponseType.ACCEPT:
                containers = None
                objects = None
                containers, objects = enumerate_descendants(child)

                while len(objects) > 0:
                    descendant = objects.pop()
                    descendant.close()
                    while Gtk.events_pending():
                        Gtk.main_iteration()
                return
            else:
                dbg('Notebook::closetab: user cancelled request')
                return
        else:
            err('Notebook::closetab: child is unknown type %s' % child)
            return
def closetab ( self , widget , label ) : tabnum = None try : nb = widget . notebook except AttributeError : err ( 'TabLabel::closetab: called on non-Notebook: %s' % widget ) return for i in range ( 0 , nb . get_n_pages ( ) + 1 ) : if label == nb . get_tab_label ( nb . get_nth_page ( i ) ) : tabnum = i break if tabnum is None : err ( 'TabLabel::closetab: %s not in %s. Bailing.' % ( label , nb ) ) return maker = Factory ( ) child = nb . get_nth_page ( tabnum ) if maker . isinstance ( child , 'Terminal' ) : dbg ( 'Notebook::closetab: child is a single Terminal' ) del nb . last_active_term [ child ] child . close ( ) # FIXME: We only do this del and return here to avoid removing the # page below, which child.close() implicitly does del ( label ) return elif maker . isinstance ( child , 'Container' ) : dbg ( 'Notebook::closetab: child is a Container' ) result = self . construct_confirm_close ( self . window , _ ( 'tab' ) ) if result == Gtk . ResponseType . ACCEPT : containers = None objects = None containers , objects = enumerate_descendants ( child ) while len ( objects ) > 0 : descendant = objects . pop ( ) descendant . close ( ) while Gtk . events_pending ( ) : Gtk . main_iteration ( ) return else : dbg ( 'Notebook::closetab: user cancelled request' ) return else : err ( 'Notebook::closetab: child is unknown type %s' % child ) return