Rich Cross-Platform Desktop Applications Using Open-Source Titanium
Listing 1. JavaScript, Python and Ruby, All in One HTML File
<html>
<head>
<script type="text/javascript">
function helloJS() {
window.document.getElementById('output').innerHTML
= "Hello from Titanium using Javascript";
}
</script>
<script type="text/python">
def helloPython():
window.document.getElementById('output').innerHTML \
= "Hello from Titanium using Python"
window.helloPython = helloPython
</script>
<script type="text/ruby">
def helloRuby
window.document.getElementById('output').innerHTML \
= "Hello from Titanium using Ruby"
end
window.helloRuby = helloRuby
</script>
</head>
<body>
<div id="output">
</div>
<div>
<button onclick="helloJS()">helloJS</button>
<button onclick="helloPython()">helloPython</button>
<button onclick="helloRuby()">helloRuby</button>
</div>
</body>
</html>
Save the file, then go to the Titanium Developer's Project tab, and click the package icon on your project. Click Package and Launch, and test your application. Click the buttons to get a hello world from three different languages—all in a single page (Figure 8).
While you're writing code, you're sure to run into bugs. Luckily, Titanium includes WebKit's Web Inspector, which you can use for various developments tasks. To open the Web Inspector, simply right-click on your app, and select Inspect Element.
Once you're done writing code and perfecting your application, you're now ready to package your application, which is easy to do with Titanium Developer. In the Packager window, click the Package for Distribution button.
You are given several options. The first one is to select for which platforms to package your app—you can choose from OS X, Windows and Linux (or all three). Next, you need to decide whether to bundle the runtime with your application or install it via the network during launch. Then, you decide which modules you'll add to your project and whether to bundle them with your app (Figure 9).
Finally, you have the choice of making your project publicly available. By checking Make app public, your application will be added to the App directory and be made available to users everywhere. This helps immensely in distributing your application, because Titanium also hosts your files for you. When you're done, click Package.
Titanium Developer then uploads your project files to the Packager Cloud for packaging. When it's done, you are presented with links to your downloads for each platform you specified. If you made your app public, Titanium Developer also starts showing statistics for your application, such as the number of downloads for each platform and the user ratings for you application (Figure 10).
As you saw in the code above, all languages supported by Titanium have a window object. This is the shared global object and is used to bind methods and objects that need to be available on all languages. The main namespace for the Titanium API is also bound to this global object and can be accessed via window.Titanium.
Aside from WebKit goodies, such as client-side database storage and CSS animations, Titanium's current API also contains many of the necessary features needed for desktop application development:
Titanium.Desktop: for launching third-party applications and opening URLs on the default browser.
Titanium.Filesystem: for working with the filesystem for things like reading and writing files, creating and managing directories and so on.
Titanium.Media: for working with media files, such as audio and video.
Titanium.Network: for working with network-related tasks, such as socket connections and IRC clients.
Titanium.Notification: for custom system notifications, as well as hooks to platform-dependent notification systems like Growl and Snarl.
Titanium.Platform: for getting information about the user's system.
Titanium.Process: for working with system processes, as well as launching and executing system commands.
Titanium.UI: for working with native windows, menus and system chrome.
Unfortunately, going over all of these APIs would require an article (or two) in itself. Fortunately, the official Titanium site provides documentation with more details.
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Designing Electronics with Linux | May 22, 2013 |
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
- RSS Feeds
- Dynamic DNS—an Object Lesson in Problem Solving
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Designing Electronics with Linux
- Using Salt Stack and Vagrant for Drupal Development
- New Products
- A Topic for Discussion - Open Source Feature-Richness?
- Drupal Is a Framework: Why Everyone Needs to Understand This
- Validate an E-Mail Address with PHP, the Right Way
- What's the tweeting protocol?
- Kernel Problem
8 hours 31 min ago - BASH script to log IPs on public web server
12 hours 58 min ago - DynDNS
16 hours 34 min ago - Reply to comment | Linux Journal
17 hours 6 min ago - All the articles you talked
19 hours 30 min ago - All the articles you talked
19 hours 33 min ago - All the articles you talked
19 hours 34 min ago - myip
23 hours 59 min ago - Keeping track of IP address
1 day 1 hour ago - Roll your own dynamic dns
1 day 7 hours ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?







Comments
Titanium: good idea, bad implementation
...except, the product is unreliable as stink (I am using 0.82). I am surprised you were able to get your example code running. Every corner I discover new show-stopper bugs that shouldn't even be in a beta product. On top of that, because you rely on their "cloud", you are at the mercy of their server code too - which is crazy unreliable. I would say 90% of the time I am not even able to get an installer built! And, once the installer is made, often it is corrupt - or doesn't install properly. Just go try to install some of the "example" apps on appcelerator's site - I only tried 3, but 2 wouldn't install properly. Geesh!
The idea is terrific: native apps with a UI in an embedded webkit. But the implementation is weird and unreliable. And, the whole so-called "cloud" bit to their development story is ridiculous. Let's hope 1.0 is dramatically better quality.