Monday, February 25, 2008

loading random widgets

one of the main things i worked on today was support for loading widgets plasma doesn't know about at build time. this is to allow us to load various sorts of widgets that aren't appropriate or possible to stick into libplasma itself.

all widgets are, at their most basic level, housed within a Plasma::Applet. libplasma itself provides support for native Plasma widgets, aka "Plasmoids". a Plasmoid is a collection of scripts, images, configuration, UI and widget specific data files that are bundled up together into a package.

the package itself is defined by a PackageStructure which informs a Plasma::Package what should be and what could be within a given Package.

Package provides the ability to install the package locally, query the packages, fetch a given resource from them, etc. Package is how we are able to list non-c++ widgest in the Add Widgets dialog, among other things. now, Package is nothing like the packages that software applications come in for your operating system (e.g. rpm, deb, pkg, tar.gz, etc....). they are both simpler and more about accessing resources rather than managing installation (though Package does that) and calculating dependencies.

this system is all well and good for Plasmoids, but what about other packages ... like MacOS Dashboard widgets? or any other widget of this style, for that matter. the widgets have their own structures; while Package can handle this it does need a way to get at the package structure. so Package can read the structure of a package from a config file. unfortunately, this isn't enough: some widget package formats are just stupid and have no predefined structure whatsoever which makes dealing with them far more annoying and code-laborious than necessary. yes, MacOS widgets are in that category, and as such can't easily be codified in a config file without adding some flexibility that would amount to a description language of sorts.

so rather than subject myself (and those who would use this) to that sort of pain, Plasma::PackageStructure can now also be provided as a C++ plugin, giving us all the flexibility we could every hope for, need and want.

the end result is that when a widget (regardless of type) is accessed (installed, listed, opened, etc) it looks like any other widget to libplasma based applications.

behind the scenes when the Package is loaded, Applet looks to see what PackageStructure it uses. if none is defined, we assume it's a native Plasmoid. if there is one then we look for a plugin and if that doesn't work out then we try for an installed config file description. assuming that goes well, we now have the PackageStructure, which directs Package, which provides a standard interface to Applet, which makes all widgets look the same to libplasma.

neat.

the last bit of work i have to do here is to add Package install pre-processing for widget archives (most of them are just zip files) so that when the user installs a new widget we can create the proper metadata that Package needs and deal with whatever compression system the widget uses. this is the easy bit, though, compared to getting the above working. once it is done we'll have the full round-trip from the Add Widgets dialog (via Get New Widgets) to disk to applet listing to desktop/panel/etc placement.

over the weekend Zack got WebKit based widgets working, both "native" plasma ones as well as MacOS widgets. the native plasma widgets have access to things like DataEngines from javascript embedded within the webpage. this is a little different from the qscript plasmoids where the javascript is stand-alone and is the widget for all intents and purposes; with the webkit based widget the webpage is the widget and javascript to manipulate it lives inside the webpage itself.

the Dashboard stuff basically came along for free. it was neat to watch the hello world, clocks and Chuck Norris MacOS widgets load up and work without any prodding. we will need to provide some additional javascript API that some dashboard widgets assume to exist, and we'll likely never be able to satisfy the macos bundles bridge that is available on MacOS due to how tied into the platform that is but thankfully few widgets seem to use those.

there are patches upstreamed for WebKit that are required for this to work, so until they hit qt-copy the code will remain in playground. we also ran into more of the same WoC (widgets on canvas) bugs with the web applet support that we had already run into with the general WoC porting of libplasma. gotta love living on the edge of development ... constantly. ;)

and the screencast will have to wait to tomorrow, as p. is back and fast asleep in bed. i don't want to wake him; in fact, i should probably head to bed soonish myself as i have to get up at 07:00 to get him off to school.

6 comments:

Anonymous said...

:o
A screenshot of Chuck Norris MacOS widgets on Plasma would have been nice ;). Can't wait for the screencast !
I can't believe how fast you were to have macos widgets working oO. Another proof that Plasma might be well done :)

Anonymous said...

Wow. I guess the title "Plasma Tube - Motion Light Widget" of one of the top10-widgets on apple.com just got a new meaning :)

Marcel said...

cool blog, thanks for all your work.

however, a question: why the ugly black squares around plasma icons? what is it good for? will this get fixed any time soon?

it's the reason I stopped using desktop icons... :\

tobami said...

the webkit integration news is great.

I'm not sure I fully understood the package part though. And how does it relate to plasmagik?.

I hope you are not going to wait for plasma to be completely finished before writing some updated overall description of the plasma vision. Even having full faith in the captain (you), some people like to know in what direction the ship sails ;). And you don't need documentation for that. For example, a post explaining the ZUI concept (as oposed to technical details) as envisioned by you would have helped avoiding repetitive bashing last week. You could regard the time spent in such a post as community-building time.

Well. I don't mean to tell you what you have to do. Technical details are also nice of course :-D

Just rock on. I hope you had fun with Zack making funny Dashboard applets work :-)

Aaron J. Seigo said...

> a post explaining the ZUI concept

i actually did exactly that a few months back. but people tend not to remember. or they miss that posting. or they don't read my blog. or they don't care.

it's a pretty lousy rate of return in that regard, but you're right that those who do read the blog and are interested find those entries nice =)

> I hope you had fun with Zack making
> funny Dashboard applets work

tobami said...

>i actually did exactly that a few months back
Mmmm. Yes you are right, there was an explanation back in July. But that's what I meant with "current", a short explanation around or after 4.0.0 about it's current incompleteness and what the goal for 4.1 is on that front. July is a long time ago in KDE4 development.

Anyway. Would you care to comment on the plasmagik question please?

>it's a pretty lousy rate of return in
>that regard, but you're right that
>those who do read the blog and are
>interested find those entries nice =)

You bet it. Apart from your coding and evangelizing contributions, invaluable as they are, I don't care to imagine what the KDE universe would be like without your "endless chatterbox", as you put it. It would be very, very silent and barren (not wanting to offend other KDE bloggers). Every big OSS project needs at least someone like you.

Thank you very much.

Miquel