Hello Toddler, thanks for your answer
The code snippets i have posted are not very clear, sry for this. In
fact 'window' and 'nativeWindowHandle' are the same handles.
But maybe i have bigger problems than i thought. I compiled xulrunner in
Debug mode (shame on me that i havent done this before) and get the
following error when calling XRE_InitEmbedding():
* Call to xpconnect wrapped JSObject produced this error: *
[Exception... "Component returned failure code: 0x80570016
(NS_ERROR_XPC_GS_RETURNED_FAILURE) [nsIJSCID.getService]"
Now im not sure wether Gecko is properly initialized at all, maybe this
is the problem with the segfault when trying to create a msBaseWindow.
What i did so far:
I compiled xulrunner from source and execute my small sample application
inside the mozilla/obj-xulrunner/dist/bin directory (without make
install - ubuntu has some bugs in the xulrunner packages and i dont want
to mess up my firefox installation). For the xul directory and the app
directory i use the same absolute paths as the execution directory:
std::string appRuntimeDir("/home/schmelly/mozilla/obj-xulrunner/dist/bin");
std::string xulRuntimeDir("/home/schmelly/mozilla/obj-xulrunner/dist/bin");
nsCOMPtr< nsILocalFile > xulDir;
nsCOMPtr< nsILocalFile > appDir;
NS_NewNativeLocalFile(nsCString(xulRuntimeDir.c_str() ), PR_FALSE,
getter_AddRefs(xulDir ) );
S_NewNativeLocalFile(nsCString(appRuntimeDir.c_str() ), PR_FALSE,
getter_AddRefs(appDir ) );
XRE_InitEmbedding()(xulDir, appDir, nsnull, nsnull, 0);
Is this supposed to work at all? Am i missing additional dependencies or
configuration?
thanks in advance and best regards,
David
-------------------------------------------------------------------
for completeness the whole source code of my small sample app:
#include <gtk/gtk.h>
#include <nsXULAppAPI.h>
#include <nsISupports.h>
#include <nsILocalFile.h>
#include <nsIPref.h>
#include <nsString.h>
#include <iostream>
static void on_destroy(GtkWidget * widget, gpointer data) {
gtk_main_quit ();
}
int main(int argc, char *argv[]) {
GtkWidget *window;
GtkWidget *label;
gtk_init (&argc, &argv);
/* create the main, top level, window */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
/* give the window a 20px wide border */
gtk_container_set_border_width (GTK_CONTAINER (window), 20);
/* give it the title */
gtk_window_set_title (GTK_WINDOW (window), "Test");
/* open it a bit wider so that both the label and title show up */
gtk_window_set_default_size (GTK_WINDOW (window), 200, 50);
/* Connect the destroy event of the window with our on_destroy function
* When the window is about to be destroyed we get a notificaiton and
* stop the main GTK loop
*/
g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (on_destroy),
NULL);
/* Create the "Hello, World" label */
label = gtk_label_new ("Hello, World");
/* and insert it into the main window */
gtk_container_add (GTK_CONTAINER (window), label);
std::string
appRuntimeDir("/home/schmelly/Dateien/Projekte/Cpp/mozilla/obj-xulrunner/dist/bin");
std::string
xulRuntimeDir("/home/schmelly/Dateien/Projekte/Cpp/mozilla/obj-xulrunner/dist/bin");
nsCOMPtr< nsILocalFile > xulDir;
nsresult result = NS_NewNativeLocalFile(nsCString(xulRuntimeDir.c_str()
),
PR_FALSE, getter_AddRefs(xulDir ) );
if (NS_FAILED(result ) ) {
return -1;
};
nsCOMPtr< nsILocalFile > appDir;
result = NS_NewNativeLocalFile(nsCString(appRuntimeDir.c_str() ),
PR_FALSE,
getter_AddRefs(appDir ) );
if (NS_FAILED(result ) ) {
return -1;
};
result = XRE_InitEmbedding()(xulDir, appDir, nsnull, nsnull, 0);
if (NS_FAILED(result ) ) {
return -1;
};
XRE_TermEmbedding();
/* make sure that everything, window and label, are visible */
gtk_widget_show_all (window);
/* start the main loop */
gtk_main ();
return 0;
}
-------------------------------------------------------------------
Moz Toddler schrieb:
> :
> :
>> gtk_init (&argc, &argv);
>> GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
> :
> :
>> baseWindow = do_QueryInterface(webBrowser);
>> baseWindow->InitWindow(nativeWindowHandle, nsnull, 0, 0, 50, 50);
>
> I think you should pass GtkWidget* 'window' as first argument to
> 'InitWindow'
>
>
>
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding