Package Manager add-on now functional, with limitations
- For now, add-ons are downloaded from http://localhost:8000/. - Add-ons on the index.json (from blender.org gitweb) are only displayed if they are not installed locally, or installed in the USER path. - Only .py add-ons are supported for now, but .zip add-ons will be supported next commit.
This commit is contained in:
@@ -30,10 +30,18 @@ bl_info = {
|
||||
|
||||
|
||||
import bpy
|
||||
import addon_utils
|
||||
from bpy.types import Operator, AddonPreferences
|
||||
from bpy.props import StringProperty, BoolProperty, IntProperty, CollectionProperty
|
||||
|
||||
from . import networking
|
||||
if "bpy" in locals():
|
||||
import imp
|
||||
try:
|
||||
imp.reload(networking)
|
||||
except NameError:
|
||||
from . import networking
|
||||
else:
|
||||
from . import networking
|
||||
|
||||
class PackageManagerAddon(bpy.types.PropertyGroup):
|
||||
source = StringProperty()
|
||||
@@ -49,6 +57,7 @@ class PackageManagerAddon(bpy.types.PropertyGroup):
|
||||
warning = StringProperty()
|
||||
support = StringProperty()
|
||||
filename = StringProperty()
|
||||
module_name = StringProperty()
|
||||
|
||||
class PackageManagerPreferences(AddonPreferences):
|
||||
# this must match the addon name, use '__package__'
|
||||
@@ -56,15 +65,74 @@ class PackageManagerPreferences(AddonPreferences):
|
||||
bl_idname = __name__
|
||||
|
||||
pm_addons = CollectionProperty(type=PackageManagerAddon)
|
||||
|
||||
pm_addons_index = IntProperty()
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.operator("wm.update_index", text="Update List", icon='FILE_REFRESH')
|
||||
rows = 1 if len(self.pm_addons) == 0 else 6
|
||||
rows = 1 if len(self.pm_addons) == 0 else 4
|
||||
layout.template_list("UI_UL_list", "addons_list", self, "pm_addons",
|
||||
self, "pm_addons_index", rows=rows)
|
||||
|
||||
if len(self.pm_addons) == 0:
|
||||
# No add-ons, return
|
||||
return
|
||||
|
||||
# Display selected add-on
|
||||
addon = self.pm_addons[self.pm_addons_index]
|
||||
|
||||
installed = False
|
||||
for module in addon_utils.modules():
|
||||
if module.__name__ == addon.module_name:
|
||||
installed = True
|
||||
break
|
||||
|
||||
col_box = layout.column()
|
||||
box = col_box.box()
|
||||
colsub = box.column()
|
||||
|
||||
split = colsub.row().split(percentage=0.25)
|
||||
split.label(text="Installed: %s" % ("Yes" if installed else "No"))
|
||||
split.separator()
|
||||
split.separator()
|
||||
split.operator("wm.addon_download_install",
|
||||
text="Install from Web",
|
||||
icon='URL').addon = addon.module_name
|
||||
|
||||
if addon.description:
|
||||
split = colsub.row().split(percentage=0.15)
|
||||
split.label(text="Description:")
|
||||
split.label(text=addon.description)
|
||||
if addon.location:
|
||||
split = colsub.row().split(percentage=0.15)
|
||||
split.label(text="Location:")
|
||||
split.label(text=addon.location)
|
||||
if addon.author:
|
||||
split = colsub.row().split(percentage=0.15)
|
||||
split.label(text="Author:")
|
||||
split.label(text=addon.author, translate=False)
|
||||
if addon.version:
|
||||
split = colsub.row().split(percentage=0.15)
|
||||
split.label(text="Version:")
|
||||
split.label(text=addon.version, translate=False)
|
||||
if addon.warning:
|
||||
split = colsub.row().split(percentage=0.15)
|
||||
split.label(text="Warning:")
|
||||
split.label(text=' ' + addon.warning, icon='ERROR')
|
||||
|
||||
tot_row = bool(addon.wiki_url)
|
||||
|
||||
if tot_row:
|
||||
split = colsub.row().split(percentage=0.15)
|
||||
split.label(text="Internet:")
|
||||
if addon.wiki_url:
|
||||
split.operator("wm.url_open", text="Documentation", icon='HELP').url = addon.wiki_url
|
||||
split.operator("wm.url_open", text="Report a Bug", icon='URL').url = addon.get(
|
||||
"tracker_url",
|
||||
"http://developer.blender.org/maniphest/task/create/?project=3&type=Bug")
|
||||
|
||||
for i in range(4 - tot_row):
|
||||
split.separator()
|
||||
|
||||
def register():
|
||||
networking.register()
|
||||
|
Reference in New Issue
Block a user