{January 8, 2009}   adventures in plasmaland, part 2

we’ve got a bit more in the way of javascript bindings, and only one of my teachers has posted homework, so I decided to work on kconfigmenu some more. :)

now that it can install and run, I want it to display a pretty icon. so, first thing, we create an icon:

icon = new IconWidget();

re-using kde’s confiugure icon once again. :)
but it turns out that plasmoids have no layout by default, and that’s not good… so at the top of the file we have to create one, and then after out icon is made we have to put it in the layout.

layout = new LinearLayout(plasmoid);
icon = new IconWidget();

now, unfortunately javascript plasmoids are defaulting to 200×200 on the desktop, and if i try to resize my plasmoid it overrides the configured size every time plasma restarts (a Bad Thing). that’s gonna have to be fixed in the bindings; until then, I start with a ridiculously large config icon. :)

Update: fixed! I made it possible to set a default size in the metadata :)

now that that’s working, the next step is to figure out how to put things in hte contextmenu.
ideally my code should pop up a menu on left-click instead, but I’m going to be lazy right now and try to get it working before I get it pretty.

getting a dummy action in the contextmenu was easy. copy&pasted this from the tiger plasmoid:

plasmoid.setAction("myAction", "Select Me!", "plasma");

plasmoid.action_myAction = function()
print("myAction triggered!");

and once again I’ve committed it.
it even has an icon! :)
the action

now, what we want is some data to make actions out of. if I was using c++, I would start with KService::List modules = KServiceTypeTrader::self()->query("KCModule"); – but I’m not. I’m just using a simple javascript API. there *is* a dataengine that will execute arbitrary commands, and kcmshell4 can output a list of all the modules… but then I’d have to parse the list, and I’d only get the module name (in a not-very-userfriendly form) and the description (which isn’t always something I can show as a title either).

hmmmmm. I’m gonna have to think about this next step a bit.

Mr. Tahoma says:

Offtopic, but…

Your screenshot has now made it clear to me why the Oxygen theme menus don’t look right on my system. Apparently, they are designed for large font sizes (your picture looks great). When I use Tahoma 8, the menus look horrible, as if they don’t scale down. Now I think I can file a bug report.

cheko says:

Can’t you use the settings-kio-slave?

There you get the following structure:

…- Advanced User Settings
……- Audio CDs
……- Autostart
……- …

…- System
……- Task Scheduler
……- Login Manager
……- …

…- Computer Administration
……- Display
……- Input Actions
……- …

…- Look & Feel
……- Appereance
……- Desktop
……- …

…- Network & Connectivity
……- Bluetooth
……- Network Settings
……- …

…- Personal
……- About Me
……- Accessibility
……- …

So you don’t need to parse the output from kcmshell4 –list, you get the right icons, right names etc. for free.

Will Stephenson says:

Didn’t Chani start by saying she didn’t want the SystemSettings module tree…?

Comments are closed.

et cetera
%d bloggers like this: