[#21807] Import Key Configuration problems
[blender.git] / release / scripts / ui / space_userpref.py
index ed41b8975390f0b6b3777a743bffc495c9363989..4ee1f119f53626336e0b0305a0c69f4d0c085787 100644 (file)
 #
 #  You should have received a copy of the GNU General Public License
 #  along with this program; if not, write to the Free Software Foundation,
-#  Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 #
 # ##### END GPL LICENSE BLOCK #####
 
 # <pep8 compliant>
 import bpy
+import os
+import re
+import shutil
+
+
+def ui_items_general(col, context):
+    """ General UI Theme Settings (User Interface)
+    """
+    row = col.row()
+    sub = row.column()
+    sub.prop(context, "outline")
+    sub.prop(context, "item", slider=True)
+    sub = row.column()
+    sub.prop(context, "inner", slider=True)
+    sub.prop(context, "inner_sel", slider=True)
+    sub = row.column()
+    sub.prop(context, "text")
+    sub.prop(context, "text_sel")
+    sub = row.column()
+    sub.prop(context, "shaded")
+    subsub = sub.column(align=True)
+    subsub.active = context.shaded
+    subsub.prop(context, "shadetop")
+    subsub.prop(context, "shadedown")
+
+    col.separator()
+
+
+def opengl_lamp_buttons(column, lamp):
+    split = column.split(percentage=0.1)
+
+    if lamp.enabled == True:
+        split.prop(lamp, "enabled", text="", icon='OUTLINER_OB_LAMP')
+    else:
+        split.prop(lamp, "enabled", text="", icon='LAMP_DATA')
+
+    col = split.column()
+    col.active = lamp.enabled
+    row = col.row()
+    row.label(text="Diffuse:")
+    row.prop(lamp, "diffuse_color", text="")
+    row = col.row()
+    row.label(text="Specular:")
+    row.prop(lamp, "specular_color", text="")
+
+    col = split.column()
+    col.active = lamp.enabled
+    col.prop(lamp, "direction", text="")
 
 KM_HIERARCHY = [
                     ('Window', 'EMPTY', 'WINDOW', []), # file save, window change, exit
@@ -119,7 +167,14 @@ class USERPREF_HT_header(bpy.types.Header):
 
         if userpref.active_section == 'INPUT':
             layout.operator_context = 'INVOKE_DEFAULT'
-            layout.operator("wm.keyconfig_export", "Export Key Configuration...").path = "keymap.py"
+            op = layout.operator("wm.keyconfig_export", "Export Key Configuration...")
+            op.path = "keymap.py"
+            op = layout.operator("wm.keyconfig_import", "Import Key Configuration...")
+            op.path = "keymap.py"
+        elif userpref.active_section == 'ADDONS':
+            layout.operator_context = 'INVOKE_DEFAULT'
+            op = layout.operator("wm.addon_install", "Install Add-On...")
+            op.path = "*.py"
 
 
 class USERPREF_PT_tabs(bpy.types.Panel):
@@ -154,7 +209,6 @@ class USERPREF_PT_interface(bpy.types.Panel):
 
         row = layout.row()
 
-
         col = row.column()
         col.label(text="Display:")
         col.prop(view, "tooltips")
@@ -176,16 +230,15 @@ class USERPREF_PT_interface(bpy.types.Panel):
         sub.prop(view, "mini_axis_size", text="Size")
         sub.prop(view, "mini_axis_brightness", text="Brightness")
 
-
         row.separator()
         row.separator()
 
         col = row.column()
         col.label(text="View Manipulation:")
         col.prop(view, "auto_depth")
-        col.prop(view, "global_pivot")
         col.prop(view, "zoom_to_mouse")
         col.prop(view, "rotate_around_selection")
+        col.prop(view, "global_pivot")
 
         col.separator()
 
@@ -193,6 +246,13 @@ class USERPREF_PT_interface(bpy.types.Panel):
         col.prop(view, "smooth_view")
         col.prop(view, "rotation_angle")
 
+        col.separator()
+        col.separator()
+
+        col.label(text="2D Viewports:")
+        col.prop(view, "view2d_grid_minimum_spacing", text="Minimum Grid Spacing")
+        col.prop(view, "timecode_style")
+
         row.separator()
         row.separator()
 
@@ -220,6 +280,10 @@ class USERPREF_PT_interface(bpy.types.Panel):
         col.prop(view, "open_toplevel_delay", text="Top Level")
         col.prop(view, "open_sublevel_delay", text="Sub Level")
 
+        col.separator()
+
+        col.prop(view, "show_splash")
+
 
 class USERPREF_PT_edit(bpy.types.Panel):
     bl_space_type = 'USER_PREFERENCES'
@@ -237,13 +301,11 @@ class USERPREF_PT_edit(bpy.types.Panel):
         userpref = context.user_preferences
         edit = userpref.edit
 
-
         row = layout.row()
 
-
         col = row.column()
         col.label(text="Link Materials To:")
-        col.row().prop(edit, "material_link", expand=True)
+        col.prop(edit, "material_link", text="")
 
         col.separator()
         col.separator()
@@ -252,7 +314,7 @@ class USERPREF_PT_edit(bpy.types.Panel):
         col.label(text="New Objects:")
         col.prop(edit, "enter_edit_mode")
         col.label(text="Align To:")
-        col.row().prop(edit, "object_align", expand=True)
+        col.prop(edit, "object_align", text="")
 
         col.separator()
         col.separator()
@@ -263,11 +325,9 @@ class USERPREF_PT_edit(bpy.types.Panel):
         col.prop(edit, "undo_steps", text="Steps")
         col.prop(edit, "undo_memory_limit", text="Memory Limit")
 
-
         row.separator()
         row.separator()
 
-
         col = row.column()
         col.label(text="Snap:")
         col.prop(edit, "snap_translate", text="Translate")
@@ -282,12 +342,15 @@ class USERPREF_PT_edit(bpy.types.Panel):
         #col.prop(edit, "grease_pencil_simplify_stroke", text="Simplify Stroke")
         col.prop(edit, "grease_pencil_eraser_radius", text="Eraser Radius")
         col.prop(edit, "grease_pencil_smooth_stroke", text="Smooth Stroke")
-
+        col.separator()
+        col.separator()
+        col.separator()
+        col.label(text="Playback:")
+        col.prop(edit, "use_negative_frames")
 
         row.separator()
         row.separator()
 
-
         col = row.column()
         col.label(text="Keyframing:")
         col.prop(edit, "use_visual_keying")
@@ -295,20 +358,20 @@ class USERPREF_PT_edit(bpy.types.Panel):
 
         col.separator()
 
-        col.label(text="New F-Curve Defaults:")
-        col.prop(edit, "new_interpolation_type", text="Interpolation")
-        col.prop(edit, "insertkey_xyz_to_rgb", text="XYZ to RGB")
-
-        col.separator()
-
-        col.prop(edit, "auto_keying_enable", text="Auto Keyframing:")
+        col.prop(edit, "use_auto_keying", text="Auto Keyframing:")
 
         sub = col.column()
 
-        sub.active = edit.auto_keying_enable
+        # sub.active = edit.use_auto_keying # incorrect, timeline can enable
         sub.prop(edit, "auto_keyframe_insert_keyingset", text="Only Insert for Keying Set")
         sub.prop(edit, "auto_keyframe_insert_available", text="Only Insert Available")
 
+        col.separator()
+
+        col.label(text="New F-Curve Defaults:")
+        col.prop(edit, "new_interpolation_type", text="Interpolation")
+        col.prop(edit, "insertkey_xyz_to_rgb", text="XYZ to RGB")
+
         col.separator()
         col.separator()
         col.separator()
@@ -316,11 +379,9 @@ class USERPREF_PT_edit(bpy.types.Panel):
         col.label(text="Transform:")
         col.prop(edit, "drag_immediately")
 
-
         row.separator()
         row.separator()
 
-
         col = row.column()
         col.label(text="Duplicate Data:")
         col.prop(edit, "duplicate_mesh", text="Mesh")
@@ -352,12 +413,11 @@ class USERPREF_PT_system(bpy.types.Panel):
 
         userpref = context.user_preferences
         system = userpref.system
-        lamp0 = system.solid_lights[0]
-        lamp1 = system.solid_lights[1]
-        lamp2 = system.solid_lights[2]
 
         split = layout.split()
 
+
+        # 1. Column
         column = split.column()
         colsplit = column.split(percentage=0.85)
 
@@ -366,7 +426,8 @@ class USERPREF_PT_system(bpy.types.Panel):
         col.prop(system, "dpi")
         col.prop(system, "frame_server_port")
         col.prop(system, "scrollback", text="Console Scrollback")
-        col.prop(system, "auto_run_python_scripts")
+        col.prop(system, "auto_execute_scripts")
+        col.prop(system, "tabs_as_spaces")
 
         col.separator()
         col.separator()
@@ -377,7 +438,6 @@ class USERPREF_PT_system(bpy.types.Panel):
         sub = col.column()
         sub.active = system.audio_device != 'NONE'
         #sub.prop(system, "enable_all_codecs")
-        sub.prop(system, "game_sound")
         sub.prop(system, "audio_channels", text="Channels")
         sub.prop(system, "audio_mixing_buffer", text="Mixing Buffer")
         sub.prop(system, "audio_sample_rate", text="Sample Rate")
@@ -387,7 +447,12 @@ class USERPREF_PT_system(bpy.types.Panel):
         col.separator()
         col.separator()
 
-
+        col.label(text="Screencast:")
+        col.prop(system, "screencast_fps")
+        col.prop(system, "screencast_wait_time")
+        col.separator()
+        col.separator()
+        col.separator()
 
         #column = split.column()
         #colsplit = column.split(percentage=0.85)
@@ -403,6 +468,8 @@ class USERPREF_PT_system(bpy.types.Panel):
 
         #col.prop(system, "use_textured_fonts")
 
+
+        # 2. Column
         column = split.column()
         colsplit = column.split(percentage=0.85)
 
@@ -411,8 +478,10 @@ class USERPREF_PT_system(bpy.types.Panel):
         col.prop(system, "clip_alpha", slider=True)
         col.prop(system, "use_mipmaps")
         col.prop(system, "use_vbos")
+        #Anti-aliasing is disabled as it breaks broder/lasso select
+        #col.prop(system, "use_antialiasing")
         col.label(text="Window Draw Method:")
-        col.row().prop(system, "window_draw_method", expand=True)
+        col.prop(system, "window_draw_method", text="")
         col.label(text="Textures:")
         col.prop(system, "gl_texture_limit", text="Limit Size")
         col.prop(system, "texture_time_out", text="Time Out")
@@ -426,6 +495,8 @@ class USERPREF_PT_system(bpy.types.Panel):
         col.prop(system, "prefetch_frames")
         col.prop(system, "memory_cache_limit")
 
+
+        # 3. Column
         column = split.column()
 
         column.label(text="Solid OpenGL lights:")
@@ -435,78 +506,28 @@ class USERPREF_PT_system(bpy.types.Panel):
         split.label(text="Colors:")
         split.label(text="Direction:")
 
+        lamp = system.solid_lights[0]
+        opengl_lamp_buttons(column, lamp)
 
-        split = column.split(percentage=0.1)
-
-        if lamp0.enabled == True:
-            split.prop(lamp0, "enabled", text="", icon='OUTLINER_OB_LAMP')
-        else:
-            split.prop(lamp0, "enabled", text="", icon='LAMP_DATA')
-
-        col = split.column()
-        col.active = lamp0.enabled
-        row = col.row()
-        row.label(text="Diffuse:")
-        row.prop(lamp0, "diffuse_color", text="")
-        row = col.row()
-        row.label(text="Specular:")
-        row.prop(lamp0, "specular_color", text="")
-
-        col = split.column()
-        col.active = lamp0.enabled
-        col.prop(lamp0, "direction", text="")
+        lamp = system.solid_lights[1]
+        opengl_lamp_buttons(column, lamp)
 
+        lamp = system.solid_lights[2]
+        opengl_lamp_buttons(column, lamp)
 
-        split = column.split(percentage=0.1)
-
-        if lamp1.enabled == True:
-            split.prop(lamp1, "enabled", text="", icon='OUTLINER_OB_LAMP')
-        else:
-            split.prop(lamp1, "enabled", text="", icon='LAMP_DATA')
-
-        col = split.column()
-        col.active = lamp1.enabled
-        row = col.row()
-        row.label(text="Diffuse:")
-        row.prop(lamp1, "diffuse_color", text="")
-        row = col.row()
-        row.label(text="Specular:")
-        row.prop(lamp1, "specular_color", text="")
-
-        col = split.column()
-        col.active = lamp1.enabled
-        col.prop(lamp1, "direction", text="")
-
-
-        split = column.split(percentage=0.1)
-
-        if lamp2.enabled == True:
-            split.prop(lamp2, "enabled", text="", icon='OUTLINER_OB_LAMP')
-        else:
-            split.prop(lamp2, "enabled", text="", icon='LAMP_DATA')
-
-        col = split.column()
-        col.active = lamp2.enabled
-        row = col.row()
-        row.label(text="Diffuse:")
-        row.prop(lamp2, "diffuse_color", text="")
-        row = col.row()
-        row.label(text="Specular:")
-        row.prop(lamp2, "specular_color", text="")
-
-        col = split.column()
-        col.active = lamp2.enabled
-        col.prop(lamp2, "direction", text="")
+        column.separator()
+        column.separator()
+        column.separator()
 
+        column.label(text="Color Picker Type:")
+        column.row().prop(system, "color_picker_type", text="")
 
         column.separator()
         column.separator()
         column.separator()
 
-        col = column.column()
-
-        col.prop(system, "use_weight_color_range", text="Custom Weight Paint Range")
-        sub = col.column()
+        column.prop(system, "use_weight_color_range", text="Custom Weight Paint Range")
+        sub = column.column()
         sub.active = system.use_weight_color_range
         sub.template_color_ramp(system, "weight_color_range", expand=True)
 
@@ -526,351 +547,78 @@ class USERPREF_PT_theme(bpy.types.Panel):
 
         theme = context.user_preferences.themes[0]
 
-        split = layout.split(percentage=0.33)
-        split.prop(theme, "active_theme", text="")
+        split_themes = layout.split(percentage=0.2)
+        split_themes.prop(theme, "theme_area", expand=True)
 
-        layout.separator()
-
-        split = layout.split()
-
-        if theme.active_theme == 'VIEW_3D':
-            v3d = theme.view_3d
+        split = split_themes.split()
 
+        if theme.theme_area == 'USER_INTERFACE':
             col = split.column()
-            col.prop(v3d, "back")
-            col.prop(v3d, "button")
-            col.prop(v3d, "button_title")
-            col.prop(v3d, "button_text")
-            col.prop(v3d, "header")
-
-            col = split.column()
-            col.prop(v3d, "grid")
-            col.prop(v3d, "wire")
-            col.prop(v3d, "lamp", slider=True)
-            col.prop(v3d, "editmesh_active", slider=True)
 
-            col = split.column()
-            col.prop(v3d, "object_selected")
-            col.prop(v3d, "object_active")
-            col.prop(v3d, "object_grouped")
-            col.prop(v3d, "object_grouped_active")
-            col.prop(v3d, "transform")
-
-            col = split.column()
-            col.prop(v3d, "vertex")
-            col.prop(v3d, "face", slider=True)
-            col.prop(v3d, "normal")
-            col.prop(v3d, "bone_solid")
-            col.prop(v3d, "bone_pose")
-            #col.prop(v3d, "edge") Doesn't seem to work
-
-        elif theme.active_theme == 'USER_INTERFACE':
             ui = theme.user_interface.wcol_regular
-            layout.label(text="Regular:")
-
-            row = layout.row()
-            sub = row.column()
-            sub.prop(ui, "outline")
-            sub.prop(ui, "item", slider=True)
-            sub = row.column()
-            sub.prop(ui, "inner", slider=True)
-            sub.prop(ui, "inner_sel", slider=True)
-            sub = row.column()
-            sub.prop(ui, "text")
-            sub.prop(ui, "text_sel")
-            sub = row.column()
-            sub.prop(ui, "shaded")
-            subsub = sub.column(align=True)
-            subsub.active = ui.shaded
-            subsub.prop(ui, "shadetop")
-            subsub.prop(ui, "shadedown")
-
-            layout.separator()
+            col.label(text="Regular:")
+            ui_items_general(col, ui)
 
             ui = theme.user_interface.wcol_tool
-            layout.label(text="Tool:")
-
-            row = layout.row()
-            sub = row.column()
-            sub.prop(ui, "outline")
-            sub.prop(ui, "item", slider=True)
-            sub = row.column()
-            sub.prop(ui, "inner", slider=True)
-            sub.prop(ui, "inner_sel", slider=True)
-            sub = row.column()
-            sub.prop(ui, "text")
-            sub.prop(ui, "text_sel")
-            sub = row.column()
-            sub.prop(ui, "shaded")
-            subsub = sub.column(align=True)
-            subsub.active = ui.shaded
-            subsub.prop(ui, "shadetop")
-            subsub.prop(ui, "shadedown")
+            col.label(text="Tool:")
+            ui_items_general(col, ui)
 
             ui = theme.user_interface.wcol_radio
-            layout.label(text="Radio Buttons:")
-
-            row = layout.row()
-            sub = row.column()
-            sub.prop(ui, "outline")
-            sub.prop(ui, "item", slider=True)
-            sub = row.column()
-            sub.prop(ui, "inner", slider=True)
-            sub.prop(ui, "inner_sel", slider=True)
-            sub = row.column()
-            sub.prop(ui, "text")
-            sub.prop(ui, "text_sel")
-            sub = row.column()
-            sub.prop(ui, "shaded")
-            subsub = sub.column(align=True)
-            subsub.active = ui.shaded
-            subsub.prop(ui, "shadetop")
-            subsub.prop(ui, "shadedown")
+            col.label(text="Radio Buttons:")
+            ui_items_general(col, ui)
 
             ui = theme.user_interface.wcol_text
-            layout.label(text="Text:")
-
-            row = layout.row()
-            sub = row.column()
-            sub.prop(ui, "outline")
-            sub.prop(ui, "item", slider=True)
-            sub = row.column()
-            sub.prop(ui, "inner", slider=True)
-            sub.prop(ui, "inner_sel", slider=True)
-            sub = row.column()
-            sub.prop(ui, "text")
-            sub.prop(ui, "text_sel")
-            sub = row.column()
-            sub.prop(ui, "shaded")
-            subsub = sub.column(align=True)
-            subsub.active = ui.shaded
-            subsub.prop(ui, "shadetop")
-            subsub.prop(ui, "shadedown")
+            col.label(text="Text:")
+            ui_items_general(col, ui)
 
             ui = theme.user_interface.wcol_option
-            layout.label(text="Option:")
-
-            row = layout.row()
-            sub = row.column()
-            sub.prop(ui, "outline")
-            sub.prop(ui, "item", slider=True)
-            sub = row.column()
-            sub.prop(ui, "inner", slider=True)
-            sub.prop(ui, "inner_sel", slider=True)
-            sub = row.column()
-            sub.prop(ui, "text")
-            sub.prop(ui, "text_sel")
-            sub = row.column()
-            sub.prop(ui, "shaded")
-            subsub = sub.column(align=True)
-            subsub.active = ui.shaded
-            subsub.prop(ui, "shadetop")
-            subsub.prop(ui, "shadedown")
+            col.label(text="Option:")
+            ui_items_general(col, ui)
 
             ui = theme.user_interface.wcol_toggle
-            layout.label(text="Toggle:")
-
-            row = layout.row()
-            sub = row.column()
-            sub.prop(ui, "outline")
-            sub.prop(ui, "item", slider=True)
-            sub = row.column()
-            sub.prop(ui, "inner", slider=True)
-            sub.prop(ui, "inner_sel", slider=True)
-            sub = row.column()
-            sub.prop(ui, "text")
-            sub.prop(ui, "text_sel")
-            sub = row.column()
-            sub.prop(ui, "shaded")
-            subsub = sub.column(align=True)
-            subsub.active = ui.shaded
-            subsub.prop(ui, "shadetop")
-            subsub.prop(ui, "shadedown")
+            col.label(text="Toggle:")
+            ui_items_general(col, ui)
 
             ui = theme.user_interface.wcol_num
-            layout.label(text="Number Field:")
-
-            row = layout.row()
-            sub = row.column()
-            sub.prop(ui, "outline")
-            sub.prop(ui, "item", slider=True)
-            sub = row.column()
-            sub.prop(ui, "inner", slider=True)
-            sub.prop(ui, "inner_sel", slider=True)
-            sub = row.column()
-            sub.prop(ui, "text")
-            sub.prop(ui, "text_sel")
-            sub = row.column()
-            sub.prop(ui, "shaded")
-            subsub = sub.column(align=True)
-            subsub.active = ui.shaded
-            subsub.prop(ui, "shadetop")
-            subsub.prop(ui, "shadedown")
+            col.label(text="Number Field:")
+            ui_items_general(col, ui)
 
             ui = theme.user_interface.wcol_numslider
-            layout.label(text="Value Slider:")
-
-            row = layout.row()
-            sub = row.column()
-            sub.prop(ui, "outline")
-            sub.prop(ui, "item", slider=True)
-            sub = row.column()
-            sub.prop(ui, "inner", slider=True)
-            sub.prop(ui, "inner_sel", slider=True)
-            sub = row.column()
-            sub.prop(ui, "text")
-            sub.prop(ui, "text_sel")
-            sub = row.column()
-            sub.prop(ui, "shaded")
-            subsub = sub.column(align=True)
-            subsub.active = ui.shaded
-            subsub.prop(ui, "shadetop")
-            subsub.prop(ui, "shadedown")
+            col.label(text="Value Slider:")
+            ui_items_general(col, ui)
 
             ui = theme.user_interface.wcol_box
-            layout.label(text="Box:")
-
-            row = layout.row()
-            sub = row.column()
-            sub.prop(ui, "outline")
-            sub.prop(ui, "item", slider=True)
-            sub = row.column()
-            sub.prop(ui, "inner", slider=True)
-            sub.prop(ui, "inner_sel", slider=True)
-            sub = row.column()
-            sub.prop(ui, "text")
-            sub.prop(ui, "text_sel")
-            sub = row.column()
-            sub.prop(ui, "shaded")
-            subsub = sub.column(align=True)
-            subsub.active = ui.shaded
-            subsub.prop(ui, "shadetop")
-            subsub.prop(ui, "shadedown")
+            col.label(text="Box:")
+            ui_items_general(col, ui)
 
             ui = theme.user_interface.wcol_menu
-            layout.label(text="Menu:")
-
-            row = layout.row()
-            sub = row.column()
-            sub.prop(ui, "outline")
-            sub.prop(ui, "item", slider=True)
-            sub = row.column()
-            sub.prop(ui, "inner", slider=True)
-            sub.prop(ui, "inner_sel", slider=True)
-            sub = row.column()
-            sub.prop(ui, "text")
-            sub.prop(ui, "text_sel")
-            sub = row.column()
-            sub.prop(ui, "shaded")
-            subsub = sub.column(align=True)
-            subsub.active = ui.shaded
-            subsub.prop(ui, "shadetop")
-            subsub.prop(ui, "shadedown")
+            col.label(text="Menu:")
+            ui_items_general(col, ui)
 
             ui = theme.user_interface.wcol_pulldown
-            layout.label(text="Pulldown:")
-
-            row = layout.row()
-            sub = row.column()
-            sub.prop(ui, "outline")
-            sub.prop(ui, "item", slider=True)
-            sub = row.column()
-            sub.prop(ui, "inner", slider=True)
-            sub.prop(ui, "inner_sel", slider=True)
-            sub = row.column()
-            sub.prop(ui, "text")
-            sub.prop(ui, "text_sel")
-            sub = row.column()
-            sub.prop(ui, "shaded")
-            subsub = sub.column(align=True)
-            subsub.active = ui.shaded
-            subsub.prop(ui, "shadetop")
-            subsub.prop(ui, "shadedown")
+            col.label(text="Pulldown:")
+            ui_items_general(col, ui)
 
             ui = theme.user_interface.wcol_menu_back
-            layout.label(text="Menu Back:")
-
-            row = layout.row()
-            sub = row.column()
-            sub.prop(ui, "outline")
-            sub.prop(ui, "item", slider=True)
-            sub = row.column()
-            sub.prop(ui, "inner", slider=True)
-            sub.prop(ui, "inner_sel", slider=True)
-            sub = row.column()
-            sub.prop(ui, "text")
-            sub.prop(ui, "text_sel")
-            sub = row.column()
-            sub.prop(ui, "shaded")
-            subsub = sub.column(align=True)
-            subsub.active = ui.shaded
-            subsub.prop(ui, "shadetop")
-            subsub.prop(ui, "shadedown")
+            col.label(text="Menu Back:")
+            ui_items_general(col, ui)
 
             ui = theme.user_interface.wcol_menu_item
-            layout.label(text="Menu Item:")
-
-            row = layout.row()
-            sub = row.column()
-            sub.prop(ui, "outline")
-            sub.prop(ui, "item", slider=True)
-            sub = row.column()
-            sub.prop(ui, "inner", slider=True)
-            sub.prop(ui, "inner_sel", slider=True)
-            sub = row.column()
-            sub.prop(ui, "text")
-            sub.prop(ui, "text_sel")
-            sub = row.column()
-            sub.prop(ui, "shaded")
-            subsub = sub.column(align=True)
-            subsub.active = ui.shaded
-            subsub.prop(ui, "shadetop")
-            subsub.prop(ui, "shadedown")
+            col.label(text="Menu Item:")
+            ui_items_general(col, ui)
 
             ui = theme.user_interface.wcol_scroll
-            layout.label(text="Scroll Bar:")
-
-            row = layout.row()
-            sub = row.column()
-            sub.prop(ui, "outline")
-            sub.prop(ui, "item", slider=True)
-            sub = row.column()
-            sub.prop(ui, "inner", slider=True)
-            sub.prop(ui, "inner_sel", slider=True)
-            sub = row.column()
-            sub.prop(ui, "text")
-            sub.prop(ui, "text_sel")
-            sub = row.column()
-            sub.prop(ui, "shaded")
-            subsub = sub.column(align=True)
-            subsub.active = ui.shaded
-            subsub.prop(ui, "shadetop")
-            subsub.prop(ui, "shadedown")
+            col.label(text="Scroll Bar:")
+            ui_items_general(col, ui)
 
             ui = theme.user_interface.wcol_list_item
-            layout.label(text="List Item:")
-
-            row = layout.row()
-            sub = row.column()
-            sub.prop(ui, "outline")
-            sub.prop(ui, "item", slider=True)
-            sub = row.column()
-            sub.prop(ui, "inner", slider=True)
-            sub.prop(ui, "inner_sel", slider=True)
-            sub = row.column()
-            sub.prop(ui, "text")
-            sub.prop(ui, "text_sel")
-            sub = row.column()
-            sub.prop(ui, "shaded")
-            subsub = sub.column(align=True)
-            subsub.active = ui.shaded
-            subsub.prop(ui, "shadetop")
-            subsub.prop(ui, "shadedown")
+            col.label(text="List Item:")
+            ui_items_general(col, ui)
 
             ui = theme.user_interface.wcol_state
-            layout.label(text="State:")
+            col.label(text="State:")
 
-            row = layout.row()
+            row = col.row()
             sub = row.column()
             sub.prop(ui, "inner_anim")
             sub.prop(ui, "inner_anim_sel")
@@ -884,16 +632,61 @@ class USERPREF_PT_theme(bpy.types.Panel):
             sub.prop(ui, "blend")
 
             ui = theme.user_interface
-            layout.separator()
-
-            sub = layout.row()
-            sub.prop(ui, "icon_file")
+            col.separator()
+            col.separator()
+            col.prop(ui, "icon_file")
 
             layout.separator()
             layout.separator()
 
 
-        elif theme.active_theme == 'GRAPH_EDITOR':
+        elif theme.theme_area == 'VIEW_3D':
+            v3d = theme.view_3d
+
+            col = split.column()
+            col.prop(v3d, "back")
+            col.prop(v3d, "button")
+            col.prop(v3d, "button_title")
+            col.prop(v3d, "button_text")
+            col.prop(v3d, "header")
+
+            col = split.column()
+            col.prop(v3d, "grid")
+            col.prop(v3d, "wire")
+            col.prop(v3d, "lamp", slider=True)
+            col.prop(v3d, "editmesh_active", slider=True)
+
+            col = split.column()
+            col.prop(v3d, "object_selected")
+            col.prop(v3d, "object_active")
+            col.prop(v3d, "object_grouped")
+            col.prop(v3d, "object_grouped_active")
+            col.prop(v3d, "transform")
+            col.prop(v3d, "nurb_uline")
+            col.prop(v3d, "nurb_vline")
+            col.prop(v3d, "nurb_sel_uline")
+            col.prop(v3d, "nurb_sel_vline")
+            col.prop(v3d, "handle_free")
+            col.prop(v3d, "handle_auto")
+            col.prop(v3d, "handle_vect")
+            col.prop(v3d, "handle_align")
+            col.prop(v3d, "handle_sel_free")
+            col.prop(v3d, "handle_sel_auto")
+            col.prop(v3d, "handle_sel_vect")
+            col.prop(v3d, "handle_sel_align")
+            col.prop(v3d, "act_spline")
+
+            col = split.column()
+            col.prop(v3d, "vertex")
+            col.prop(v3d, "face", slider=True)
+            col.prop(v3d, "normal")
+            col.prop(v3d, "vertex_normal")
+            col.prop(v3d, "bone_solid")
+            col.prop(v3d, "bone_pose")
+            col.prop(v3d, "edge_seam")
+            #col.prop(v3d, "edge") Doesn't seem to work
+
+        elif theme.theme_area == 'GRAPH_EDITOR':
             graph = theme.graph_editor
 
             col = split.column()
@@ -921,7 +714,7 @@ class USERPREF_PT_theme(bpy.types.Panel):
             col.separator()
             col.prop(graph, "handle_vertex_size")
 
-        elif theme.active_theme == 'FILE_BROWSER':
+        elif theme.theme_area == 'FILE_BROWSER':
             file_browse = theme.file_browser
 
             col = split.column()
@@ -941,7 +734,7 @@ class USERPREF_PT_theme(bpy.types.Panel):
             col.prop(file_browse, "active_file")
             col.prop(file_browse, "active_file_text")
 
-        elif theme.active_theme == 'NLA_EDITOR':
+        elif theme.theme_area == 'NLA_EDITOR':
             nla = theme.nla_editor
 
             col = split.column()
@@ -964,7 +757,7 @@ class USERPREF_PT_theme(bpy.types.Panel):
             col.prop(nla, "strips_selected")
             col.prop(nla, "current_frame")
 
-        elif theme.active_theme == 'DOPESHEET_EDITOR':
+        elif theme.theme_area == 'DOPESHEET_EDITOR':
             dope = theme.dopesheet_editor
 
             col = split.column()
@@ -989,11 +782,12 @@ class USERPREF_PT_theme(bpy.types.Panel):
             col.prop(dope, "dopesheet_channel")
             col.prop(dope, "dopesheet_subchannel")
 
-        elif theme.active_theme == 'IMAGE_EDITOR':
+        elif theme.theme_area == 'IMAGE_EDITOR':
             image = theme.image_editor
 
             col = split.column()
             col.prop(image, "back")
+            col.prop(image, "scope_back")
             col.prop(image, "button")
 
             col = split.column()
@@ -1006,7 +800,7 @@ class USERPREF_PT_theme(bpy.types.Panel):
             col = split.column()
             col.prop(image, "editmesh_active", slider=True)
 
-        elif theme.active_theme == 'SEQUENCE_EDITOR':
+        elif theme.theme_area == 'SEQUENCE_EDITOR':
             seq = theme.sequence_editor
 
             col = split.column()
@@ -1035,7 +829,7 @@ class USERPREF_PT_theme(bpy.types.Panel):
             col.prop(seq, "keyframe")
             col.prop(seq, "draw_action")
 
-        elif theme.active_theme == 'PROPERTIES':
+        elif theme.theme_area == 'PROPERTIES':
             prop = theme.properties
 
             col = split.column()
@@ -1050,7 +844,7 @@ class USERPREF_PT_theme(bpy.types.Panel):
             col = split.column()
             col.prop(prop, "header")
 
-        elif theme.active_theme == 'TEXT_EDITOR':
+        elif theme.theme_area == 'TEXT_EDITOR':
             text = theme.text_editor
 
             col = split.column()
@@ -1076,7 +870,7 @@ class USERPREF_PT_theme(bpy.types.Panel):
             col.prop(text, "syntax_string")
             col.prop(text, "syntax_numbers")
 
-        elif theme.active_theme == 'TIMELINE':
+        elif theme.theme_area == 'TIMELINE':
             time = theme.timeline
 
             col = split.column()
@@ -1092,7 +886,7 @@ class USERPREF_PT_theme(bpy.types.Panel):
             col = split.column()
             col.prop(time, "current_frame")
 
-        elif theme.active_theme == 'NODE_EDITOR':
+        elif theme.theme_area == 'NODE_EDITOR':
             node = theme.node_editor
 
             col = split.column()
@@ -1118,7 +912,7 @@ class USERPREF_PT_theme(bpy.types.Panel):
             col.prop(node, "operator_node")
             col.prop(node, "group_node")
 
-        elif theme.active_theme == 'LOGIC_EDITOR':
+        elif theme.theme_area == 'LOGIC_EDITOR':
             logic = theme.logic_editor
 
             col = split.column()
@@ -1136,7 +930,7 @@ class USERPREF_PT_theme(bpy.types.Panel):
             col = split.column()
             col.prop(logic, "panel")
 
-        elif theme.active_theme == 'OUTLINER':
+        elif theme.theme_area == 'OUTLINER':
             out = theme.outliner
 
             col = split.column()
@@ -1151,7 +945,7 @@ class USERPREF_PT_theme(bpy.types.Panel):
             col = split.column()
             col.prop(out, "header")
 
-        elif theme.active_theme == 'INFO':
+        elif theme.theme_area == 'INFO':
             info = theme.info
 
             col = split.column()
@@ -1165,7 +959,7 @@ class USERPREF_PT_theme(bpy.types.Panel):
 
             col = split.column()
 
-        elif theme.active_theme == 'USER_PREFERENCES':
+        elif theme.theme_area == 'USER_PREFERENCES':
             prefs = theme.user_preferences
 
             col = split.column()
@@ -1180,6 +974,20 @@ class USERPREF_PT_theme(bpy.types.Panel):
             col = split.column()
             col.prop(prefs, "header_text")
 
+        elif theme.theme_area == 'CONSOLE':
+            prefs = theme.console
+
+            col = split.column()
+            col.prop(prefs, "back")
+            col.prop(prefs, "header")
+
+            col = split.column()
+            col.prop(prefs, "line_output")
+            col.prop(prefs, "line_input")
+            col.prop(prefs, "line_info")
+            col.prop(prefs, "line_error")
+            col.prop(prefs, "cursor")
+
 
 class USERPREF_PT_file(bpy.types.Panel):
     bl_space_type = 'USER_PREFERENCES'
@@ -1214,6 +1022,7 @@ class USERPREF_PT_file(bpy.types.Panel):
         sub.label(text="Scripts:")
         sub.label(text="Sounds:")
         sub.label(text="Temp:")
+        sub.label(text="Image Editor:")
         sub.label(text="Animation Player:")
 
         sub = col1.column()
@@ -1225,6 +1034,7 @@ class USERPREF_PT_file(bpy.types.Panel):
         sub.prop(paths, "python_scripts_directory", text="")
         sub.prop(paths, "sounds_directory", text="")
         sub.prop(paths, "temporary_directory", text="")
+        sub.prop(paths, "image_editor", text="")
         subsplit = sub.split(percentage=0.3)
         subsplit.prop(paths, "animation_player_preset", text="")
         subsplit.prop(paths, "animation_player", text="")
@@ -1293,10 +1103,12 @@ class USERPREF_PT_input(bpy.types.Panel):
         row.label()
         row.label()
 
+        if km.modal:
+            row.label(text="", icon='LINKED')
         if km.user_defined:
-            row.operator("wm.keymap_restore", text="Restore")
+            op = row.operator("wm.keymap_restore", text="Restore")
         else:
-            row.operator("wm.keymap_edit", text="Edit")
+            op = row.operator("wm.keymap_edit", text="Edit")
 
         if km.children_expanded:
             if children:
@@ -1317,8 +1129,8 @@ class USERPREF_PT_input(bpy.types.Panel):
                 # "Add New" at end of keymap item list
                 col = self.indented_layout(col, level + 1)
                 subcol = col.split(percentage=0.2).column()
-                subcol.active = km.user_defined
-                subcol.operator("wm.keyitem_add", text="Add New", icon='ZOOMIN')
+                subcol.enabled = km.user_defined
+                op = subcol.operator("wm.keyitem_add", text="Add New", icon='ZOOMIN')
 
             col.separator()
 
@@ -1331,23 +1143,24 @@ class USERPREF_PT_input(bpy.types.Panel):
                     self.draw_entry(kc, entry, col, level + 1)
 
     def draw_kmi(self, kc, km, kmi, layout, level):
-        layout.set_context_pointer("keyitem", kmi)
+        map_type = kmi.map_type
 
         col = self.indented_layout(layout, level)
 
-        col.enabled = km.user_defined
-
         if km.user_defined:
             col = col.column(align=True)
             box = col.box()
         else:
             box = col.column()
 
-        split = box.split(percentage=0.4)
+        split = box.split(percentage=0.05)
 
         # header bar
         row = split.row()
         row.prop(kmi, "expanded", text="", no_bg=True)
+
+        row = split.row()
+        row.enabled = km.user_defined
         row.prop(kmi, "active", text="", no_bg=True)
 
         if km.modal:
@@ -1356,28 +1169,34 @@ class USERPREF_PT_input(bpy.types.Panel):
             row.label(text=kmi.name)
 
         row = split.row()
+        row.enabled = km.user_defined
         row.prop(kmi, "map_type", text="")
-        if kmi.map_type == 'KEYBOARD':
+        if map_type == 'KEYBOARD':
             row.prop(kmi, "type", text="", full_event=True)
-        elif kmi.map_type == 'MOUSE':
+        elif map_type == 'MOUSE':
             row.prop(kmi, "type", text="", full_event=True)
-        elif kmi.map_type == 'TWEAK':
+        elif map_type == 'TWEAK':
             subrow = row.row()
             subrow.prop(kmi, "type", text="")
             subrow.prop(kmi, "value", text="")
-        elif kmi.map_type == 'TIMER':
+        elif map_type == 'TIMER':
             row.prop(kmi, "type", text="")
         else:
             row.label()
 
-        row.operator("wm.keyitem_restore", text="", icon='BACK')
-        row.operator("wm.keyitem_remove", text="", icon='X')
+        if kmi.id:
+            op = row.operator("wm.keyitem_restore", text="", icon='BACK')
+            op.item_id = kmi.id
+        op = row.operator("wm.keyitem_remove", text="", icon='X')
+        op.item_id = kmi.id
 
         # Expanded, additional event settings
         if kmi.expanded:
             box = col.box()
 
-            if kmi.map_type not in ('TEXTINPUT', 'TIMER'):
+            box.enabled = km.user_defined
+
+            if map_type not in ('TEXTINPUT', 'TIMER'):
                 split = box.split(percentage=0.4)
                 sub = split.row()
 
@@ -1389,10 +1208,10 @@ class USERPREF_PT_input(bpy.types.Panel):
                 sub = split.column()
                 subrow = sub.row(align=True)
 
-                if kmi.map_type == 'KEYBOARD':
+                if map_type == 'KEYBOARD':
                     subrow.prop(kmi, "type", text="", event=True)
                     subrow.prop(kmi, "value", text="")
-                elif kmi.map_type == 'MOUSE':
+                elif map_type == 'MOUSE':
                     subrow.prop(kmi, "type", text="")
                     subrow.prop(kmi, "value", text="")
 
@@ -1405,20 +1224,30 @@ class USERPREF_PT_input(bpy.types.Panel):
                 subrow.prop(kmi, "oskey", text="Cmd")
                 subrow.prop(kmi, "key_modifier", text="", event=True)
 
+            def display_properties(properties, title=None):
+                box.separator()
+                if title:
+                    box.label(text=title)
+                flow = box.column_flow(columns=2)
+                for pname in dir(properties):
+                    if not properties.is_property_hidden(pname):
+                        value = eval("properties." + pname)
+                        if isinstance(value, bpy.types.OperatorProperties):
+                            display_properties(value, title=pname)
+                        else:
+                            flow.prop(properties, pname)
+
             # Operator properties
             props = kmi.properties
             if props is not None:
-                box.separator()
-                flow = box.column_flow(columns=2)
-                for pname in dir(props):
-                    if not props.is_property_hidden(pname):
-                        flow.prop(props, pname)
+                display_properties(props)
 
             # Modal key maps attached to this operator
             if not km.modal:
                 kmm = kc.find_keymap_modal(kmi.idname)
                 if kmm:
                     self.draw_km(kc, kmm, None, layout, level + 1)
+                    layout.set_context_pointer("keymap", km)
 
     def draw_input_prefs(self, inputs, layout):
         # General settings
@@ -1475,14 +1304,14 @@ class USERPREF_PT_input(bpy.types.Panel):
         filter = kc.filter.lower()
 
         for km in kc.keymaps:
+            km = km.active()
+            layout.set_context_pointer("keymap", km)
+
             filtered_items = [kmi for kmi in km.items if filter in kmi.name.lower()]
-            
-            if len(filtered_items) != 0:
-                km = km.active()
 
-                layout.set_context_pointer("keymap", km)
+            if len(filtered_items) != 0:
                 col = layout.column()
-               
+
                 row = col.row()
                 row.label(text=km.name, icon="DOT")
 
@@ -1490,18 +1319,18 @@ class USERPREF_PT_input(bpy.types.Panel):
                 row.label()
 
                 if km.user_defined:
-                    row.operator("wm.keymap_restore", text="Restore")
+                    op = row.operator("wm.keymap_restore", text="Restore")
                 else:
-                    row.operator("wm.keymap_edit", text="Edit")
+                    op = row.operator("wm.keymap_edit", text="Edit")
 
                 for kmi in filtered_items:
                     self.draw_kmi(kc, km, kmi, col, 1)
-                    
+
                 # "Add New" at end of keymap item list
                 col = self.indented_layout(layout, 1)
                 subcol = col.split(percentage=0.2).column()
-                subcol.active = km.user_defined
-                subcol.operator("wm.keyitem_add", text="Add New", icon='ZOOMIN')
+                subcol.enabled = km.user_defined
+                op = subcol.operator("wm.keyitem_add", text="Add New", icon='ZOOMIN')
 
     def draw_hierarchy(self, defkc, layout):
         for entry in KM_HIERARCHY:
@@ -1510,6 +1339,10 @@ class USERPREF_PT_input(bpy.types.Panel):
     def draw(self, context):
         layout = self.layout
 
+        #import time
+
+        #start = time.time()
+
         userpref = context.user_preferences
         wm = context.manager
 
@@ -1529,10 +1362,13 @@ class USERPREF_PT_input(bpy.types.Panel):
 
         subsplit = sub.split()
         subcol = subsplit.column()
-        subcol.prop_object(wm, "active_keyconfig", wm, "keyconfigs", text="Configuration:")
+        row = subcol.row()
+        row.prop_object(wm, "active_keyconfig", wm, "keyconfigs", text="Configuration:")
 
-        subcol = subsplit.column()
-        subcol.prop(kc, "filter", icon="VIEWZOOM")
+        layout.set_context_pointer("keyconfig", wm.active_keyconfig)
+        row.operator("wm.keyconfig_remove", text="", icon='X')
+
+        row.prop(kc, "filter", icon="VIEWZOOM")
 
         col.separator()
 
@@ -1541,20 +1377,319 @@ class USERPREF_PT_input(bpy.types.Panel):
         else:
             self.draw_hierarchy(kc, col)
 
-bpy.types.register(USERPREF_HT_header)
-bpy.types.register(USERPREF_PT_tabs)
-bpy.types.register(USERPREF_PT_interface)
-bpy.types.register(USERPREF_PT_theme)
-bpy.types.register(USERPREF_PT_edit)
-bpy.types.register(USERPREF_PT_system)
-bpy.types.register(USERPREF_PT_file)
-bpy.types.register(USERPREF_PT_input)
+        #print("runtime", time.time() - start)
+
+
+class USERPREF_PT_addons(bpy.types.Panel):
+    bl_space_type = 'USER_PREFERENCES'
+    bl_label = "Addons"
+    bl_region_type = 'WINDOW'
+    bl_show_header = False
+
+    def poll(self, context):
+        userpref = context.user_preferences
+        return (userpref.active_section == 'ADDONS')
+
+    def _addon_list(self):
+        import sys
+        modules = []
+        loaded_modules = set()
+        paths = bpy.utils.script_paths("addons")
+        # sys.path.insert(0, None)
+        for path in paths:
+            # sys.path[0] = path
+            modules.extend(bpy.utils.modules_from_path(path, loaded_modules))
+
+        # del sys.path[0]
+        return modules
+
+    def draw(self, context):
+        layout = self.layout
+
+        userpref = context.user_preferences
+        used_ext = {ext.module for ext in userpref.addons}
+
+        # collect the categories that can be filtered on
+        addons = [(mod, addon_info_get(mod)) for mod in self._addon_list()]
+
+        cats = {info["category"] for mod, info in addons}
+        cats.discard("")
+
+        cats = ['All', 'Disabled', 'Enabled'] + sorted(cats)
+
+        bpy.types.Scene.EnumProperty(items=[(cats[i], cats[i], str(i)) for i in range(len(cats))],
+            name="Category", attr="addon_filter", description="Filter add-ons by category")
+        bpy.types.Scene.StringProperty(name="Search", attr="addon_search",
+            description="Search within the selected filter")
+
+        row = layout.row()
+        row.prop(context.scene, "addon_filter", text="Filter")
+        row.prop(context.scene, "addon_search", text="Search", icon='VIEWZOOM')
+        layout.separator()
+
+        filter = context.scene.addon_filter
+        search = context.scene.addon_search.lower()
+
+        for mod, info in addons:
+            module_name = mod.__name__
+
+            # check if add-on should be visible with current filters
+            if filter != "All" and \
+                    filter != info["category"] and \
+                    not (module_name not in used_ext and filter == "Disabled"):
+
+                continue
+
+            if search and search not in info["name"].lower():
+                if info["author"]:
+                    if search not in info["author"].lower():
+                        continue
+                else:
+                    continue
+
+            # Addon UI Code
+            box = layout.column().box()
+            column = box.column()
+            row = column.row()
+
+            # Arrow #
+            # If there are Infos or UI is expanded
+            if info["expanded"]:
+                row.operator("wm.addon_expand", icon="TRIA_DOWN").module = module_name
+            elif info["author"] or info["version"] or info["url"] or info["location"]:
+                row.operator("wm.addon_expand", icon="TRIA_RIGHT").module = module_name
+            else:
+                # Else, block UI
+                arrow = row.column()
+                arrow.enabled = False
+                arrow.operator("wm.addon_expand", icon="TRIA_RIGHT").module = module_name
+
+            row.label(text=info["name"])
+            row.operator("wm.addon_disable" if module_name in used_ext else "wm.addon_enable").module = module_name
+
+            # Expanded UI (only if additional infos are available)
+            if info["expanded"]:
+                if info["author"]:
+                    split = column.row().split(percentage=0.15)
+                    split.label(text='Author:')
+                    split.label(text=info["author"])
+                if info["version"]:
+                    split = column.row().split(percentage=0.15)
+                    split.label(text='Version:')
+                    split.label(text=info["version"])
+                if info["location"]:
+                    split = column.row().split(percentage=0.15)
+                    split.label(text='Location:')
+                    split.label(text=info["location"])
+                if info["url"]:
+                    split = column.row().split(percentage=0.15)
+                    split.label(text="Internet:")
+                    split.operator("wm.addon_links", text="Link to the Wiki").link = info["url"]
+                    split.separator()
+                    split.separator()
+
+        # Append missing scripts
+        # First collect scripts that are used but have no script file.
+        module_names = {mod.__name__ for mod, info in addons}
+        missing_modules = {ext for ext in used_ext if ext not in module_names}
+
+        if missing_modules and filter in ("All", "Enabled"):
+            layout.column().separator()
+            layout.column().label(text="Missing script files")
+
+            module_names = {mod.__name__ for mod, info in addons}
+            for ext in sorted(missing_modules):
+                # Addon UI Code
+                box = layout.column().box()
+                column = box.column()
+                row = column.row()
+
+                row.label(text=ext, icon="ERROR")
+                row.operator("wm.addon_disable").module = ext
 
 from bpy.props import *
 
 
+def addon_info_get(mod, info_basis={"name": "", "author": "", "version": "", "blender": "", "location": "", "url": "", "category": "", "expanded": False}):
+    addon_info = getattr(mod, "bl_addon_info", {})
+
+    # avoid re-initializing
+    if "_init" in addon_info:
+        return addon_info
+
+    if not addon_info:
+        mod.bl_addon_info = addon_info
+
+    for key, value in info_basis.items():
+        addon_info.setdefault(key, value)
+
+    if not addon_info["name"]:
+        addon_info["name"] = mod.__name__
+
+    addon_info["_init"] = None
+    return addon_info
+
+
+class WM_OT_addon_enable(bpy.types.Operator):
+    "Enable an addon"
+    bl_idname = "wm.addon_enable"
+    bl_label = "Enable Add-On"
+
+    module = StringProperty(name="Module", description="Module name of the addon to enable")
+
+    def execute(self, context):
+        module_name = self.properties.module
+
+        try:
+            mod = __import__(module_name)
+            mod.register()
+        except:
+            import traceback
+            traceback.print_exc()
+            return {'CANCELLED'}
+
+        ext = context.user_preferences.addons.new()
+        ext.module = module_name
+
+        # check if add-on is written for current blender version, or raise a warning
+        info = addon_info_get(mod)
+
+        if info.get("blender", (0, 0, 0)) > bpy.app.version:
+            self.report("WARNING','This script was written for a newer version of Blender and might not function (correctly).\nThe script is enabled though.")
+
+        return {'FINISHED'}
+
+
+class WM_OT_addon_disable(bpy.types.Operator):
+    "Disable an addon"
+    bl_idname = "wm.addon_disable"
+    bl_label = "Disable Add-On"
+
+    module = StringProperty(name="Module", description="Module name of the addon to disable")
+
+    def execute(self, context):
+        import traceback
+        module_name = self.properties.module
+
+        try:
+            mod = __import__(module_name)
+            mod.unregister()
+        except:
+            traceback.print_exc()
+
+        addons = context.user_preferences.addons
+        ok = True
+        while ok: # incase its in more then once.
+            ok = False
+            for ext in addons:
+                if ext.module == module_name:
+                    addons.remove(ext)
+                    ok = True
+                    break
+
+        return {'FINISHED'}
+
+
+class WM_OT_addon_install(bpy.types.Operator):
+    "Install an addon"
+    bl_idname = "wm.addon_install"
+    bl_label = "Install Add-On"
+
+    module = StringProperty(name="Module", description="Module name of the addon to disable")
+
+    path = StringProperty(name="File Path", description="File path to write file to")
+    filename = StringProperty(name="File Name", description="Name of the file")
+    directory = StringProperty(name="Directory", description="Directory of the file")
+    filter_folder = BoolProperty(name="Filter folders", description="", default=True, options={'HIDDEN'})
+    filter_python = BoolProperty(name="Filter python", description="", default=True, options={'HIDDEN'})
+
+    def execute(self, context):
+        import traceback
+        import zipfile
+        pyfile = self.properties.path
+
+        path_addons = bpy.utils.script_paths("addons")[-1]
+
+        #check to see if the file is in compressed format (.zip)
+        if zipfile.is_zipfile(pyfile):
+            try:
+                file_to_extract = zipfile.ZipFile(pyfile, 'r')
+
+                #extract the file to "addons"
+                file_to_extract.extractall(path_addons)
+
+            except:
+                traceback.print_exc()
+                return {'CANCELLED'}
+
+        else:
+            path_dest = os.path.join(path_addons, os.path.basename(pyfile))
+
+            if os.path.exists(path_dest):
+                self.report({'WARNING'}, "File already installed to '%s'\n" % path_dest)
+                return {'CANCELLED'}
+
+            #if not compressed file just copy into the addon path
+            try:
+                shutil.copyfile(pyfile, path_dest)
+
+            except:
+                traceback.print_exc()
+                return {'CANCELLED'}
+
+        # TODO, should not be a warning.
+        # self.report({'WARNING'}, "File installed to '%s'\n" % path_dest)
+        return {'FINISHED'}
+
+    def invoke(self, context, event):
+        paths = bpy.utils.script_paths("addons")
+        if not paths:
+            self.report({'ERROR'}, "No 'addons' path could be found in " + str(bpy.utils.script_paths()))
+            return {'CANCELLED'}
+
+        wm = context.manager
+        wm.add_fileselect(self)
+        return {'RUNNING_MODAL'}
+
+
+class WM_OT_addon_expand(bpy.types.Operator):
+    "Display more information on this add-on"
+    bl_idname = "wm.addon_expand"
+    bl_label = ""
+
+    module = StringProperty(name="Module", description="Module name of the addon to expand")
+
+    def execute(self, context):
+        module_name = self.properties.module
+
+        # unlikely to fail, module should have alredy been imported
+        try:
+            mod = __import__(module_name)
+        except:
+            import traceback
+            traceback.print_exc()
+            return {'CANCELLED'}
+
+        info = addon_info_get(mod)
+        info["expanded"] = not info["expanded"]
+        return {'FINISHED'}
+
+
+class WM_OT_addon_links(bpy.types.Operator):
+    "Open the Blender Wiki in the Webbrowser"
+    bl_idname = "wm.addon_links"
+    bl_label = ""
+
+    link = StringProperty(name="Link", description="Link to open")
+
+    def execute(self, context):
+        import webbrowser
+        webbrowser.open(self.properties.link)
+        return {'FINISHED'}
+
+
 class WM_OT_keyconfig_test(bpy.types.Operator):
-    "Test keyconfig for conflicts."
+    "Test keyconfig for conflicts"
     bl_idname = "wm.keyconfig_test"
     bl_label = "Test Key Configuration for Conflicts"
 
@@ -1583,15 +1718,21 @@ class WM_OT_keyconfig_test(bpy.types.Operator):
 
             s.append(")\n")
 
+            def export_properties(prefix, properties):
+                for pname in dir(properties):
+                    if not properties.is_property_hidden(pname):
+                        value = eval("properties.%s" % pname)
+                        if isinstance(value, bpy.types.OperatorProperties):
+                            export_properties(prefix + "." + pname, value)
+                        elif properties.is_property_set(pname):
+                            value = _string_value(value)
+                            if value != "":
+                                s.append(prefix + ".%s = %s\n" % (pname, value))
+
             props = kmi.properties
 
             if props is not None:
-                for pname in dir(props):
-                    if props.is_property_set(pname) and not props.is_property_hidden(pname):
-                        value = eval("props.%s" % pname)
-                        value = _string_value(value)
-                        if value != "":
-                            s.append("kmi.properties.%s = %s\n" % (pname, value))
+                export_properties("kmi.properties", props)
 
             return "".join(s).strip()
 
@@ -1656,65 +1797,118 @@ class WM_OT_keyconfig_test(bpy.types.Operator):
 
 
 def _string_value(value):
-    result = ""
-    if isinstance(value, str):
-        if value != "":
-            result = "\'%s\'" % value
-    elif isinstance(value, bool):
-        if value:
-            result = "True"
-        else:
-            result = "False"
-    elif isinstance(value, float):
-        result = "%.10f" % value
-    elif isinstance(value, int):
-        result = "%d" % value
+    if isinstance(value, str) or isinstance(value, bool) or isinstance(value, float) or isinstance(value, int):
+        result = repr(value)
     elif getattr(value, '__len__', False):
-        if len(value):
-            result = "["
-            for i in range(0, len(value)):
-                result += _string_value(value[i])
-                if i != len(value)-1:
-                    result += ", "
-            result += "]"
+        repr(list(value))
     else:
         print("Export key configuration: can't write ", value)
 
     return result
 
 
+class WM_OT_keyconfig_import(bpy.types.Operator):
+    "Import key configuration from a python script"
+    bl_idname = "wm.keyconfig_import"
+    bl_label = "Import Key Configuration..."
+
+    path = StringProperty(name="File Path", description="File path to write file to")
+    filename = StringProperty(name="File Name", description="Name of the file")
+    directory = StringProperty(name="Directory", description="Directory of the file")
+    filter_folder = BoolProperty(name="Filter folders", description="", default=True, options={'HIDDEN'})
+    filter_text = BoolProperty(name="Filter text", description="", default=True, options={'HIDDEN'})
+    filter_python = BoolProperty(name="Filter python", description="", default=True, options={'HIDDEN'})
+
+    keep_original = BoolProperty(name="Keep original", description="Keep original file after copying to configuration folder", default=True)
+
+    def execute(self, context):
+        if not self.properties.path:
+            raise Exception("File path not set")
+
+        f = open(self.properties.path, "r")
+        if not f:
+            raise Exception("Could not open file")
+
+        name_pattern = re.compile("^kc = wm.add_keyconfig\('(.*)'\)$")
+
+        for line in f.readlines():
+            match = name_pattern.match(line)
+
+            if match:
+                config_name = match.groups()[0]
+
+        f.close()
+
+        path = os.path.split(os.path.split(__file__)[0])[0] # remove ui/space_userpref.py
+        path = os.path.join(path, "cfg")
+
+        # create config folder if needed
+        if not os.path.exists(path):
+            os.mkdir(path)
+
+        path = os.path.join(path, config_name + ".py")
+
+        if self.properties.keep_original:
+            shutil.copy(self.properties.path, path)
+        else:
+            shutil.move(self.properties.path, path)
+
+        exec("import " + config_name)
+
+        wm = bpy.context.manager
+        wm.active_keyconfig = wm.keyconfigs[config_name]
+
+        return {'FINISHED'}
+
+    def invoke(self, context, event):
+        wm = context.manager
+        wm.add_fileselect(self)
+        return {'RUNNING_MODAL'}
+
+
 class WM_OT_keyconfig_export(bpy.types.Operator):
-    "Export key configuration to a python script."
+    "Export key configuration to a python script"
     bl_idname = "wm.keyconfig_export"
     bl_label = "Export Key Configuration..."
 
-    path = bpy.props.StringProperty(name="File Path", description="File path to write file to.")
+    path = StringProperty(name="File Path", description="File path to write file to")
+    filename = StringProperty(name="File Name", description="Name of the file")
+    directory = StringProperty(name="Directory", description="Directory of the file")
+    filter_folder = BoolProperty(name="Filter folders", description="", default=True, options={'HIDDEN'})
+    filter_text = BoolProperty(name="Filter text", description="", default=True, options={'HIDDEN'})
+    filter_python = BoolProperty(name="Filter python", description="", default=True, options={'HIDDEN'})
 
     def execute(self, context):
         if not self.properties.path:
-            raise Exception("File path not set.")
+            raise Exception("File path not set")
 
         f = open(self.properties.path, "w")
         if not f:
-            raise Exception("Could not open file.")
+            raise Exception("Could not open file")
 
         wm = context.manager
         kc = wm.active_keyconfig
 
-        f.write('# Configuration %s\n' % kc.name)
+        if kc.name == 'Blender':
+            name = os.path.splitext(os.path.basename(self.properties.path))[0]
+        else:
+            name = kc.name
+
+        f.write("# Configuration %s\n" % name)
 
-        f.write("wm = bpy.data.windowmanagers[0]\n")
-        f.write("kc = wm.add_keyconfig(\'%s\')\n\n" % kc.name)
+        f.write("import bpy\n\n")
+        f.write("wm = bpy.context.manager\n")
+        f.write("kc = wm.add_keyconfig('%s')\n\n" % name)
 
         for km in kc.keymaps:
             km = km.active()
             f.write("# Map %s\n" % km.name)
-            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))
+            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))
             for kmi in km.items:
                 if km.modal:
