Example #1
0
	def plugin_sidebar_update(self, plugin_id):
		about = gtk.VBox()
		about.set_property("spacing", 15)
		about.set_property("border-width", 5)
		info = self._plugin_info_for_id(plugin_id)
		title_label = gtk.Label()
		title_label.set_markup(u"<b><big>%s</big></b>" % info["localized_name"])
		version, description, author = plugins.get_plugin_attributes(plugin_id,
				( "__version__", "__description__", "__author__", ))
		about.pack_start(title_label, False)
		infobox = gtk.VBox()
		infobox.set_property("spacing", 3)
		# TRANS: Plugin info fields
		for field, val in zip((_("Description"), _("Author")),
				(description, author)):
			if not val:
				continue
			label = gtk.Label()
			label.set_alignment(0, 0)
			label.set_markup(u"<b>%s</b>" % field)
			infobox.pack_start(label, False)
			label = wrapped_label()
			label.set_alignment(0, 0)
			label.set_markup(u"%s" % gobject.markup_escape_text(val))
			label.set_selectable(True)
			infobox.pack_start(label, False)
		if version:
			label = wrapped_label()
			label.set_alignment(0, 0)
			label.set_markup(u"<b>%s:</b> %s" % (_("Version"), version))
			label.set_selectable(True)
			infobox.pack_start(label, False)
		about.pack_start(infobox, False)

		# Check for plugin load exception
		exc_info = plugins.get_plugin_error(plugin_id)
		if exc_info is not None:
			etype, error, tb = exc_info
			# TRANS: Error message when Plugin needs a Python module to load
			import_error_localized = _("Python module '%s' is needed") % u"\\1"
			import_error_pat = u"No module named ([^\s]+)"
			errmsg = unicode(error)
			if re.match(import_error_pat, errmsg):
				errstr = re.sub(import_error_pat,
						import_error_localized,
						errmsg, count=1)
			else:
				import traceback
				errstr = "".join(traceback.format_exception(*exc_info))

			label = wrapped_label()
			label.set_alignment(0, 0)
			label.set_markup(u"<b>%s</b>\n\n%s" % (
				_("Plugin could not be read due to an error:"),
				gobject.markup_escape_text(errstr),
				))
			label.set_selectable(True)
			about.pack_start(label, False)
		elif not plugins.is_plugin_loaded(plugin_id):
			label = gtk.Label()
			label.set_alignment(0, 0)
			label.set_text(u"(%s)" % _("disabled"))
			about.pack_start(label, False)

		wid = self._make_plugin_info_widget(plugin_id)
		about.pack_start(wid, False)
		psettings_wid = self._make_plugin_settings_widget(plugin_id)
		if psettings_wid:
			about.pack_start(psettings_wid, False)

		oldch = self.plugin_about_parent.get_child()
		if oldch:
			self.plugin_about_parent.remove(oldch)
		vp = gtk.Viewport()
		vp.set_shadow_type(gtk.SHADOW_NONE)
		vp.add(about)
		self.plugin_about_parent.add(vp)
		self.plugin_about_parent.show_all()
Example #2
0
    def plugin_sidebar_update(self, plugin_id):
        about = Gtk.VBox()
        about.set_property("spacing", 15)
        about.set_property("border-width", 5)
        info = self._plugin_info_for_id(plugin_id)
        title_label = Gtk.Label()
        m_localized_name = GLib.markup_escape_text(info["localized_name"])
        title_label.set_markup("<b><big>%s</big></b>" % m_localized_name)
        version, description, author = plugins.get_plugin_attributes(
            plugin_id, (
                "__version__",
                "__description__",
                "__author__",
            ))
        about.pack_start(title_label, False, True, 0)
        infobox = Gtk.VBox()
        infobox.set_property("spacing", 3)
        # TRANS: Plugin info fields
        for field, val in zip((_("Description"), _("Author")),
                              (description, author)):
            if not val:
                continue
            label = Gtk.Label()
            label.set_alignment(0, 0)
            label.set_markup("<b>%s</b>" % field)
            infobox.pack_start(label, False, True, 0)
            label = wrapped_label()
            label.set_alignment(0, 0)
            label.set_markup("%s" % GLib.markup_escape_text(val))
            label.set_selectable(True)
            infobox.pack_start(label, False, True, 0)
        if version:
            label = wrapped_label()
            label.set_alignment(0, 0)
            m_version = GLib.markup_escape_text(version)
            label.set_markup("<b>%s:</b> %s" % (_("Version"), m_version))
            label.set_selectable(True)
            infobox.pack_start(label, False, True, 0)
        about.pack_start(infobox, False, True, 0)

        # Check for plugin load exception
        exc_info = plugins.get_plugin_error(plugin_id)
        if exc_info is not None:
            etype, error, tb = exc_info
            # TRANS: Error message when Plugin needs a Python module to load
            import_error_localized = _("Python module '%s' is needed") % "\\1"
            import_error_pat = "No module named ([^\s]+)"
            errmsg = str(error)
            if re.match(import_error_pat, errmsg):
                errstr = re.sub(import_error_pat,
                                import_error_localized,
                                errmsg,
                                count=1)
            elif issubclass(etype, ImportError):
                errstr = errmsg
            else:
                import traceback
                errstr = "".join(traceback.format_exception(*exc_info))

            label = wrapped_label()
            label.set_alignment(0, 0)
            label.set_markup("<b>%s</b>\n\n%s" % (
                _("Plugin could not be read due to an error:"),
                GLib.markup_escape_text(errstr),
            ))
            label.set_selectable(True)
            about.pack_start(label, False, True, 0)
        elif not plugins.is_plugin_loaded(plugin_id):
            label = Gtk.Label()
            label.set_alignment(0, 0)
            label.set_text("(%s)" % _("disabled"))
            about.pack_start(label, False, True, 0)

        wid = self._make_plugin_info_widget(plugin_id)
        about.pack_start(wid, False, True, 0)
        psettings_wid = self._make_plugin_settings_widget(plugin_id)
        if psettings_wid:
            about.pack_start(psettings_wid, False, True, 0)

        oldch = self.plugin_about_parent.get_child()
        if oldch:
            self.plugin_about_parent.remove(oldch)
        vp = Gtk.Viewport()
        vp.set_shadow_type(Gtk.ShadowType.NONE)
        vp.add(about)
        self.plugin_about_parent.add(vp)
        self.plugin_about_parent.show_all()