faq
flatforty
contribute
subscribe
configure
search
rdf
main
parent
|
Callbacks?
by Mark Kretschmann on Monday 10/Jul/2006, @01:15
|
I'm very interested in using Kross in Amarok 2.0. This seems like exactly the technology we want for implementing a plugin system, to replace or complement our existing scripting facilities.
My question: How can you implement callbacks with Kross, that is, invoking methods from the script when certain events occur in the application? |
|
|
The Fine Print: The following comments
are owned by whomever posted them.
( Reply )
|
Re: Callbacks?
by Cyrille Berger on Monday 10/Jul/2006, @01:23
|
The answer is short : we can't yet :) but that something we want to do.
|
[
Reply To This | View ]
|
Re: Callbacks?
by Ben Schleimer on Monday 10/Jul/2006, @06:37
|
I hate to sound like a simpleton,
but isn't this what signals/slots is supposed to do?
Wouldn't it be possible to make the event trigger a signal in the backend and then all of the connected slots in the script get called? I got the impression that QtRuby could do this... (but I am not an expert)
Cheers,
Ben
|
[
Reply To This | View ]
|
Re: Callbacks?
by Pau Garcia i Quiles on Monday 10/Jul/2006, @15:22
|
It would be possible to make the event trigger a signal in the backend and call the slots in the script, but it might get bit tricky.
For instance, here's what I'm doing in Korundum/QtRuby to know when a KPresenter presentation has finished:
factory = KDE::LibLoader.self().factory("libkpresenterpart")
@kpresenter = factory.create(w, nil, "KParts::ReadOnlyPart")
@kpresenter.openURL(KDE::URL.new(file))
connect( @kpresenter.widget().children[0], SIGNAL('presentationFinished()'), self, SIGNAL('itemFinished()') )
Look at that: @kpresenter.widget().children[0]. Thanks to Qt introspection I can get to the presentationFinished() signal, but it's quite contrived. It works flawlessly, though.
If the plugin just displays contents and needs no interactivity, another possibility is to use the winId trick: the backend would be an empty QWidget and we then tell the plugin you developed with Kross/QtRuby/PyQt/whatever to display its contents in the window with the winId of the aforementioned QWidget. It works but you get no events, therefore is a very limited approach.
|
[
Reply To This | View ]
|
|
The Fine Print: The previous
comments are owned by whomever posted them.
( Reply )
|
|