This article was written and submitted by an external developer. The Google Desktop Team thanks Rodrigo Costa for his time and expertise.
When developing a new gadget, we should pay attention to this fact: the average user has multiple gadgets in the Sidebar, and a power user has yet even more. Because space is limited, users typically keep a few gadgets in a minimized state. As gadget developers, we have to take this issue in consideration to improve the usability of our gadgets.
When a gadget is minimized, it collapses to save space.
It displays the gadget's small icon and the contents of view.caption
attribute within the title.
In this state, some functions such as framework.audio.play
are disabled. However, if you have a gadget that uses a timer to periodically retrieve information, you have to
realize that the timer continues to run even when the gadget is minimized.
For the minimize/un-minimize transitions, the Google Desktop API provides some useful "hooks":
view.onrestore
- Fires when the gadget is restored from the minimized state.view.onminimize
- Fires when the gadget is minimized.Within these events, you can do intelligent things such as halting animations or intensive computations. However, this article focuses on updating the minimized title content, which can be done without handling any events.
The AdSense Tracker gadget has an hourly timer that updates your earnings of the day in the Google AdSense program. When the gadget is operating normally (Figure 1), you can see yesterday's earnings, monthly earnings, and other information.
Now in Figure 2, you can see that when the gadget is minimized, it displays the most useful statistic in the title, which is your earnings today. Even when minimized, the gadget is useful to the user and helps to conserve space in the Sidebar. This should be a concern for every gadget you develop: "Can the gadget provide a valuable service to the user at all times?"
Below is the code that sets the gadget's title:
view.caption="Adsense-US$ "+earnings;
Let's look at another example. Suppose you have a digital clock gadget. The code below updates a label in the gadget to display the current time:
function view_onOpen() { clock(); } function clock(){ var date = new Date(); var minute = date.getMinutes(); var hour = date.getHours(); var second = date.getSeconds(); label1.innertext = hour + ":" + minute + ":" + second; view.setTimeout(clock, 1000); }
The timer fires every single second. Now, if the title is some static text such as "Digital Clock", and the gadget is minimized, the gadget won't be of any value to the user. But if you instead show the current time in the title, the gadget will remain useful when minimized.
function clock(){ var date = new Date(); var minute = date.getMinutes(); var hour = date.getHours(); var second = date.getSeconds(); view.caption = "Digital Clock - " + hour + ":" + minute + ":" + second; label1.innertext = hour + ":" + minute + ":" + second; view.setTimeout(clock, 1000); }
Before you release a new gadget, you should think on how it behaves when minimized.
This is one important aspect of maximizing the usability of a minimized gadget.
After reading this article, I hope you will consider using view.caption
when maximizing the usefulness of your own gadget.
I am an enthusiast of technology since the 80's...today I mostly work on Internet development with ASP, PHP, PERL, .NET...and the improvement of my sites on Google AdSense. Like all here, I am also a big Google fan. Quote: If an elderly but distinguished scientist says that something is possible, he is almost certainly right; but if he says that it is impossible, he is very probably wrong. (Arthur C. Clarke) You can see my gadgets on my website. Also, please visit my Adsense Tracker gadget.
This work is licensed under a
Creative Commons Attribution-No Derivative Works 3.0 United States License.