[Gtk-sharp-list] Embedding Gtk-Sharp Programs into C
Mikkel Kruse Johnsen
mikkel@linet.dk
Thu, 22 Jul 2004 22:47:15 +0200
--=-FHnq21IbCSc5gnQSFiR9
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
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 =3D 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;=09
MonoClass *class;
MonoImage *image;
MonoMethod *method;
MonoObject *object;
MonoMethodDesc *desc;
gpointer args[1];
GtkWidget *widget;
domain =3D mono_domain_get ();
assembly =3D mono_domain_assembly_open (domain, "test.dll");
image =3D mono_assembly_get_image (assembly);
class =3D mono_class_from_name (image, "TestApp", "Test");
desc =3D mono_method_desc_new ("TestApp.Test:Init", TRUE);
method =3D mono_method_desc_search_in_class (desc, class);
mono_method_desc_free (desc);
object =3D mono_object_new (domain, class);
mono_runtime_object_init (object);
args[0] =3D &widget;
mono_runtime_invoke (method, object, args, NULL);
C#
namespace TestApp
{
class Test
{
public void Init (IntPtr raw)
{=09
}
}
}
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=20
> C program. I know you can do this with Mono, however what I'm worried=20
> about is the ability to return Gtk Widgets, Containers, ect. to the=20
> parent C program and use them with GTK or GTKmm code. Our program has a=20
> plugin structure, and we call the plugin to return the main GTK frame=20
> for the plugin, which we then display in the parent program. I am=20
> looking for a way to embed the Mono runtime and use mono plugins for=20
> this. Is it possible?
>=20
> Allen Cook
> _______________________________________________
> Gtk-sharp-list maillist - Gtk-sharp-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
--=-FHnq21IbCSc5gnQSFiR9
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQBBACfRs/DIef2Kq/IRAkMrAJ4i6MyyZaP5loa8kJb3wE4CmBljsgCfdgm5
GFeAKaqOTRqLvtDbJGcnlE8=
=hqdf
-----END PGP SIGNATURE-----
--=-FHnq21IbCSc5gnQSFiR9--