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