Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: HOWTO: Getting Started with Linux Standalone Apps using XUL

  1. #11
    Join Date
    Jul 2005
    Location
    Remote Desert, USA
    Beans
    683

    Re: HOWTO: Getting Started with Linux Standalone Apps using XUL

    Packaging XUL Apps

    I just found that if you use this in your Javascript in order to enable XPCOM components:

    netscape.security.PrivilegeManager.enablePrivilege ("UniversalXPConnect");

    ...your browser will pop up an UNSAFE warning.

    So how do you stop it? Well, unfortunately it means you must use the 'xulrunner' application, which you can download here:

    http://developer.mozilla.org/en/docs/XULRunner
    (Look for Linux link.)

    This, unfortunately, adds 8.9MB to your application distribution and I wish that Ubuntu would ship with it by default because it's so important for newbies in developing apps. I also wish that you could just do 'apt-get install xulrunner', but I don't have that option.

    Okay, so xulrunner can run your XUL application, but it's not that easy yet. You need to do it like so:

    1. Create a directory structure like the following, and yes, I know it's crazy:

    - application.ini (a text file we will edit in a moment)
    - chrome (folder)
    - content (folder)
    - sample (folder)
    - sample.css (a CSS file for the "skin" of your app)
    - sample.js (a javascript file for what you hook up your XUL events to)
    - sample.xul (the GUI of the application
    - chrome.manifest (a text file we will edit in a moment)
    - defaults (folder)
    - preferences (folder)
    prefs.js (a special kind of Javascript file we will edit in a moment)

    2. Previously, I have mentioned how you build your sample .xul, .js, and .css files, so I won't go over those again. However, there is a special file you need called application.ini. Edit it so it looks like so:

    Code:
    [App]
    Name=sample
    BuildID=0
    
    [Gecko]
    MinVersion=1.5
    ...changing 'sample' above to whatever you want to name your application.

    3. Next, find your prefs.js text file that you created and put this into it:

    Code:
    pref('toolkit.defaultChromeURI', 'chrome://sample/content/sample.xul');
    ...changing all the 'sample' keywords above to what you want to name your app.

    4. Next, find your chrome.manifest text file that you created and put this into it:

    Code:
    content sample file:content/sample/
    ...changing all the 'sample' keywords above to what you want to name your app.

    5. In your XUL file, you'll need a different way to address your Javascript. Do it like this right after your last xmlns line, starting a new line:

    Code:
    <html:script src='chrome://sample/content/sample.js' />
    ...changing all the 'sample' keywords above to what you want to name your app.

    6. In your XUL file, to load the CSS, I think I learned that you don't need a path to it. I load my CSS like so:

    Code:
    <?xml-stylesheet href="sample.css" type="text/css"?>
    ...right after the line about global skin and right before the window tag.

    7. So, with all this preparation done, you need to download and install your XUL Runner app. I just uncompress it into /usr/share as /usr/share/xulrunner and then do this:

    Code:
    $ sudo  ln  -s  /usr/share/xulrunner  /usr/bin/xulrunner
    8. And now, FINALLY (phew!), to call for instance a 'sample' folder that contains my app, which I might have placed inside /usr/share as /usr/share/sample, I would call it like so:

    Code:
    $ xulrunner  /usr/share/sample/application.ini
    ...and up pops your window for your application. Moreover, when you do something that activates your Javascript and if that Javascript calls an XPCOM object, it will no longer prompt you about things being unsafe or not. It will just run.

    Commentary: I guess I can fault the Mozilla devs who came up with this crazy way to call an XUL app through xulrunner. If it were me, I would just prefer to throw everything into one directory and call it with 'xulrunner <directory>/sample.xul', but this is the way it is.

    So, now that you know this, here's some more advice. There's a tool you can find on the web called 'makeself' that can combine all of this into one Linux executable and have it call your Bash script. The only thing it doesn't come with is 'xulrunner'. Now, if you prefer to bundle your app with 'xulrunner', and you have read the license agreement for it and are in compliance, then you can use makeself to throw everything together including xulrunner. This could potentially make your application somewhere between 9MB and 15MB, but I guess that's not too bad -- I've seen worse. And, if distros of Linux start to ship with the 8.9MB xulrunner, or if it's easily available on 'apt', then you can reduce your application's size by that much.
    SuperMike
    When in doubt, follow the penguins.
    Evil Kitty is watching you

  2. #12
    Join Date
    Jul 2005
    Location
    Remote Desert, USA
    Beans
    683

    Re: HOWTO: Getting Started with Linux Standalone Apps using XUL

    Hosted Sample

    I have decided to build a great example of standalone XUL applications for Ubuntu Linux (and other Linuxes) at Google Code's new Hosted Projects site.

    You can go to this page here:

    http://code.google.com/p/simplexul/

    The download there permits you to rapidly build standalone, simple-to-powerful Ubuntu Linux applications with nothing more than HTML and Javascript knowledge, and you can also build client/server applications too.
    SuperMike
    When in doubt, follow the penguins.
    Evil Kitty is watching you

  3. #13
    Join Date
    Oct 2005
    Location
    Adelaide, South Australia
    Beans
    746
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: HOWTO: Getting Started with Linux Standalone Apps using XUL

    you are superrrrrrrmiiiiiiike......i canna bend space anna time.

    lol seriously though...this process you describe is where i was on windows about ten years ago.....its awesome. it was soooo ahead of its time and the damn microsoft management canned it.

    It was aslo the time when this XUL was being forumlated...but now you've given me hope again....

    could we make things like :

    + web desktop ( gnome-active-desktop)?
    + custome konfabulator type widgets?
    + virtual layers for each virtual desktop? like osx does for its widgets.


    edit : oooo [[jumps for joy]] we can use mootools now too... wooohoo

    reality-check : i hope it doesnt consume too much cpu or ram for low-end machines like 500mhz 256mb ram type setups.
    if so then maybe there is a way through the use of XML, XSLT, to convert it into a ncurses interface descripta?
    Last edited by airtonix; May 14th, 2007 at 10:49 AM.
    Fear is the mindkiller....
    The little death that obliterates...

  4. #14
    Join Date
    Jul 2005
    Location
    Remote Desert, USA
    Beans
    683

    Re: HOWTO: Getting Started with Linux Standalone Apps using XUL

    Glad you can actually comprehend this complexity and appreciate what I have figured out. Not many people have noticed how cool this is.

    Answers to your questions:

    web desktop: is a pretty heavy solution for that, no, not a good match
    konfabulator: don't know what that is
    osx widgets: again, not the best match for that kind of solution -- for that you need something designed in C or C++ that displays windows super fast, with low memory consumption, and acts just like the OS X widgets

    The best solution for these XUL apps are for building rich client (mostly Linux) apps like you might use VB6 on Windows, for instance. Also, if you're clever, you can even make the app check the web server for more recent code and download an updated version before running.

    You could even make a knockoff Quickbooks for Small Business clone with this, should you feel so benevolent.
    Last edited by SuperMike; May 15th, 2007 at 05:58 PM.
    SuperMike
    When in doubt, follow the penguins.
    Evil Kitty is watching you

  5. #15
    Join Date
    Jul 2006
    Location
    Córdoba, Argentina
    Beans
    1,341
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: HOWTO: Getting Started with Linux Standalone Apps using XUL

    Hi Mike, cool how to and very enthusiastic intro to the XUL world. Congratulations. I totally share your thoughts.

    In case I missed it in your posts let me tell you that you can grab xulrunner directly from repos in Feisty.
    I started learning XUL and coupling it with pyXPCOM (to save me the C++ amenities) since a few weeks ago and so far I'm happy with it (It seems that the Ubuntu's xulrunner does not come with pyXPCOM included so I'll have to build it from source).
    Mariano
    Ubuntu Linux User Group Argentina
    Let's all get up and dance to a song/ That was a hit before your mother was born/ Though she was born a long long time ago

  6. #16
    Join Date
    Jul 2005
    Location
    Remote Desert, USA
    Beans
    683

    Re: HOWTO: Getting Started with Linux Standalone Apps using XUL

    Word to all, now that time has passed.

    Making XUL apps is fairly easy once you know the steps. You can probably have less frustration with it than with PyGTK and Python. The downside? Well, it's slow and sucks memory. Every time you fire up xulrunner, even though it's smaller than a full blown browser, in a sense it's like opening a web browser every time you open one of these XUL apps. Sure, you can knock out stuff fast, but you're going to need a decent workstation to make these things pop on the screen fairly fast.

    If you want something faster, it appears that Python and PyGTK is still the way to go. It's how Gnome implements some (but not all) control panels and how many apps are built these days.

    Maybe some day someone will make either a faster xulrunner or come up with a new platform. Let's hope that new platform uses Javascript since everyone who does web dev already knows it and since it can be a beautiful language at times when you rip out the cross-platform browser junk out. BTW, if you haven't checked out ngs-js, I suggest you give it a try. It has a lot of potential.
    SuperMike
    When in doubt, follow the penguins.
    Evil Kitty is watching you

  7. #17
    Join Date
    Feb 2009
    Beans
    5

    Re: HOWTO: Getting Started with Linux Standalone Apps using XUL

    I would like to post some current info on XUL app development, having just jumped through the hoops and scoured the Mozilla site for hours just get a Hello World app working.

    Firstly, you can now bootstrap your XUL app with Firefox (since version 3). So you don't need to require XULRunner. Recent versions of firefox come with their own internal XUL runtime, which you can access with the -app commandline switch (you don't use -chrome anymore).

    e.g.
    Code:
    firefox -app path/to/application.ini -jsconsole
    The structure of a XUL app is much the same as SuperMike has described, with one important exception -- the "chrome.manifest" must now be in the root of the app directory. So Mike's example might now contain the manifest file:
    Code:
    content sample chrome/content/sample
    Another option is to have 2 chrome.manifest files, one in the app root, containing:
    Code:
    manifest chrome/chrome.manifest
    And the other in the chrome directory containing:
    Code:
    content sample content/sample
    This is a way of making a single root manifest point to as many other manifests as you like, giving you more control of the directory structure.
    But as Mike says, its still crazy.

    There are a lot of silly hoops to jump through to get started with XUL, and the documentation is patchy, but it really is a great technology and very beginner friendly once you figure out the boilerplate stuff. I should mention that the APIs themselves are actually well documented at the Mozilla Developer Network.
    And the ability to implement as much of your application in HTML as you like is all the more attractive with the current advent of HTML5.

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •