'Setup window layout'

def setup_layout(self, default=False):

    prefix = ('window' + '/')
    settings = self.load_window_settings(prefix, default)
    hexstate = settings[0]
    self.first_spyder_run = False
    if (hexstate is None):
        self.setWindowState(Qt.WindowMaximized)
        self.first_spyder_run = True
        self.setup_default_layouts('default', settings)
        section = 'quick_layouts'
        get_func = (CONF.get_default if default else CONF.get)
        order = get_func(section, 'order')
        if default:
            CONF.set(section, 'active', order)
            CONF.set(section, 'order', order)
            CONF.set(section, 'names', order)
        for (index, name) in enumerate(order):
            prefix = 'layout_{0}/'.format(index)
            self.save_current_window_settings(prefix, section)
            CONF.set(section, (prefix + 'state'), None)
        prefix = 'layout_default/'
        section = 'quick_layouts'
        self.save_current_window_settings(prefix, section)
        self.current_quick_layout = 'default'
        CONF.set(section, (prefix + 'state'), None)
        self.quick_layout_set_menu()
    self.set_window_settings(*settings)
    for plugin in self.widgetlist:
        try:
            plugin.initialize_plugin_in_mainwindow_layout()
        except Exception as error:
            print(('%s:    %s' % (plugin, str(error))), file=STDERR)
            traceback.print_exc(file=STDERR)
