Understanding Widgets
Widgets (also know as gadgets) are usually flash-based (or platform specific) mini-applications that can be developed and deployed on your website, blog or desktop. Most widget are task-specific and lightweight, many are self-contained.
Widgets fall into one of the following three categories:
* Accessory Widgets are self-contained and don't require support from an application or Internet access. Clocks, timers, calculators, and note-takers fall into this category.
* Application Widgets are associated with a full-fledged application. This kind of Widget enhances the application by providing a less complicated and often read-only interface. The iTunes Controller and Address Book Widgets fall into this category.
* Information Widgets are designed to work with data from the Internet. These Widgets allow you to monitor external events such as the weather, flight status, or stock prices.
Dashboard Architecture
The runtime architecture of Dashboard consists of the following components:
* The Dashboard server, a lightweight process that manages the Dashboard user interface including the Widget bar, close box, and Widget launch effects.
* Dashboard client processes, providing all the needed glue between the Dashboard server and individual Widgets as well as the Web Kit view for the Widget to display its user interface within. The Dashboard server launches one client process per running Widget.
* The Widget instances, displaying data to, and interacting with, the user.
Each Widget is run inside a separate client process which provides a sandbox so that it doesn't affect any other Widgets or applications. For reliability, Dashboard also carefully manages Widgets. If a Widget crashes, it is automatically restarted so that it simply reappears in the Dashboard. If it misbehaves, crashing more than three times in a row, it is automatically removed from the Dashboard.
What's Inside a Widget?
basicwidget.jpeg
At its simplest, a Widget is simply a web page that is displayed in the Dashboard rather than in a browser, such as Safari. A Widget is contained on disk in a bundle a directory that groups all the needed resources for the Widget together in one place. Widget bundles are named with the .wdgt extension. Like any other bundle, a Widget's bundle is managed by the Finder as a single entity.
A basic Widget contains the following files:
* A main HTML file defining the user-interface for the Widget.
* A default background image in PNG format that can be displayed by Dashboard while it loads the Widget. The PNG format is used because of its excellent support for alpha channel transparency.
* An icon image, also in PNG format, used to represent the Widget in the Widget Bar.
* A property list file named Info.plist that contains a Widget's identifier, name, version information, size, and the main HTML page as well as other optional information used by Dashboard.
As a Widget grows, you can place other files, such as images and external CSS and JavaScript files, into the Widget's bundle.
Let's take a look at the various components of a Widget, starting with HTML.
|
| |