用emacs创建第一个基于mozilla的xulrunner应用程序。

创建xulrunner应用不是很复杂:
按照MDC的 Getting started with XULRunner提示
首先要按照提示装好xulrunner,然后在path路径中指定好xulrunner的路径
下面要分几步:
创建下面的目录文件结构
+ /myapp
|
+-+ /chrome
| |
| +-+ /content
| | |
| | +- main.xul
| |
| +- chrome.manifest
|
+-+ /defaults
| |
| +-+ /preferences
| |
| +- prefs.js
|
+- application.ini

再来是编辑application.ini文件内容:
[App]
Vendor=Finkle
Name=Test App
Version=1.0
BuildID=20060101
Copyright=Copyright (c) 2006 Mark Finkle
ID=xulapp@starkravingfinkle.org

[Gecko]
MinVersion=1.8
MaxVersion=1.9.0.*

然后是chrome.manifest文件:

content myapp file:content/


最后再编写main.xul:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<window id="main" title="My App" width="300" height="300"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<caption label="Hello World"/>
</window>

存盘后,在工程的顶级目录运行命令行:
xulrunner.exe application.ini
就可以看到效果了。。

HelloWord xulapp的效果图

在看这个tutorial时,区区一边看一边写下一个emacs命令,这样可以只用一个命令就在目录中完成基本xul程序结构,虽然可以同样通过下载myapp.zip解压或者使用xul explorer达到同样效果,可是一个自定义的emacs命令还是有其好处的,比如对于区区而言:
1.用emacs命令肯定比开启shell再解压文件快得多;
2.用xul explorer向导生成的工程在gecko最新版中不可运行;

下面是emacs源码:
(defun xul-app (dir)
  "在一下目录下面创建一个最基本的xulrunner应用程序"
  (interactive "D")
  (save-excursion
    (make-directory (concat dir "/chrome") t)
    (make-directory (concat dir "/chrome" "/content") t)
    (with-temp-file (concat dir "/chrome" "/content/main.xul")
      (insert "<?xml version=/"1.0/"?>/n")
      (insert "<?xml-stylesheet href=/"chrome://global/skin//" type=/"text/css/"?>/n")
      (insert "/n")
      (insert "<window id=/"main/" title=/"My App/" width=/"300/" height=/"300/" /n")
      (insert "xmlns=/"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul/"> /n")
      (insert "<caption label=/"Hello World/"/> /n")
      (insert "</window>/n")
      
      )
    (with-temp-file (concat dir "/chrome/chrome.manifest")
      (insert "content myapp file:content/       /n")
      )
    (make-directory (concat dir "/defaults") t)
    (make-directory (concat dir "/defaults" "/preferences") t)
    (with-temp-file (concat dir "/defaults" "/preferences/prefs.js")
      (insert "pref(/"toolkit.defaultChromeURI/", /"chrome://myapp/content/main.xul/"); /n")
      )
    (with-temp-file (concat dir "/application.ini")
      (insert "[App]/n")
      (insert "Vendor=Finkle/n")
      (insert "Name=Test App/n")
      (insert "Version=1.0/n")
      (insert "BuildID=20060101/n")
      (insert "Copyright=Copyright (c) 2006 Mark Finkle/n")
      (insert "ID=xulapp@starkravingfinkle.org/n")
      (insert " /n")
      (insert "[Gecko]/n")
      (insert "MinVersion=1.8/n")
      (insert "MaxVersion=1.9.0.*/n")

      )
    ))



这样一来,以后就不用再为这个wizard操太多心了。哈!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值