2017-06-22 01:43:08 -07:00
|
|
|
bl_info = {
|
|
|
|
'name': 'Package Manager',
|
|
|
|
'description': 'Testing package management',
|
|
|
|
'category': 'System',
|
|
|
|
'support': 'TESTING',
|
|
|
|
}
|
|
|
|
import bpy
|
2017-07-04 02:11:03 -07:00
|
|
|
from bpy.props import CollectionProperty
|
|
|
|
from bpy.types import PropertyGroup, Panel, UIList, AddonPreferences
|
2017-06-22 01:43:08 -07:00
|
|
|
|
2017-07-04 02:11:03 -07:00
|
|
|
class RepositoryProperty(PropertyGroup):
|
2017-06-22 01:43:08 -07:00
|
|
|
url = bpy.props.StringProperty(name="URL")
|
|
|
|
|
2017-07-04 02:11:03 -07:00
|
|
|
class PACKAGE_UL_repositories(UIList):
|
|
|
|
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
|
|
|
split = layout.split(0.3)
|
|
|
|
split.prop(item, "name")
|
|
|
|
split.prop(item, "url")
|
|
|
|
|
|
|
|
def invoke(self, onctext, event):
|
|
|
|
pass
|
|
|
|
|
|
|
|
class PackagePreferences(AddonPreferences):
|
|
|
|
bl_idname = __package__
|
|
|
|
|
|
|
|
repositories = CollectionProperty(type=RepositoryProperty)
|
|
|
|
active_repository = bpy.props.IntProperty()
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
row = layout.row()
|
|
|
|
row.template_list("PACKAGE_UL_repositories", "", self, "repositories", self, "active_repository")
|
|
|
|
col = row.column(align=True)
|
|
|
|
col.operator("package.add_repository", icon="ZOOMIN", text="")
|
|
|
|
col.operator("package.remove_repository", icon="ZOOMOUT", text="")
|
|
|
|
|
2017-06-29 17:46:08 -07:00
|
|
|
# class PackageManager:
|
2017-06-29 21:11:43 -07:00
|
|
|
# # For some reason accessing *Property objects stored in this class gives a TypeError:
|
|
|
|
# # UILayout.prop(): error with argument 1, "data" - Function.data expected a AnyType type, not tuple
|
|
|
|
# # But accessing them when not stored in a class or dict is fine?
|
|
|
|
# settings = bpy.props.PointerProperty(type=PackageSettings)
|
|
|
|
# last_response_code = bpy.props.PointerProperty(type=bpy.types.StringProperty)
|
2017-06-29 17:46:08 -07:00
|
|
|
|
2017-06-22 01:43:08 -07:00
|
|
|
def register():
|
|
|
|
|
2017-07-04 02:11:03 -07:00
|
|
|
# Reload support
|
|
|
|
import sys
|
|
|
|
if '%s.pkg_ops' % __name__ in sys.modules:
|
|
|
|
import importlib
|
|
|
|
def reload_mod(name):
|
|
|
|
print("Reloading %s" % name)
|
|
|
|
modname = '%s.%s' % (__name__, name)
|
|
|
|
try:
|
|
|
|
old_module = sys.modules[modname]
|
|
|
|
except KeyError:
|
|
|
|
# Wasn't loaded before -- can happen after an upgrade.
|
|
|
|
new_module = importlib.import_module(modname)
|
|
|
|
else:
|
|
|
|
new_module = importlib.reload(old_module)
|
|
|
|
|
|
|
|
sys.modules[modname] = new_module
|
|
|
|
return new_module
|
|
|
|
|
|
|
|
pkg_ops = reload_mod('pkg_ops')
|
|
|
|
pkg_ui = reload_mod('pkg_ui')
|
|
|
|
|
|
|
|
else:
|
|
|
|
from . import (pkg_ops, pkg_ui)
|
|
|
|
|
|
|
|
bpy.utils.register_class(RepositoryProperty)
|
|
|
|
bpy.utils.register_class(PACKAGE_UL_repositories)
|
|
|
|
bpy.utils.register_class(PackagePreferences)
|
2017-06-22 01:43:08 -07:00
|
|
|
pkg_ops.register()
|
|
|
|
pkg_ui.register()
|
|
|
|
|
|
|
|
def unregister():
|
|
|
|
from . import (pkg_ops, pkg_ui)
|
|
|
|
|
|
|
|
pkg_ops.unregister()
|
|
|
|
pkg_ui.unregister();
|
2017-07-04 02:11:03 -07:00
|
|
|
bpy.utils.unregister_class(RepositoryProperty)
|
|
|
|
bpy.utils.unregister_class(PACKAGE_UL_repositories)
|
|
|
|
bpy.utils.unregister_class(PackagePreferences)
|
|
|
|
del bpy.types.Scene.custom
|
|
|
|
del bpy.types.Scene.custom_idx
|
2017-06-22 01:43:08 -07:00
|
|
|
|