diff --git a/terminatorlib/container.py b/terminatorlib/container.py index f133648f..e8057588 100755 --- a/terminatorlib/container.py +++ b/terminatorlib/container.py @@ -198,7 +198,7 @@ the %s will also close all terminals within it.') % (reqtype, reqtype)) return(terminals) - def describe_layout(self, count, parent, global_layout): + def describe_layout(self, count, parent, global_layout, child_order): """Describe our current layout""" layout = {} maker = Factory() @@ -209,6 +209,7 @@ the %s will also close all terminals within it.') % (reqtype, reqtype)) layout['type'] = mytype layout['parent'] = parent + layout['order'] = child_order if hasattr(self, 'get_position'): position = self.get_position() @@ -224,9 +225,11 @@ the %s will also close all terminals within it.') % (reqtype, reqtype)) global_layout[name] = layout + child_order = 0 for child in self.get_children(): if hasattr(child, 'describe_layout'): - count = child.describe_layout(count, name, global_layout) + count = child.describe_layout(count, name, global_layout, child_order) + child_order = child_order + 1 return(count) diff --git a/terminatorlib/paned.py b/terminatorlib/paned.py index cab3c29b..f2f066cf 100755 --- a/terminatorlib/paned.py +++ b/terminatorlib/paned.py @@ -205,13 +205,29 @@ class Paned(Container): err('incorrect number of children for Paned: %s' % layout) return + keys = [] + + # FIXME: This seems kinda ugly. All we want here is to know the order + # of children based on child['order'] + try: + child_order_map = {} + for child in children: + key = children[child]['order'] + child_order_map[key] = child + map_keys = child_order_map.keys() + map_keys.sort() + for map_key in map_keys: + keys.append(child_order_map[map_key]) + except KeyError: + # We've failed to figure out the order. At least give the terminals + # in the wrong order + keys = children.keys() + num = 0 - keys = children.keys() - keys.sort() for child_key in keys: child = children[child_key] if child['type'] == 'Terminal': - continue + pass elif child['type'] == 'VPaned': if num == 0: terminal = self.get_child1() diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index d21d7bad..689f7823 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -1216,11 +1216,12 @@ for %s (%s)' % (name, urlplugin.__class__.__name__)) if self.config['icon_bell'] == True: self.titlebar.icon_bell() - def describe_layout(self, count, parent, global_layout): + def describe_layout(self, count, parent, global_layout, child_order): """Describe our layout""" layout = {} layout['type'] = 'Terminal' layout['parent'] = parent + layout['order'] = child_order name = 'terminal%d' % count count = count + 1 global_layout[name] = layout diff --git a/terminatorlib/terminator.py b/terminatorlib/terminator.py index 829edd38..047475db 100755 --- a/terminatorlib/terminator.py +++ b/terminatorlib/terminator.py @@ -309,7 +309,7 @@ class Terminator(Borg): count = 0 for window in self.windows: parent = '' - count = window.describe_layout(count, parent, layout) + count = window.describe_layout(count, parent, layout, 0) return(layout)