Cleanup:
[blender.git] / release / scripts / ui / space_userpref.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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21
22
23 class USERPREF_HT_header(bpy.types.Header):
24     bl_space_type = 'USER_PREFERENCES'
25
26     def draw(self, context):
27         layout = self.layout
28         layout.template_header(menus=False)
29
30         userpref = context.user_preferences
31
32         layout.operator_context = 'EXEC_AREA'
33         layout.operator("wm.save_homefile", text="Save As Default")
34
35         if userpref.active_section == 'INPUT':
36             layout.operator_context = 'INVOKE_DEFAULT'
37             layout.operator("wm.keyconfig_export", "Export Key Configuration...").path = "keymap.py"
38
39
40 class USERPREF_MT_view(bpy.types.Menu):
41     bl_label = "View"
42
43     def draw(self, context):
44         pass # layout = self.layout
45
46
47 class USERPREF_PT_tabs(bpy.types.Panel):
48     bl_label = ""
49     bl_space_type = 'USER_PREFERENCES'
50     bl_region_type = 'WINDOW'
51     bl_show_header = False
52
53     def draw(self, context):
54         layout = self.layout
55
56         userpref = context.user_preferences
57
58         layout.prop(userpref, "active_section", expand=True)
59
60
61 class USERPREF_PT_interface(bpy.types.Panel):
62     bl_space_type = 'USER_PREFERENCES'
63     bl_label = "Interface"
64     bl_region_type = 'WINDOW'
65     bl_show_header = False
66
67     def poll(self, context):
68         userpref = context.user_preferences
69         return (userpref.active_section == 'INTERFACE')
70
71     def draw(self, context):
72         layout = self.layout
73
74         userpref = context.user_preferences
75         view = userpref.view
76
77         split = layout.split()
78
79         col = split.column()
80         sub = col.split(percentage=0.85)
81
82         sub1 = sub.column()
83         sub1.label(text="Display:")
84         sub1.prop(view, "tooltips")
85         sub1.prop(view, "display_object_info", text="Object Info")
86         sub1.prop(view, "use_large_cursors")
87         sub1.prop(view, "show_view_name", text="View Name")
88         sub1.prop(view, "show_playback_fps", text="Playback FPS")
89         sub1.prop(view, "global_scene")
90         sub1.prop(view, "pin_floating_panels")
91         sub1.prop(view, "object_origin_size")
92         sub1.separator()
93         sub1.separator()
94         sub1.separator()
95         sub1.prop(view, "show_mini_axis", text="Display Mini Axis")
96         sub2 = sub1.column()
97         sub2.enabled = view.show_mini_axis
98         sub2.prop(view, "mini_axis_size", text="Size")
99         sub2.prop(view, "mini_axis_brightness", text="Brightness")
100
101         col = split.column()
102         sub = col.split(percentage=0.85)
103
104         sub1 = sub.column()
105         sub1.label(text="View Manipulation:")
106         sub1.prop(view, "auto_depth")
107         sub1.prop(view, "global_pivot")
108         sub1.prop(view, "zoom_to_mouse")
109         sub1.prop(view, "rotate_around_selection")
110         sub1.separator()
111
112
113         sub1.prop(view, "auto_perspective")
114         sub1.prop(view, "smooth_view")
115         sub1.prop(view, "rotation_angle")
116
117         col = split.column()
118         sub = col.split(percentage=0.85)
119         sub1 = sub.column()
120
121 #Toolbox doesn't exist yet
122 #       sub1.label(text="Toolbox:")
123 #       sub1.prop(view, "use_column_layout")
124 #       sub1.label(text="Open Toolbox Delay:")
125 #       sub1.prop(view, "open_left_mouse_delay", text="Hold LMB")
126 #       sub1.prop(view, "open_right_mouse_delay", text="Hold RMB")
127
128         #manipulator
129         sub1.prop(view, "use_manipulator")
130         sub2 = sub1.column()
131         sub2.enabled = view.use_manipulator
132         sub2.prop(view, "manipulator_size", text="Size")
133         sub2.prop(view, "manipulator_handle_size", text="Handle Size")
134         sub2.prop(view, "manipulator_hotspot", text="Hotspot")
135
136         sub1.separator()
137         sub1.separator()
138         sub1.separator()
139
140         sub1.label(text="Menus:")
141         sub1.prop(view, "open_mouse_over")
142         sub1.label(text="Menu Open Delay:")
143         sub1.prop(view, "open_toplevel_delay", text="Top Level")
144         sub1.prop(view, "open_sublevel_delay", text="Sub Level")
145
146
147 class USERPREF_PT_edit(bpy.types.Panel):
148     bl_space_type = 'USER_PREFERENCES'
149     bl_label = "Edit"
150     bl_region_type = 'WINDOW'
151     bl_show_header = False
152
153     def poll(self, context):
154         userpref = context.user_preferences
155         return (userpref.active_section == 'EDITING')
156
157     def draw(self, context):
158         layout = self.layout
159
160         userpref = context.user_preferences
161         edit = userpref.edit
162
163         split = layout.split()
164
165         col = split.column()
166         sub = col.split(percentage=0.85)
167
168         sub1 = sub.column()
169         sub1.label(text="Link Materials To:")
170         sub1.row().prop(edit, "material_link", expand=True)
171         sub1.separator()
172         sub1.separator()
173         sub1.separator()
174         sub1.label(text="New Objects:")
175         sub1.prop(edit, "enter_edit_mode")
176         sub1.label(text="Align To:")
177         sub1.row().prop(edit, "object_align", expand=True)
178         sub1.separator()
179         sub1.separator()
180         sub1.separator()
181
182         sub1.label(text="Undo:")
183         sub1.prop(edit, "global_undo")
184         sub1.prop(edit, "undo_steps", text="Steps")
185         sub1.prop(edit, "undo_memory_limit", text="Memory Limit")
186
187         col = split.column()
188         sub = col.split(percentage=0.85)
189
190         sub1 = sub.column()
191         sub1.label(text="Snap:")
192         sub1.prop(edit, "snap_translate", text="Translate")
193         sub1.prop(edit, "snap_rotate", text="Rotate")
194         sub1.prop(edit, "snap_scale", text="Scale")
195         sub1.separator()
196         sub1.separator()
197         sub1.separator()
198         sub1.label(text="Grease Pencil:")
199         sub1.prop(edit, "grease_pencil_manhattan_distance", text="Manhattan Distance")
200         sub1.prop(edit, "grease_pencil_euclidean_distance", text="Euclidean Distance")
201         # sub1.prop(edit, "grease_pencil_simplify_stroke", text="Simplify Stroke")
202         sub1.prop(edit, "grease_pencil_eraser_radius", text="Eraser Radius")
203         sub1.prop(edit, "grease_pencil_smooth_stroke", text="Smooth Stroke")
204
205         col = split.column()
206         sub = col.split(percentage=0.85)
207
208         sub1 = sub.column()
209         sub1.label(text="Keyframing:")
210         sub1.prop(edit, "use_visual_keying")
211         sub1.prop(edit, "keyframe_insert_needed", text="Only Insert Needed")
212         sub1.separator()
213         sub1.label(text="New F-Curve Defaults:")
214         sub1.prop(edit, "new_interpolation_type", text="Interpolation")
215         sub1.separator()
216         sub1.prop(edit, "auto_keying_enable", text="Auto Keyframing:")
217         sub2 = sub1.column()
218         sub2.active = edit.auto_keying_enable
219         sub2.prop(edit, "auto_keyframe_insert_keyingset", text="Only Insert for Keying Set")
220         sub2.prop(edit, "auto_keyframe_insert_available", text="Only Insert Available")
221
222         sub1.separator()
223         sub1.separator()
224         sub1.separator()
225
226         sub1.label(text="Transform:")
227         sub1.prop(edit, "drag_immediately")
228
229         sub1.separator()
230         sub1.separator()
231         sub1.separator()
232
233         col = split.column()
234         sub = col.split(percentage=0.85)
235
236         sub1 = sub.column()
237         sub1.label(text="Duplicate Data:")
238         sub1.prop(edit, "duplicate_mesh", text="Mesh")
239         sub1.prop(edit, "duplicate_surface", text="Surface")
240         sub1.prop(edit, "duplicate_curve", text="Curve")
241         sub1.prop(edit, "duplicate_text", text="Text")
242         sub1.prop(edit, "duplicate_metaball", text="Metaball")
243         sub1.prop(edit, "duplicate_armature", text="Armature")
244         sub1.prop(edit, "duplicate_lamp", text="Lamp")
245         sub1.prop(edit, "duplicate_material", text="Material")
246         sub1.prop(edit, "duplicate_texture", text="Texture")
247         sub1.prop(edit, "duplicate_fcurve", text="F-Curve")
248         sub1.prop(edit, "duplicate_action", text="Action")
249         sub1.prop(edit, "duplicate_particle", text="Particle")
250
251
252 class USERPREF_PT_system(bpy.types.Panel):
253     bl_space_type = 'USER_PREFERENCES'
254     bl_label = "System"
255     bl_region_type = 'WINDOW'
256     bl_show_header = False
257
258     def poll(self, context):
259         userpref = context.user_preferences
260         return (userpref.active_section == 'SYSTEM')
261
262     def draw(self, context):
263         layout = self.layout
264
265         userpref = context.user_preferences
266         system = userpref.system
267         lamp0 = system.solid_lights[0]
268         lamp1 = system.solid_lights[1]
269         lamp2 = system.solid_lights[2]
270
271         split = layout.split()
272
273         col = split.column()
274         sub = col.split(percentage=0.9)
275
276         sub1 = sub.column()
277         sub1.label(text="General:")
278         sub1.prop(system, "dpi")
279         sub1.prop(system, "frame_server_port")
280         sub1.prop(system, "scrollback", text="Console Scrollback")
281         sub1.prop(system, "auto_run_python_scripts")
282
283         sub1.separator()
284         sub1.separator()
285         sub1.separator()
286
287         sub1.label(text="Sound:")
288         sub1.row().prop(system, "audio_device", expand=True)
289         sub2 = sub1.column()
290         sub2.active = system.audio_device != 'NONE'
291         sub2.prop(system, "enable_all_codecs")
292         sub2.prop(system, "game_sound")
293         sub2.prop(system, "audio_channels", text="Channels")
294         sub2.prop(system, "audio_mixing_buffer", text="Mixing Buffer")
295         sub2.prop(system, "audio_sample_rate", text="Sample Rate")
296         sub2.prop(system, "audio_sample_format", text="Sample Format")
297
298         col = split.column()
299         sub = col.split(percentage=0.9)
300
301         sub1 = sub .column()
302         sub1.label(text="Weight Colors:")
303         sub1.prop(system, "use_weight_color_range", text="Use Custom Range")
304         sub2 = sub1.column()
305         sub2.active = system.use_weight_color_range
306         sub2.template_color_ramp(system, "weight_color_range", expand=True)
307
308         sub1.separator()
309         sub1.separator()
310         sub1.separator()
311
312         sub1.prop(system, "language")
313         sub1.label(text="Translate:")
314         sub1.prop(system, "translate_tooltips", text="Tooltips")
315         sub1.prop(system, "translate_buttons", text="Labels")
316         sub1.prop(system, "translate_toolbox", text="Toolbox")
317
318         sub1.separator()
319
320         sub1.prop(system, "use_textured_fonts")
321
322         col = split.column()
323         sub = col.split(percentage=0.9)
324
325         sub1 = sub.column()
326
327         sub1.label(text="Solid OpenGL lights:")
328
329         sub2 = sub1.split()
330
331         col = sub2.column()
332         col.prop(lamp0, "enabled")
333         sub = col.column()
334         sub.active = lamp0.enabled
335         sub.prop(lamp0, "diffuse_color")
336         sub.prop(lamp0, "specular_color")
337         sub.prop(lamp0, "direction")
338
339         col = sub2.column()
340         col.prop(lamp1, "enabled")
341         sub = col.column()
342         sub.active = lamp1.enabled
343         sub.prop(lamp1, "diffuse_color")
344         sub.prop(lamp1, "specular_color")
345         sub.prop(lamp1, "direction")
346
347         col = sub2.column()
348         col.prop(lamp2, "enabled")
349         sub = col.column()
350         sub.active = lamp2.enabled
351         sub.prop(lamp2, "diffuse_color")
352         sub.prop(lamp2, "specular_color")
353         sub.prop(lamp2, "direction")
354
355         sub1.label(text="OpenGL:")
356         sub1.prop(system, "clip_alpha", slider=True)
357         sub1.prop(system, "use_mipmaps")
358         sub1.prop(system, "use_vbos")
359         sub1.label(text="Window Draw Method:")
360         sub1.row().prop(system, "window_draw_method", expand=True)
361         sub1.label(text="Textures:")
362         sub1.prop(system, "gl_texture_limit", text="Limit Size")
363         sub1.prop(system, "texture_time_out", text="Time Out")
364         sub1.prop(system, "texture_collection_rate", text="Collection Rate")
365
366         sub1.separator()
367         sub1.separator()
368         sub1.separator()
369
370         sub1.label(text="Sequencer:")
371         sub1.prop(system, "prefetch_frames")
372         sub1.prop(system, "memory_cache_limit")
373
374
375 class USERPREF_PT_theme(bpy.types.Panel):
376     bl_space_type = 'USER_PREFERENCES'
377     bl_label = "Themes"
378     bl_region_type = 'WINDOW'
379     bl_show_header = False
380
381     def poll(self, context):
382         userpref = context.user_preferences
383
384         return (userpref.active_section == 'THEMES')
385
386     def draw(self, context):
387         layout = self.layout
388
389         theme = context.user_preferences.themes[0]
390
391
392         split = layout.split(percentage=0.33)
393         split.prop(theme, "active_theme", text="")
394
395         layout.separator()
396
397         split = layout.split()
398
399         if theme.active_theme == 'VIEW_3D':
400             v3d = theme.view_3d
401
402             col = split.column()
403             col.prop(v3d, "back")
404             col.prop(v3d, "button")
405             col.prop(v3d, "button_title")
406             col.prop(v3d, "button_text")
407             col.prop(v3d, "header")
408
409             col = split.column()
410             col.prop(v3d, "grid")
411             col.prop(v3d, "wire")
412             col.prop(v3d, "lamp", slider=True)
413             col.prop(v3d, "editmesh_active", slider=True)
414
415             col = split.column()
416
417             col.prop(v3d, "object_selected")
418             col.prop(v3d, "object_active")
419             col.prop(v3d, "object_grouped")
420             col.prop(v3d, "object_grouped_active")
421             col.prop(v3d, "transform")
422
423             col = split.column()
424             col.prop(v3d, "vertex")
425             col.prop(v3d, "face", slider=True)
426             col.prop(v3d, "normal")
427             col.prop(v3d, "bone_solid")
428             col.prop(v3d, "bone_pose")
429
430 #           col.prop(v3d, "edge") Doesn't seem to work
431         elif theme.active_theme == 'USER_INTERFACE':
432
433             ui = theme.user_interface.wcol_regular
434
435             layout.label(text="Regular:")
436
437             sub = layout.row()
438             sub1 = sub.column()
439             sub1.prop(ui, "outline")
440             sub1.prop(ui, "item", slider=True)
441             sub1 = sub.column()
442             sub1.prop(ui, "inner", slider=True)
443             sub1.prop(ui, "inner_sel", slider=True)
444             sub1 = sub.column()
445             sub1.prop(ui, "text")
446             sub1.prop(ui, "text_sel")
447             sub1 = sub.column()
448             sub1.prop(ui, "shaded")
449             sub2 = sub1.column(align=True)
450             sub2.active = ui.shaded
451             sub2.prop(ui, "shadetop")
452             sub2.prop(ui, "shadedown")
453             layout.separator()
454
455             ui = theme.user_interface.wcol_tool
456             layout.label(text="Tool:")
457
458             sub = layout.row()
459             sub1 = sub.column()
460             sub1.prop(ui, "outline")
461             sub1.prop(ui, "item", slider=True)
462             sub1 = sub.column()
463             sub1.prop(ui, "inner", slider=True)
464             sub1.prop(ui, "inner_sel", slider=True)
465             sub1 = sub.column()
466             sub1.prop(ui, "text")
467             sub1.prop(ui, "text_sel")
468             sub1 = sub.column()
469             sub1.prop(ui, "shaded")
470             sub2 = sub1.column(align=True)
471             sub2.active = ui.shaded
472             sub2.prop(ui, "shadetop")
473             sub2.prop(ui, "shadedown")
474
475             ui = theme.user_interface.wcol_radio
476             layout.label(text="Radio Buttons:")
477
478             sub = layout.row()
479             sub1 = sub.column()
480             sub1.prop(ui, "outline")
481             sub1.prop(ui, "item", slider=True)
482             sub1 = sub.column()
483             sub1.prop(ui, "inner", slider=True)
484             sub1.prop(ui, "inner_sel", slider=True)
485             sub1 = sub.column()
486             sub1.prop(ui, "text")
487             sub1.prop(ui, "text_sel")
488             sub1 = sub.column()
489             sub1.prop(ui, "shaded")
490             sub2 = sub1.column(align=True)
491             sub2.active = ui.shaded
492             sub2.prop(ui, "shadetop")
493             sub2.prop(ui, "shadedown")
494
495             ui = theme.user_interface.wcol_text
496             layout.label(text="Text:")
497
498             sub = layout.row()
499             sub1 = sub.column()
500             sub1.prop(ui, "outline")
501             sub1.prop(ui, "item", slider=True)
502             sub1 = sub.column()
503             sub1.prop(ui, "inner", slider=True)
504             sub1.prop(ui, "inner_sel", slider=True)
505             sub1 = sub.column()
506             sub1.prop(ui, "text")
507             sub1.prop(ui, "text_sel")
508             sub1 = sub.column()
509             sub1.prop(ui, "shaded")
510             sub2 = sub1.column(align=True)
511             sub2.active = ui.shaded
512             sub2.prop(ui, "shadetop")
513             sub2.prop(ui, "shadedown")
514
515             ui = theme.user_interface.wcol_option
516             layout.label(text="Option:")
517
518             sub = layout.row()
519             sub1 = sub.column()
520             sub1.prop(ui, "outline")
521             sub1.prop(ui, "item", slider=True)
522             sub1 = sub.column()
523             sub1.prop(ui, "inner", slider=True)
524             sub1.prop(ui, "inner_sel", slider=True)
525             sub1 = sub.column()
526             sub1.prop(ui, "text")
527             sub1.prop(ui, "text_sel")
528             sub1 = sub.column()
529             sub1.prop(ui, "shaded")
530             sub2 = sub1.column(align=True)
531             sub2.active = ui.shaded
532             sub2.prop(ui, "shadetop")
533             sub2.prop(ui, "shadedown")
534
535             ui = theme.user_interface.wcol_toggle
536             layout.label(text="Toggle:")
537
538             sub = layout.row()
539             sub1 = sub.column()
540             sub1.prop(ui, "outline")
541             sub1.prop(ui, "item", slider=True)
542             sub1 = sub.column()
543             sub1.prop(ui, "inner", slider=True)
544             sub1.prop(ui, "inner_sel", slider=True)
545             sub1 = sub.column()
546             sub1.prop(ui, "text")
547             sub1.prop(ui, "text_sel")
548             sub1 = sub.column()
549             sub1.prop(ui, "shaded")
550             sub2 = sub1.column(align=True)
551             sub2.active = ui.shaded
552             sub2.prop(ui, "shadetop")
553             sub2.prop(ui, "shadedown")
554
555             ui = theme.user_interface.wcol_num
556             layout.label(text="Number Field:")
557
558             sub = layout.row()
559             sub1 = sub.column()
560             sub1.prop(ui, "outline")
561             sub1.prop(ui, "item", slider=True)
562             sub1 = sub.column()
563             sub1.prop(ui, "inner", slider=True)
564             sub1.prop(ui, "inner_sel", slider=True)
565             sub1 = sub.column()
566             sub1.prop(ui, "text")
567             sub1.prop(ui, "text_sel")
568             sub1 = sub.column()
569             sub1.prop(ui, "shaded")
570             sub2 = sub1.column(align=True)
571             sub2.active = ui.shaded
572             sub2.prop(ui, "shadetop")
573             sub2.prop(ui, "shadedown")
574
575             ui = theme.user_interface.wcol_numslider
576             layout.label(text="Value Slider:")
577
578             sub = layout.row()
579             sub1 = sub.column()
580             sub1.prop(ui, "outline")
581             sub1.prop(ui, "item", slider=True)
582             sub1 = sub.column()
583             sub1.prop(ui, "inner", slider=True)
584             sub1.prop(ui, "inner_sel", slider=True)
585             sub1 = sub.column()
586             sub1.prop(ui, "text")
587             sub1.prop(ui, "text_sel")
588             sub1 = sub.column()
589             sub1.prop(ui, "shaded")
590             sub2 = sub1.column(align=True)
591             sub2.active = ui.shaded
592             sub2.prop(ui, "shadetop")
593             sub2.prop(ui, "shadedown")
594
595             ui = theme.user_interface.wcol_box
596             layout.label(text="Box:")
597
598             sub = layout.row()
599             sub1 = sub.column()
600             sub1.prop(ui, "outline")
601             sub1.prop(ui, "item", slider=True)
602             sub1 = sub.column()
603             sub1.prop(ui, "inner", slider=True)
604             sub1.prop(ui, "inner_sel", slider=True)
605             sub1 = sub.column()
606             sub1.prop(ui, "text")
607             sub1.prop(ui, "text_sel")
608             sub1 = sub.column()
609             sub1.prop(ui, "shaded")
610             sub2 = sub1.column(align=True)
611             sub2.active = ui.shaded
612             sub2.prop(ui, "shadetop")
613             sub2.prop(ui, "shadedown")
614
615             ui = theme.user_interface.wcol_menu
616             layout.label(text="Menu:")
617
618             sub = layout.row()
619             sub1 = sub.column()
620             sub1.prop(ui, "outline")
621             sub1.prop(ui, "item", slider=True)
622             sub1 = sub.column()
623             sub1.prop(ui, "inner", slider=True)
624             sub1.prop(ui, "inner_sel", slider=True)
625             sub1 = sub.column()
626             sub1.prop(ui, "text")
627             sub1.prop(ui, "text_sel")
628             sub1 = sub.column()
629             sub1.prop(ui, "shaded")
630             sub2 = sub1.column(align=True)
631             sub2.active = ui.shaded
632             sub2.prop(ui, "shadetop")
633             sub2.prop(ui, "shadedown")
634
635             ui = theme.user_interface.wcol_pulldown
636             layout.label(text="Pulldown:")
637
638             sub = layout.row()
639             sub1 = sub.column()
640             sub1.prop(ui, "outline")
641             sub1.prop(ui, "item", slider=True)
642             sub1 = sub.column()
643             sub1.prop(ui, "inner", slider=True)
644             sub1.prop(ui, "inner_sel", slider=True)
645             sub1 = sub.column()
646             sub1.prop(ui, "text")
647             sub1.prop(ui, "text_sel")
648             sub1 = sub.column()
649             sub1.prop(ui, "shaded")
650             sub2 = sub1.column(align=True)
651             sub2.active = ui.shaded
652             sub2.prop(ui, "shadetop")
653             sub2.prop(ui, "shadedown")
654
655             ui = theme.user_interface.wcol_menu_back
656             layout.label(text="Menu Back:")
657
658             sub = layout.row()
659             sub1 = sub.column()
660             sub1.prop(ui, "outline")
661             sub1.prop(ui, "item", slider=True)
662             sub1 = sub.column()
663             sub1.prop(ui, "inner", slider=True)
664             sub1.prop(ui, "inner_sel", slider=True)
665             sub1 = sub.column()
666             sub1.prop(ui, "text")
667             sub1.prop(ui, "text_sel")
668             sub1 = sub.column()
669             sub1.prop(ui, "shaded")
670             sub2 = sub1.column(align=True)
671             sub2.active = ui.shaded
672             sub2.prop(ui, "shadetop")
673             sub2.prop(ui, "shadedown")
674
675             ui = theme.user_interface.wcol_menu_item
676             layout.label(text="Menu Item:")
677
678             sub = layout.row()
679             sub1 = sub.column()
680             sub1.prop(ui, "outline")
681             sub1.prop(ui, "item", slider=True)
682             sub1 = sub.column()
683             sub1.prop(ui, "inner", slider=True)
684             sub1.prop(ui, "inner_sel", slider=True)
685             sub1 = sub.column()
686             sub1.prop(ui, "text")
687             sub1.prop(ui, "text_sel")
688             sub1 = sub.column()
689             sub1.prop(ui, "shaded")
690             sub2 = sub1.column(align=True)
691             sub2.active = ui.shaded
692             sub2.prop(ui, "shadetop")
693             sub2.prop(ui, "shadedown")
694
695             ui = theme.user_interface.wcol_scroll
696             layout.label(text="Scroll Bar:")
697
698             sub = layout.row()
699             sub1 = sub.column()
700             sub1.prop(ui, "outline")
701             sub1.prop(ui, "item", slider=True)
702             sub1 = sub.column()
703             sub1.prop(ui, "inner", slider=True)
704             sub1.prop(ui, "inner_sel", slider=True)
705             sub1 = sub.column()
706             sub1.prop(ui, "text")
707             sub1.prop(ui, "text_sel")
708             sub1 = sub.column()
709             sub1.prop(ui, "shaded")
710             sub2 = sub1.column(align=True)
711             sub2.active = ui.shaded
712             sub2.prop(ui, "shadetop")
713             sub2.prop(ui, "shadedown")
714
715             ui = theme.user_interface.wcol_list_item
716             layout.label(text="List Item:")
717
718             sub = layout.row()
719             sub1 = sub.column()
720             sub1.prop(ui, "outline")
721             sub1.prop(ui, "item", slider=True)
722             sub1 = sub.column()
723             sub1.prop(ui, "inner", slider=True)
724             sub1.prop(ui, "inner_sel", slider=True)
725             sub1 = sub.column()
726             sub1.prop(ui, "text")
727             sub1.prop(ui, "text_sel")
728             sub1 = sub.column()
729             sub1.prop(ui, "shaded")
730             sub2 = sub1.column(align=True)
731             sub2.active = ui.shaded
732             sub2.prop(ui, "shadetop")
733             sub2.prop(ui, "shadedown")
734
735             ui = theme.user_interface.wcol_state
736             layout.label(text="State:")
737
738             sub = layout.row()
739             sub1 = sub.column()
740             sub1.prop(ui, "inner_anim")
741             sub1.prop(ui, "inner_anim_sel")
742             sub1 = sub.column()
743             sub1.prop(ui, "inner_driven")
744             sub1.prop(ui, "inner_driven_sel")
745             sub1 = sub.column()
746             sub1.prop(ui, "inner_key")
747             sub1.prop(ui, "inner_key_sel")
748             sub1 = sub.column()
749             sub1.prop(ui, "blend")
750
751             ui = theme.user_interface
752             layout.separator()
753
754             sub = layout.row()
755             sub.prop(ui, "icon_file")
756
757             layout.separator()
758             layout.separator()
759
760
761         elif theme.active_theme == 'GRAPH_EDITOR':
762             graph = theme.graph_editor
763
764             col = split.column()
765             col.prop(graph, "back")
766             col.prop(graph, "button")
767             col.prop(graph, "button_title")
768             col.prop(graph, "button_text")
769
770             col = split.column()
771             col.prop(graph, "header")
772             col.prop(graph, "grid")
773             col.prop(graph, "list")
774             col.prop(graph, "channel_group")
775
776             col = split.column()
777             col.prop(graph, "active_channels_group")
778             col.prop(graph, "dopesheet_channel")
779             col.prop(graph, "dopesheet_subchannel")
780             col.prop(graph, "vertex")
781
782             col = split.column()
783             col.prop(graph, "current_frame")
784             col.prop(graph, "handle_vertex")
785             col.prop(graph, "handle_vertex_select")
786             col.separator()
787             col.prop(graph, "handle_vertex_size")
788
789         elif theme.active_theme == 'FILE_BROWSER':
790             file_browse = theme.file_browser
791
792             col = split.column()
793             col.prop(file_browse, "back")
794             col.prop(file_browse, "text")
795             col.prop(file_browse, "text_hi")
796
797             col = split.column()
798             col.prop(file_browse, "header")
799             col.prop(file_browse, "list")
800
801             col = split.column()
802             col.prop(file_browse, "selected_file")
803             col.prop(file_browse, "tiles")
804
805             col = split.column()
806             col.prop(file_browse, "active_file")
807             col.prop(file_browse, "active_file_text")
808
809         elif theme.active_theme == 'NLA_EDITOR':
810             nla = theme.nla_editor
811
812             col = split.column()
813             col.prop(nla, "back")
814             col.prop(nla, "button")
815             col.prop(nla, "button_title")
816
817             col = split.column()
818             col.prop(nla, "button_text")
819             col.prop(nla, "text")
820             col.prop(nla, "header")
821
822             col = split.column()
823             col.prop(nla, "grid")
824             col.prop(nla, "bars")
825             col.prop(nla, "bars_selected")
826
827             col = split.column()
828             col.prop(nla, "strips")
829             col.prop(nla, "strips_selected")
830             col.prop(nla, "current_frame")
831
832         elif theme.active_theme == 'DOPESHEET_EDITOR':
833             dope = theme.dopesheet_editor
834
835             col = split.column()
836             col.prop(dope, "back")
837             col.prop(dope, "list")
838             col.prop(dope, "text")
839             col.prop(dope, "header")
840
841             col = split.column()
842             col.prop(dope, "grid")
843             col.prop(dope, "channels")
844             col.prop(dope, "channels_selected")
845             col.prop(dope, "channel_group")
846
847             col = split.column()
848             col.prop(dope, "active_channels_group")
849             col.prop(dope, "long_key")
850             col.prop(dope, "long_key_selected")
851
852             col = split.column()
853             col.prop(dope, "current_frame")
854             col.prop(dope, "dopesheet_channel")
855             col.prop(dope, "dopesheet_subchannel")
856
857         elif theme.active_theme == 'IMAGE_EDITOR':
858             image = theme.image_editor
859
860             col = split.column()
861             col.prop(image, "back")
862             col.prop(image, "button")
863
864             col = split.column()
865             col.prop(image, "button_title")
866             col.prop(image, "button_text")
867
868             col = split.column()
869             col.prop(image, "header")
870
871             col = split.column()
872             col.prop(image, "editmesh_active", slider=True)
873
874         elif theme.active_theme == 'SEQUENCE_EDITOR':
875             seq = theme.sequence_editor
876
877             col = split.column()
878             col.prop(seq, "back")
879             col.prop(seq, "button")
880             col.prop(seq, "button_title")
881             col.prop(seq, "button_text")
882             col.prop(seq, "text")
883
884             col = split.column()
885             col.prop(seq, "header")
886             col.prop(seq, "grid")
887             col.prop(seq, "movie_strip")
888             col.prop(seq, "image_strip")
889             col.prop(seq, "scene_strip")
890
891             col = split.column()
892             col.prop(seq, "audio_strip")
893             col.prop(seq, "effect_strip")
894             col.prop(seq, "plugin_strip")
895             col.prop(seq, "transition_strip")
896
897             col = split.column()
898             col.prop(seq, "meta_strip")
899             col.prop(seq, "current_frame")
900             col.prop(seq, "keyframe")
901             col.prop(seq, "draw_action")
902
903         elif theme.active_theme == 'PROPERTIES':
904             prop = theme.properties
905
906             col = split.column()
907             col.prop(prop, "back")
908
909             col = split.column()
910             col.prop(prop, "title")
911
912             col = split.column()
913             col.prop(prop, "text")
914
915             col = split.column()
916             col.prop(prop, "header")
917
918         elif theme.active_theme == 'TEXT_EDITOR':
919             text = theme.text_editor
920
921             col = split.column()
922             col.prop(text, "back")
923             col.prop(text, "button")
924             col.prop(text, "button_title")
925             col.prop(text, "button_text")
926
927             col = split.column()
928             col.prop(text, "text")
929             col.prop(text, "text_hi")
930             col.prop(text, "header")
931             col.prop(text, "line_numbers_background")
932
933             col = split.column()
934             col.prop(text, "selected_text")
935             col.prop(text, "cursor")
936             col.prop(text, "syntax_builtin")
937             col.prop(text, "syntax_special")
938
939             col = split.column()
940             col.prop(text, "syntax_comment")
941             col.prop(text, "syntax_string")
942             col.prop(text, "syntax_numbers")
943
944         elif theme.active_theme == 'TIMELINE':
945             time = theme.timeline
946
947             col = split.column()
948             col.prop(time, "back")
949             col.prop(time, "text")
950
951             col = split.column()
952             col.prop(time, "header")
953
954             col = split.column()
955             col.prop(time, "grid")
956
957             col = split.column()
958             col.prop(time, "current_frame")
959
960         elif theme.active_theme == 'NODE_EDITOR':
961             node = theme.node_editor
962
963             col = split.column()
964             col.prop(node, "back")
965             col.prop(node, "button")
966             col.prop(node, "button_title")
967             col.prop(node, "button_text")
968
969
970             col = split.column()
971             col.prop(node, "text")
972             col.prop(node, "text_hi")
973             col.prop(node, "header")
974             col.prop(node, "wires")
975
976             col = split.column()
977             col.prop(node, "wire_select")
978             col.prop(node, "selected_text")
979             col.prop(node, "node_backdrop", slider=True)
980             col.prop(node, "in_out_node")
981
982             col = split.column()
983             col.prop(node, "converter_node")
984             col.prop(node, "operator_node")
985             col.prop(node, "group_node")
986
987         elif theme.active_theme == 'LOGIC_EDITOR':
988             logic = theme.logic_editor
989
990             col = split.column()
991             col.prop(logic, "back")
992             col.prop(logic, "button")
993
994             col = split.column()
995             col.prop(logic, "button_title")
996             col.prop(logic, "button_text")
997
998             col = split.column()
999             col.prop(logic, "text")
1000             col.prop(logic, "header")
1001
1002             col = split.column()
1003             col.prop(logic, "panel")
1004
1005         elif theme.active_theme == 'OUTLINER':
1006             out = theme.outliner
1007
1008             col = split.column()
1009             col.prop(out, "back")
1010
1011             col = split.column()
1012             col.prop(out, "text")
1013
1014             col = split.column()
1015             col.prop(out, "text_hi")
1016
1017             col = split.column()
1018             col.prop(out, "header")
1019
1020         elif theme.active_theme == 'INFO':
1021             info = theme.info
1022
1023             col = split.column()
1024             col.prop(info, "back")
1025
1026             col = split.column()
1027             col.prop(info, "header")
1028
1029             col = split.column()
1030             col.prop(info, "header_text")
1031
1032             col = split.column()
1033
1034         elif theme.active_theme == 'USER_PREFERENCES':
1035             prefs = theme.user_preferences
1036
1037             col = split.column()
1038             col.prop(prefs, "back")
1039
1040             col = split.column()
1041             col.prop(prefs, "text")
1042
1043             col = split.column()
1044             col.prop(prefs, "header")
1045
1046             col = split.column()
1047             col.prop(prefs, "header_text")
1048
1049
1050 class USERPREF_PT_file(bpy.types.Panel):
1051     bl_space_type = 'USER_PREFERENCES'
1052     bl_label = "Files"
1053     bl_region_type = 'WINDOW'
1054     bl_show_header = False
1055
1056     def poll(self, context):
1057         userpref = context.user_preferences
1058         return (userpref.active_section == 'FILES')
1059
1060     def draw(self, context):
1061         layout = self.layout
1062
1063         userpref = context.user_preferences
1064         paths = userpref.filepaths
1065
1066         split = layout.split(percentage=0.6)
1067
1068         col = split.column()
1069         col.label(text="File Paths:")
1070         sub = col.split(percentage=0.3)
1071
1072         sub.label(text="Fonts:")
1073         sub.prop(paths, "fonts_directory", text="")
1074         sub = col.split(percentage=0.3)
1075         sub.label(text="Textures:")
1076         sub.prop(paths, "textures_directory", text="")
1077         sub = col.split(percentage=0.3)
1078         sub.label(text="Texture Plugins:")
1079         sub.prop(paths, "texture_plugin_directory", text="")
1080         sub = col.split(percentage=0.3)
1081         sub.label(text="Sequence Plugins:")
1082         sub.prop(paths, "sequence_plugin_directory", text="")
1083         sub = col.split(percentage=0.3)
1084         sub.label(text="Render Output:")
1085         sub.prop(paths, "render_output_directory", text="")
1086         sub = col.split(percentage=0.3)
1087         sub.label(text="Scripts:")
1088         sub.prop(paths, "python_scripts_directory", text="")
1089         sub = col.split(percentage=0.3)
1090         sub.label(text="Sounds:")
1091         sub.prop(paths, "sounds_directory", text="")
1092         sub = col.split(percentage=0.3)
1093         sub.label(text="Temp:")
1094         sub.prop(paths, "temporary_directory", text="")
1095
1096         col = split.column()
1097         sub = col.split(percentage=0.2)
1098         sub.column() # sub1, unused
1099         sub2 = sub.column()
1100         sub2.label(text="Save & Load:")
1101         sub2.prop(paths, "use_relative_paths")
1102         sub2.prop(paths, "compress_file")
1103         sub2.prop(paths, "load_ui")
1104         sub2.prop(paths, "filter_file_extensions")
1105         sub2.prop(paths, "hide_dot_files_datablocks")
1106         sub2.separator()
1107         sub2.separator()
1108         sub2.label(text="Auto Save:")
1109         sub2.prop(paths, "save_version")
1110         sub2.prop(paths, "recent_files")
1111         sub2.prop(paths, "save_preview_images")
1112         sub2.prop(paths, "auto_save_temporary_files")
1113         sub3 = sub2.column()
1114         sub3.enabled = paths.auto_save_temporary_files
1115         sub3.prop(paths, "auto_save_time", text="Timer (mins)")
1116
1117
1118 class USERPREF_PT_input(bpy.types.Panel):
1119     bl_space_type = 'USER_PREFERENCES'
1120     bl_label = "Input"
1121     bl_region_type = 'WINDOW'
1122     bl_show_header = False
1123
1124     def poll(self, context):
1125         userpref = context.user_preferences
1126         return (userpref.active_section == 'INPUT')
1127
1128     def draw(self, context):
1129         layout = self.layout
1130
1131         userpref = context.user_preferences
1132         wm = context.manager
1133         #input = userpref.input
1134         #input = userpref
1135         inputs = userpref.inputs
1136
1137         split = layout.split(percentage=0.25)
1138
1139         # General settings
1140         row = split.row()
1141         col = row.column()
1142
1143         sub = col.column()
1144         sub.label(text="Configuration:")
1145         sub.prop_object(wm, "active_keyconfig", wm, "keyconfigs", text="")
1146
1147         col.separator()
1148
1149         sub = col.column()
1150         sub.label(text="Mouse:")
1151         sub1 = sub.column()
1152         sub1.enabled = (inputs.select_mouse == 'RIGHT')
1153         sub1.prop(inputs, "emulate_3_button_mouse")
1154         sub.prop(inputs, "continuous_mouse")
1155
1156         sub.label(text="Select With:")
1157         sub.row().prop(inputs, "select_mouse", expand=True)
1158
1159         sub.separator()
1160
1161         sub.prop(inputs, "emulate_numpad")
1162
1163         sub.separator()
1164
1165         sub.label(text="Orbit Style:")
1166         sub.row().prop(inputs, "view_rotation", expand=True)
1167
1168         sub.label(text="Zoom Style:")
1169         sub.row().prop(inputs, "viewport_zoom_style", expand=True)
1170         if inputs.viewport_zoom_style == 'DOLLY':
1171             sub.row().prop(inputs, "zoom_axis", expand=True)
1172             sub.prop(inputs, "invert_zoom_direction")
1173
1174         #sub.prop(inputs, "use_middle_mouse_paste")
1175
1176         #col.separator()
1177
1178         #sub = col.column()
1179         #sub.label(text="Mouse Wheel:")
1180         #sub.prop(view, "wheel_scroll_lines", text="Scroll Lines")
1181
1182         col.separator()
1183
1184         sub = col.column()
1185         sub.label(text="NDOF Device:")
1186         sub.prop(inputs, "ndof_pan_speed", text="Pan Speed")
1187         sub.prop(inputs, "ndof_rotate_speed", text="Orbit Speed")
1188
1189         row.separator()
1190
1191         # Keymap Settings
1192         col = split.column()
1193
1194         # kc = wm.active_keyconfig
1195         defkc = wm.default_keyconfig
1196         km = wm.active_keymap
1197
1198         subsplit = col.split()
1199         subsplit.prop_object(wm, "active_keymap", defkc, "keymaps", text="Map:")
1200         if km.user_defined:
1201             row = subsplit.row()
1202             row.operator("WM_OT_keymap_restore", text="Restore")
1203             row.operator("WM_OT_keymap_restore", text="Restore All").all = True
1204         else:
1205             row = subsplit.row()
1206             row.operator("WM_OT_keymap_edit", text="Edit")
1207             row.label()
1208
1209         col.separator()
1210
1211         for kmi in km.items:
1212             subcol = col.column()
1213             subcol.set_context_pointer("keyitem", kmi)
1214
1215             row = subcol.row()
1216
1217             if kmi.expanded:
1218                 row.prop(kmi, "expanded", text="", icon='ICON_TRIA_DOWN')
1219             else:
1220                 row.prop(kmi, "expanded", text="", icon='ICON_TRIA_RIGHT')
1221
1222             itemrow = row.row()
1223             itemrow.enabled = km.user_defined
1224             if kmi.active:
1225                 itemrow.prop(kmi, "active", text="", icon='ICON_CHECKBOX_HLT')
1226             else:
1227                 itemrow.prop(kmi, "active", text="", icon='ICON_CHECKBOX_DEHLT')
1228
1229             itemcol = itemrow.column()
1230             itemcol.active = kmi.active
1231             row = itemcol.row()
1232
1233             if km.modal:
1234                 row.prop(kmi, "propvalue", text="")
1235             else:
1236                 row.prop(kmi, "idname", text="")
1237
1238             sub = row.row()
1239             sub.scale_x = 0.6
1240             sub.prop(kmi, "map_type", text="")
1241
1242             sub = row.row(align=True)
1243             if kmi.map_type == 'KEYBOARD':
1244                 sub.prop(kmi, "type", text="", full_event=True)
1245             elif kmi.map_type == 'MOUSE':
1246                 sub.prop(kmi, "type", text="", full_event=True)
1247             elif kmi.map_type == 'TWEAK':
1248                 sub.scale_x = 0.5
1249                 sub.prop(kmi, "type", text="")
1250                 sub.prop(kmi, "value", text="")
1251             elif kmi.map_type == 'TIMER':
1252                 sub.prop(kmi, "type", text="")
1253             else:
1254                 sub.label()
1255
1256             if kmi.expanded:
1257                 if kmi.map_type not in ('TEXTINPUT', 'TIMER'):
1258                     sub = itemcol.row(align=True)
1259
1260                     if kmi.map_type == 'KEYBOARD':
1261                         sub.prop(kmi, "type", text="", event=True)
1262                         sub.prop(kmi, "value", text="")
1263                     elif kmi.map_type == 'MOUSE':
1264                         sub.prop(kmi, "type", text="")
1265                         sub.prop(kmi, "value", text="")
1266                     else:
1267                         sub.label()
1268                         sub.label()
1269
1270                     subrow = sub.row()
1271                     subrow.scale_x = 0.75
1272                     subrow.prop(kmi, "any")
1273                     subrow.prop(kmi, "shift")
1274                     subrow.prop(kmi, "ctrl")
1275                     subrow.prop(kmi, "alt")
1276                     subrow.prop(kmi, "oskey", text="Cmd")
1277                     sub.prop(kmi, "key_modifier", text="", event=True)
1278
1279                 flow = itemcol.column_flow(columns=2)
1280                 props = kmi.properties
1281
1282                 if props is not None:
1283                     for pname in dir(props):
1284                         if not props.is_property_hidden(pname):
1285                             flow.prop(props, pname)
1286
1287                 itemcol.separator()
1288
1289             itemrow.operator("wm.keyitem_remove", text="", icon='ICON_ZOOMOUT')
1290
1291         itemrow = col.row()
1292         itemrow.label()
1293         itemrow.operator("wm.keyitem_add", text="", icon='ICON_ZOOMIN')
1294         itemrow.enabled = km.user_defined
1295
1296 bpy.types.register(USERPREF_HT_header)
1297 bpy.types.register(USERPREF_MT_view)
1298 bpy.types.register(USERPREF_PT_tabs)
1299 bpy.types.register(USERPREF_PT_interface)
1300 bpy.types.register(USERPREF_PT_theme)
1301 bpy.types.register(USERPREF_PT_edit)
1302 bpy.types.register(USERPREF_PT_system)
1303 bpy.types.register(USERPREF_PT_file)
1304 bpy.types.register(USERPREF_PT_input)
1305
1306 from bpy.props import *
1307
1308
1309 class WM_OT_keyconfig_export(bpy.types.Operator):
1310     "Export key configuration to a python script."
1311     bl_idname = "wm.keyconfig_export"
1312     bl_label = "Export Key Configuration..."
1313
1314     path = bpy.props.StringProperty(name="File Path", description="File path to write file to.")
1315
1316     def _string_value(self, value):
1317         result = ""
1318         if isinstance(value, str):
1319             if value != "":
1320                 result = "\'%s\'" % value
1321         elif isinstance(value, bool):
1322             if value:
1323                 result = "True"
1324             else:
1325                 result = "False"
1326         elif isinstance(value, float):
1327             result = "%.10f" % value
1328         elif isinstance(value, int):
1329             result = "%d" % value
1330         elif getattr(value, '__len__', False):
1331             if len(value):
1332                 result = "["
1333                 for i in range(0, len(value)):
1334                     result += self._string_value(value[i])
1335                     if i != len(value)-1:
1336                         result += ", "
1337                 result += "]"
1338         else:
1339             print("Export key configuration: can't write ", value)
1340
1341         return result
1342
1343     def execute(self, context):
1344         if not self.properties.path:
1345             raise Exception("File path not set.")
1346
1347         f = open(self.properties.path, "w")
1348         if not f:
1349             raise Exception("Could not open file.")
1350
1351         wm = context.manager
1352         kc = wm.active_keyconfig
1353
1354         f.write('# Configuration %s\n' % kc.name)
1355
1356         f.write("wm = bpy.data.windowmanagers[0]\n")
1357         f.write("kc = wm.add_keyconfig(\'%s\')\n\n" % kc.name)
1358
1359         for km in kc.keymaps:
1360             km = km.active()
1361             f.write("# Map %s\n" % km.name)
1362             f.write("km = kc.add_keymap(\'%s\', space_type=\'%s\', region_type=\'%s\', modal=%s)\n\n" % (km.name, km.space_type, km.region_type, km.modal))
1363             for kmi in km.items:
1364                 if km.modal:
1365                     f.write("kmi = km.add_modal_item(\'%s\', \'%s\', \'%s\'" % (kmi.propvalue, kmi.type, kmi.value))
1366                 else:
1367                     f.write("kmi = km.add_item(\'%s\', \'%s\', \'%s\'" % (kmi.idname, kmi.type, kmi.value))
1368                 if kmi.any:
1369                     f.write(", any=True")
1370                 else:
1371                     if kmi.shift:
1372                         f.write(", shift=True")
1373                     if kmi.ctrl:
1374                         f.write(", ctrl=True")
1375                     if kmi.alt:
1376                         f.write(", alt=True")
1377                     if kmi.oskey:
1378                         f.write(", oskey=True")
1379                 if kmi.key_modifier and kmi.key_modifier != 'NONE':
1380                     f.write(", key_modifier=\'%s\'" % kmi.key_modifier)
1381                 f.write(")\n")
1382
1383                 props = kmi.properties
1384
1385                 if props is not None:
1386                     for pname in dir(props):
1387                         if props.is_property_set(pname) and not props.is_property_hidden(pname):
1388                             value = eval("props.%s" % pname)
1389                             value = self._string_value(value)
1390                             if value != "":
1391                                 f.write("kmi.properties.%s = %s\n" % (pname, value))
1392
1393             f.write("\n")
1394
1395         f.close()
1396
1397         return ('FINISHED',)
1398
1399     def invoke(self, context, event):
1400         wm = context.manager
1401         wm.add_fileselect(self)
1402         return ('RUNNING_MODAL',)
1403
1404
1405 class WM_OT_keymap_edit(bpy.types.Operator):
1406     "Edit key map."
1407     bl_idname = "wm.keymap_edit"
1408     bl_label = "Edit Key Map"
1409
1410     def execute(self, context):
1411         wm = context.manager
1412         km = wm.active_keymap
1413         km.copy_to_user()
1414         return ('FINISHED',)
1415
1416
1417 class WM_OT_keymap_restore(bpy.types.Operator):
1418     "Restore key map"
1419     bl_idname = "wm.keymap_restore"
1420     bl_label = "Restore Key Map"
1421
1422     all = BoolProperty(attr="all", name="All Keymaps", description="Restore all keymaps to default.")
1423
1424     def execute(self, context):
1425         wm = context.manager
1426
1427         if self.properties.all:
1428             for km in wm.default_keyconfig.keymaps:
1429                 km.restore_to_default()
1430         else:
1431             km = wm.active_keymap
1432             km.restore_to_default()
1433
1434         return ('FINISHED',)
1435
1436
1437 class WM_OT_keyitem_add(bpy.types.Operator):
1438     "Add key map item."
1439     bl_idname = "wm.keyitem_add"
1440     bl_label = "Add Key Map Item"
1441
1442     def execute(self, context):
1443         wm = context.manager
1444         km = wm.active_keymap
1445         if km.modal:
1446             km.add_modal_item("", 'A', 'PRESS') # kmi
1447         else:
1448             km.add_item("", 'A', 'PRESS') # kmi
1449         return ('FINISHED',)
1450
1451
1452 class WM_OT_keyitem_remove(bpy.types.Operator):
1453     "Remove key map item."
1454     bl_idname = "wm.keyitem_remove"
1455     bl_label = "Remove Key Map Item"
1456
1457     def execute(self, context):
1458         wm = context.manager
1459         kmi = context.keyitem
1460         km = wm.active_keymap
1461         km.remove_item(kmi)
1462         return ('FINISHED',)
1463
1464 bpy.ops.add(WM_OT_keyconfig_export)
1465 bpy.ops.add(WM_OT_keymap_edit)
1466 bpy.ops.add(WM_OT_keymap_restore)
1467 bpy.ops.add(WM_OT_keyitem_add)
1468 bpy.ops.add(WM_OT_keyitem_remove)