rename extension to addon after discussion with meta-androcto & mindrones

This commit is contained in:
2010-02-26 14:28:29 +00:00
parent bbf6dde277
commit 10dbf6faee
12 changed files with 76 additions and 76 deletions

View File

@@ -187,9 +187,9 @@ def load_scripts(reload_scripts=False, refresh_scripts=False):
for mod in modules_from_path(path, loaded_modules): for mod in modules_from_path(path, loaded_modules):
test_register(mod) test_register(mod)
# load extensions # load addons
used_ext = {ext.module for ext in _bpy.context.user_preferences.extensions} used_ext = {ext.module for ext in _bpy.context.user_preferences.addons}
paths = script_paths("extensions") paths = script_paths("addons")
for path in paths: for path in paths:
sys_path_ensure(path) sys_path_ensure(path)

View File

@@ -171,9 +171,9 @@ class USERPREF_HT_header(bpy.types.Header):
op.path = "keymap.py" op.path = "keymap.py"
op = layout.operator("wm.keyconfig_import", "Import Key Configuration...") op = layout.operator("wm.keyconfig_import", "Import Key Configuration...")
op.path = "keymap.py" op.path = "keymap.py"
elif userpref.active_section == 'EXTENSIONS': elif userpref.active_section == 'ADDONS':
layout.operator_context = 'INVOKE_DEFAULT' layout.operator_context = 'INVOKE_DEFAULT'
op = layout.operator("wm.extension_install", "Install Extension...") op = layout.operator("wm.addon_install", "Install Add-On...")
op.path = "*.py" op.path = "*.py"
@@ -1359,21 +1359,21 @@ class USERPREF_PT_input(bpy.types.Panel):
#print("runtime", time.time() - start) #print("runtime", time.time() - start)
class USERPREF_PT_extensions(bpy.types.Panel): class USERPREF_PT_addons(bpy.types.Panel):
bl_space_type = 'USER_PREFERENCES' bl_space_type = 'USER_PREFERENCES'
bl_label = "Extensions" bl_label = "Addons"
bl_region_type = 'WINDOW' bl_region_type = 'WINDOW'
bl_show_header = False bl_show_header = False
def poll(self, context): def poll(self, context):
userpref = context.user_preferences userpref = context.user_preferences
return (userpref.active_section == 'EXTENSIONS') return (userpref.active_section == 'ADDONS')
def _extension_list(self): def _addon_list(self):
import sys import sys
modules = [] modules = []
loaded_modules = set() loaded_modules = set()
paths = bpy.utils.script_paths("extensions") paths = bpy.utils.script_paths("addons")
# sys.path.insert(0, None) # sys.path.insert(0, None)
for path in paths: for path in paths:
# sys.path[0] = path # sys.path[0] = path
@@ -1386,11 +1386,11 @@ class USERPREF_PT_extensions(bpy.types.Panel):
layout = self.layout layout = self.layout
userpref = context.user_preferences userpref = context.user_preferences
used_ext = {ext.module for ext in userpref.extensions} used_ext = {ext.module for ext in userpref.addons}
col = layout.column() col = layout.column()
for mod in self._extension_list(): for mod in self._addon_list():
box = col.box() box = col.box()
row = box.row() row = box.row()
text = mod.__doc__ text = mod.__doc__
@@ -1398,22 +1398,22 @@ class USERPREF_PT_extensions(bpy.types.Panel):
text = mod.__name__ text = mod.__name__
row.label(text=text) row.label(text=text)
module_name = mod.__name__ module_name = mod.__name__
row.operator("wm.extension_disable" if module_name in used_ext else "wm.extension_enable").module = module_name row.operator("wm.addon_disable" if module_name in used_ext else "wm.addon_enable").module = module_name
from bpy.props import * from bpy.props import *
class WM_OT_extension_enable(bpy.types.Operator): class WM_OT_addon_enable(bpy.types.Operator):
"Enable an extension" "Enable an addon"
bl_idname = "wm.extension_enable" bl_idname = "wm.addon_enable"
bl_label = "Enable Extension" bl_label = "Enable Add-On"
module = StringProperty(name="Module", description="Module name of the extension to enable") module = StringProperty(name="Module", description="Module name of the addon to enable")
def execute(self, context): def execute(self, context):
import traceback import traceback
ext = context.user_preferences.extensions.new() ext = context.user_preferences.addons.new()
module_name = self.properties.module module_name = self.properties.module
ext.module = module_name ext.module = module_name
@@ -1426,12 +1426,12 @@ class WM_OT_extension_enable(bpy.types.Operator):
return {'FINISHED'} return {'FINISHED'}
class WM_OT_extension_disable(bpy.types.Operator): class WM_OT_addon_disable(bpy.types.Operator):
"Disable an extension" "Disable an addon"
bl_idname = "wm.extension_disable" bl_idname = "wm.addon_disable"
bl_label = "Disable Extension" bl_label = "Disable Add-On"
module = StringProperty(name="Module", description="Module name of the extension to disable") module = StringProperty(name="Module", description="Module name of the addon to disable")
def execute(self, context): def execute(self, context):
import traceback import traceback
@@ -1443,25 +1443,25 @@ class WM_OT_extension_disable(bpy.types.Operator):
except: except:
traceback.print_exc() traceback.print_exc()
extensions = context.user_preferences.extensions addons = context.user_preferences.addons
ok = True ok = True
while ok: # incase its in more then once. while ok: # incase its in more then once.
ok = False ok = False
for ext in extensions: for ext in addons:
if ext.module == module_name: if ext.module == module_name:
extensions.remove(ext) addons.remove(ext)
ok = True ok = True
break break
return {'FINISHED'} return {'FINISHED'}
class WM_OT_extension_install(bpy.types.Operator): class WM_OT_addon_install(bpy.types.Operator):
"Install an extension" "Install an addon"
bl_idname = "wm.extension_install" bl_idname = "wm.addon_install"
bl_label = "Install Extension" bl_label = "Install Add-On"
module = StringProperty(name="Module", description="Module name of the extension to disable") module = StringProperty(name="Module", description="Module name of the addon to disable")
path = 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") filename = StringProperty(name="File Name", description="Name of the file")
@@ -1473,7 +1473,7 @@ class WM_OT_extension_install(bpy.types.Operator):
import traceback import traceback
pyfile = self.properties.path pyfile = self.properties.path
paths = bpy.utils.script_paths("extensions") paths = bpy.utils.script_paths("addons")
path_dest = os.path.join(paths[-1], os.path.basename(pyfile)) path_dest = os.path.join(paths[-1], os.path.basename(pyfile))
if os.path.exists(path_dest): if os.path.exists(path_dest):
@@ -1495,9 +1495,9 @@ class WM_OT_extension_install(bpy.types.Operator):
return {'FINISHED'} return {'FINISHED'}
def invoke(self, context, event): def invoke(self, context, event):
paths = bpy.utils.script_paths("extensions") paths = bpy.utils.script_paths("addons")
if not paths: if not paths:
self.report({'ERROR'}, "No 'extensions' path could be found in " + str(bpy.utils.script_paths())) self.report({'ERROR'}, "No 'addons' path could be found in " + str(bpy.utils.script_paths()))
return {'CANCELLED'} return {'CANCELLED'}
wm = context.manager wm = context.manager
@@ -1893,11 +1893,11 @@ classes = [
USERPREF_PT_system, USERPREF_PT_system,
USERPREF_PT_file, USERPREF_PT_file,
USERPREF_PT_input, USERPREF_PT_input,
USERPREF_PT_extensions, USERPREF_PT_addons,
WM_OT_extension_enable, WM_OT_addon_enable,
WM_OT_extension_disable, WM_OT_addon_disable,
WM_OT_extension_install, WM_OT_addon_install,
WM_OT_keyconfig_export, WM_OT_keyconfig_export,
WM_OT_keyconfig_import, WM_OT_keyconfig_import,

View File

@@ -358,7 +358,7 @@ void BKE_userdef_free(void)
BLI_freelistN(&U.uifonts); BLI_freelistN(&U.uifonts);
BLI_freelistN(&U.themes); BLI_freelistN(&U.themes);
BLI_freelistN(&U.keymaps); BLI_freelistN(&U.keymaps);
BLI_freelistN(&U.extensions); BLI_freelistN(&U.addons);
} }
/* returns: /* returns:

View File

@@ -10690,7 +10690,7 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead)
link_list(fd, &user->themes); link_list(fd, &user->themes);
link_list(fd, &user->keymaps); link_list(fd, &user->keymaps);
link_list(fd, &user->extensions); link_list(fd, &user->addons);
for(keymap=user->keymaps.first; keymap; keymap=keymap->next) { for(keymap=user->keymaps.first; keymap; keymap=keymap->next) {
keymap->modal_items= NULL; keymap->modal_items= NULL;

View File

@@ -542,7 +542,7 @@ static void write_userdef(WriteData *wd)
bTheme *btheme; bTheme *btheme;
wmKeyMap *keymap; wmKeyMap *keymap;
wmKeyMapItem *kmi; wmKeyMapItem *kmi;
bExtension *bext; bAddon *bext;
writestruct(wd, USER, "UserDef", 1, &U); writestruct(wd, USER, "UserDef", 1, &U);
@@ -560,8 +560,8 @@ static void write_userdef(WriteData *wd)
} }
} }
for(bext= U.extensions.first; bext; bext=bext->next) for(bext= U.addons.first; bext; bext=bext->next)
writestruct(wd, DATA, "bExtension", 1, bext); writestruct(wd, DATA, "bAddon", 1, bext);
} }
static void write_boid_state(WriteData *wd, BoidState *state) static void write_boid_state(WriteData *wd, BoidState *state)

View File

@@ -276,10 +276,10 @@ typedef struct bTheme {
} bTheme; } bTheme;
/* for the moment only the name. may want to store options with this later */ /* for the moment only the name. may want to store options with this later */
typedef struct bExtension { typedef struct bAddon {
struct bExtension *next, *prev; struct bAddon *next, *prev;
char module[64]; char module[64];
} bExtension; } bAddon;
typedef struct SolidLight { typedef struct SolidLight {
int flag, pad; int flag, pad;
@@ -327,7 +327,7 @@ typedef struct UserDef {
struct ListBase uifonts; struct ListBase uifonts;
struct ListBase uistyles; struct ListBase uistyles;
struct ListBase keymaps; struct ListBase keymaps;
struct ListBase extensions; struct ListBase addons;
char keyconfigstr[64]; char keyconfigstr[64];
short undosteps; short undosteps;
@@ -378,7 +378,7 @@ extern UserDef U; /* from blenkernel blender.c */
#define USER_SECTION_SYSTEM 3 #define USER_SECTION_SYSTEM 3
#define USER_SECTION_THEME 4 #define USER_SECTION_THEME 4
#define USER_SECTION_INPUT 5 #define USER_SECTION_INPUT 5
#define USER_SECTION_EXTENSIONS 6 #define USER_SECTION_ADDONS 6
/* flag */ /* flag */
#define USER_AUTOSAVE (1 << 0) #define USER_AUTOSAVE (1 << 0)

View File

@@ -49,6 +49,7 @@ extern StructRNA RNA_ActionConstraint;
extern StructRNA RNA_ActionGroup; extern StructRNA RNA_ActionGroup;
extern StructRNA RNA_Actuator; extern StructRNA RNA_Actuator;
extern StructRNA RNA_ActuatorSensor; extern StructRNA RNA_ActuatorSensor;
extern StructRNA RNA_Addon;
extern StructRNA RNA_AlwaysSensor; extern StructRNA RNA_AlwaysSensor;
extern StructRNA RNA_AndController; extern StructRNA RNA_AndController;
extern StructRNA RNA_AnimData; extern StructRNA RNA_AnimData;
@@ -198,7 +199,6 @@ extern StructRNA RNA_EnvironmentMapTexture;
extern StructRNA RNA_Event; extern StructRNA RNA_Event;
extern StructRNA RNA_ExplodeModifier; extern StructRNA RNA_ExplodeModifier;
extern StructRNA RNA_ExpressionController; extern StructRNA RNA_ExpressionController;
extern StructRNA RNA_Extension;
extern StructRNA RNA_FCurve; extern StructRNA RNA_FCurve;
extern StructRNA RNA_FCurveSample; extern StructRNA RNA_FCurveSample;
extern StructRNA RNA_FieldSettings; extern StructRNA RNA_FieldSettings;

View File

@@ -211,16 +211,16 @@ static void rna_userdef_autosave_update(Main *bmain, Scene *scene, PointerRNA *p
rna_userdef_update(bmain, scene, ptr); rna_userdef_update(bmain, scene, ptr);
} }
static bExtension *rna_userdef_extension_new(void) static bAddon *rna_userdef_addon_new(void)
{ {
bExtension *bext= MEM_callocN(sizeof(bExtension), "bext"); bAddon *bext= MEM_callocN(sizeof(bAddon), "bAddon");
BLI_addtail(&U.extensions, bext); BLI_addtail(&U.addons, bext);
return bext; return bext;
} }
static void rna_userdef_extension_remove(bExtension *bext) static void rna_userdef_addon_remove(bAddon *bext)
{ {
BLI_freelinkN(&U.extensions, bext); BLI_freelinkN(&U.addons, bext);
} }
@@ -1687,14 +1687,14 @@ static void rna_def_userdef_themes(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Bone Color Sets", ""); RNA_def_property_ui_text(prop, "Bone Color Sets", "");
} }
static void rna_def_userdef_extensions(BlenderRNA *brna) static void rna_def_userdef_addon(BlenderRNA *brna)
{ {
StructRNA *srna; StructRNA *srna;
PropertyRNA *prop; PropertyRNA *prop;
srna= RNA_def_struct(brna, "Extension", NULL); srna= RNA_def_struct(brna, "Addon", NULL);
RNA_def_struct_sdna(srna, "bExtension"); RNA_def_struct_sdna(srna, "bAddon");
RNA_def_struct_ui_text(srna, "Extension", "Python extensions to be loaded automatically"); RNA_def_struct_ui_text(srna, "Addon", "Python addons to be loaded automatically");
prop= RNA_def_property(srna, "module", PROP_STRING, PROP_NONE); prop= RNA_def_property(srna, "module", PROP_STRING, PROP_NONE);
RNA_def_property_ui_text(prop, "Module", "Module name"); RNA_def_property_ui_text(prop, "Module", "Module name");
@@ -1727,7 +1727,6 @@ static void rna_def_userdef_dothemes(BlenderRNA *brna)
rna_def_userdef_theme_space_logic(brna); rna_def_userdef_theme_space_logic(brna);
rna_def_userdef_theme_colorset(brna); rna_def_userdef_theme_colorset(brna);
rna_def_userdef_themes(brna); rna_def_userdef_themes(brna);
rna_def_userdef_extensions(brna);
} }
static void rna_def_userdef_solidlight(BlenderRNA *brna) static void rna_def_userdef_solidlight(BlenderRNA *brna)
@@ -2649,27 +2648,27 @@ static void rna_def_userdef_filepaths(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Save Preview Images", "Enables automatic saving of preview images in the .blend file"); RNA_def_property_ui_text(prop, "Save Preview Images", "Enables automatic saving of preview images in the .blend file");
} }
void rna_def_userdef_extension_collection(BlenderRNA *brna, PropertyRNA *cprop) void rna_def_userdef_addon_collection(BlenderRNA *brna, PropertyRNA *cprop)
{ {
StructRNA *srna; StructRNA *srna;
FunctionRNA *func; FunctionRNA *func;
PropertyRNA *parm; PropertyRNA *parm;
RNA_def_property_srna(cprop, "UserExtensions"); RNA_def_property_srna(cprop, "Addons");
srna= RNA_def_struct(brna, "UserExtensions", NULL); srna= RNA_def_struct(brna, "Addons", NULL);
RNA_def_struct_ui_text(srna, "User Extensions", "Collection of extensions"); RNA_def_struct_ui_text(srna, "User Add-Ons", "Collection of add-ons");
func= RNA_def_function(srna, "new", "rna_userdef_extension_new"); func= RNA_def_function(srna, "new", "rna_userdef_addon_new");
RNA_def_function_flag(func, FUNC_NO_SELF); RNA_def_function_flag(func, FUNC_NO_SELF);
RNA_def_function_ui_description(func, "Add a new camera to the main database"); RNA_def_function_ui_description(func, "Add a new addon");
/* return type */ /* return type */
parm= RNA_def_pointer(func, "extension", "Extension", "", "Extension datablock."); parm= RNA_def_pointer(func, "addon", "Addon", "", "Addon datablock.");
RNA_def_function_return(func, parm); RNA_def_function_return(func, parm);
func= RNA_def_function(srna, "remove", "rna_userdef_extension_remove"); func= RNA_def_function(srna, "remove", "rna_userdef_addon_remove");
RNA_def_function_flag(func, FUNC_NO_SELF); RNA_def_function_flag(func, FUNC_NO_SELF);
RNA_def_function_ui_description(func, "Remove a camera from the current blendfile."); RNA_def_function_ui_description(func, "Remove addon.");
parm= RNA_def_pointer(func, "extension", "Extension", "", "Extension to remove."); parm= RNA_def_pointer(func, "addon", "Addon", "", "Addon to remove.");
RNA_def_property_flag(parm, PROP_REQUIRED); RNA_def_property_flag(parm, PROP_REQUIRED);
} }
@@ -2682,7 +2681,7 @@ void RNA_def_userdef(BlenderRNA *brna)
{USER_SECTION_INTERFACE, "INTERFACE", 0, "Interface", ""}, {USER_SECTION_INTERFACE, "INTERFACE", 0, "Interface", ""},
{USER_SECTION_EDIT, "EDITING", 0, "Editing", ""}, {USER_SECTION_EDIT, "EDITING", 0, "Editing", ""},
{USER_SECTION_INPUT, "INPUT", 0, "Input", ""}, {USER_SECTION_INPUT, "INPUT", 0, "Input", ""},
{USER_SECTION_EXTENSIONS, "EXTENSIONS", 0, "Extensions", ""}, {USER_SECTION_ADDONS, "ADDONS", 0, "Add-Ons", ""},
{USER_SECTION_THEME, "THEMES", 0, "Themes", ""}, {USER_SECTION_THEME, "THEMES", 0, "Themes", ""},
{USER_SECTION_FILE, "FILES", 0, "File", ""}, {USER_SECTION_FILE, "FILES", 0, "File", ""},
{USER_SECTION_SYSTEM, "SYSTEM", 0, "System", ""}, {USER_SECTION_SYSTEM, "SYSTEM", 0, "System", ""},
@@ -2711,11 +2710,11 @@ void RNA_def_userdef(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "ThemeStyle"); RNA_def_property_struct_type(prop, "ThemeStyle");
RNA_def_property_ui_text(prop, "Styles", ""); RNA_def_property_ui_text(prop, "Styles", "");
prop= RNA_def_property(srna, "extensions", PROP_COLLECTION, PROP_NONE); prop= RNA_def_property(srna, "addons", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "extensions", NULL); RNA_def_property_collection_sdna(prop, NULL, "addons", NULL);
RNA_def_property_struct_type(prop, "Extension"); RNA_def_property_struct_type(prop, "Addon");
RNA_def_property_ui_text(prop, "Extension", ""); RNA_def_property_ui_text(prop, "Addon", "");
rna_def_userdef_extension_collection(brna, prop); rna_def_userdef_addon_collection(brna, prop);
/* nested structs */ /* nested structs */
@@ -2754,6 +2753,7 @@ void RNA_def_userdef(BlenderRNA *brna)
rna_def_userdef_input(brna); rna_def_userdef_input(brna);
rna_def_userdef_filepaths(brna); rna_def_userdef_filepaths(brna);
rna_def_userdef_system(brna); rna_def_userdef_system(brna);
rna_def_userdef_addon(brna);
} }