In fact, I succeed in displaying a xul box with an event queue and
everything worked fine. here is the code :
----------- 8<--------------- cut here ----------- 8< -------------
var EventQClass =
Components.classes['@mozilla.org/event-queue-service;1'];
var EventQObj = EventQClass.getService(Components.interfaces.nsIEventQueueService);
EventQObj.createThreadEventQueue();
var AppShellClass =
Components.classes['@mozilla.org/appshell/appShellService;1'];
var AppShellObj =
AppShellClass.getService(Components.interfaces.nsIAppShellService);
var URLClass = Components.classes['@mozilla.org/network/standard-url;1'];
var URLObj = URLClass.createInstance(Components.interfaces.nsIURL);
URLObj.scheme="file";
URLObj.path="/tmp/test.xul";
AppShellObj.Initialize(null,null);
var test = new Object();
toto = AppShellObj.CreateTopLevelWindow(null,URLObj,
true,true,
Components.interfaces.nsIWebBrowserChrome.CHROME_ALL,
640,480,test);
AppShellObj.Run();
----------- 8<--------------- cut here ----------- 8< -------------
If you try this code you'll get a segmentation fault from gtk.
In http://lxr.mozilla.org/mozilla/source/widget/src/gtk/nsAppShell.cpp#245
the main problem is that this code use nsICmdLineService interface which
can't be initialize from JS :
[noscript] void initialize(in long argc, out string argv);
so I modified nsAppShell.cpp to test :
----------- 8<--------------- cut here ----------- 8< -------------
//gtk_init(&argc,&argv);
char ** t_argv = new char*;
t_argv[0] ="/mnt/addon/comedia/mozilla/dist/bin/xpcshell";
int t_argc=1;
gtk_init (&t_argc,&t_argv);
----------- 8<--------------- cut here ----------- 8< -------------
And miracle !!! it worked a XUL Window appears, I use :
http://bugzilla.mozilla.org/showattachment.cgi?attach_id=42837
as test.xul all the event worked.
But the drawback is the modification of nsAppShell.cpp. A solution could
be the implementation of something between nsAppRunner and xpcshell. An
application that allow interactive mode in the main JS Context.
David Olivari
eProcess