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