(self, widget, metadata=None)
Add a widget to the container
Add a widget to the container
Add a widget to the container
def add(self, widget, metadata=None):
        """Add a widget to the container"""
        if len(self.children) == 0:
            self.pack1(widget, False, True)
            self.children.append(widget)
        elif len(self.children) == 1:
            if self.get_child1():
                self.pack2(widget, False, True)
            else:
                self.pack1(widget, False, True)
            self.children.append(widget)
        else:
            raise ValueError('Paned widgets can only have two children')

        if self.maker.isinstance(widget, 'Terminal'):
            top_window = self.get_toplevel()
            signals = {'close-term': self.wrapcloseterm,
                    'split-horiz': self.split_horiz,
                    'split-vert': self.split_vert,
                    'title-change': self.propagate_title_change,
                    'resize-term': self.resizeterm,
                    'size-allocate': self.new_size,
                    'zoom': top_window.zoom,
                    '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,
                    'maximise': [top_window.zoom, False],
                    'tab-new': [top_window.tab_new, widget],
                    'navigate': top_window.navigate_terminal,
                    'rotate-cw': [top_window.rotate, True],
                    'rotate-ccw': [top_window.rotate, False]}

            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 \
               'had_focus' in metadata and \
               metadata['had_focus'] == True:
                    widget.grab_focus()

        elif isinstance(widget, Gtk.Paned):
            try:
                self.connect_child(widget, 'resize-term', self.resizeterm)
                self.connect_child(widget, 'size-allocate', self.new_size)
            except TypeError:
                err('Paned::add: %s has no signal resize-term' % widget)
def add ( self , widget , metadata = None ) : if len ( self . children ) == 0 : self . pack1 ( widget , False , True ) self . children . append ( widget ) elif len ( self . children ) == 1 : if self . get_child1 ( ) : self . pack2 ( widget , False , True ) else : self . pack1 ( widget , False , True ) self . children . append ( widget ) else : raise ValueError ( 'Paned widgets can only have two children' ) if self . maker . isinstance ( widget , 'Terminal' ) : top_window = self . get_toplevel ( ) signals = { 'close-term' : self . wrapcloseterm , 'split-horiz' : self . split_horiz , 'split-vert' : self . split_vert , 'title-change' : self . propagate_title_change , 'resize-term' : self . resizeterm , 'size-allocate' : self . new_size , 'zoom' : top_window . zoom , '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 , 'maximise' : [ top_window . zoom , False ] , 'tab-new' : [ top_window . tab_new , widget ] , 'navigate' : top_window . navigate_terminal , 'rotate-cw' : [ top_window . rotate , True ] , 'rotate-ccw' : [ top_window . rotate , False ] } 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 'had_focus' in metadata and metadata [ 'had_focus' ] == True : widget . grab_focus ( ) elif isinstance ( widget , Gtk . Paned ) : try : self . connect_child ( widget , 'resize-term' , self . resizeterm ) self . connect_child ( widget , 'size-allocate' , self . new_size ) except TypeError : err ( 'Paned::add: %s has no signal resize-term' % widget )