[Gtk-sharp-list] Embedding Gtk-Sharp Programs into C
Pyroman[FO]
pyroman@ninjapanda.org
Fri, 23 Jul 2004 10:12:01 -0400
So if I create in C#
Gtk.Frame frame;
Then in the Test.Init function do
raw = frame
Then resulting C program can then use widget as a valid GtkWidget pointer?
Allen Cook
Mikkel Kruse Johnsen wrote:
> Hi Pyroman
>
> Yes, it is possible.
>
> I'm myself embedding bonobo componets written in gtk-sharp (C#) into my
> C program. It is where possible to return Gtk.Widget, I don't do that
> myself, but im passing a Gtk.Container to the C# code and the adding
> stuff to that.
>
> Just do this in the C program:
>
> domain = mono_jit_init (PACKAGE);
> mono_config_parse ("/etc/mono/machine.config");
> mono_config_parse ("/etc/mono/config");
> mono_thread_attach (domain);
>
> and then:
>
> MonoDomain *domain;
> MonoAssembly *assembly;
> MonoClass *class;
> MonoImage *image;
> MonoMethod *method;
> MonoObject *object;
> MonoMethodDesc *desc;
> gpointer args[1];
> GtkWidget *widget;
>
> domain = mono_domain_get ();
> assembly = mono_domain_assembly_open (domain, "test.dll");
> image = mono_assembly_get_image (assembly);
> class = mono_class_from_name (image, "TestApp", "Test");
> desc = mono_method_desc_new ("TestApp.Test:Init", TRUE);
> method = mono_method_desc_search_in_class (desc, class);
> mono_method_desc_free (desc);
> object = mono_object_new (domain, class);
> mono_runtime_object_init (object);
> args[0] = &widget;
> mono_runtime_invoke (method, object, args, NULL);
>
> C#
>
> namespace TestApp
> {
> class Test
> {
> public void Init (IntPtr raw)
> {
> }
> }
> }
>
>
> This is just a rough paste, but should work somewhat.
>
> /Mikkel
>
> On Thu, 2004-07-22 at 19:29, Pyroman[FO] wrote:
>
>>I was wondering if there was a way to embed a Gtk-Sharp application in a
>>C program. I know you can do this with Mono, however what I'm worried
>>about is the ability to return Gtk Widgets, Containers, ect. to the
>>parent C program and use them with GTK or GTKmm code. Our program has a
>>plugin structure, and we call the plugin to return the main GTK frame
>>for the plugin, which we then display in the parent program. I am
>>looking for a way to embed the Mono runtime and use mono plugins for
>>this. Is it possible?
>>
>>Allen Cook
>>_______________________________________________
>>Gtk-sharp-list maillist - Gtk-sharp-list@lists.ximian.com
>>http://lists.ximian.com/mailman/listinfo/gtk-sharp-lis
>
> t