Fix [#34005] blender will close immediately in debug mode on deleting objects
[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_mask_common",
42     "properties_material",
43     "properties_object_constraint",
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_scene",
57     "properties_texture",
58     "properties_world",
59     "space_clip",
60     "space_console",
61     "space_dopesheet",
62     "space_filebrowser",
63     "space_graph",
64     "space_image",
65     "space_info",
66     "space_logic",
67     "space_nla",
68     "space_node",
69     "space_outliner",
70     "space_sequencer",
71     "space_text",
72     "space_time",
73     "space_userpref_keymap",
74     "space_userpref",
75     "space_view3d",
76     "space_view3d_toolbar",
77 )
78 __import__(name=__name__, fromlist=_modules)
79 _namespace = globals()
80 _modules_loaded = {name: _namespace[name] for name in _modules}
81 del _namespace
82
83
84 import bpy
85
86
87 def register():
88     bpy.utils.register_module(__name__)
89
90     # space_userprefs.py
91     from bpy.props import StringProperty, EnumProperty
92     from bpy.types import WindowManager
93
94     def addon_filter_items(self, context):
95         import addon_utils
96
97         items = [('All', "All", "All Addons"),
98                  ('User', "User", "All Addons Installed by User"),
99                  ('Enabled', "Enabled", "All Enabled Addons"),
100                  ('Disabled', "Disabled", "All Disabled Addons"),
101                  ]
102
103         items_unique = set()
104
105         for mod in addon_utils.modules(addon_utils.addons_fake_modules):
106             info = addon_utils.module_bl_info(mod)
107             items_unique.add(info["category"])
108
109         items.extend([(cat, cat, "") for cat in sorted(items_unique)])
110         return items
111
112     WindowManager.addon_search = StringProperty(
113             name="Search",
114             description="Search within the selected filter",
115             )
116     WindowManager.addon_filter = EnumProperty(
117             items=addon_filter_items,
118             name="Category",
119             description="Filter addons by category",
120             )
121
122     WindowManager.addon_support = EnumProperty(
123             items=[('OFFICIAL', "Official", "Officially supported"),
124                    ('COMMUNITY', "Community", "Maintained by community developers"),
125                    ('TESTING', "Testing", "Newly contributed scripts (excluded from release builds)")
126                    ],
127             name="Support",
128             description="Display support level",
129             default={'OFFICIAL', 'COMMUNITY'},
130             options={'ENUM_FLAG'},
131             )
132     # done...
133
134
135 def unregister():
136     bpy.utils.unregister_module(__name__)
137
138
139 # Define a default UIList, when a list does not need any custom drawing...
140 class UI_UL_list(bpy.types.UIList):
141     pass
142
143 bpy.utils.register_class(UI_UL_list)