(self, debugtab=False, widget=None, cwd=None, metadata=None, profile=None)
Add a new tab, optionally supplying a child widget
Add a new tab, optionally supplying a child widget
Add a new tab optionally supplying a child widget
def newtab(self, debugtab=False, widget=None, cwd=None, metadata=None, profile=None):
        """Add a new tab, optionally supplying a child widget"""
        dbg('making a new tab')
        maker = Factory()
        top_window = self.get_toplevel()

        if not widget:
            widget = maker.make('Terminal')
            if cwd:
                widget.set_cwd(cwd)
            if profile and self.config['always_split_with_profile']:
                widget.force_set_profile(None, profile)
            widget.spawn_child(debugserver=debugtab)
        elif profile and self.config['always_split_with_profile']:
            widget.force_set_profile(None, profile)

        signals = {'close-term': self.wrapcloseterm,
                   'split-horiz': self.split_horiz,
                   'split-vert': self.split_vert,
                   'title-change': self.propagate_title_change,
                   'tab-change': top_window.tab_change,
                   'group-all': top_window.group_all,
                   'group-all-toggle': top_window.group_all_toggle,
                   'ungroup-all': top_window.ungroup_all,
                   'group-win': top_window.group_win,
                   'group-win-toggle': top_window.group_win_toggle,
                   'ungroup-win': top_window.ungroup_win,
                   'group-tab': top_window.group_tab,
                   'group-tab-toggle': top_window.group_tab_toggle,
                   'ungroup-tab': top_window.ungroup_tab,
                   'move-tab': top_window.move_tab,
                   'tab-new': [top_window.tab_new, widget],
                   'navigate': top_window.navigate_terminal}

        if maker.isinstance(widget, 'Terminal'):
            for signal in signals:
                args = []
                handler = signals[signal]
                if isinstance(handler, list):
                    args = handler[1:]
                    handler = handler[0]
                self.connect_child(widget, signal, handler, *args)

        if metadata and 'tabnum' in metadata:
            tabpos = metadata['tabnum']
        else:
            tabpos = -1

        label = TabLabel(self.window.get_title(), self)
        if metadata and 'label' in metadata:
            dbg('creating TabLabel with text: %s' % metadata['label'])
            label.set_custom_label(metadata['label'])
        label.connect('close-clicked', self.closetab)

        label.show_all()
        widget.show_all()

        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])
        else:
            containers, objects = enumerate_descendants(widget)

        term_widget = None
        for term_widget in objects:
            if maker.isinstance(term_widget, 'Terminal'):
                self.set_last_active_term(term_widget.uuid)
                break

        self.set_tab_label(widget, label)
        self.child_set_property(widget, 'tab-expand', True)
        self.child_set_property(widget, 'tab-fill', True)

        self.set_tab_reorderable(widget, True)
        self.set_current_page(tabpos)
        self.show_all()
        if maker.isinstance(term_widget, 'Terminal'):
            widget.grab_focus()
def newtab ( self , debugtab = False , widget = None , cwd = None , metadata = None , profile = None ) : dbg ( 'making a new tab' ) maker = Factory ( ) top_window = self . get_toplevel ( ) if not widget : widget = maker . make ( 'Terminal' ) if cwd : widget . set_cwd ( cwd ) if profile and self . config [ 'always_split_with_profile' ] : widget . force_set_profile ( None , profile ) widget . spawn_child ( debugserver = debugtab ) elif profile and self . config [ 'always_split_with_profile' ] : widget . force_set_profile ( None , profile ) signals = { 'close-term' : self . wrapcloseterm , 'split-horiz' : self . split_horiz , 'split-vert' : self . split_vert , 'title-change' : self . propagate_title_change , 'tab-change' : top_window . tab_change , 'group-all' : top_window . group_all , 'group-all-toggle' : top_window . group_all_toggle , 'ungroup-all' : top_window . ungroup_all , 'group-win' : top_window . group_win , 'group-win-toggle' : top_window . group_win_toggle , 'ungroup-win' : top_window . ungroup_win , 'group-tab' : top_window . group_tab , 'group-tab-toggle' : top_window . group_tab_toggle , 'ungroup-tab' : top_window . ungroup_tab , 'move-tab' : top_window . move_tab , 'tab-new' : [ top_window . tab_new , widget ] , 'navigate' : top_window . navigate_terminal } if maker . isinstance ( widget , 'Terminal' ) : for signal in signals : args = [ ] handler = signals [ signal ] if isinstance ( handler , list ) : args = handler [ 1 : ] handler = handler [ 0 ] self . connect_child ( widget , signal , handler , * args ) if metadata and 'tabnum' in metadata : tabpos = metadata [ 'tabnum' ] else : tabpos = - 1 label = TabLabel ( self . window . get_title ( ) , self ) if metadata and 'label' in metadata : dbg ( 'creating TabLabel with text: %s' % metadata [ 'label' ] ) label . set_custom_label ( metadata [ 'label' ] ) label . connect ( 'close-clicked' , self . closetab ) label . show_all ( ) widget . show_all ( ) 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 ] ) else : containers , objects = enumerate_descendants ( widget ) term_widget = None for term_widget in objects : if maker . isinstance ( term_widget , 'Terminal' ) : self . set_last_active_term ( term_widget . uuid ) break self . set_tab_label ( widget , label ) self . child_set_property ( widget , 'tab-expand' , True ) self . child_set_property ( widget , 'tab-fill' , True ) self . set_tab_reorderable ( widget , True ) self . set_current_page ( tabpos ) self . show_all ( ) if maker . isinstance ( term_widget , 'Terminal' ) : widget . grab_focus ( )