Merged changes in the trunk up to revision 55357.
[blender.git] / release / scripts / startup / bl_ui / __init__.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software Foundation,
15 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20
21 # note, properties_animviz is a helper module only.
22
23 if "bpy" in locals():
24     from imp import reload as _reload
25     for val in _modules_loaded.values():
26         _reload(val)
27 _modules = (
28     "properties_animviz",
29     "properties_constraint",
30     "properties_data_armature",
31     "properties_data_bone",
32     "properties_data_camera",
33     "properties_data_curve",
34     "properties_data_empty",
35     "properties_data_lamp",
36     "properties_data_lattice",
37     "properties_data_mesh",
38     "properties_data_metaball",
39     "properties_data_modifier",
40     "properties_data_speaker",
41     "properties_game",
42     "properties_mask_common",
43     "properties_material",
44     "properties_object",
45     "properties_particle",
46     "properties_physics_cloth",
47     "properties_physics_common",
48     "properties_physics_dynamicpaint",
49     "properties_physics_field",
50     "properties_physics_fluid",
51     "properties_physics_rigidbody",
52     "properties_physics_rigidbody_constraint",
53     "properties_physics_smoke",
54     "properties_physics_softbody",
55     "properties_render",
56     "properties_render_layer",
57     "properties_scene",
58     "properties_texture",
59     "properties_world",
60     "space_clip",
61     "space_console",
62     "space_dopesheet",
63     "space_filebrowser",
64     "space_graph",
65     "space_image",
66     "space_info",
67     "space_logic",
68     "space_nla",
69     "space_node",
70     "space_outliner",
71     "space_sequencer",
72     "space_text",
73     "space_time",
74     "space_userpref_keymap",
75     "space_userpref",
76     "space_view3d",
77     "space_view3d_toolbar",
78 )
79 __import__(name=__name__, fromlist=_modules)
80 _namespace = globals()
81 _modules_loaded = {name: _namespace[name] for name in _modules}
82 del _namespace
83
84
85 import bpy
86
87
88 def register():
89     bpy.utils.register_module(__name__)
90
91     # space_userprefs.py
92     from bpy.props import StringProperty, EnumProperty
93     from bpy.types import WindowManager
94
95     def addon_filter_items(self, context):
96         import addon_utils
97
98         items = [('All', "All", "All Addons"),
99                  ('User', "User", "All Addons Installed by User"),
100                  ('Enabled', "Enabled", "All Enabled Addons"),
101                  ('Disabled', "Disabled", "All Disabled Addons"),
102                  ]
103
104         items_unique = set()
105
106         for mod in addon_utils.modules(addon_utils.addons_fake_modules):
107             info = addon_utils.module_bl_info(mod)
108             items_unique.add(info["category"])
109
110         items.extend([(cat, cat, "") for cat in sorted(items_unique)])
111         return items
112
113     WindowManager.addon_search = StringProperty(
114             name="Search",
115             description="Search within the selected filter",
116             )
117     WindowManager.addon_filter = EnumProperty(
118             items=addon_filter_items,
119             name="Category",
120             description="Filter addons by category",
121             )
122
123     WindowManager.addon_support = EnumProperty(
124             items=[('OFFICIAL', "Official", "Officially supported"),
125                    ('COMMUNITY', "Community", "Maintained by community developers"),
126                    ('TESTING', "Testing", "Newly contributed scripts (excluded from release builds)")
127                    ],
128             name="Support",
129             description="Display support level",
130             default={'OFFICIAL', 'COMMUNITY'},
131             options={'ENUM_FLAG'},
132             )
133     # done...
134
135
136 def unregister():
137     bpy.utils.unregister_module(__name__)
138
139
140 # Define a default UIList, when a list does not need any custom drawing...
141 # Keep in sync with its #defined name in UI_interface.h
142 class UI_UL_list(bpy.types.UIList):
143     pass
144
145 bpy.utils.register_class(UI_UL_list)