you may have noticed at the beginning of
nikolaj's last blog post that he made a small reference to a
competition that we are having to see who can come up with the biggest code-drop once trunk opens again. he then went on to describe his playing around with the navigation system in the left-hand browsers. well, i'm not about to let his challenge to unmet, am i? i can't let him take all the spotlight for himself!
so in order to make amarok more flexible, and give potential community members more tools at their disposals, i finally looked into adding scripting support to the Context View. just like plasma, you can write applets for the context view in a ridiculously small amount of code. the architecture (read: plasma) was always in place, but it was never really exposed properly and it was always a hack to get it to work. so of course, no one wrote any scripts. and so there are no amarok scripted applets at the moment.
but hopefully that will all change! because now i've given you all the power to write your own britney spears themed applets! and just in a few lines of code! i could sit around and explain, but i'd rather show you a picture:
and then because i'm such a great guy, i'll even show you the code that makes that magic happen:
plasmoid.drawAppletBackground = function()
{
return true;
}
plasmoid.dataUpdate = function(a, b)
{
if ( b.current )
label.text = "Playing " + b.current[ "xesam:title" ] + " from " + b.current[ "xesam:author" ] + " on " + b.current[ "xesam:album" ];
}
layout = new LinearLayout( plasmoid );
layout.setAlignment( 2 );
label1 = new Label( );
label1.text = "This is a javascript applet. Just to show off that we can get data from c++ dataengines, here's info on the currently playing track:";
layout.addItem( label1 );
label = new Label();
layout.addItem( label );
label.text = "This is a Javascript Applet";
plasmoid.dataEngine("amarok-current").connectSource( "current", plasmoid );
and, thats it. you'll be able to install new scripted applets directly from inside amarok, and have all the fun that you want. i'd like to note that this is still in a very early stage and all the UI bits are still a work in progress--that includes the currently location of the "Install New Widgets" button. i needed somewhere to put it, and that seemed good for testing.
so, nikolaj... whats next?