mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-05 15:59:45 +00:00
Fixes to sort of get OpenDialog to work from C++
This commit is contained in:
parent
2fabcf8441
commit
47da48bf59
@ -18,7 +18,8 @@
|
||||
|
||||
#include "nsIAppShellComponent.idl"
|
||||
|
||||
interface nsIObserver;
|
||||
//interface nsIObserver;
|
||||
#include "nsIObserver.idl"
|
||||
|
||||
/*------------------------ nsISampleAppShellComponent --------------------------
|
||||
| This file describes the interface for a sample "application shell |
|
||||
|
@ -0,0 +1,63 @@
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
var title = "Sample Application Shell Component Test";
|
||||
var progid = "component://netscape/appshell/component/sample";
|
||||
var iid = Components.interfaces.nsISampleAppShellComponent;
|
||||
var observer = {
|
||||
Observe: function( observer, subject, topic, data ) {
|
||||
dump( "observe called; subject=[" + subject + "] topic=[" + topic +
|
||||
"] data=[" + data + "]\n" );
|
||||
}
|
||||
}
|
||||
function RunTest() {
|
||||
var sampleComponent = Components.classes[progid].getService();
|
||||
if ( sampleComponent ) {
|
||||
dump("sampleComponent is " + sampleComponent + "\n" );
|
||||
sampleComponent = sampleComponent.QueryInterface( iid );
|
||||
if ( sampleComponent ) {
|
||||
dump("sampleComponent is " + sampleComponent + "\n" );
|
||||
sampleComponent.DoDialogTests( window, observer );
|
||||
} else {
|
||||
alert( "QueryInterface failed for " + progid + "\n" );
|
||||
}
|
||||
} else {
|
||||
alert( "getService failed for " + progid + "\n" );
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<title>
|
||||
<script>document.write(title);</script>
|
||||
</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1><center>
|
||||
<script>document.write(title);</script>
|
||||
</center></h1>
|
||||
<p/>
|
||||
This page provides a test of a sample "app shell component."
|
||||
<p/>
|
||||
Clicking on the button below will:
|
||||
<ol>
|
||||
<p/><li>Execute a JavaScript function that will use XPConnect to dynamically
|
||||
access that sample component (as a "service" in the nsIServiceManager sense).
|
||||
Specifically, it will invoke the "DoDialogTests()" member on that service.</li>
|
||||
<p/><li>That will trigger display of a sequence of dialogs. The first will open
|
||||
a dialog from C++. You enter some text on that dialog and press a button.</li>
|
||||
<p/><li>That triggers display of a similar dialog from JavaScript. You enter
|
||||
some text there and press another button.</li>
|
||||
<p/><li>Finally, you return here and the results are displayed, demonstrating
|
||||
that input was passed along to each dialog in turn and that the results
|
||||
were passed back!</li>
|
||||
</ol>
|
||||
<p/>
|
||||
This sample also demonstrates how to implement an interface in JavaScript and
|
||||
how to use that interface to communicate with other code using the
|
||||
nsIObserverService (that's how the results show up back here).
|
||||
<center>
|
||||
<button onclick="RunTest()">Click here to test</button>
|
||||
</center>
|
||||
<hr/>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -118,15 +118,16 @@ nsSampleAppShellComponent::DoDialogTests( nsISupports *parent, nsIObserver *obse
|
||||
// Get a jsval corresponding to the wrapped object.
|
||||
jsval arg = OBJECT_TO_JSVAL( obj );
|
||||
void *stackPtr;
|
||||
jsval *argv = JS_PushArguments( jsContext, &stackPtr, "ssso",
|
||||
jsval *argv = JS_PushArguments( jsContext, &stackPtr, "sssv",
|
||||
"resource:/res/samples/nsSampleAppShellComponent.xul",
|
||||
"",
|
||||
"foobar",
|
||||
"chrome",
|
||||
arg );
|
||||
if ( argv ) {
|
||||
nsIDOMWindow *newWindow;
|
||||
rv = parentWindow->OpenDialog( jsContext, argv, 4, &newWindow );
|
||||
if ( NS_SUCCEEDED( rv ) ) {
|
||||
newWindow->Release();
|
||||
} else {
|
||||
}
|
||||
JS_PopArguments( jsContext, stackPtr );
|
||||
|
Loading…
Reference in New Issue
Block a user