Firefox があまりに良く出来ているので、ふとモジラでアプリを作る方法 - xul - を調べたくなった。サワリだけメモ。
空のディレクトリを作成し、hello.xul という名前で以下の内容のファイルを作る。
<?xml version="1.0"?> <?xml-stylesheet href="chrome://global/skin/" type="text/css"?> <window id="hello" title="Hello world" xmlns:html="http://www.w3.org/1999/xhtml" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <label value="Hello world"/> </window>
同じディレクトリ、contents.rdf という名前で以下のファイルを作る
<?xml version="1.0"?> <RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:chrome="http://www.mozilla.org/rdf/chrome#"> <RDF:Seq about="urn:mozilla:package:root"> <RDF:li resource="urn:mozilla:package:hello"/> </RDF:Seq> <RDF:Description about="urn:mozilla:package:hello" chrome:displayName="Hello world" chrome:author="Hello Taro" chrome:name="hello" chrome:extension="true"/> </RDF:RDF>
C:\Program Files\Mozilla Firefox\chrome\installed-chrome.txt (windows の場合) に以下の行を追加
content,install,url,file:///c|/takasi/doc/mozilla/hello/
なお、file:///c|/takasi/doc/mozilla/hello/ はファイルを作った場所で、ドライブレターを表すのに c| のように書くのと、最後に / が必須なのがポイント。
C:\Program Files\Mozilla Firefox\chrome\chrome.rdf を削除
Firefox を再起動して、chrome://hello/content/hello.xul にアクセスするか、コマンドラインより
$ ./firefox.exe -chrome chrome://hello/content/hello.xul
を実行する。
contents.rdf を書いたりinstalled-chrome.txt を編集したりしなくても、file:// で直接 xul ファイルを指定しても内容を見る事が出来ます。chrome:// からアクセスする方法については以下を読んでください。
http://www.xulplanet.com/tutorials/xultu/packaging.html
さて、例によってこれを Squeak から制御できるかを考えている。xul の目的の一つに Gtk のような汎用の GUI エンジンというのがあるらしいので、これは突飛な発想では無い。今回 xul を Firefox 経由で呼び出したわけだが、これを独立したアプリにする事も可能で、Firefox もそういうアプリの一つだ。面白そうだけど、面倒かな。どうかな?