-                    f.write("kmi = km.add_modal_item(\'%s\', \'%s\', \'%s\'" % (kmi.propvalue, kmi.type, kmi.value))
+                    f.write("kmi = km.add_modal_item('%s', '%s', '%s'" % (kmi.propvalue, kmi.type, kmi.value))
                 else:
-                    f.write("kmi = km.add_item(\'%s\', \'%s\', \'%s\'" % (kmi.idname, kmi.type, kmi.value))
+                    f.write("kmi = km.add_item('%s', '%s', '%s'" % (kmi.idname, kmi.type, kmi.value))
                 if kmi.any:
                     f.write(", any=True")
                 else:
@@ -1727,18 +1921,24 @@ class WM_OT_keyconfig_export(bpy.types.Operator):
                     if kmi.oskey:
                         f.write(", oskey=True")
                 if kmi.key_modifier and kmi.key_modifier != 'NONE':
-                    f.write(", key_modifier=\'%s\'" % kmi.key_modifier)
+                    f.write(", key_modifier='%s'" % kmi.key_modifier)
                 f.write(")\n")
 
+                def export_properties(prefix, properties):
+                    for pname in dir(properties):
+                        if not properties.is_property_hidden(pname):
+                            value = eval("properties.%s" % pname)
+                            if isinstance(value, bpy.types.OperatorProperties):
+                                export_properties(prefix + "." + pname, value)
+                            elif properties.is_property_set(pname):
+                                value = _string_value(value)
+                                if value != "":
+                                    f.write(prefix + ".%s = %s\n" % (pname, value))
+
                 props = kmi.properties
 
                 if props is not None:
