initialize.py 文件源码

python
阅读 34 收藏 0 点赞 0 评论 0

项目:griffith 作者: Strit 项目源码 文件源码
def extension(self, module, enabled):
    if enabled:
        try:
            ext = module(self)
        except (NotImplementedError, DeprecationWarning), e:
            log.warning('extension skipped: %s', e.message)
            log.debug('extension skipped: %s', module.__file__)
            return [None, None]
        if module.toolbar_icon:
            toolbar = self.widgets['extensions']['toolbar']
            if module.toolbar_icon.endswith(('.png', '.svg')):
                icon_path = os.path.join(os.path.dirname(module.__file__), 'data', module.toolbar_icon)
                if not os.path.isfile(icon_path):
                    icon_path = os.path.join(self.locations['images'], module.toolbar_icon)
                if not os.path.isfile(icon_path):
                    log.error('icon not found: %s', module.toolbar_icon)
                else:
                    icon = gtk.Image()
                    icon.set_from_file(icon_path)
                    ext.toolbar_icon_widget = toolbar.insert_item(None, module.description, None, icon, ext._on_toolbar_icon_clicked, None, -1)
            else:
                ext.toolbar_icon_widget = toolbar.insert_stock(module.toolbar_icon, module.description, None, ext._on_toolbar_icon_clicked, None, -1)
    else:
        ext = None

    return ext
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号