日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

xulrunner html5,XULRunner入门

發(fā)布時間:2025/3/19 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 xulrunner html5,XULRunner入门 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

XULRunner入門

這一節(jié)通過使用XULRunner構(gòu)建一個基本的桌面應用來探討Mozilla平臺。已知的Firefox(“火狐”Web瀏覽器)、Thunderbird(“雷鳥”Email客戶端)和其它多種類應用程序都是使用這個平臺編寫完成的,可以堅信一點Mozilla平臺可以被用來構(gòu)建基本的應用程序。另有一個名為Creating XULRunner Apps with the Mozilla Build System的章節(jié)包含了更加完整的內(nèi)容用于構(gòu)建XULRunner應用程序。如果你需要修改XULRunner本身或是將XULRunner整合到外部二進制程序中,那么你需要閱讀這個章節(jié)。

你能夠在MDC里的XULRunner主頁中找到下載連接。由于我們并不創(chuàng)建任何的二進制XPCOM組件,所以僅需要下載并安裝XULRunner運行時包而不是SDK。

針對WIndows版本下載得到的是一個ZIP文件而并不是真正的安裝程序。作為一個開發(fā)者我更喜歡這種簡單解壓縮就可以完成安裝的方式。我假設它不會掛接到我的Windows系統(tǒng)上而這是件好事。這同時也意味著XULRunner是“便攜式”的,所以如果你將應用開發(fā)成一種“便攜式”的形式,那么你將可以將程序放到閃存存儲器中或在云端同步。

Mac版本的XULRunner被發(fā)布成tar.bz2格式的歸檔文件。你可以解壓縮到任何你喜歡的位置,但在本文檔中的多個位置都假設了你已經(jīng)將解壓縮得到的文件放置在了/Library/Frameworks目錄中。

到從版本11.10開始在Ubuntu桌面系統(tǒng)及它的各種變體版本中(Xubuntu,Kubuntu),XULRunner已經(jīng)不再被維護并且不存在于Ubuntu的軟件倉庫中了。因此不管你是想手動編譯XULRunner或是從Mozilla's FTP服務器上下載發(fā)布版本。一種方法就是在每次你想安裝新版本時運行以下腳本:

FIREFOX_VERSION=`grep -Po? "\d{2}\.\d+" /usr/lib/firefox/platform.ini`

ARCH=`uname -p`

XURL=https://ftp.mozilla.org/pub/mozilla.org/xulrunner/releases/$FIREFOX_VERSION/runtimes/xulrunner-$FIREFOX_VERSION.en-US.linux-$ARCH.tar.bz2

cd /opt

sudo sh -c "wget -O- $XURL | tar -xj"

sudo ln -s /opt/xulrunner/xulrunner /usr/bin/xulrunner

sudo ln -s /opt/xulrunner/xpcshell /usr/bin/xpcshell

你也應該保存此腳本以便使用。注意:如果你使用的Firefox是構(gòu)建于Ubuntuzilla倉庫的,請將/usr/lib/firefox/platform.ini替換為/opt/firefox/platform.ini。

在Windows系統(tǒng)中將壓縮文件解壓縮到一個合理的位置。我將其解壓縮到了一個新創(chuàng)建的目錄中C:\program files\xulrunner。

在Mac系統(tǒng)中將tar.bz2文件解壓縮到名為XUL.Framework的目錄中。將此目錄拷貝到/Library/Frameworks,或是其它你喜歡的位置。

在Linux系統(tǒng)中如果你使用的是預發(fā)布(Pre-release)的XULRunner的話,你僅需要解包歸檔文件即可。

Optionally, if you've downloaded the compressed archive of XULRunner and would like to install it on your system you can do so by running作為可選的步驟,如果你已經(jīng)下載了XULRunner的壓縮文檔并想將其安裝到你的系統(tǒng)中,你可以運行以下命令來做到這一點

xulrunner --register-global

作為管理名以上命令會將XULRunner注冊給本機上的所有用戶。僅注冊給當前用戶可以運行以下命令

xulrunner --register-user

不管你是否執(zhí)行了安裝過程XULRunner都會正常工作。這純粹是為了方便。

In all systems you should unzip theomni.jafile into some example directory and take a look at all the awesome! First change the file extension to zip and then use your normal filesystem's decompression tool to open it up. The contents of omni.ja are available to XULRunner applications and are what make it possible to build amazing applications easily!

是時候了,我們做一個簡單的沒有什么功能的應用程序。如果你愿意你可以稱它為“Hello World”。所有以下你看到的你都可以在MDC的XULRunner文檔中找到更細節(jié)的內(nèi)容。

Hint: Skip ahead and download the sample application, you can experiment with it while following this tutorial. You can download the sample application from https://github.com/matthewkastor/XULRunner-Examples. Please continue reading to learn the "what", "why" and "how" parts of building a XULRunner application.

在Windows中我新創(chuàng)建了root目錄在c:\program files\myapp,但你可以將其創(chuàng)建在任何你喜歡的地方,使用任意一種你喜歡的OS。Windows、Mac和Linux使用了相同的目錄結(jié)構(gòu)。這里列出了子目錄的結(jié)構(gòu):

+ myapp/

|

+-+ chrome/

| |

| +-+ content/

| | |

| | +-- main.xul

| | |

| | +-- main.js

| |

| +-- chrome.manifest

|

+-+ defaults/

| |

| +-+ preferences/

| |

| +-- prefs.js

|

+-- application.ini

|

+-- chrome.manifest

注意在目錄結(jié)構(gòu)中有5個文件:application.ini、chrome.manifest (2個)、 prefs.js和main.xul。/chrome/chrome.manifest文件是可選的,但可能對向下兼容是有用的。請看以下記述內(nèi)容。

