4588fb42088aedf37db3c488beec99e01b530bc5
[blender-staging.git] / release / scripts / ui / space_userpref.py
1 # This software is distributable under the terms of the GNU
2 # General Public License (GPL) v2, the text of which can be found at
3 # http://www.gnu.org/copyleft/gpl.html. Installing, importing or otherwise
4 # using this module constitutes acceptance of the terms of this License.
5
6
7 import bpy
8
9 class USERPREF_HT_header(bpy.types.Header):
10     bl_space_type = 'USER_PREFERENCES'
11
12     def draw(self, context):
13         layout = self.layout
14         layout.template_header(menus=False)
15
16         userpref = context.user_preferences
17
18         layout.operator_context = "EXEC_AREA"
19         layout.itemO("wm.save_homefile", text="Save As Default")
20
21         if userpref.active_section == 'INPUT':
22             layout.operator_context = "INVOKE_DEFAULT"
23             layout.itemO("wm.keyconfig_export", "Export Key Configuration...")
24
25 class USERPREF_MT_view(bpy.types.Menu):
26     bl_label = "View"
27
28     def draw(self, context):
29         layout = self.layout
30
31 class USERPREF_PT_tabs(bpy.types.Panel):
32     bl_label = ""
33     bl_space_type = 'USER_PREFERENCES'
34     bl_region_type = 'WINDOW'
35     bl_show_header = False
36
37     def draw(self, context):
38         layout = self.layout
39
40         userpref = context.user_preferences
41
42         layout.itemR(userpref, "active_section", expand=True)
43
44 class USERPREF_PT_interface(bpy.types.Panel):
45     bl_space_type = 'USER_PREFERENCES'
46     bl_label = "Interface"
47     bl_region_type = 'WINDOW'
48     bl_show_header = False
49
50     def poll(self, context):
51         userpref = context.user_preferences
52         return (userpref.active_section == 'INTERFACE')
53
54     def draw(self, context):
55         layout = self.layout
56
57         userpref = context.user_preferences
58         view = userpref.view
59
60         split = layout.split()
61
62         col = split.column()
63         sub = col.split(percentage=0.85)
64
65         sub1 = sub.column()
66         sub1.itemL(text="Display:")
67         sub1.itemR(view, "tooltips")
68         sub1.itemR(view, "display_object_info", text="Object Info")
69         sub1.itemR(view, "use_large_cursors")
70         sub1.itemR(view, "show_view_name", text="View Name")
71         sub1.itemR(view, "show_playback_fps", text="Playback FPS")
72         sub1.itemR(view, "global_scene")
73         sub1.itemR(view, "pin_floating_panels")
74         sub1.itemR(view, "object_center_size")
75         sub1.itemS()
76         sub1.itemS()
77         sub1.itemS()
78         sub1.itemR(view, "show_mini_axis", text="Display Mini Axis")
79         sub2 = sub1.column()
80         sub2.enabled = view.show_mini_axis
81         sub2.itemR(view, "mini_axis_size", text="Size")
82         sub2.itemR(view, "mini_axis_brightness", text="Brightness")
83
84         col = split.column()
85         sub = col.split(percentage=0.85)
86
87         sub1 = sub.column()
88         sub1.itemL(text="View Manipulation:")
89         sub1.itemR(view, "auto_depth")
90         sub1.itemR(view, "global_pivot")
91         sub1.itemR(view, "zoom_to_mouse")
92         sub1.itemR(view, "rotate_around_selection")
93         sub1.itemS()
94
95
96         sub1.itemR(view, "auto_perspective")
97         sub1.itemR(view, "smooth_view")
98         sub1.itemR(view, "rotation_angle")
99
100         col = split.column()
101         sub = col.split(percentage=0.85)
102         sub1 = sub.column()
103
104 #Toolbox doesn't exist yet
105 #               sub1.itemL(text="Toolbox:")
106 #               sub1.itemR(view, "use_column_layout")
107 #               sub1.itemL(text="Open Toolbox Delay:")
108 #               sub1.itemR(view, "open_left_mouse_delay", text="Hold LMB")
109 #               sub1.itemR(view, "open_right_mouse_delay", text="Hold RMB")
110
111         #manipulator
112         sub1.itemR(view, "use_manipulator")
113         sub2 = sub1.column()
114         sub2.enabled = view.use_manipulator
115         sub2.itemR(view, "manipulator_size", text="Size")
116         sub2.itemR(view, "manipulator_handle_size", text="Handle Size")
117         sub2.itemR(view, "manipulator_hotspot", text="Hotspot")
118
119         sub1.itemS()
120         sub1.itemS()
121         sub1.itemS()
122
123         sub1.itemL(text="Menus:")
124         sub1.itemR(view, "open_mouse_over")
125         sub1.itemL(text="Menu Open Delay:")
126         sub1.itemR(view, "open_toplevel_delay", text="Top Level")
127         sub1.itemR(view, "open_sublevel_delay", text="Sub Level")
128
129 class USERPREF_PT_edit(bpy.types.Panel):
130     bl_space_type = 'USER_PREFERENCES'
131     bl_label = "Edit"
132     bl_region_type = 'WINDOW'
133     bl_show_header = False
134
135     def poll(self, context):
136         userpref = context.user_preferences
137         return (userpref.active_section == 'EDITING')
138
139     def draw(self, context):
140         layout = self.layout
141
142         userpref = context.user_preferences
143         edit = userpref.edit
144
145         split = layout.split()
146
147         col = split.column()
148         sub = col.split(percentage=0.85)
149
150         sub1 = sub.column()
151         sub1.itemL(text="Link Materials To:")
152         sub1.row().itemR(edit, "material_link", expand=True)
153         sub1.itemS()
154         sub1.itemS()
155         sub1.itemS()
156         sub1.itemL(text="New Objects:")
157         sub1.itemR(edit, "enter_edit_mode")
158         sub1.itemL(text="Align To:")
159         sub1.row().itemR(edit, "object_align", expand=True)
160         sub1.itemS()
161         sub1.itemS()
162         sub1.itemS()
163
164         sub1.itemL(text="Undo:")
165         sub1.itemR(edit, "global_undo")
166         sub1.itemR(edit, "undo_steps", text="Steps")
167         sub1.itemR(edit, "undo_memory_limit", text="Memory Limit")
168
169         col = split.column()
170         sub = col.split(percentage=0.85)
171
172         sub1 = sub.column()
173         sub1.itemL(text="Snap:")
174         sub1.itemR(edit, "snap_translate", text="Translate")
175         sub1.itemR(edit, "snap_rotate", text="Rotate")
176         sub1.itemR(edit, "snap_scale", text="Scale")
177         sub1.itemS()
178         sub1.itemS()
179         sub1.itemS()
180         sub1.itemL(text="Grease Pencil:")
181         sub1.itemR(edit, "grease_pencil_manhattan_distance", text="Manhattan Distance")
182         sub1.itemR(edit, "grease_pencil_euclidean_distance", text="Euclidean Distance")
183         # sub1.itemR(edit, "grease_pencil_simplify_stroke", text="Simplify Stroke")
184         sub1.itemR(edit, "grease_pencil_eraser_radius", text="Eraser Radius")
185         sub1.itemR(edit, "grease_pencil_smooth_stroke", text="Smooth Stroke")
186
187         col = split.column()
188         sub = col.split(percentage=0.85)
189
190         sub1 = sub.column()
191         sub1.itemL(text="Keyframing:")
192         sub1.itemR(edit, "use_visual_keying")
193         sub1.itemR(edit, "keyframe_insert_needed", text="Only Insert Needed")
194         sub1.itemS()
195         sub1.itemL(text="New F-Curve Defaults:")
196         sub1.itemR(edit, "new_interpolation_type", text="Interpolation")
197         sub1.itemS()
198         sub1.itemR(edit, "auto_keying_enable", text="Auto Keyframing:")
199         sub2 = sub1.column()
200         sub2.active = edit.auto_keying_enable
201         sub2.itemR(edit, "auto_keyframe_insert_keyingset", text="Only Insert for Keying Set")
202         sub2.itemR(edit, "auto_keyframe_insert_available", text="Only Insert Available")
203
204         sub1.itemS()
205         sub1.itemS()
206         sub1.itemS()
207
208         sub1.itemL(text="Transform:")
209         sub1.itemR(edit, "drag_immediately")
210
211         sub1.itemS()
212         sub1.itemS()
213         sub1.itemS()
214
215         col = split.column()
216         sub = col.split(percentage=0.85)
217
218         sub1 = sub.column()
219         sub1.itemL(text="Duplicate Data:")
220         sub1.itemR(edit, "duplicate_mesh", text="Mesh")
221         sub1.itemR(edit, "duplicate_surface", text="Surface")
222         sub1.itemR(edit, "duplicate_curve", text="Curve")
223         sub1.itemR(edit, "duplicate_text", text="Text")
224         sub1.itemR(edit, "duplicate_metaball", text="Metaball")
225         sub1.itemR(edit, "duplicate_armature", text="Armature")
226         sub1.itemR(edit, "duplicate_lamp", text="Lamp")
227         sub1.itemR(edit, "duplicate_material", text="Material")
228         sub1.itemR(edit, "duplicate_texture", text="Texture")
229         sub1.itemR(edit, "duplicate_ipo", text="F-Curve")
230         sub1.itemR(edit, "duplicate_action", text="Action")
231         sub1.itemR(edit, "duplicate_particle", text="Particle")
232
233 class USERPREF_PT_system(bpy.types.Panel):
234     bl_space_type = 'USER_PREFERENCES'
235     bl_label = "System"
236     bl_region_type = 'WINDOW'
237     bl_show_header = False
238
239     def poll(self, context):
240         userpref = context.user_preferences
241         return (userpref.active_section == 'SYSTEM')
242
243     def draw(self, context):
244         layout = self.layout
245
246         userpref = context.user_preferences
247         system = userpref.system
248
249         split = layout.split()
250
251         col = split.column()
252         sub = col.split(percentage=0.9)
253
254         sub1 = sub.column()
255         sub1.itemL(text="General:")
256         sub1.itemR(system, "dpi")
257         sub1.itemR(system, "frame_server_port")
258         sub1.itemR(system, "scrollback", text="Console Scrollback")
259         sub1.itemR(system, "emulate_numpad")
260         sub1.itemR(system, "auto_run_python_scripts")
261
262         sub1.itemS()
263         sub1.itemS()
264         sub1.itemS()
265
266         sub1.itemL(text="Sound:")
267         sub1.row().itemR(system, "audio_device", expand=True)
268         sub2 = sub1.column()
269         sub2.active = system.audio_device != 'NONE'
270         sub2.itemR(system, "enable_all_codecs")
271         sub2.itemR(system, "game_sound")
272         sub2.itemR(system, "audio_channels", text="Channels")
273         sub2.itemR(system, "audio_mixing_buffer", text="Mixing Buffer")
274         sub2.itemR(system, "audio_sample_rate", text="Sample Rate")
275         sub2.itemR(system, "audio_sample_format", text="Sample Format")
276
277         col = split.column()
278         sub = col.split(percentage=0.9)
279
280         sub1 = sub .column()
281         sub1.itemL(text="Weight Colors:")
282         sub1.itemR(system, "use_weight_color_range", text="Use Custom Range")
283         sub2 = sub1.column()
284         sub2.active = system.use_weight_color_range
285         sub2.template_color_ramp(system, "weight_color_range", expand=True)
286
287         sub1.itemS()
288         sub1.itemS()
289         sub1.itemS()
290
291         sub1.itemR(system, "language")
292         sub1.itemL(text="Translate:")
293         sub1.itemR(system, "translate_tooltips", text="Tooltips")
294         sub1.itemR(system, "translate_buttons", text="Labels")
295         sub1.itemR(system, "translate_toolbox", text="Toolbox")
296
297         sub1.itemS()
298
299         sub1.itemR(system, "use_textured_fonts")
300
301         col = split.column()
302         sub = col.split(percentage=0.9)
303
304         sub1 = sub.column()
305
306         sub1.itemL(text="OpenGL:")
307         sub1.itemR(system, "clip_alpha", slider=True)
308         sub1.itemR(system, "use_mipmaps")
309         sub1.itemR(system, "use_vbos")
310         sub1.itemL(text="Window Draw Method:")
311         sub1.row().itemR(system, "window_draw_method", expand=True)
312         sub1.itemL(text="Textures:")
313         sub1.itemR(system, "gl_texture_limit", text="Limit Size")
314         sub1.itemR(system, "texture_time_out", text="Time Out")
315         sub1.itemR(system, "texture_collection_rate", text="Collection Rate")
316
317         sub1.itemS()
318         sub1.itemS()
319         sub1.itemS()
320
321         sub1.itemL(text="Sequencer:")
322         sub1.itemR(system, "prefetch_frames")
323         sub1.itemR(system, "memory_cache_limit")
324
325 class USERPREF_PT_file(bpy.types.Panel):
326     bl_space_type = 'USER_PREFERENCES'
327     bl_label = "Files"
328     bl_region_type = 'WINDOW'
329     bl_show_header = False
330
331     def poll(self, context):
332         userpref = context.user_preferences
333         return (userpref.active_section == 'FILES')
334
335     def draw(self, context):
336         layout = self.layout
337
338         userpref = context.user_preferences
339         paths = userpref.filepaths
340
341         split = layout.split(percentage=0.6)
342
343         col = split.column()
344         col.itemL(text="File Paths:")
345         sub = col.split(percentage=0.3)
346
347         sub.itemL(text="Fonts:")
348         sub.itemR(paths, "fonts_directory", text="")
349         sub = col.split(percentage=0.3)
350         sub.itemL(text="Textures:")
351         sub.itemR(paths, "textures_directory", text="")
352         sub = col.split(percentage=0.3)
353         sub.itemL(text="Texture Plugins:")
354         sub.itemR(paths, "texture_plugin_directory", text="")
355         sub = col.split(percentage=0.3)
356         sub.itemL(text="Sequence Plugins:")
357         sub.itemR(paths, "sequence_plugin_directory", text="")
358         sub = col.split(percentage=0.3)
359         sub.itemL(text="Render Output:")
360         sub.itemR(paths, "render_output_directory", text="")
361         sub = col.split(percentage=0.3)
362         sub.itemL(text="Scripts:")
363         sub.itemR(paths, "python_scripts_directory", text="")
364         sub = col.split(percentage=0.3)
365         sub.itemL(text="Sounds:")
366         sub.itemR(paths, "sounds_directory", text="")
367         sub = col.split(percentage=0.3)
368         sub.itemL(text="Temp:")
369         sub.itemR(paths, "temporary_directory", text="")
370
371         col = split.column()
372         sub = col.split(percentage=0.2)
373         sub1 = sub.column()
374         sub2 = sub.column()
375         sub2.itemL(text="Save & Load:")
376         sub2.itemR(paths, "use_relative_paths")
377         sub2.itemR(paths, "compress_file")
378         sub2.itemR(paths, "load_ui")
379         sub2.itemR(paths, "filter_file_extensions")
380         sub2.itemR(paths, "hide_dot_files_datablocks")
381         sub2.itemS()
382         sub2.itemS()
383         sub2.itemL(text="Auto Save:")
384         sub2.itemR(paths, "save_version")
385         sub2.itemR(paths, "recent_files")
386         sub2.itemR(paths, "save_preview_images")
387         sub2.itemR(paths, "auto_save_temporary_files")
388         sub3 = sub2.column()
389         sub3.enabled = paths.auto_save_temporary_files
390         sub3.itemR(paths, "auto_save_time", text="Timer (mins)")
391
392 class USERPREF_PT_input(bpy.types.Panel):
393     bl_space_type = 'USER_PREFERENCES'
394     bl_label = "Input"
395     bl_region_type = 'WINDOW'
396     bl_show_header = False
397
398     def poll(self, context):
399         userpref = context.user_preferences
400         return (userpref.active_section == 'INPUT')
401
402     def draw(self, context):
403         layout = self.layout
404
405         userpref = context.user_preferences
406         wm = context.manager
407         #input = userpref.input
408         input = userpref
409         inputs = userpref.inputs
410
411         split = layout.split(percentage=0.25)
412
413         # General settings
414         row = split.row()
415         col = row.column()
416
417         sub = col.column()
418         sub.itemL(text="Configuration:")
419         sub.item_pointerR(wm, "active_keyconfig", wm, "keyconfigs", text="")
420
421         col.itemS()
422
423         sub = col.column()
424         sub.itemL(text="Mouse:")
425         sub1 = sub.column()
426         sub1.enabled = (inputs.select_mouse == 'RIGHT')
427         sub1.itemR(inputs, "emulate_3_button_mouse")
428         sub.itemR(inputs, "continuous_mouse")
429
430         sub.itemL(text="Select With:")
431         sub.row().itemR(inputs, "select_mouse", expand=True)
432         sub.itemL(text="Middle Mouse:")
433         sub.row().itemR(inputs, "middle_mouse", expand=True)
434
435         sub.itemS()
436         sub.itemS()
437         sub.itemS()
438
439         sub.itemL(text="Orbit Style:")
440         sub.row().itemR(inputs, "view_rotation", expand=True)
441
442         sub.itemL(text="Zoom Style:")
443         sub.row().itemR(inputs, "viewport_zoom_style", expand=True)
444
445         #sub.itemR(inputs, "use_middle_mouse_paste")
446
447         #col.itemS()
448
449         #sub = col.column()
450         #sub.itemL(text="Mouse Wheel:")
451         #sub.itemR(view, "wheel_invert_zoom", text="Invert Zoom")
452         #sub.itemR(view, "wheel_scroll_lines", text="Scroll Lines")
453
454         col.itemS()
455
456         sub = col.column()
457         sub.itemL(text="NDOF Device:")
458         sub.itemR(inputs, "ndof_pan_speed", text="Pan Speed")
459         sub.itemR(inputs, "ndof_rotate_speed", text="Orbit Speed")
460
461         row.itemS()
462
463         # Keymap Settings
464         col = split.column()
465
466         kc = wm.active_keyconfig
467         defkc = wm.default_keyconfig
468         km = wm.active_keymap
469
470         subsplit = col.split()
471         subsplit.item_pointerR(wm, "active_keymap", defkc, "keymaps", text="Map:")
472         if km.user_defined:
473             row = subsplit.row()
474             row.itemO("WM_OT_keymap_restore", text="Restore")
475             row.item_booleanO("WM_OT_keymap_restore", "all", True, text="Restore All")
476         else:
477             row = subsplit.row()
478             row.itemO("WM_OT_keymap_edit", text="Edit")
479             row.itemL()
480
481         col.itemS()
482
483         for kmi in km.items:
484             subcol = col.column()
485             subcol.set_context_pointer("keyitem", kmi)
486
487             row = subcol.row()
488
489             if kmi.expanded:
490                 row.itemR(kmi, "expanded", text="", icon="ICON_TRIA_RIGHT")
491             else:
492                 row.itemR(kmi, "expanded", text="", icon="ICON_TRIA_RIGHT")
493
494             itemrow = row.row()
495             itemrow.enabled = km.user_defined
496             itemrow.itemR(kmi, "active", text="", icon="ICON_CHECKBOX_DEHLT")
497
498             itemcol = itemrow.column()
499             itemcol.active = kmi.active
500             row = itemcol.row()
501             row.itemR(kmi, "idname", text="")
502
503             sub = row.row()
504             sub.scale_x = 0.6
505             sub.itemR(kmi, "map_type", text="")
506
507             sub = row.row(align=True)
508             if kmi.map_type == 'KEYBOARD':
509                 sub.itemR(kmi, "type", text="", full_event=True)
510             elif kmi.map_type == 'MOUSE':
511                 sub.itemR(kmi, "type", text="", full_event=True)
512             elif kmi.map_type == 'TWEAK':
513                 sub.scale_x = 0.5
514                 sub.itemR(kmi, "type", text="")
515                 sub.itemR(kmi, "value", text="")
516             elif kmi.map_type == 'TIMER':
517                 sub.itemR(kmi, "type", text="")
518             else:
519                 sub.itemL()
520
521             if kmi.expanded:
522                 if kmi.map_type not in ('TEXTINPUT', 'TIMER'):
523                     sub = itemcol.row(align=True)
524
525                     if kmi.map_type == 'KEYBOARD':
526                         sub.itemR(kmi, "type", text="", event=True)
527                         sub.itemR(kmi, "value", text="")
528                     elif kmi.map_type == 'MOUSE':
529                         sub.itemR(kmi, "type", text="")
530                         sub.itemR(kmi, "value", text="")
531                     else:
532                         sub.itemL()
533                         sub.itemL()
534
535                     subrow = sub.row()
536                     subrow.scale_x = 0.75
537                     subrow.itemR(kmi, "shift")
538                     subrow.itemR(kmi, "ctrl")
539                     subrow.itemR(kmi, "alt")
540                     subrow.itemR(kmi, "oskey", text="Cmd")
541                     sub.itemR(kmi, "key_modifier", text="", event=True)
542
543                 flow = itemcol.column_flow(columns=2)
544                 props = kmi.properties
545
546                 if props != None:
547                     for pname in dir(props):
548                         if not props.is_property_hidden(pname):
549                             flow.itemR(props, pname)
550
551                 itemcol.itemS()
552
553             itemrow.itemO("wm.keyitem_remove", text="", icon="ICON_ZOOMOUT")
554
555         itemrow = col.row()
556         itemrow.itemL()
557         itemrow.itemO("wm.keyitem_add", text="", icon="ICON_ZOOMIN")
558         itemrow.enabled = km.user_defined
559
560 bpy.types.register(USERPREF_HT_header)
561 bpy.types.register(USERPREF_MT_view)
562 bpy.types.register(USERPREF_PT_tabs)
563 bpy.types.register(USERPREF_PT_interface)
564 bpy.types.register(USERPREF_PT_edit)
565 bpy.types.register(USERPREF_PT_system)
566 bpy.types.register(USERPREF_PT_file)
567 bpy.types.register(USERPREF_PT_input)
568
569 from bpy.props import *
570
571
572 class WM_OT_keyconfig_export(bpy.types.Operator):
573     "Export key configuration to a python script."
574     bl_idname = "wm.keyconfig_export"
575     bl_label = "Export Key Configuration..."
576
577     path = bpy.props.StringProperty(name="File Path", description="File path to write file to.")
578
579     def _string_value(self, value):
580         result = ""
581         if isinstance(value, str):
582             if value != "":
583                 result = "\'%s\'" % value
584         elif isinstance(value, bool):
585             if value:
586                 result = "True"
587             else:
588                 result = "False"
589         elif isinstance(value, float):
590             result = "%.10f" % value
591         elif isinstance(value, int):
592             result = "%d" % value
593         elif getattr(value, '__len__', False):
594             if len(value):
595                 result = "["
596                 for i in range(0, len(value)):
597                     result += self._string_value(value[i])
598                     if i != len(value)-1:
599                         result += ", "
600                 result += "]"
601         else:
602             print("Export key configuration: can't write ", value)
603
604         return result
605
606     def execute(self, context):
607         if not self.path:
608             raise Exception("File path not set.")
609
610         f = open(self.path, "w")
611         if not f:
612             raise Exception("Could not open file.")
613
614         wm = context.manager
615         kc = wm.active_keyconfig
616
617         f.write('# Configuration %s\n' % kc.name)
618
619         f.write("wm = bpy.data.windowmanagers[0]\n");
620         f.write("kc = wm.add_keyconfig(\'%s\')\n\n" % kc.name)
621
622         for km in kc.keymaps:
623             f.write("# Map %s\n" % km.name)
624             f.write("km = kc.add_keymap(\'%s\', space_type=\'%s\', region_type=\'%s\')\n\n" % (km.name, km.space_type, km.region_type))
625             for kmi in km.items:
626                 f.write("kmi = km.add_item(\'%s\', \'%s\', \'%s\'" % (kmi.idname, kmi.type, kmi.value))
627                 if kmi.shift:
628                     f.write(", shift=True")
629                 if kmi.ctrl:
630                     f.write(", ctrl=True")
631                 if kmi.alt:
632                     f.write(", alt=True")
633                 if kmi.oskey:
634                     f.write(", oskey=True")
635                 if kmi.key_modifier and kmi.key_modifier != 'NONE':
636                     f.write(", key_modifier=\'%s\'" % kmi.key_modifier)
637                 f.write(")\n")
638
639                 props = kmi.properties
640
641                 if props != None:
642                     for pname in dir(props):
643                         if props.is_property_set(pname) and not props.is_property_hidden(pname):
644                             value = eval("props.%s" % pname)
645                             value = self._string_value(value)
646                             if value != "":
647                                 f.write("kmi.properties.%s = %s\n" % (pname, value))
648
649             f.write("\n")
650
651         f.close()
652
653         return ('FINISHED',)
654
655     def invoke(self, context, event):
656         wm = context.manager
657         wm.add_fileselect(self.__operator__)
658         return ('RUNNING_MODAL',)
659
660 class WM_OT_keymap_edit(bpy.types.Operator):
661     "Edit key map."
662     bl_idname = "wm.keymap_edit"
663     bl_label = "Edit Key Map"
664
665     def execute(self, context):
666         wm = context.manager
667         km = wm.active_keymap
668         km.copy_to_user()
669         return ('FINISHED',)
670
671 class WM_OT_keymap_restore(bpy.types.Operator):
672     "Restore key map"
673     bl_idname = "wm.keymap_restore"
674     bl_label = "Restore Key Map"
675
676     all = BoolProperty(attr="all", name="All Keymaps", description="Restore all keymaps to default.")
677
678     def execute(self, context):
679         wm = context.manager
680
681         if self.all:
682             for km in wm.default_keyconfig.keymaps:
683                 km.restore_to_default()
684         else:
685             km = wm.active_keymap
686             km.restore_to_default()
687
688         return ('FINISHED',)
689
690 class WM_OT_keyitem_add(bpy.types.Operator):
691     "Add key map item."
692     bl_idname = "wm.keyitem_add"
693     bl_label = "Add Key Map Item"
694
695     def execute(self, context):
696         wm = context.manager
697         km = wm.active_keymap
698         kmi = km.add_item("", "A", "PRESS")
699         return ('FINISHED',)
700
701 class WM_OT_keyitem_remove(bpy.types.Operator):
702     "Remove key map item."
703     bl_idname = "wm.keyitem_remove"
704     bl_label = "Remove Key Map Item"
705
706     def execute(self, context):
707         wm = context.manager
708         kmi = context.keyitem
709         km = wm.active_keymap
710         km.remove_item(kmi)
711         return ('FINISHED',)
712
713 bpy.ops.add(WM_OT_keyconfig_export)
714 bpy.ops.add(WM_OT_keymap_edit)
715 bpy.ops.add(WM_OT_keymap_restore)
716 bpy.ops.add(WM_OT_keyitem_add)
717 bpy.ops.add(WM_OT_keyitem_remove)
718