Friday, June 06, 2008

google gadgets

Just so that people can stop emailing me one at a time ;) ... I grabbed the Google Gadget code the day it was released and spent some time that evening looking at it. It's written in C++ which is cool; on the other hand there's also well over 100,000 lines of code in there too. Much of it seems to be about replicating things Plasma already does for applets (list them, load them, etc).

There seems to be two routes to take, in any case, to get Google Gadgets into Plasma:

a) Link the code they've released into a Plasma::ScriptEngine plugin. This ScriptEngine would need to provide a subclass of the Host class and bridge that to QGraphicsView. It seems really bulky, though, and I'm not sure we'd get overly terrific integration with plasma. It may be fast to do, though.

b) Grab their custom JS hooks and, as we have with MacOS Dashboard Widgets, provide a PackageStructure plugin and then throw the content of the gadgets into a Plasma::WebContent widget (a Webkit renderer in a QGraphicsItem). Depending on what all is in their JS, this may actually be even faster.

I'm a bit busy to do this myself, but if anyone is interested in giving (b) a try, I'd be happy to first point you to the >MacOS Dashboard PackageStructure and ScriptEngine and then help you with an implementation for Google's Gadgets. How hard can it be? =)

Oh, and if you were trying to load MacOS Dashboard widgets in KDE 4.1beta1 it doesn't work: a commit made following the API review from Tokamak inadvertently broke Package installation for those guys. I fixed it today after one of our oh-so-valuable beta testers filed a bug about it. Huzzah for beta testers! =)

update: looks like we were all beat to the punch by the google gadget hackers themselves. i guess we'll have google gadget support sooner than i could have hoped for. rock on. =)

7 comments:

Luciano said...

Hi! :)

This is interesting...

I've a question regarding the implementation b) as well as current MacOS widgets support on plasma. If you use just Webkit to show and use JS stuff, what happens to the widgets that use advanced features such as multimedia content? I've take a look at Google gadgets and they seem to use gstreamer for this kind of stuff, will plasma use Phonon for that? How does Plasma handle this issue with MacOS widgets?
Basically the question is if providing full support for all Google and MacOs widgets is as easy as using just Webkit.

Sorry for my ignorance on the topic and/or if this question is too stupid.

Thanks for your time.

Cheers

James Su said...

Google Desktop Gadgets are much different than other kind of HTML/JavaScript based gadgets/widgets.

Instead of HTML/CSS, Google Desktop Gadgets use a set of special APIs. See http://code.google.com/apis/desktop/docs/gadget_apiref.html for details.

You can't just throw Google Desktop Gadgets into a HTML engine and run them. That's what 100,000+ lines of code do.

Aaron J. Seigo said...

@Luciano: we're waiting on some new features in phonon before we can use it for media; it's a bit of a gap atm for us.

@James Su: "Google Desktop Gadgets are much different than other kind of HTML/JavaScript based gadgets/widgets."

not really; most html/css/js widget systems provide this kind of framework as well.

"Instead of HTML/CSS, Google Desktop Gadgets use a set of special APIs."

yes, i'm very aware of that.

"That's what 100,000+ lines of code do."

not really; at least not in the sense you are implying which is that to replicate it would take a similar amount of code.

a lot of the code that they released is management stuff and reimplementing things we have below us already in the stack.

the js api actually isn't that huge.

take for example framework.system.network. we don't have to implement *any* of that from scratch, just bridge over to calls into Solid.

all 14 properties, 4 methods and 2 classes are handled easily by a subset of solid.

so no, it wouldn't take anywhere *close* to the amount of code they've put into it to replicate the JS API within plasma.

moreover, given the number of gadgets that likely use framework.system.network one could even leave that out entirely if they wanted to and just deal with having gadgets that do use that not work.

we support a subset of MacOS widgets as well (though due to MacOS assumptions or code in the widgets)

"You can't just throw Google Desktop Gadgets into a HTML engine and run them. "

yeah, because that's just how stupid i am! doh! silly me! tee-hee! *rolls eyes*

maninalift said...

Google rocks! Isn't it fab to live in a world where one of largest commercial companies produces useful tools to distribute for free rather than desirable products to sell for as much as it can get?

Anonymous said...

great news :-)
http://groups.google.com/group/google-gadgets-for-linux-dev/browse_thread/thread/b695a1ade6a0d302

BrokenCrystal said...

Any chance that Plasma will eventually get support for Yahoo! Gadgets?

I use these more than anything on other OSes. They have a huge variety of them, but they currently run on both OSX and Windows.

I have asked them repeatedly to port their engine to Linux, but I asked one too many times and they temporarily banned me from their forums for a while, so I gave up and quit asking them.

Jackfield was going to have this feature, but the programmer didn't have enough time on his hands to finish the project.

Here is the Yahoo! Widgets website.
http://widgets.yahoo.com/

danzam said...

when will we have full OSX Dashboard widget support in kde?