-                    for pname in dir(props):
-                        if props.is_property_set(pname) and not props.is_property_hidden(pname):
-                            value = eval("props.%s" % pname)
-                            value = _string_value(value)
-                            if value != "":
-                                f.write("kmi.properties.%s = %s\n" % (pname, value))
+                    export_properties("kmi.properties", props)
 
             f.write("\n")
 
@@ -1753,7 +1953,7 @@ class WM_OT_keyconfig_export(bpy.types.Operator):
 
 
 class WM_OT_keymap_edit(bpy.types.Operator):
-    "Edit key map."
+    "Edit key map"
     bl_idname = "wm.keymap_edit"
     bl_label = "Edit Key Map"
 
@@ -1765,11 +1965,11 @@ class WM_OT_keymap_edit(bpy.types.Operator):
 
 
 class WM_OT_keymap_restore(bpy.types.Operator):
-    "Restore key map(s)."
+    "Restore key map(s)"
     bl_idname = "wm.keymap_restore"
     bl_label = "Restore Key Map(s)"
 
-    all = BoolProperty(attr="all", name="All Keymaps", description="Restore all keymaps to default.")
+    all = BoolProperty(attr="all", name="All Keymaps", description="Restore all keymaps to default")
 
     def execute(self, context):
         wm = context.manager
