本文整理汇总了Python中xpcom.server.UnwrapObject.loadTemplates方法的典型用法代码示例。如果您正苦于以下问题:Python UnwrapObject.loadTemplates方法的具体用法?Python UnwrapObject.loadTemplates怎么用?Python UnwrapObject.loadTemplates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xpcom.server.UnwrapObject
的用法示例。
在下文中一共展示了UnwrapObject.loadTemplates方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: KoTemplateCategoriesView
# 需要导入模块: from xpcom.server import UnwrapObject [as 别名]
# 或者: from xpcom.server.UnwrapObject import loadTemplates [as 别名]
class KoTemplateCategoriesView(TreeView):
_com_interfaces_ = [components.interfaces.koITemplateCategoriesView,
components.interfaces.nsITreeView]
_reg_clsid_ = "{0723776F-EE9D-4F20-B438-3AF893192346}"
_reg_contractid_ = "@activestate.com/koTemplateCategoriesView;1"
_reg_desc_ = "Komodo Template Categories nsITreeView"
def __init__(self):
TreeView.__init__(self) #, debug="categories") #XXX
self._tree = None
self._sortedBy = None
# The table used to fill in the tree. It is a list of dicts. Each
# dict represents one row in the tree/outliner. This dictionary is
# also (because it is convenient) used to store data in addition to
# the named rows of the XUL tree. e.g.,
# [ {"category-name": "My Templates", # row 0
# "node": <Node instance for this category>},
# ... ]
# This attribute is re-generated from self.templateTree whenever
# the rows change (say, by the user opening a category with
# sub-categories).
self._data = []
self._prefSvc = components.classes["@activestate.com/koPrefService;1"]\
.getService().prefs # global prefs
self.templateTree = None # Working copy of template tree Nodes.
self.selectedTemplateByCategory = None
self.categoryIsOpen = None
self.atomSvc = components.classes["@mozilla.org/atom-service;1"].\
getService(components.interfaces.nsIAtomService)
self.folderOpenAtom = self.atomSvc.getAtom("folderOpen")
self.folderClosedAtom = self.atomSvc.getAtom("folderClosed")
def initialize(self, templateSvc, templatesView):
# Need to unwrap these Python XPCOM object because we access
# methods on them that are not in the IDL.
self.templateSvc = UnwrapObject(templateSvc)
self.templatesView = UnwrapObject(templatesView)
if not self.templateSvc.loaded:
self.templateSvc.loadTemplates()
self.templateTree = self.templateSvc.getTemplateTree() # a working copy
# Restore the user selections from prefs
stbcStr = self._prefSvc.getStringPref("%s_selected_template_by_category" % self.templateSvc.basename)
try:
self.selectedTemplateByCategory = eval(stbcStr)
except SyntaxError, ex:
self.selectedTemplateByCategory = {}
ocStr = self._prefSvc.getStringPref("%s_open_categories" % self.templateSvc.basename)
try:
self.categoryIsOpen = eval(ocStr)
except SyntaxError, ex:
self.categoryIsOpen = {}