Merging r39717 through r39983 from trunk into soc-2011-tomato
[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_data_armature",
30     "properties_data_bone",
31     "properties_data_camera",
32     "properties_data_curve",
33     "properties_data_empty",
34     "properties_data_lamp",
35     "properties_data_lattice",
36     "properties_data_mesh",
37     "properties_data_metaball",
38     "properties_data_modifier",
39     "properties_data_speaker",
40     "properties_game",
41     "properties_material",
42     "properties_object_constraint",
43     "properties_object",
44     "properties_particle",
45     "properties_physics_cloth",
46     "properties_physics_common",
47     "properties_physics_field",
48     "properties_physics_fluid",
49     "properties_physics_smoke",
50     "properties_physics_softbody",
51     "properties_render",
52     "properties_scene",
53     "properties_texture",
54     "properties_world",
55     "space_clip",
56     "space_console",
57     "space_dopesheet",
58     "space_filebrowser",
59     "space_graph",
60     "space_image",
61     "space_info",
62     "space_logic",
63     "space_nla",
64     "space_node",
65     "space_outliner",
66     "space_sequencer",
67     "space_text",
68     "space_time",
69     "space_userpref_keymap",
70     "space_userpref",
71     "space_view3d",
72     "space_view3d_toolbar",
73 )
74 __import__(name=__name__, fromlist=_modules)
75 _namespace = globals()
76 _modules_loaded = {name: _namespace[name] for name in _modules}
77 del _namespace
78
79
80 import bpy
81
82
83 def register():
84     bpy.utils.register_module(__name__)
85
86     # space_userprefs.py
87     from bpy.props import StringProperty, EnumProperty
88     WindowManager = bpy.types.WindowManager
89
90     def addon_filter_items(self, context):
91         import addon_utils
92
93         items = [('All', "All", ""),
94                  ('Enabled', "Enabled", ""),
95                  ('Disabled', "Disabled", ""),
96                 ]
97
98         items_unique = set()
99
100         for mod in addon_utils.modules(space_userpref.USERPREF_PT_addons._addons_fake_modules):
101             info = addon_utils.module_bl_info(mod)
102             items_unique.add(info["category"])
103
104         items.extend([(cat, cat, "") for cat in sorted(items_unique)])
105         return items
106
107     WindowManager.addon_search = StringProperty(
108             name="Search",
109             description="Search within the selected filter",
110             )
111     WindowManager.addon_filter = EnumProperty(
112             items=addon_filter_items,
113             name="Category",
114             description="Filter add-ons by category",
115             )
116
117     WindowManager.addon_support = EnumProperty(
118             items=[('OFFICIAL', "Official", ""),
119                    ('COMMUNITY', 'Community', ""),
120                   ],
121             name="Support",
122             description="Display support level", default={'OFFICIAL', 'COMMUNITY'}, options={'ENUM_FLAG'})
123     # done...
124
125
126 def unregister():
127     bpy.utils.unregister_module(__name__)