Implement create new from template
Fixes #297
Adapted from Files code.
Some undecided issues:
(1) Should templates automatically enter rename mode (currrently not). I am assuming templates will be named something like "Application.vala" so will not need renaming.
(2) Should templates be automatically opened (currently not). I have kept the same behaviour as new file and folder but selected the new item so it can be easily opened if required.
(3) How to make where to put the template files more discoverable or configurable.
@danirabbit I now notice that there is some quite extensive old code already implementing a "TemplateManager". but it is not clear how this was intended to work and afaict it has never actually worked? It appears to relate to "Project Templates" so maybe similar to the unmerged PR #996? Hopefully this PR does not duplicate existing code.
Now implemented a setting for user specified template folder
On second thoughts, I think we ought to enter renaming mode so the actual desired name can be entered more conveniently. I'll implement this soon.
Turns out there are some recalcitrant timing issues in starting to edit the source list after adding a new item to it. There does not seem to be an elegant way to reliably determine that the sourcelist is in a state where it can be edited (the available signals like child-added arrive too early). In the end, after a lot of experimentation, I have just used fairly long timeouts :disappointed: Hopefully in Gtk4 this will not be necessary.
Now implemented a setting for user specified template folder
I don't think we should have a setting for the template folder, this should be using GLib.Environment.get_user_special_dir (TEMPLATES) and if the user wants to change the template folder it can do by changing the value of the XDG_TEMPLATES_DIR variable.
I don't think we should have a setting for the template folder
The idea is to keep Code specific templates separate (I am not sure why templates for different apps should all be in the same folder tbh). However, I'll bow to majority opinion and revert that.
Need to check whether this is prone to the hanging bug found in Files when the templates folder is very large.