Extensions manager ideas



Before coding I'll post my planned code for the Epiphany extensions manager (both UI and backend). If anybody has any comments about these ideas, please let me know.

First of all, the UI: a dialog with a GtkTreeView and some text underneath. The GtkTreeView will be a simple table, each row containing two elements: a checkbox (loaded/unloaded) and the extension name. The text underneath will show metadata about the selected extension in the treeview -- description, author(s), relevant URLs, etc. This is somewhat inspired by Gaim's "Plugins" config section, but of course there's simply Less Useless Stuff.

I've attached a mockup.

Next... the backend.

Epiphany's extensions manager will scan a hard-coded set of directories -- $PREFIX/lib/epiphany/extensions and $EPHY_DOT_DIR/extensions -- for XML files which contain metadata about extensions. An example XML file:

-----
error-viewer-extension.xml
-----
<?xml version="1.0" encoding="UTF-8"?>
<extension-list>
        <extension>
                <filename>errorviewer</filename>
                <name>Error Viewer</name>
<description>Provides a dialog which displays web page errors.</description>
                <version>1.1.3</version>
                <author>
                        <name>Adam Hooper</name>
                        <email>adamh densi com</email>
                </author>

<url>http://www.gnome.org/projects/epiphany/extensions</url>
        </extension>
</extension-list>
-----

The extensions manager will parse all these XML files and store them in an internal GList. Maybe at some point we can even monitor the directories and update the internal GList as new extensions are added.

The extensions manager will also monitor a GConf value -- /apps/epiphany/general/loaded_extensions (a List) -- to determine which extensions to load. The list will be a list of the desired <filename> values from the above XML file. The extensions which appear in that GConf list will be loaded; the ones which don't won't. Extensions which appear in GConf but have no matching XML file will be silently ignored.

To clarify: the extensions manager UI will *only* use these XML definition files. The actual backend will *only* use the GConf value.

To load an extension with filename $filename, the extensions manager will look for $EPHY_DOT_DIR/lib${filename}extension.so or $PREFIX/lib/epiphany/extensions/lib${filename}extension.so. If a match is found, that extension will be loaded (as it is in current Epiphany). If not, a WARNING will be printed to the console.

For both the XML files and the .so's, $EPHY_DOT_DIR/extensions will take precedence over $PREFIX/lib/epiphany/extensions.



So, the big questions: is there anything I'm forgetting? Any comments? Is this system overkill? Any ideas on how to make this system better? etc.

--
Adam Hooper
adamh densi com

PNG image

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
	<xsd:annotation>
		<xsd:documentation xml:lang="en">
			Epiphany Web Browser extension metadata schema.
			Copyright (c) 2004 Adam Hooper
		</xsd:documentation>
	</xsd:annotation>

	<xsd:element name="extension-list" type="ExtensionListType"/>

	<xsd:complexType name="ExtensionListType">
		<xsd:annotation>
			<xsd:documentation xml:lang="en">
				List of extensions. Each extension has its set
				of metadata.
			</xsd:documentation>
		</xsd:annotation>
		<xsd:sequence>
			<xsd:element name="extension"
				     type="ExtensionType"
				     minOccurs="1"/>
		</xsd:sequence>
	</xsd:complexType>

	<xsd:complexType name="ExtensionType">
		<xsd:annotation>
			<xsd:documentation xml:lang="en">
				Metadata about an extension.
			</xsd:documentation>
		</xsd:annotation>
		<xsd:sequence>
			<xsd:element name="filename"
				     type="ExtensionFilenameType"
				     minOccurs="1" maxOccurs="1"/>
			<xsd:element name="name"
				     type="xsd:string"
				     minOccurs="1" maxOccurs="1"/>
			<xsd:element name="description"
				     type="xsd:string"
				     minOccurs="1" maxOccurs="1"/>
			<xsd:element name="version"
				     type="xsd:string"
				     maxOccurs="1"/>
			<xsd:element name="author" type="AuthorType"/>
			<xsd:element name="url" type="xsd:anyURI"/>
		</xsd:sequence>
	</xsd:complexType>

	<xsd:simpleType name="ExtensionFilenameType">
		<xsd:annotation>
			<xsd:documentation xml:lang="en">
				The &quot;core&quot; of the extension's
				filename. For example, use &quot;gestures&quot;
				for an extension with a shared object name of
				&quot;libgesturesextension.so&quot;.
			</xsd:documentation>
		</xsd:annotation>
		<xsd:restriction base="xsd:string">
			<xsd:pattern value="[a-zA-Z0-9_-]+"/>
		</xsd:restriction>
	</xsd:simpleType>

	<xsd:complexType name="AuthorType">
		<xsd:annotation>
			<xsd:documentation xml:lang="en">
				An extension author -- a name and (optionally)
				an email address.
			</xsd:documentation>
		</xsd:annotation>
		<xsd:sequence>
			<xsd:element name="name"
				     type="xsd:normalizedString"
				     minOccurs="1" maxOccurs="1"/>
			<xsd:element name="email"
				     type="EmailType"
				     maxOccurs="1"/>
		</xsd:sequence>
	</xsd:complexType>

	<xsd:simpleType name="EmailType">
		<xsd:annotation>
			<xsd:documentation xml:lang="en">
				An email address
			</xsd:documentation>
		</xsd:annotation>
		<xsd:restriction base="xsd:string">
			<xsd:pattern value="[\.a-zA-Z0-9_-]+@([a-zA-Z0-9_-])+(([a-zA-Z0-9_-])*\.([a-zA-Z0-9_-])+)+"/>
		</xsd:restriction>
	</xsd:simpleType>
</xsd:schema>

Attachment: signature.asc
Description: OpenPGP digital signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]