Monday, February 2, 2009

 

ComicStrip Vista Sidebar Gadget

Download


One of the most popular demo Gadget in the book is ComicStrip Gadget. I keep getting emails from users all over the world about how to customize it. Note that this gadget is meant for education purpose only. Here is one of the conversation.



If you are also interested to customize the Gadget Read On.

The Problem from Gadget developer 

First of all let me thank you the very useful ComicStrip gadget. I really enjoy using it, However I have slight problems with it.These are:

  1. When I restart the PC, the gadget reverts all settings to default, in my case, I only need Dilbert, Garfield and Calvin & Hobbes strips but when my PC restarts the gadget always displays all the default strips like Maxine, Chicken and so on. I cannot figure out what is the problem, I am admin on my PC and I also have full control rights for the Sidebar directory. I also checked the settings.ini for gadgets, it has the right settings for ComicStrip. This also happens sometimes when I just hibernate the PC.
  2. The other thing: on the settings page Calvin and Chicken are mixed up, so when I select Calvin, I get Chicken strips and vice versa.

Could you please at least give me hints how to resolve this problem or could you please fix it? I  really enjoy using your superb gadget and I definitely do not want to switch to an other feed reader sw because the Sidebar is the most comfortable solution AND simply there is no alternative for your gadget, it is one of a kind...


The Solution 

The session in sidebar vista gadget is not saved when the computer restarts, so the only way to make the settings persist is set the defaults in the code. ComicStrip gadget is based on MyBlog Gadget which is the core focus of Chapter 4 to Chapter 8 of Creating Vista Gadgets .If you have the book, check the portion where we initialize and set the defaults for the Gadget.

Here are the steps to change the defaults:

1. Open the following location in Windows Explorer %userprofile%\AppData\Local\Microsoft\Windows Sidebar\Gadgets\ComicStrip.gadget\code

2. Open the Gadget.js file in notepad.

3. Look for the function SetDefaults()

you will see the following code

function SetDefaults()
{
System.Gadget.Settings.write("Dilbert",true );
URLFeedsActive[0] = 1;

System.Gadget.Settings.write("Garfield",true );
URLFeedsActive[1] = 1;

System.Gadget.Settings.write("Chicken",true );
URLFeedsActive[2] = 1;

URLFeedsActive[3] = 0;
URLFeedsActive[4] = 0;
URLFeedsActive[5] = 0;

System.Gadget.Settings.write("Calvin",true );
URLFeedsActive[6] = 1;

System.Gadget.Settings.write("Maxine",true );
URLFeedsActive[7] = 1;

URLFeedsActive[8] = 0;
URLFeedsActive[9] = 0;

System.Gadget.Settings.write("Peanuts",true );
URLFeedsActive[10] = 1;

System.Gadget.Settings.write("BobBetty",true );
URLFeedsActive[11] = 1;

}

SO FOR 11 COMIC STRIPS YOU HAVE 11 SETTINGS

if you want only dilbert , garfield and calvin your function code should look like the following

function SetDefaults()
{
System.Gadget.Settings.write("Dilbert",true );
URLFeedsActive[0] = 1;

System.Gadget.Settings.write("Garfield",true );
URLFeedsActive[1] = 1;

URLFeedsActive[2] = 0;
URLFeedsActive[3] = 0;
URLFeedsActive[4] = 0;
URLFeedsActive[5] = 0;

System.Gadget.Settings.write("Calvin",true );
URLFeedsActive[6] = 1;

URLFeedsActive[7] = 0;
URLFeedsActive[8] = 0;
URLFeedsActive[9] = 0;
URLFeedsActive[10] = 0;
URLFeedsActive[11] = 0;
}

4. Make the change in SetDefault function and save Gadget.js file.

5. Close the gadget from sidebar.

6. Go to gadget picker window and add the gadget again.

Hope this helps.

Labels: , , , ,


Comments: Post a Comment



Links to this post:

Create a Link



<< Home