(self, layout)
Apply layout configuration
Apply layout configuration
Apply layout configuration
def create_layout(self, layout):
        """Apply layout configuration"""
        def child_compare(a, b):
            order_a = int(children[a]['order'])
            order_b = int(children[b]['order'])

            if (order_a == order_b):
                return 0
            if (order_a < order_b):
                return -1
            if (order_a > order_b):
                return 1

        if 'children' not in layout:
            err('layout specifies no children: %s' % layout)
            return

        children = layout['children']
        if len(children) <= 1:
            #Notebooks should have two or more children
            err('incorrect number of children for Notebook: %s' % layout)
            return

        num = 0
        keys = list(children.keys())
        keys = sorted(keys, key=cmp_to_key(child_compare))

        for child_key in keys:
            child = children[child_key]
            dbg('Making a child of type: %s' % child['type'])
            if child['type'] == 'Terminal':
                pass
            elif child['type'] == 'VPaned':
                page = self.get_nth_page(num)
                self.split_axis(page, True)
            elif child['type'] == 'HPaned':
                page = self.get_nth_page(num)
                self.split_axis(page, False)
            num = num + 1

        num = 0
        for child_key in keys:
            page = self.get_nth_page(num)
            if not page:
                # This page does not yet exist, so make it
                self.newtab(children[child_key])
                page = self.get_nth_page(num)
            if 'labels' in layout:
                labeltext = layout['labels'][num]
                if labeltext and labeltext != "None":
                    label = self.get_tab_label(page)
                    label.set_custom_label(labeltext)
            page.create_layout(children[child_key])

            if  layout.get('last_active_term',  None):
                self.last_active_term[page] = make_uuid(layout['last_active_term'][num])
            num = num + 1

        if 'active_page' in layout:
            # Need to do it later, or layout changes result
            GObject.idle_add(self.set_current_page, int(layout['active_page']))
        else:
            self.set_current_page(0)
def create_layout ( self , layout ) : def child_compare ( a , b ) : order_a = int ( children [ a ] [ 'order' ] ) order_b = int ( children [ b ] [ 'order' ] ) if ( order_a == order_b ) : return 0 if ( order_a < order_b ) : return - 1 if ( order_a > order_b ) : return 1 if 'children' not in layout : err ( 'layout specifies no children: %s' % layout ) return children = layout [ 'children' ] if len ( children ) <= 1 : #Notebooks should have two or more children err ( 'incorrect number of children for Notebook: %s' % layout ) return num = 0 keys = list ( children . keys ( ) ) keys = sorted ( keys , key = cmp_to_key ( child_compare ) ) for child_key in keys : child = children [ child_key ] dbg ( 'Making a child of type: %s' % child [ 'type' ] ) if child [ 'type' ] == 'Terminal' : pass elif child [ 'type' ] == 'VPaned' : page = self . get_nth_page ( num ) self . split_axis ( page , True ) elif child [ 'type' ] == 'HPaned' : page = self . get_nth_page ( num ) self . split_axis ( page , False ) num = num + 1 num = 0 for child_key in keys : page = self . get_nth_page ( num ) if not page : # This page does not yet exist, so make it self . newtab ( children [ child_key ] ) page = self . get_nth_page ( num ) if 'labels' in layout : labeltext = layout [ 'labels' ] [ num ] if labeltext and labeltext != "None" : label = self . get_tab_label ( page ) label . set_custom_label ( labeltext ) page . create_layout ( children [ child_key ] ) if layout . get ( 'last_active_term' , None ) : self . last_active_term [ page ] = make_uuid ( layout [ 'last_active_term' ] [ num ] ) num = num + 1 if 'active_page' in layout : # Need to do it later, or layout changes result GObject . idle_add ( self . set_current_page , int ( layout [ 'active_page' ] ) ) else : self . set_current_page ( 0 )