[Kde-bindings] Qt::ScriptEngine context

Ian Monroe ian.monroe at gmail.com
Wed Mar 3 00:52:08 UTC 2010


On Tue, Mar 2, 2010 at 3:41 PM, Han Holl <han.holl at pobox.com> wrote:
>
> Hi,
> In KDE3 I had an application that displayed photographs on the background with
> captions from the EXIF headers.
> I now try to rebuild this for KDE4.4, and have several problems.
> Because under KDE4 hiding the panel is cumbersome I try to do this from a
> program. There is no dbus interface for this, but the following Javascript
> works (in the desktop shell scripting console).
>
> var p = panelById(panelIds[0]);
> hiding = p.hiding;
> if (hiding == 'none') {
>  p.hiding = 'autohide';
> } else {
>  p.hiding = 'none';
> }
>
> Question: how to run this from a ruby script ?
> The following does _not_ work: (ReferenceError: Can't find variable:
> panelById)
>
> #!/usr/bin/ruby -w
> require 'Qt4'
> require 'qtscript'
>
> a = Qt::Application.new(ARGV)
> eng = Qt::ScriptEngine.new(a)
> script = %q{
> var p = panelById(panelIds[0]);
> hiding = p.hiding;
> if (hiding == 'none') {
>  p.hiding = 'autohide';
> } else {
>  p.hiding = 'none';
> }
> }
> v = eng.evaluate script
> puts v.toString
>
>
> I suspect that it is a question of the correct Qt::ScriptContext, but I've no
> idea how set the correct context.

Well its the completely wrong process. Took me a couple of looks to
figure out what you were doing here. :) These scripts need to be run
inside plasma, that's how plasma scripting works.

So the correct question is "how do I run run a qtscript plasma script
from another app" I don't know the answer. Or maybe the question
should be "how do I write a background applet" since I think there's a
public interface for ths. Anyways I don't know the answers,
plasma-devel is probably the correct place.

Ian



More information about the Kde-bindings mailing list