"
1. Besides the original helper, g.app.gui.find_widget_by_name, we'll want g.app.gui.restore_layout. This helper will use the "split direction" setting. It should be straightforward to create this helper."
I'm not so sure it will be straightforward. That's because a given layout might have created new splitters and new widgets to go into them. They will need to be discovered and deleted, which destruction could be object-specific. I'm not saying it can't be done, just that it doesn't seem so straightforward to me.
One possibility could be that layouts will be created using dedicated method calls that would keep a record of new widgets involved with a layout and their locations. I suppose that this record should use weak references so that an object would actually be deleted by a delete operation and not accidentally kept as a zombie because a reference in the layout record didn't get removed.
I think that an undo sequence as the reverse of the creation sequence ought to be practical. For example, the creation of a layout:
1. move log frame from secondary to main splitter;
2. move body editor frame from main to secondary;
3. move log frame from main to secondary;
4. create new splitter in main splitter;
5. create new myPluginWidget;
6. insert myPluginWidget into the new splitter.
Moving from 6 to 1 using the inverse operations ought to undo the new layout:
6. remove myPluginWidget from the new splitter;
5. delete
myPluginWidget;
4. delete the new splitter;
3. move log frame from secondary to main;
2. move body editor frame from secondary to main;
1. move log frame from main to secondary.
I haven't thought too hard about it but I hope all these operations will turn out to be commutative. Otherwise things will be trickier.