Well, you could either add the folder to the gadgets folder or if you want the gadget to appear in Sidebar you could shell execute the gadget file. Of course, the latter would offer a prompt to the user asking if they want to install it.
Not quite too sure what you're asking. Does this help (link below) or are you asking how to programmatically add the gadget to the sidebar so that it just shows up on the sidebar without user intervention? If the latter, I'm not sure. Never thought about it.