Merged changes in the trunk up to revision 32124.
[blender-staging.git] / release / scripts / ui / space_userpref.py
index 74e1d758eeaf4a2aa05492dac8287d0dfb731c74..9c1d114da12db01ed3eb284960d7cbaa4fc041ac 100644 (file)
@@ -927,8 +927,8 @@ class USERPREF_PT_addons(bpy.types.Panel):
 
         split = layout.split(percentage=0.2)
         col = split.column()
-        col.prop(context.window_manager, "addon_filter", text="Filter", expand=True)
         col.prop(context.window_manager, "addon_search", text="", icon='VIEWZOOM')
+        col.prop(context.window_manager, "addon_filter", text="Filter", expand=True)
 
         col = split.column()
 
@@ -988,7 +988,7 @@ class USERPREF_PT_addons(bpy.types.Panel):
                     if info["version"]:
                         split = colsub.row().split(percentage=0.15)
                         split.label(text='Version:')
-                        split.label(text='.'.join([str(x) for x in info["version"]]))
+                        split.label(text='.'.join(str(x) for x in info["version"]))
                     if info["warning"]:
                         split = colsub.row().split(percentage=0.15)
                         split.label(text="Warning:")
@@ -1017,14 +1017,18 @@ class USERPREF_PT_addons(bpy.types.Panel):
             col.column().label(text="Missing script files")
 
             module_names = {mod.__name__ for mod, info in addons}
-            for ext in sorted(missing_modules):
+            for module_name in sorted(missing_modules):
+                is_enabled = module_name in used_ext
                 # Addon UI Code
                 box = col.column().box()
                 colsub = box.column()
                 row = colsub.row()
 
-                row.label(text=ext, icon='ERROR')
-                row.operator("wm.addon_disable").module = ext
+                row.label(text=module_name, icon='ERROR')
+
+                if is_enabled:
+                    row.operator("wm.addon_disable", icon='CHECKBOX_HLT', text="", emboss=False).module = module_name
+
 
 from bpy.props import *
 
@@ -1092,6 +1096,7 @@ class WM_OT_addon_install(bpy.types.Operator):
     filepath = StringProperty(name="File Path", description="File path to write file to")
     filter_folder = BoolProperty(name="Filter folders", description="", default=True, options={'HIDDEN'})
     filter_python = BoolProperty(name="Filter python", description="", default=True, options={'HIDDEN'})
+    filter_glob = StringProperty(default="*.py;*.zip", options={'HIDDEN'})
 
     def execute(self, context):
         import traceback
@@ -1099,6 +1104,7 @@ class WM_OT_addon_install(bpy.types.Operator):
         pyfile = self.filepath
 
         path_addons = bpy.utils.script_paths("addons")[-1]
+        contents = set(os.listdir(path_addons))
 
         #check to see if the file is in compressed format (.zip)
         if zipfile.is_zipfile(pyfile):
@@ -1127,6 +1133,23 @@ class WM_OT_addon_install(bpy.types.Operator):
                 traceback.print_exc()
                 return {'CANCELLED'}
 
+        # disable any addons we may have enabled previously and removed.
+        # this is unlikely but do just incase. bug [#23978]
+        addons_new = set(os.listdir(path_addons)) - contents
+        for new_addon in addons_new:
+            bpy.utils.addon_disable(os.path.splitext(new_addon)[0])
+
+        # possible the zip contains multiple addons, we could disallow this
+        # but for now just use the first
+        for mod in USERPREF_PT_addons._addon_list():
+            if mod.__name__ in addons_new:
+                info = addon_info_get(mod)
+
+                # show the newly installed addon.
+                context.window_manager.addon_filter = 'All'
+                context.window_manager.addon_search = info["name"]
+                break
+
         # TODO, should not be a warning.
         # self.report({'WARNING'}, "File installed to '%s'\n" % path_dest)
         return {'FINISHED'}