Note: In XULRunner 2.0, the chrome.manifest is now used to register XPCOM components in addition to its previous uses. Part of this change means the /chrome/chrome.manifest is no longer considered the "root" manifest. XULRunner will not check that folder location for a root-level chrome.manifest. You need to move your existing chrome.manifest to the application root folder, remembering to update the relative paths within the file. You could also just create a new application root-level manifest that includes the /chrome/chrome.manifest, which is what this tutorial will do.

application.ini 文件為你的應用扮演著XULRunner入口點的角色。它指定了你的應用打算如何使用XULRunner平臺以及配置一些信息以告訴XULRunner如何運行你的程序。下面是我的文件內(nèi)容:

[App]

Vendor=XULTest

Name=myapp

Version=1.0

BuildID=20100901

ID=xulapp@xultest.org

[Gecko]

MinVersion=1.8

MaxVersion=200.*

Note: MinVersion 和MaxVersion字段指示了你的應用所兼容的Gecko版本的范圍;確保你設置了它們而且你所使用的XULRunner的版本也是在這個范圍之內(nèi),否則你的應用將不能工作。

Note: 確保你的應用名稱是小寫的,并且長度大于3個字符。

The chrome manifest file is used by XULRunner to define specific URIs which in turn are used to locate application resources. This will become clearer when we see how the “chrome://” URI is used. Application chrome can be in a single or a few JAR files or uncompressed as folders and files. I am using the uncompressed method for now. Here is the chrome/chrome.manifest:

content myapp content/

As mentioned in Step 3, the default location of the chrome.manifest has changed in XULRunner 2.0, so we also need a simple chrome.manifest in the application root which will include the the manifest in our chrome root. Here is the application root chrome.manifest:

manifest chrome/chrome.manifest

The prefs.js file tells XULRunner the name of the XUL file to use as the main window. Here is mine:

pref("toolkit.defaultChromeURI", "chrome://myapp/content/main.xul");

/* debugging prefs, disable these before you deploy your application! */

pref("browser.dom.window.dump.enabled", true);

pref("javascript.options.showInConsole", true);

pref("javascript.options.strict", true);

pref("nglayout.debug.disable_xul_cache", true);

pref("nglayout.debug.disable_xul_fastload", true);

XULRunner specific preferences include:

Specifies the default window to open when the application is launched.

Specifies the features passed to

Allows configuring the application to allow only one instance at a time.

The toolkit preferences are described in further detail in XULRunner:Specifying Startup Chrome Window.

The debugging preferences are discussed in?Debugging a XULRunner Application

Finally, we need to create a simple XUL window, which is described in the file main.xul. Nothing fancy here, just the minimum we need to make a window. No menus or anything.

main.xul:

This is a simple XULRunner application. XUL is simple to use and quite powerful and can even be used on mobile devices.

Note: Make sure there is no extra whitespace at the beginning of the XML/XUL file

The application also has a JavaScript file. Most XUL applications will include some external JavaScript, so the sample application does too, just to show how to include it into the XUL file.

main.js:

function showMore() {

document.getElementById("more-text").hidden = false;

}

For more information about XUL see: XUL.

For information about mixing HTML elements into your XUL read Adding HTML Elements.

The moment of truth. We need to get XULRunner to launch the bare-bones application.

From a Windows command prompt opened to the myapp folder, we should be able to execute this:

C:\path\to\xulrunner.exe application.ini

Of course, if you opted to install xulrunner then you could simply do

?%ProgramFiles%\xulrunner.exe application.ini

or on 64 bit systems

?%ProgramFiles(x86)%\xulrunner.exe application.ini

Note: you can also install your application when you're finished debugging it. See XUL Application Packaging?for details.

On the Mac, before you can run a XULRunner application with everything intact, you must install it using the --install-app xulrunner commandline flag. Installing the application creates an OS X application bundle:

/Library/Frameworks/XUL.framework/xulrunner-bin --install-app ///myapp.zip

Once installed, you can run the application:

/Library/Frameworks/XUL.framework/xulrunner-bin "/Applications/Finkle/TestApp.app/Contents/Resources/application.ini"

You may run it without installing (but with the menu bar and dock icon missing) in OS X by typing:

/Library/Frameworks/XUL.framework/xulrunner-bin "//TestApp/application.ini"

Note: The full path is required or a "Error: couldn't parse application.ini."-message will be returned.

This might also be simplified using a very simple shell script (i call mine "run.sh"):

#!/bin/sh

/Library/Frameworks/XUL.framework/xulrunner-bin `pwd`/application.ini

On Ubuntu, you can run the application from a terminal. First change into the \myapp folder, then start the application by:

xulrunner application.ini

You should now see a window that looks something like this. This particular screenshot is from Ubuntu 10.

With Firefox 3 and later, you can tell the Firefox executable to run a XUL application from the command line. The XUL application will run instead of the Firefox browser that normally starts. This is similar to starting a XUL app using XULRunner. See Using Firefox to run XULRunner applications. This does not work if Firefox itself was installed as a XUL app - you need to use the installed XULRunner directly.

There are many things you can do with XULRunner. Before you get too far into things you might want to read the XULRunner tips article. Also, throughout this tutorial you've been introduced to various bits of the Toolkit API and it may help you to get familiar with it. Once you've got an application that's ready for the world you'll love our article titled?Deploying XULRunner.

For now, click the "next" link to learn about windows and menus in XULRunner!

Original Document Information

Author: Mark Finkle, October 2, 2006

總結(jié)

以上是生活随笔為你收集整理的xulrunner html5,XULRunner入门的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。