[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: KJSEmbed added to kdenonbeta
From: Richard Moore <rich () ipso-facto ! freeserve ! co ! uk>
Date: 2001-11-13 23:25:24
[Download RAW message or body]
I've just added a new library KJSEmbed to kdenonbeta that makes it easy to
embed a KJS interpreter in a KDE app. The lib includes bindings that let
scripts access QWidgetFactory (so they can load dialogs/widgets from
QtDesigner .ui files), and a binding to the properties of QObjects.
If you want to know more, look at the kdoc comments or try building the
example app by running 'make testkjsembed'. Here is section that illustrates
things a little:
// Setup Interpreter
KJS::Object global( new KJS::ObjectImp() );
KJS::Interpreter *js = new KJS::Interpreter( global );
// Create Console Widget
KJSEmbed::JSConsoleWidget *win = new KJSEmbed::JSConsoleWidget( js );
// Add Bindings
win->addBindings( js->globalExec(), global );
KJSEmbed::DialogFactory::addBindings( js->globalExec(), global );
KJSEmbed::JSObjectProxy *appProxy = new KJSEmbed::JSObjectProxy( js, &app
);
KJS::Object appObj( appProxy );
appProxy->addBindings( js->globalExec(), appObj );
global.put( js->globalExec(), "app", appProxy );
KJSEmbed::JSObjectProxy *consoleProxy = new KJSEmbed::JSObjectProxy( js,
win );
KJS::Object consoleObj( consoleProxy );
consoleProxy->addBindings( js->globalExec(), consoleObj );
global.put( js->globalExec(), "console", consoleProxy );
I hope to add support for the scripting interface Ian Geiser is working on
soon. Where should this code live? Personally I'd prefer kdelibs, but
kdebindings might also be suitable.
Note: There IS a security mechanism, and NO this WON'T make the kjs in
konqueror insecure - only the specified interpreter has access to this stuff
and only a defined set of objects and properties is made available to scripts.
The current code can be viewed here:
http://webcvs.kde.org/cgi-bin/cvsweb.cgi/~checkout~/kdenonbeta/kjsembed/
Cheers
Rich.
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic