COLLADA branch: merge from trunk -r 24522:24758.
[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.item_stringO("wm.keyconfig_export", "path", "keymap.py", "Export Key Configuration...")
38
39
40 class USERPREF_MT_view(bpy.types.Menu):
41     bl_label = "View"
42
43     def draw(self, context):
44         pass # layout = self.layout
45
46
47 class USERPREF_PT_tabs(bpy.types.Panel):
48     bl_label = ""
49     bl_space_type = 'USER_PREFERENCES'
50     bl_region_type = 'WINDOW'
51     bl_show_header = False
52
53     def draw(self, context):
54         layout = self.layout
55
56         userpref = context.user_preferences
57
58         layout.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, "button")
375             col.itemR(v3d, "button_title")
376             col.itemR(v3d, "button_text")
377             col.itemR(v3d, "header")
378
379             col = split.column()
380             col.itemR(v3d, "grid")
381             col.itemR(v3d, "wire")
382             col.itemR(v3d, "lamp", slider=True)
383             col.itemR(v3d, "editmesh_active", slider=True)
384
385             col = split.column()
386
387             col.itemR(v3d, "object_selected")
388             col.itemR(v3d, "object_active")
389             col.itemR(v3d, "object_grouped")
390             col.itemR(v3d, "object_grouped_active")
391             col.itemR(v3d, "transform")
392
393             col = split.column()
394             col.itemR(v3d, "vertex")
395             col.itemR(v3d, "face", slider=True)
396             col.itemR(v3d, "normal")
397             col.itemR(v3d, "bone_solid")
398             col.itemR(v3d, "bone_pose")
399
400 #           col.itemR(v3d, "edge") Doesn't seem to work
401         elif theme.active_theme == 'USER_INTERFACE':
402
403             ui = theme.user_interface.wcol_regular
404
405             layout.itemL(text="Regular:")
406
407             sub = layout.row()
408             sub1 = sub.column()
409             sub1.itemR(ui, "outline")
410             sub1.itemR(ui, "item", slider=True)
411             sub1 = sub.column()
412             sub1.itemR(ui, "inner", slider=True)
413             sub1.itemR(ui, "inner_sel", slider=True)
414             sub1 = sub.column()
415             sub1.itemR(ui, "text")
416             sub1.itemR(ui, "text_sel")
417             sub1 = sub.column()
418             sub1.itemR(ui, "shaded")
419             sub2 = sub1.column(align=True)
420             sub2.active = ui.shaded
421             sub2.itemR(ui, "shadetop")
422             sub2.itemR(ui, "shadedown")
423             layout.itemS()
424
425             ui = theme.user_interface.wcol_tool
426             layout.itemL(text="Tool:")
427
428             sub = layout.row()
429             sub1 = sub.column()
430             sub1.itemR(ui, "outline")
431             sub1.itemR(ui, "item", slider=True)
432             sub1 = sub.column()
433             sub1.itemR(ui, "inner", slider=True)
434             sub1.itemR(ui, "inner_sel", slider=True)
435             sub1 = sub.column()
436             sub1.itemR(ui, "text")
437             sub1.itemR(ui, "text_sel")
438             sub1 = sub.column()
439             sub1.itemR(ui, "shaded")
440             sub2 = sub1.column(align=True)
441             sub2.active = ui.shaded
442             sub2.itemR(ui, "shadetop")
443             sub2.itemR(ui, "shadedown")
444
445             ui = theme.user_interface.wcol_radio
446             layout.itemL(text="Radio Buttons:")
447
448             sub = layout.row()
449             sub1 = sub.column()
450             sub1.itemR(ui, "outline")
451             sub1.itemR(ui, "item", slider=True)
452             sub1 = sub.column()
453             sub1.itemR(ui, "inner", slider=True)
454             sub1.itemR(ui, "inner_sel", slider=True)
455             sub1 = sub.column()
456             sub1.itemR(ui, "text")
457             sub1.itemR(ui, "text_sel")
458             sub1 = sub.column()
459             sub1.itemR(ui, "shaded")
460             sub2 = sub1.column(align=True)
461             sub2.active = ui.shaded
462             sub2.itemR(ui, "shadetop")
463             sub2.itemR(ui, "shadedown")
464
465             ui = theme.user_interface.wcol_text
466             layout.itemL(text="Text:")
467
468             sub = layout.row()
469             sub1 = sub.column()
470             sub1.itemR(ui, "outline")
471             sub1.itemR(ui, "item", slider=True)
472             sub1 = sub.column()
473             sub1.itemR(ui, "inner", slider=True)
474             sub1.itemR(ui, "inner_sel", slider=True)
475             sub1 = sub.column()
476             sub1.itemR(ui, "text")
477             sub1.itemR(ui, "text_sel")
478             sub1 = sub.column()
479             sub1.itemR(ui, "shaded")
480             sub2 = sub1.column(align=True)
481             sub2.active = ui.shaded
482             sub2.itemR(ui, "shadetop")
483             sub2.itemR(ui, "shadedown")
484
485             ui = theme.user_interface.wcol_option
486             layout.itemL(text="Option:")
487
488             sub = layout.row()
489             sub1 = sub.column()
490             sub1.itemR(ui, "outline")
491             sub1.itemR(ui, "item", slider=True)
492             sub1 = sub.column()
493             sub1.itemR(ui, "inner", slider=True)
494             sub1.itemR(ui, "inner_sel", slider=True)
495             sub1 = sub.column()
496             sub1.itemR(ui, "text")
497             sub1.itemR(ui, "text_sel")
498             sub1 = sub.column()
499             sub1.itemR(ui, "shaded")
500             sub2 = sub1.column(align=True)
501             sub2.active = ui.shaded
502             sub2.itemR(ui, "shadetop")
503             sub2.itemR(ui, "shadedown")
504
505             ui = theme.user_interface.wcol_toggle
506             layout.itemL(text="Toggle:")
507
508             sub = layout.row()
509             sub1 = sub.column()
510             sub1.itemR(ui, "outline")
511             sub1.itemR(ui, "item", slider=True)
512             sub1 = sub.column()
513             sub1.itemR(ui, "inner", slider=True)
514             sub1.itemR(ui, "inner_sel", slider=True)
515             sub1 = sub.column()
516             sub1.itemR(ui, "text")
517             sub1.itemR(ui, "text_sel")
518             sub1 = sub.column()
519             sub1.itemR(ui, "shaded")
520             sub2 = sub1.column(align=True)
521             sub2.active = ui.shaded
522             sub2.itemR(ui, "shadetop")
523             sub2.itemR(ui, "shadedown")
524
525             ui = theme.user_interface.wcol_num
526             layout.itemL(text="Number Field:")
527
528             sub = layout.row()
529             sub1 = sub.column()
530             sub1.itemR(ui, "outline")
531             sub1.itemR(ui, "item", slider=True)
532             sub1 = sub.column()
533             sub1.itemR(ui, "inner", slider=True)
534             sub1.itemR(ui, "inner_sel", slider=True)
535             sub1 = sub.column()
536             sub1.itemR(ui, "text")
537             sub1.itemR(ui, "text_sel")
538             sub1 = sub.column()
539             sub1.itemR(ui, "shaded")
540             sub2 = sub1.column(align=True)
541             sub2.active = ui.shaded
542             sub2.itemR(ui, "shadetop")
543             sub2.itemR(ui, "shadedown")
544
545             ui = theme.user_interface.wcol_numslider
546             layout.itemL(text="Value Slider:")
547
548             sub = layout.row()
549             sub1 = sub.column()
550             sub1.itemR(ui, "outline")
551             sub1.itemR(ui, "item", slider=True)
552             sub1 = sub.column()
553             sub1.itemR(ui, "inner", slider=True)
554             sub1.itemR(ui, "inner_sel", slider=True)
555             sub1 = sub.column()
556             sub1.itemR(ui, "text")
557             sub1.itemR(ui, "text_sel")
558             sub1 = sub.column()
559             sub1.itemR(ui, "shaded")
560             sub2 = sub1.column(align=True)
561             sub2.active = ui.shaded
562             sub2.itemR(ui, "shadetop")
563             sub2.itemR(ui, "shadedown")
564
565             ui = theme.user_interface.wcol_box
566             layout.itemL(text="Box:")
567
568             sub = layout.row()
569             sub1 = sub.column()
570             sub1.itemR(ui, "outline")
571             sub1.itemR(ui, "item", slider=True)
572             sub1 = sub.column()
573             sub1.itemR(ui, "inner", slider=True)
574             sub1.itemR(ui, "inner_sel", slider=True)
575             sub1 = sub.column()
576             sub1.itemR(ui, "text")
577             sub1.itemR(ui, "text_sel")
578             sub1 = sub.column()
579             sub1.itemR(ui, "shaded")
580             sub2 = sub1.column(align=True)
581             sub2.active = ui.shaded
582             sub2.itemR(ui, "shadetop")
583             sub2.itemR(ui, "shadedown")
584
585             ui = theme.user_interface.wcol_menu
586             layout.itemL(text="Menu:")
587
588             sub = layout.row()
589             sub1 = sub.column()
590             sub1.itemR(ui, "outline")
591             sub1.itemR(ui, "item", slider=True)
592             sub1 = sub.column()
593             sub1.itemR(ui, "inner", slider=True)
594             sub1.itemR(ui, "inner_sel", slider=True)
595             sub1 = sub.column()
596             sub1.itemR(ui, "text")
597             sub1.itemR(ui, "text_sel")
598             sub1 = sub.column()
599             sub1.itemR(ui, "shaded")
600             sub2 = sub1.column(align=True)
601             sub2.active = ui.shaded
602             sub2.itemR(ui, "shadetop")
603             sub2.itemR(ui, "shadedown")
604
605             ui = theme.user_interface.wcol_pulldown
606             layout.itemL(text="Pulldown:")
607
608             sub = layout.row()
609             sub1 = sub.column()
610             sub1.itemR(ui, "outline")
611             sub1.itemR(ui, "item", slider=True)
612             sub1 = sub.column()
613             sub1.itemR(ui, "inner", slider=True)
614             sub1.itemR(ui, "inner_sel", slider=True)
615             sub1 = sub.column()
616             sub1.itemR(ui, "text")
617             sub1.itemR(ui, "text_sel")
618             sub1 = sub.column()
619             sub1.itemR(ui, "shaded")
620             sub2 = sub1.column(align=True)
621             sub2.active = ui.shaded
622             sub2.itemR(ui, "shadetop")
623             sub2.itemR(ui, "shadedown")
624
625             ui = theme.user_interface.wcol_menu_back
626             layout.itemL(text="Menu Back:")
627
628             sub = layout.row()
629             sub1 = sub.column()
630             sub1.itemR(ui, "outline")
631             sub1.itemR(ui, "item", slider=True)
632             sub1 = sub.column()
633             sub1.itemR(ui, "inner", slider=True)
634             sub1.itemR(ui, "inner_sel", slider=True)
635             sub1 = sub.column()
636             sub1.itemR(ui, "text")
637             sub1.itemR(ui, "text_sel")
638             sub1 = sub.column()
639             sub1.itemR(ui, "shaded")
640             sub2 = sub1.column(align=True)
641             sub2.active = ui.shaded
642             sub2.itemR(ui, "shadetop")
643             sub2.itemR(ui, "shadedown")
644
645             ui = theme.user_interface.wcol_menu_item
646             layout.itemL(text="Menu Item:")
647
648             sub = layout.row()
649             sub1 = sub.column()
650             sub1.itemR(ui, "outline")
651             sub1.itemR(ui, "item", slider=True)
652             sub1 = sub.column()
653             sub1.itemR(ui, "inner", slider=True)
654             sub1.itemR(ui, "inner_sel", slider=True)
655             sub1 = sub.column()
656             sub1.itemR(ui, "text")
657             sub1.itemR(ui, "text_sel")
658             sub1 = sub.column()
659             sub1.itemR(ui, "shaded")
660             sub2 = sub1.column(align=True)
661             sub2.active = ui.shaded
662             sub2.itemR(ui, "shadetop")
663             sub2.itemR(ui, "shadedown")
664
665             ui = theme.user_interface.wcol_scroll
666             layout.itemL(text="Scroll Bar:")
667
668             sub = layout.row()
669             sub1 = sub.column()
670             sub1.itemR(ui, "outline")
671             sub1.itemR(ui, "item", slider=True)
672             sub1 = sub.column()
673             sub1.itemR(ui, "inner", slider=True)
674             sub1.itemR(ui, "inner_sel", slider=True)
675             sub1 = sub.column()
676             sub1.itemR(ui, "text")
677             sub1.itemR(ui, "text_sel")
678             sub1 = sub.column()
679             sub1.itemR(ui, "shaded")
680             sub2 = sub1.column(align=True)
681             sub2.active = ui.shaded
682             sub2.itemR(ui, "shadetop")
683             sub2.itemR(ui, "shadedown")
684
685             ui = theme.user_interface.wcol_list_item
686             layout.itemL(text="List Item:")
687
688             sub = layout.row()
689             sub1 = sub.column()
690             sub1.itemR(ui, "outline")
691             sub1.itemR(ui, "item", slider=True)
692             sub1 = sub.column()
693             sub1.itemR(ui, "inner", slider=True)
694             sub1.itemR(ui, "inner_sel", slider=True)
695             sub1 = sub.column()
696             sub1.itemR(ui, "text")
697             sub1.itemR(ui, "text_sel")
698             sub1 = sub.column()
699             sub1.itemR(ui, "shaded")
700             sub2 = sub1.column(align=True)
701             sub2.active = ui.shaded
702             sub2.itemR(ui, "shadetop")
703             sub2.itemR(ui, "shadedown")
704
705             ui = theme.user_interface.wcol_state
706             layout.itemL(text="State:")
707
708             sub = layout.row()
709             sub1 = sub.column()
710             sub1.itemR(ui, "inner_anim")
711             sub1.itemR(ui, "inner_anim_sel")
712             sub1 = sub.column()
713             sub1.itemR(ui, "inner_driven")
714             sub1.itemR(ui, "inner_driven_sel")
715             sub1 = sub.column()
716             sub1.itemR(ui, "inner_key")
717             sub1.itemR(ui, "inner_key_sel")
718             sub1 = sub.column()
719             sub1.itemR(ui, "blend")
720
721             ui = theme.user_interface
722             layout.itemS()
723
724             sub = layout.row()
725             sub.itemR(ui, "icon_file")
726
727             layout.itemS()
728             layout.itemS()
729
730
731         elif theme.active_theme == 'GRAPH_EDITOR':
732             graph = theme.graph_editor
733
734             col = split.column()
735             col.itemR(graph, "back")
736             col.itemR(graph, "button")
737             col.itemR(graph, "button_title")
738             col.itemR(graph, "button_text")
739
740             col = split.column()
741             col.itemR(graph, "header")
742             col.itemR(graph, "grid")
743             col.itemR(graph, "list")
744             col.itemR(graph, "channel_group")
745
746             col = split.column()
747             col.itemR(graph, "active_channels_group")
748             col.itemR(graph, "dopesheet_channel")
749             col.itemR(graph, "dopesheet_subchannel")
750             col.itemR(graph, "vertex")
751
752             col = split.column()
753             col.itemR(graph, "current_frame")
754             col.itemR(graph, "handle_vertex")
755             col.itemR(graph, "handle_vertex_select")
756             col.itemS()
757             col.itemR(graph, "handle_vertex_size")
758
759         elif theme.active_theme == 'FILE_BROWSER':
760             file_browse = theme.file_browser
761
762             col = split.column()
763             col.itemR(file_browse, "back")
764             col.itemR(file_browse, "text")
765             col.itemR(file_browse, "text_hi")
766
767             col = split.column()
768             col.itemR(file_browse, "header")
769             col.itemR(file_browse, "list")
770
771             col = split.column()
772             col.itemR(file_browse, "selected_file")
773             col.itemR(file_browse, "tiles")
774
775             col = split.column()
776             col.itemR(file_browse, "active_file")
777             col.itemR(file_browse, "active_file_text")
778
779         elif theme.active_theme == 'NLA_EDITOR':
780             nla = theme.nla_editor
781
782             col = split.column()
783             col.itemR(nla, "back")
784             col.itemR(nla, "button")
785             col.itemR(nla, "button_title")
786
787             col = split.column()
788             col.itemR(nla, "button_text")
789             col.itemR(nla, "text")
790             col.itemR(nla, "header")
791
792             col = split.column()
793             col.itemR(nla, "grid")
794             col.itemR(nla, "bars")
795             col.itemR(nla, "bars_selected")
796
797             col = split.column()
798             col.itemR(nla, "strips")
799             col.itemR(nla, "strips_selected")
800             col.itemR(nla, "current_frame")
801
802         elif theme.active_theme == 'DOPESHEET_EDITOR':
803             dope = theme.dopesheet_editor
804
805             col = split.column()
806             col.itemR(dope, "back")
807             col.itemR(dope, "list")
808             col.itemR(dope, "text")
809             col.itemR(dope, "header")
810
811             col = split.column()
812             col.itemR(dope, "grid")
813             col.itemR(dope, "channels")
814             col.itemR(dope, "channels_selected")
815             col.itemR(dope, "channel_group")
816
817             col = split.column()
818             col.itemR(dope, "active_channels_group")
819             col.itemR(dope, "long_key")
820             col.itemR(dope, "long_key_selected")
821
822             col = split.column()
823             col.itemR(dope, "current_frame")
824             col.itemR(dope, "dopesheet_channel")
825             col.itemR(dope, "dopesheet_subchannel")
826
827         elif theme.active_theme == 'IMAGE_EDITOR':
828             image = theme.image_editor
829
830             col = split.column()
831             col.itemR(image, "back")
832             col.itemR(image, "button")
833
834             col = split.column()
835             col.itemR(image, "button_title")
836             col.itemR(image, "button_text")
837
838             col = split.column()
839             col.itemR(image, "header")
840
841             col = split.column()
842             col.itemR(image, "editmesh_active", slider=True)
843
844         elif theme.active_theme == 'SEQUENCE_EDITOR':
845             seq = theme.sequence_editor
846
847             col = split.column()
848             col.itemR(seq, "back")
849             col.itemR(seq, "button")
850             col.itemR(seq, "button_title")
851             col.itemR(seq, "button_text")
852             col.itemR(seq, "text")
853
854             col = split.column()
855             col.itemR(seq, "header")
856             col.itemR(seq, "grid")
857             col.itemR(seq, "movie_strip")
858             col.itemR(seq, "image_strip")
859             col.itemR(seq, "scene_strip")
860
861             col = split.column()
862             col.itemR(seq, "audio_strip")
863             col.itemR(seq, "effect_strip")
864             col.itemR(seq, "plugin_strip")
865             col.itemR(seq, "transition_strip")
866
867             col = split.column()
868             col.itemR(seq, "meta_strip")
869             col.itemR(seq, "current_frame")
870             col.itemR(seq, "keyframe")
871             col.itemR(seq, "draw_action")
872
873         elif theme.active_theme == 'PROPERTIES':
874             prop = theme.properties
875
876             col = split.column()
877             col.itemR(prop, "back")
878
879             col = split.column()
880             col.itemR(prop, "title")
881
882             col = split.column()
883             col.itemR(prop, "text")
884
885             col = split.column()
886             col.itemR(prop, "header")
887
888         elif theme.active_theme == 'TEXT_EDITOR':
889             text = theme.text_editor
890
891             col = split.column()
892             col.itemR(text, "back")
893             col.itemR(text, "button")
894             col.itemR(text, "button_title")
895             col.itemR(text, "button_text")
896
897             col = split.column()
898             col.itemR(text, "text")
899             col.itemR(text, "text_hi")
900             col.itemR(text, "header")
901             col.itemR(text, "line_numbers_background")
902
903             col = split.column()
904             col.itemR(text, "selected_text")
905             col.itemR(text, "cursor")
906             col.itemR(text, "syntax_builtin")
907             col.itemR(text, "syntax_special")
908
909             col = split.column()
910             col.itemR(text, "syntax_comment")
911             col.itemR(text, "syntax_string")
912             col.itemR(text, "syntax_numbers")
913
914         elif theme.active_theme == 'TIMELINE':
915             time = theme.timeline
916
917             col = split.column()
918             col.itemR(time, "back")
919             col.itemR(time, "text")
920
921             col = split.column()
922             col.itemR(time, "header")
923
924             col = split.column()
925             col.itemR(time, "grid")
926
927             col = split.column()
928             col.itemR(time, "current_frame")
929
930         elif theme.active_theme == 'NODE_EDITOR':
931             node = theme.node_editor
932
933             col = split.column()
934             col.itemR(node, "back")
935             col.itemR(node, "button")
936             col.itemR(node, "button_title")
937             col.itemR(node, "button_text")
938
939
940             col = split.column()
941             col.itemR(node, "text")
942             col.itemR(node, "text_hi")
943             col.itemR(node, "header")
944             col.itemR(node, "wires")
945
946             col = split.column()
947             col.itemR(node, "wire_select")
948             col.itemR(node, "selected_text")
949             col.itemR(node, "node_backdrop", slider=True)
950             col.itemR(node, "in_out_node")
951
952             col = split.column()
953             col.itemR(node, "converter_node")
954             col.itemR(node, "operator_node")
955             col.itemR(node, "group_node")
956
957         elif theme.active_theme == 'LOGIC_EDITOR':
958             logic = theme.logic_editor
959
960             col = split.column()
961             col.itemR(logic, "back")
962             col.itemR(logic, "button")
963
964             col = split.column()
965             col.itemR(logic, "button_title")
966             col.itemR(logic, "button_text")
967
968             col = split.column()
969             col.itemR(logic, "text")
970             col.itemR(logic, "header")
971
972             col = split.column()
973             col.itemR(logic, "panel")
974
975         elif theme.active_theme == 'OUTLINER':
976             out = theme.outliner
977
978             col = split.column()
979             col.itemR(out, "back")
980
981             col = split.column()
982             col.itemR(out, "text")
983
984             col = split.column()
985             col.itemR(out, "text_hi")
986
987             col = split.column()
988             col.itemR(out, "header")
989
990         elif theme.active_theme == 'INFO':
991             info = theme.info
992
993             col = split.column()
994             col.itemR(info, "back")
995
996             col = split.column()
997             col.itemR(info, "header")
998
999             col = split.column()
1000             col.itemR(info, "header_text")
1001
1002             col = split.column()
1003
1004         elif theme.active_theme == 'USER_PREFERENCES':
1005             prefs = theme.user_preferences
1006
1007             col = split.column()
1008             col.itemR(prefs, "back")
1009
1010             col = split.column()
1011             col.itemR(prefs, "text")
1012
1013             col = split.column()
1014             col.itemR(prefs, "header")
1015
1016             col = split.column()
1017             col.itemR(prefs, "header_text")
1018
1019
1020 class USERPREF_PT_file(bpy.types.Panel):
1021     bl_space_type = 'USER_PREFERENCES'
1022     bl_label = "Files"
1023     bl_region_type = 'WINDOW'
1024     bl_show_header = False
1025
1026     def poll(self, context):
1027         userpref = context.user_preferences
1028         return (userpref.active_section == 'FILES')
1029
1030     def draw(self, context):
1031         layout = self.layout
1032
1033         userpref = context.user_preferences
1034         paths = userpref.filepaths
1035
1036         split = layout.split(percentage=0.6)
1037
1038         col = split.column()
1039         col.itemL(text="File Paths:")
1040         sub = col.split(percentage=0.3)
1041
1042         sub.itemL(text="Fonts:")
1043         sub.itemR(paths, "fonts_directory", text="")
1044         sub = col.split(percentage=0.3)
1045         sub.itemL(text="Textures:")
1046         sub.itemR(paths, "textures_directory", text="")
1047         sub = col.split(percentage=0.3)
1048         sub.itemL(text="Texture Plugins:")
1049         sub.itemR(paths, "texture_plugin_directory", text="")
1050         sub = col.split(percentage=0.3)
1051         sub.itemL(text="Sequence Plugins:")
1052         sub.itemR(paths, "sequence_plugin_directory", text="")
1053         sub = col.split(percentage=0.3)
1054         sub.itemL(text="Render Output:")
1055         sub.itemR(paths, "render_output_directory", text="")
1056         sub = col.split(percentage=0.3)
1057         sub.itemL(text="Scripts:")
1058         sub.itemR(paths, "python_scripts_directory", text="")
1059         sub = col.split(percentage=0.3)
1060         sub.itemL(text="Sounds:")
1061         sub.itemR(paths, "sounds_directory", text="")
1062         sub = col.split(percentage=0.3)
1063         sub.itemL(text="Temp:")
1064         sub.itemR(paths, "temporary_directory", text="")
1065
1066         col = split.column()
1067         sub = col.split(percentage=0.2)
1068         sub.column() # sub1, unused
1069         sub2 = sub.column()
1070         sub2.itemL(text="Save & Load:")
1071         sub2.itemR(paths, "use_relative_paths")
1072         sub2.itemR(paths, "compress_file")
1073         sub2.itemR(paths, "load_ui")
1074         sub2.itemR(paths, "filter_file_extensions")
1075         sub2.itemR(paths, "hide_dot_files_datablocks")
1076         sub2.itemS()
1077         sub2.itemS()
1078         sub2.itemL(text="Auto Save:")
1079         sub2.itemR(paths, "save_version")
1080         sub2.itemR(paths, "recent_files")
1081         sub2.itemR(paths, "save_preview_images")
1082         sub2.itemR(paths, "auto_save_temporary_files")
1083         sub3 = sub2.column()
1084         sub3.enabled = paths.auto_save_temporary_files
1085         sub3.itemR(paths, "auto_save_time", text="Timer (mins)")
1086
1087
1088 class USERPREF_PT_input(bpy.types.Panel):
1089     bl_space_type = 'USER_PREFERENCES'
1090     bl_label = "Input"
1091     bl_region_type = 'WINDOW'
1092     bl_show_header = False
1093
1094     def poll(self, context):
1095         userpref = context.user_preferences
1096         return (userpref.active_section == 'INPUT')
1097
1098     def draw(self, context):
1099         layout = self.layout
1100
1101         userpref = context.user_preferences
1102         wm = context.manager
1103         #input = userpref.input
1104         #input = userpref
1105         inputs = userpref.inputs
1106
1107         split = layout.split(percentage=0.25)
1108
1109         # General settings
1110         row = split.row()
1111         col = row.column()
1112
1113         sub = col.column()
1114         sub.itemL(text="Configuration:")
1115         sub.item_pointerR(wm, "active_keyconfig", wm, "keyconfigs", text="")
1116
1117         col.itemS()
1118
1119         sub = col.column()
1120         sub.itemL(text="Mouse:")
1121         sub1 = sub.column()
1122         sub1.enabled = (inputs.select_mouse == 'RIGHT')
1123         sub1.itemR(inputs, "emulate_3_button_mouse")
1124         sub.itemR(inputs, "continuous_mouse")
1125
1126         sub.itemL(text="Select With:")
1127         sub.row().itemR(inputs, "select_mouse", expand=True)
1128         sub.itemL(text="Middle Mouse:")
1129         sub.row().itemR(inputs, "middle_mouse", expand=True)
1130
1131         sub.itemS()
1132         sub.itemS()
1133         sub.itemS()
1134
1135         sub.itemL(text="Orbit Style:")
1136         sub.row().itemR(inputs, "view_rotation", expand=True)
1137
1138         sub.itemL(text="Zoom Style:")
1139         sub.row().itemR(inputs, "viewport_zoom_style", expand=True)
1140
1141         #sub.itemR(inputs, "use_middle_mouse_paste")
1142
1143         #col.itemS()
1144
1145         #sub = col.column()
1146         #sub.itemL(text="Mouse Wheel:")
1147         #sub.itemR(view, "wheel_invert_zoom", text="Invert Zoom")
1148         #sub.itemR(view, "wheel_scroll_lines", text="Scroll Lines")
1149
1150         col.itemS()
1151
1152         sub = col.column()
1153         sub.itemL(text="NDOF Device:")
1154         sub.itemR(inputs, "ndof_pan_speed", text="Pan Speed")
1155         sub.itemR(inputs, "ndof_rotate_speed", text="Orbit Speed")
1156
1157         row.itemS()
1158
1159         # Keymap Settings
1160         col = split.column()
1161
1162         # kc = wm.active_keyconfig
1163         defkc = wm.default_keyconfig
1164         km = wm.active_keymap
1165
1166         subsplit = col.split()
1167         subsplit.item_pointerR(wm, "active_keymap", defkc, "keymaps", text="Map:")
1168         if km.user_defined:
1169             row = subsplit.row()
1170             row.itemO("WM_OT_keymap_restore", text="Restore")
1171             row.item_booleanO("WM_OT_keymap_restore", "all", True, text="Restore All")
1172         else:
1173             row = subsplit.row()
1174             row.itemO("WM_OT_keymap_edit", text="Edit")
1175             row.itemL()
1176
1177         col.itemS()
1178
1179         for kmi in km.items:
1180             subcol = col.column()
1181             subcol.set_context_pointer("keyitem", kmi)
1182
1183             row = subcol.row()
1184
1185             if kmi.expanded:
1186                 row.itemR(kmi, "expanded", text="", icon='ICON_TRIA_DOWN')
1187             else:
1188                 row.itemR(kmi, "expanded", text="", icon='ICON_TRIA_RIGHT')
1189
1190             itemrow = row.row()
1191             itemrow.enabled = km.user_defined
1192             if kmi.active:
1193                 itemrow.itemR(kmi, "active", text="", icon='ICON_CHECKBOX_HLT')
1194             else:
1195                 itemrow.itemR(kmi, "active", text="", icon='ICON_CHECKBOX_DEHLT')
1196
1197             itemcol = itemrow.column()
1198             itemcol.active = kmi.active
1199             row = itemcol.row()
1200
1201             if km.modal:
1202                 row.itemR(kmi, "propvalue", text="")
1203             else:
1204                 row.itemR(kmi, "idname", text="")
1205
1206             sub = row.row()
1207             sub.scale_x = 0.6
1208             sub.itemR(kmi, "map_type", text="")
1209
1210             sub = row.row(align=True)
1211             if kmi.map_type == 'KEYBOARD':
1212                 sub.itemR(kmi, "type", text="", full_event=True)
1213             elif kmi.map_type == 'MOUSE':
1214                 sub.itemR(kmi, "type", text="", full_event=True)
1215             elif kmi.map_type == 'TWEAK':
1216                 sub.scale_x = 0.5
1217                 sub.itemR(kmi, "type", text="")
1218                 sub.itemR(kmi, "value", text="")
1219             elif kmi.map_type == 'TIMER':
1220                 sub.itemR(kmi, "type", text="")
1221             else:
1222                 sub.itemL()
1223
1224             if kmi.expanded:
1225                 if kmi.map_type not in ('TEXTINPUT', 'TIMER'):
1226                     sub = itemcol.row(align=True)
1227
1228                     if kmi.map_type == 'KEYBOARD':
1229                         sub.itemR(kmi, "type", text="", event=True)
1230                         sub.itemR(kmi, "value", text="")
1231                     elif kmi.map_type == 'MOUSE':
1232                         sub.itemR(kmi, "type", text="")
1233                         sub.itemR(kmi, "value", text="")
1234                     else:
1235                         sub.itemL()
1236                         sub.itemL()
1237
1238                     subrow = sub.row()
1239                     subrow.scale_x = 0.75
1240                     subrow.itemR(kmi, "any")
1241                     subrow.itemR(kmi, "shift")
1242                     subrow.itemR(kmi, "ctrl")
1243                     subrow.itemR(kmi, "alt")
1244                     subrow.itemR(kmi, "oskey", text="Cmd")
1245                     sub.itemR(kmi, "key_modifier", text="", event=True)
1246
1247                 flow = itemcol.column_flow(columns=2)
1248                 props = kmi.properties
1249
1250                 if props != None:
1251                     for pname in dir(props):
1252                         if not props.is_property_hidden(pname):
1253                             flow.itemR(props, pname)
1254
1255                 itemcol.itemS()
1256
1257             itemrow.itemO("wm.keyitem_remove", text="", icon='ICON_ZOOMOUT')
1258
1259         itemrow = col.row()
1260         itemrow.itemL()
1261         itemrow.itemO("wm.keyitem_add", text="", icon='ICON_ZOOMIN')
1262         itemrow.enabled = km.user_defined
1263
1264 bpy.types.register(USERPREF_HT_header)
1265 bpy.types.register(USERPREF_MT_view)
1266 bpy.types.register(USERPREF_PT_tabs)
1267 bpy.types.register(USERPREF_PT_interface)
1268 bpy.types.register(USERPREF_PT_theme)
1269 bpy.types.register(USERPREF_PT_edit)
1270 bpy.types.register(USERPREF_PT_system)
1271 bpy.types.register(USERPREF_PT_file)
1272 bpy.types.register(USERPREF_PT_input)
1273
1274 from bpy.props import *
1275
1276
1277 class WM_OT_keyconfig_export(bpy.types.Operator):
1278     "Export key configuration to a python script."
1279     bl_idname = "wm.keyconfig_export"
1280     bl_label = "Export Key Configuration..."
1281
1282     path = bpy.props.StringProperty(name="File Path", description="File path to write file to.")
1283
1284     def _string_value(self, value):
1285         result = ""
1286         if isinstance(value, str):
1287             if value != "":
1288                 result = "\'%s\'" % value
1289         elif isinstance(value, bool):
1290             if value:
1291                 result = "True"
1292             else:
1293                 result = "False"
1294         elif isinstance(value, float):
1295             result = "%.10f" % value
1296         elif isinstance(value, int):
1297             result = "%d" % value
1298         elif getattr(value, '__len__', False):
1299             if len(value):
1300                 result = "["
1301                 for i in range(0, len(value)):
1302                     result += self._string_value(value[i])
1303                     if i != len(value)-1:
1304                         result += ", "
1305                 result += "]"
1306         else:
1307             print("Export key configuration: can't write ", value)
1308
1309         return result
1310
1311     def execute(self, context):
1312         if not self.properties.path:
1313             raise Exception("File path not set.")
1314
1315         f = open(self.properties.path, "w")
1316         if not f:
1317             raise Exception("Could not open file.")
1318
1319         wm = context.manager
1320         kc = wm.active_keyconfig
1321
1322         f.write('# Configuration %s\n' % kc.name)
1323
1324         f.write("wm = bpy.data.windowmanagers[0]\n")
1325         f.write("kc = wm.add_keyconfig(\'%s\')\n\n" % kc.name)
1326
1327         for km in kc.keymaps:
1328             km = km.active()
1329             f.write("# Map %s\n" % km.name)
1330             f.write("km = kc.add_keymap(\'%s\', space_type=\'%s\', region_type=\'%s\', modal=%s)\n\n" % (km.name, km.space_type, km.region_type, km.modal))
1331             for kmi in km.items:
1332                 if km.modal:
1333                     f.write("kmi = km.add_modal_item(\'%s\', \'%s\', \'%s\'" % (kmi.propvalue, kmi.type, kmi.value))
1334                 else:
1335                     f.write("kmi = km.add_item(\'%s\', \'%s\', \'%s\'" % (kmi.idname, kmi.type, kmi.value))
1336                 if kmi.any:
1337                     f.write(", any=True")
1338                 else:
1339                     if kmi.shift:
1340                         f.write(", shift=True")
1341                     if kmi.ctrl:
1342                         f.write(", ctrl=True")
1343                     if kmi.alt:
1344                         f.write(", alt=True")
1345                     if kmi.oskey:
1346                         f.write(", oskey=True")
1347                 if kmi.key_modifier and kmi.key_modifier != 'NONE':
1348                     f.write(", key_modifier=\'%s\'" % kmi.key_modifier)
1349                 f.write(")\n")
1350
1351                 props = kmi.properties
1352
1353                 if props != None:
1354                     for pname in dir(props):
1355                         if props.is_property_set(pname) and not props.is_property_hidden(pname):
1356                             value = eval("props.%s" % pname)
1357                             value = self._string_value(value)
1358                             if value != "":
1359                                 f.write("kmi.properties.%s = %s\n" % (pname, value))
1360
1361             f.write("\n")
1362
1363         f.close()
1364
1365         return ('FINISHED',)
1366
1367     def invoke(self, context, event):
1368         wm = context.manager
1369         wm.add_fileselect(self)
1370         return ('RUNNING_MODAL',)
1371
1372
1373 class WM_OT_keymap_edit(bpy.types.Operator):
1374     "Edit key map."
1375     bl_idname = "wm.keymap_edit"
1376     bl_label = "Edit Key Map"
1377
1378     def execute(self, context):
1379         wm = context.manager
1380         km = wm.active_keymap
1381         km.copy_to_user()
1382         return ('FINISHED',)
1383
1384
1385 class WM_OT_keymap_restore(bpy.types.Operator):
1386     "Restore key map"
1387     bl_idname = "wm.keymap_restore"
1388     bl_label = "Restore Key Map"
1389
1390     all = BoolProperty(attr="all", name="All Keymaps", description="Restore all keymaps to default.")
1391
1392     def execute(self, context):
1393         wm = context.manager
1394
1395         if self.properties.all:
1396             for km in wm.default_keyconfig.keymaps:
1397                 km.restore_to_default()
1398         else:
1399             km = wm.active_keymap
1400             km.restore_to_default()
1401
1402         return ('FINISHED',)
1403
1404
1405 class WM_OT_keyitem_add(bpy.types.Operator):
1406     "Add key map item."
1407     bl_idname = "wm.keyitem_add"
1408     bl_label = "Add Key Map Item"
1409
1410     def execute(self, context):
1411         wm = context.manager
1412         km = wm.active_keymap
1413         if km.modal:
1414             km.add_modal_item("", 'A', 'PRESS') # kmi
1415         else:
1416             km.add_item("", 'A', 'PRESS') # kmi
1417         return ('FINISHED',)
1418
1419
1420 class WM_OT_keyitem_remove(bpy.types.Operator):
1421     "Remove key map item."
1422     bl_idname = "wm.keyitem_remove"
1423     bl_label = "Remove Key Map Item"
1424
1425     def execute(self, context):
1426         wm = context.manager
1427         kmi = context.keyitem
1428         km = wm.active_keymap
1429         km.remove_item(kmi)
1430         return ('FINISHED',)
1431
1432 bpy.ops.add(WM_OT_keyconfig_export)
1433 bpy.ops.add(WM_OT_keymap_edit)
1434 bpy.ops.add(WM_OT_keymap_restore)
1435 bpy.ops.add(WM_OT_keyitem_add)
1436 bpy.ops.add(WM_OT_keyitem_remove)