feedbacks needed for scripting interface

Ian Monroe ian at monroe.nu
Thu Jul 10 18:31:09 CEST 2008


After talking to Nikolaj, turns out I had misunderstood the purpose of
the "callback" and "id" variables in the current DBus-based system.

In this slightly revised hypothetical script, I got rid of the id's
and used just callbacks (I call them labels) to tell the script what
parent item that it is populating. This label makes more sense in a
more complicated script, where it could be a URL.

function CoolStream()
{
   ScriptableServiceManager.call( this )
   this.serviceName = "Cool Streams";
   this.levels = 2;
   this.shortDescription = "List of some really cool radio streams";
   this.rootHtml = = "Some really cool radio streams, hand picked for
your listening pleasure by your friendly Amarok developers";
}

CoolStream.prototype.populate = function( parent_label )
{
   if ( parent_label == "root" )
   {
       print( "Populating main level..." );

       //add top level item
       coolParent = StreamItem.new();
       coolParent.label = "Parent";
       coolParent.parentLabel = parent_label;
       coolParent.name = "The Amarok Crew\'s Top Streams";
       coolParent.htmlInfo = "Just a parent item to show how nesting works";
       coolParent.url = "";
       this.insertItem( coolParent );

       print( "... done" );
   }
   else if ( parent_label == "Parent" )
   {
       print( " Populating station level..." );

       //add the station streams as leaf nodes
       for (i = 0; i < stationUrl.length; i++)
       {
           coolStream = CoolStream.new();
           coolStream.url = stationURL[i];
           coolStream.name = stationName[i];
           coolStream.parent_label = parent_label;
           coolStream.htmlInfo = "A cool stream called " + stationName[i];
           this.insertItem( coolStream );
       }
   }
}

CoolStream.prototype.onConfigure = function()
{
   Amarok.Statusbar.longMessageThreadSafe( "This script does not
require any configuration." );
}

CoolStream.new()


More information about the Amarok-devel mailing list