Page MenuHome

Application Templates Pach

Authored by Campbell Barton (campbellbarton) on Mar 17 2017, 9:24 PM.



This patch adds use of 'app_templates', the initial work of implementing T50901.

Changes on master are quite minimal since changes which can be applied to master have been.

The patch is WIP, this is for on-going review.


  • Template menu is only visible when templates are available.
  • Templates are stored in scripts/startup/bl_app_templates_system or scripts/startup/bl_app_templates_system (we may want to move them into their own repo).
  • Each template can have startup.blend and userprefs.blend which are used as factory settings.
  • When a template is active it's startup is saved as {template_id}/startup.blend, {template_id}/userpref.blend.
  • Templates are one python package, which each template is a sub-package (avoids namespace collissions).
  • Method of opening a startup file is to run wm_homefile_read with a template string which is used and written into the preferences when set.

Open topics:

  • None

Diff Detail

rB Blender
Build Status
Buildable 495
Build 495: arc lint + arc unit

Event Timeline

Campbell Barton (campbellbarton) edited the summary of this revision. (Show Details)

Bring the template file storage and API close to completion

Support 'factory settings' as well as user startup for templates.

  • Use shorter label
  • menu in class list
  • Add template to file menu
  • Fix leak freeing addons
  • Add support for a template addons directory
  • Addon support enable/disable now works
  • Disable template before addons
  • Use blank string for default template
  • Add filtering for UI elements
  • Pass in filters as functions instead of sets
  • Remove most panels again
  • Fix for preset menus
  • Correct missing text argument for label
  • Add menu filtering
  • Remove underscore blecklist/whitelist
  • Add back basic panels for 101 making it more usable
  • Fix for new-file removing template
  • Hide most panels in the NKey 3d view region
  • Split out override class into its own base class
  • Move AppOverrideState into a helpers submodule
  • Include classes to filter as a callback
  • Missed adding this previous commit
  • Cleanup: style
  • Use BLI_path_name_at_index
  • Support both factory and user startup for templates
  • Minor changes, remove force_load_startup
  • UI: be more specific about splash sizes
  • Minor sync with master
  • Hide templates from the UI when none are found
  • Fix for showing error when no template paths exist
  • Simplify path calculation

Use single patch package for storing app-templates

Don't attempt template loading when they're not present

From quick review see nothing wrong here, and rather like how things get done. :)

Besides minor points noted below, unless I missed it, it seems there is no template option in UserPref themselves, is this intended? I’d expect to be able to select template from there (especially since it’s saved as userpref)?


Probably also want to add bpy.types.UIList here?


Type, Then call call ;)


and UIList maybe too?


Shouldn’t those be defined in BLI_path_util.h, where we already define their char versions? Could be useful in other places…

This revision is now accepted and ready to land.Mar 23 2017, 12:25 PM

Main change is templates now have their own user-preferences
in the config dir and templates now save their config (startup and prefs) in their own directory.

  • Cleanup, also move SEP_STR into the header
  • Make BKE_appdir_app_template_id_search take a path arg
  • Fix BKE_appdir_app_template_id_search and splash loading
  • Minor cleanup
  • Cleanup: cruft
  • Cleanup
  • Change path resolution order to match script resolution order
  • Use BKE_appdir_folder_id_ex
  • Use keymap from template prefs
  • Add support for saving user-local app-template preferences
  • Minor rename
  • Don't raise error when there is a missing file
  • Use much more specific checks for template directories
  • remove prints


Besides minor points noted below, unless I missed it, it seems there is no template option in UserPref themselves, is this intended? I’d expect to be able to select template from there (especially since it’s saved as userpref)?

Makes sense, it just doesn't really fit well anywhere in the user preferences.
I suppose it could be added to the "Interface" section? (very trivial to add this)

For now it can be accessed from the splash screen and file menu.


Corrected, although I've since removed this text. I'd rather have some more extensive docs and examples for using this class elsewhere.


Well spotted, I think in practice you would be most likely to remove a panel that contains a UI list that doesn't apply.

The chance you want to remove a single button that shows within a UI-element is quite low.

In general I'm not against doing this, the use-case just seems quite obscure.

  • Rename menu item
  • Remove bl_app_templates_system/
  • Minor comment update
  • Add install operator for templates
  • Merge branch 'master' into app-templates

Committed to master rBf68145011fd46d0e22145363e5b5d9a704a912df

There are a few loose ends (such as UIList and showing in preferences), these can be handled as part of regular development.