@@ -1785,19 +1985,16 @@ class WM_OT_keymap_restore(bpy.types.Operator):
 
 
 class WM_OT_keyitem_restore(bpy.types.Operator):
-    "Restore key map item."
+    "Restore key map item"
     bl_idname = "wm.keyitem_restore"
     bl_label = "Restore Key Map Item"
 
-    def poll(self, context):
-        kmi = context.keyitem
-        km = context.keymap
-        return km and kmi and kmi.id != 0
+    item_id = IntProperty(attr="item_id", name="Item Identifier", description="Identifier of the item to remove")
 
     def execute(self, context):
         wm = context.manager
-        kmi = context.keyitem
         km = context.keymap
+        kmi = km.item_from_id(self.properties.item_id)
 
         km.restore_item_to_default(kmi)
 
@@ -1805,7 +2002,7 @@ class WM_OT_keyitem_restore(bpy.types.Operator):
 
 
 class WM_OT_keyitem_add(bpy.types.Operator):
-    "Add key map item."
+    "Add key map item"
     bl_idname = "wm.keyitem_add"
     bl_label = "Add Key Map Item"
 
@@ -1813,37 +2010,101 @@ class WM_OT_keyitem_add(bpy.types.Operator):
         wm = context.manager
         km = context.keymap
         kc = wm.default_keyconfig
