From 69c8a3f1d94b9d3337645347e83f00b32b2f41f9 Mon Sep 17 00:00:00 2001 From: David Levanon Date: Sun, 20 Sep 2020 21:15:14 +0300 Subject: [PATCH] fix some complicated layouts --- terminatorlib/layoutfile.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/terminatorlib/layoutfile.py b/terminatorlib/layoutfile.py index ff25933b..add0b529 100644 --- a/terminatorlib/layoutfile.py +++ b/terminatorlib/layoutfile.py @@ -14,10 +14,7 @@ class LayoutFile(object): } } - if len(layoutjson) == 1: - self.build_terminal_layout(layoutjson, result, 'root', 0) - else: - self.build_container_layout(layoutjson, result, 'root', 0, vertical) + self.build_container_layout(layoutjson, result, 'root', 0, vertical) return result @@ -41,10 +38,7 @@ class LayoutFile(object): for tab in layoutjson: tabs['labels'].append(tab) - if len(layoutjson[tab]) == 1: - self.build_terminal_layout(layoutjson[tab][0], result, 'tabs', counter) - else: - self.build_container_layout(layoutjson[tab], result, 'tabs', counter, vertical) + self.build_container_layout(layoutjson[tab], result, 'tabs', counter, vertical) counter += 1 return result @@ -60,6 +54,15 @@ class LayoutFile(object): } def build_container_layout(self, layoutjson, children, parent, order, vertical): + if len(layoutjson) == 1: + layoutjson = layoutjson[0] + + if 'children' in layoutjson: + self.build_container_layout(layoutjson['children'], children, parent, order, False if vertical else True) + else: + self.build_terminal_layout(layoutjson, children, parent, order) + return + dbg ('Building %s layout from json: %s' % ("vertical" if vertical else "horizental", layoutjson)) counter = 0 @@ -78,10 +81,7 @@ class LayoutFile(object): actualparent = containername if 'children' in pane: - if len(pane['children']) == 1: - self.build_terminal_layout(pane, pane['children'], containername, counter) - else: - self.build_container_layout(pane['children'], children, containername, counter, False if vertical else True) + self.build_container_layout(pane['children'], children, containername, counter, False if vertical else True) else: self.build_terminal_layout(pane, children, containername, counter)