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
评论列表
文章目录