-        
+
         if km.modal:
             km.add_modal_item("", 'A', 'PRESS') # kmi
         else:
             km.add_item("none", 'A', 'PRESS') # kmi
-            
+
         # clear filter and expand keymap so we can see the newly added item
         if kc.filter != '':
             kc.filter = ''
             km.items_expanded = True
             km.children_expanded = True
-        
+
         return {'FINISHED'}
 
 
 class WM_OT_keyitem_remove(bpy.types.Operator):
-    "Remove key map item."
+    "Remove key map item"
     bl_idname = "wm.keyitem_remove"
     bl_label = "Remove Key Map Item"
 
+    item_id = IntProperty(attr="item_id", name="Item Identifier", description="Identifier of the item to remove")
+
     def execute(self, context):
         wm = context.manager
-        kmi = context.keyitem
         km = context.keymap
+        kmi = km.item_from_id(self.properties.item_id)
         km.remove_item(kmi)
         return {'FINISHED'}
 
-bpy.types.register(WM_OT_keyconfig_export)
-bpy.types.register(WM_OT_keyconfig_test)
-bpy.types.register(WM_OT_keymap_edit)
-bpy.types.register(WM_OT_keymap_restore)
-bpy.types.register(WM_OT_keyitem_add)
-bpy.types.register(WM_OT_keyitem_remove)
-bpy.types.register(WM_OT_keyitem_restore)
+
+class WM_OT_keyconfig_remove(bpy.types.Operator):
+    "Remove key config"
+    bl_idname = "wm.keyconfig_remove"
+    bl_label = "Remove Key Config"
+
+    def poll(self, context):
+        wm = context.manager
+        return wm.active_keyconfig.user_defined
+
+    def execute(self, context):
+        wm = context.manager
+
+        keyconfig = wm.active_keyconfig
+
+        module = __import__(keyconfig.name)
+
+        os.remove(module.__file__)
+
+        compiled_path = module.__file__ + "c" # for .pyc
+
+        if os.path.exists(compiled_path):
+            os.remove(compiled_path)
+
+        wm.remove_keyconfig(keyconfig)
+        return {'FINISHED'}
+
+
+classes = [
+    USERPREF_HT_header,
+    USERPREF_PT_tabs,
+    USERPREF_PT_interface,
+    USERPREF_PT_theme,
+    USERPREF_PT_edit,
+    USERPREF_PT_system,
+    USERPREF_PT_file,
+    USERPREF_PT_input,
+    USERPREF_PT_addons,
+
+    WM_OT_addon_enable,
+    WM_OT_addon_disable,
+    WM_OT_addon_install,
+    WM_OT_addon_expand,
+    WM_OT_addon_links,
+
+    WM_OT_keyconfig_export,
+    WM_OT_keyconfig_import,
+    WM_OT_keyconfig_test,
+    WM_OT_keyconfig_remove,
+    WM_OT_keymap_edit,
+    WM_OT_keymap_restore,
+    WM_OT_keyitem_add,
+    WM_OT_keyitem_remove,
+    WM_OT_keyitem_restore]
+
+
+def register():
+    register = bpy.types.register
+    for cls in classes:
+        register(cls)
+
+
+def unregister():
+    unregister = bpy.types.unregister
+    for cls in classes:
+        unregister(cls)
+
+if __name__ == "__main__":
+    register()