当前位置: 首页>>代码示例>>Python>>正文


Python UnwrapObject.loadTemplates方法代码示例

本文整理汇总了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 = {}
开发者ID:,项目名称:,代码行数:57,代码来源:


注:本文中的xpcom.server.UnwrapObject.loadTemplates方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。