Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-03-14 23:07:15 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-03-14 23:07:15 +0300
commit149fe90a08d32b764875fb01a00b685df73b1ec7 (patch)
tree83a556fe10416c33837b4beb7a36fa3c00fa8ae4 /release
parentcbe776655a3f5c402dc03b87fb815ed8be0a8af1 (diff)
cleanup for addon python internals, fix filtering bug.
Diffstat (limited to 'release')
-rw-r--r--release/scripts/op/wm.py15
-rw-r--r--release/scripts/ui/space_userpref.py79
2 files changed, 52 insertions, 42 deletions
diff --git a/release/scripts/op/wm.py b/release/scripts/op/wm.py
index a2c05562c65..07a7afe026e 100644
--- a/release/scripts/op/wm.py
+++ b/release/scripts/op/wm.py
@@ -418,6 +418,19 @@ class WM_OT_context_modal_mouse(bpy.types.Operator):
return {'RUNNING_MODAL'}
+class WM_OT_url_open(bpy.types.Operator):
+ "Open the Blender Wiki in the Webbrowser"
+ bl_idname = "wm.url_open"
+ bl_label = ""
+
+ url = StringProperty(name="URL", description="URL to open")
+
+ def execute(self, context):
+ import webbrowser
+ webbrowser.open(self.properties.url)
+ return {'FINISHED'}
+
+
class WM_OT_doc_view(bpy.types.Operator):
'''Load online reference docs'''
bl_idname = "wm.doc_view"
@@ -556,6 +569,8 @@ classes = [
WM_OT_context_cycle_enum,
WM_OT_context_cycle_int,
WM_OT_context_modal_mouse,
+
+ WM_OT_url_open,
WM_OT_doc_view,
WM_OT_doc_edit,
diff --git a/release/scripts/ui/space_userpref.py b/release/scripts/ui/space_userpref.py
index 61c514135bd..426b23355d0 100644
--- a/release/scripts/ui/space_userpref.py
+++ b/release/scripts/ui/space_userpref.py
@@ -1385,6 +1385,8 @@ class USERPREF_PT_addons(bpy.types.Panel):
bl_label = "Addons"
bl_region_type = 'WINDOW'
bl_show_header = False
+
+ _addon_blank = {"name": "", "author": "", "version": "", "blender": "", "location": "", "url": "", "category": ""}
def poll(self, context):
userpref = context.user_preferences
@@ -1405,21 +1407,16 @@ class USERPREF_PT_addons(bpy.types.Panel):
def _attributes(self, mod):
# collect, check and process all attributes of the add-on
- module_name = mod.__name__
if not hasattr(mod, 'expanded'):
mod.expanded = False
-
- info = getattr(mod, "bl_addon_info", {})
+
+ info = self._addon_blank.copy()
+ info.update(getattr(mod, "bl_addon_info", {}))
- name = info.get("name", "")
- author = info.get("author", "")
- version = info.get("version", "")
- blender = info.get("blender", "")
- location = info.get("location", "")
- url = info.get("url", "")
- category = info.get("category", "")
+ if not info["name"]:
+ info["name"] = mod.__name__
- return module_name, name, author, version, blender, location, url, category
+ return info
def draw(self, context):
layout = self.layout
@@ -1428,16 +1425,13 @@ class USERPREF_PT_addons(bpy.types.Panel):
used_ext = {ext.module for ext in userpref.addons}
# collect the categories that can be filtered on
- cats = []
- for mod in self._addon_list():
- try:
- if category not in cats:
- cats.append(category)
- except:
- pass
+ addons = [(mod, self._attributes(mod)) for mod in self._addon_list()]
- cats.sort()
- cats = ['All', 'Disabled', 'Enabled']+cats
+ cats = {info["category"] for mod, info in addons}
+ cats.add("")
+ cats.remove("")
+
+ 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")
@@ -1450,18 +1444,22 @@ class USERPREF_PT_addons(bpy.types.Panel):
layout.separator()
filter = context.scene.addon_filter
- search = context.scene.addon_search
+ search = context.scene.addon_search.lower()
+
for mod in self._addon_list():
- module_name, name, author, version, blender, location, url, category = \
- self._attributes(mod)
+ module_name = mod.__name__
+ info = self._attributes(mod)
# check if add-on should be visible with current filters
- if filter!='All' and filter!=category and not (module_name in used_ext and filter=='Enabled')\
- and not (module_name not in used_ext and filter=='Disabled'):
+ if filter != "All" and \
+ filter != info["category"] and \
+ not (module_name not in used_ext and filter == "Disabled"):
+
continue
- if search and name.lower().find(search.lower())<0:
- if author:
- if author.lower().find(search.lower())<0:
+
+ if search and search not in info["name"].lower():
+ if info["author"]:
+ if search not in info["author"].lower():
continue
else:
continue
@@ -1475,38 +1473,35 @@ class USERPREF_PT_addons(bpy.types.Panel):
# If there are Infos or UI is expanded
if mod.expanded:
row.operator("wm.addon_expand", icon="TRIA_DOWN").module = module_name
- elif author or version or url or location:
+ 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
-
- if name:
- row.label(text=name)
- else: #For now, can be removed when all addons, have a proper dict
- row.label(text=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 mod.expanded:
- if author:
+ if info["author"]:
split = column.row().split(percentage=0.15)
split.label(text='Author:')
- split.label(text=author)
- if version:
+ split.label(text=info["author"])
+ if info["version"]:
split = column.row().split(percentage=0.15)
split.label(text='Version:')
- split.label(text=version)
- if location:
+ split.label(text=info["version"])
+ if info["location"]:
split = column.row().split(percentage=0.15)
split.label(text='Location:')
- split.label(text=location)
- if url:
+ 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 = url
+ split.operator("wm.addon_links", text="Link to the Wiki").link = info["url"]
split.separator()
split.separator()