[Gtk-sharp-list] Embedding Gtk-Sharp Programs into C
Mikkel Kruse Johnsen
mikkel@linet.dk
Fri, 23 Jul 2004 18:26:55 +0200
--=-8Tkoe+QuVrSP0+M4UfxY
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
Hi Pyroman
I don't think that will work, but try. I would make the GtkFrame in C
like this and have C# add to it.
GtkFrame *frame;
frame =3D gtk_frame_new ();
args[0] =3D &frame;
mono_runtime_invoke (method, object, args, NULL);
and in C# do:
namespace TestApp
{
class Plugin : Gtk.Frame
{
public Plugin (IntPtr raw) : base(raw)=09
{
this.Add (new Gtk.Button("Hello World");
}
}
class Test
{
public void Init (IntPtr raw)
{
new Plugin (raw);
}
}
}
/Mikkel
On Fri, 2004-07-23 at 16:12, Pyroman[FO] wrote:
> So if I create in C#
>=20
> Gtk.Frame frame;
>=20
> Then in the Test.Init function do
>=20
> raw =3D frame
>=20
> Then resulting C program can then use widget as a valid GtkWidget pointer=
?
>=20
> Allen Cook
>=20
> Mikkel Kruse Johnsen wrote:
> > Hi Pyroman
> >=20
> > Yes, it is possible.
> >=20
> > 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.
> >=20
> > Just do this in the C program:
> >=20
> > domain =3D mono_jit_init (PACKAGE);
> > mono_config_parse ("/etc/mono/machine.config");
> > mono_config_parse ("/etc/mono/config");
> > mono_thread_attach (domain);
> >=20
> > and then:
> >=20
> > MonoDomain *domain;
> > MonoAssembly *assembly;=09
> > MonoClass *class;
> > MonoImage *image;
> > MonoMethod *method;
> > MonoObject *object;
> > MonoMethodDesc *desc;
> > gpointer args[1];
> > GtkWidget *widget;
> >=20
> > 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);
> >=20
> > C#
> >=20
> > namespace TestApp
> > {
> > class Test
> > {
> > public void Init (IntPtr raw)
> > {=09
> > }
> > }
> > }
> >=20
> >=20
> > This is just a rough paste, but should work somewhat.
> >=20
> > /Mikkel
> >=20
> > On Thu, 2004-07-22 at 19:29, Pyroman[FO] wrote:
> >=20
> >>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?
> >>
> >>Allen Cook
> >>_______________________________________________
> >>Gtk-sharp-list maillist - Gtk-sharp-list@lists.ximian.com
> >>http://lists.ximian.com/mailman/listinfo/gtk-sharp-lis
> >=20
> > t
> _______________________________________________
> Gtk-sharp-list maillist - Gtk-sharp-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
--=-8Tkoe+QuVrSP0+M4UfxY
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)
iD8DBQBBATxNs/DIef2Kq/IRAnsFAJ9ZlLwF2JL6v+IQ0fyi+oWDOI9ZqgCgk74Q
QfCQjQttmhNZj3S9vNcMSFI=
=AVgr
-----END PGP SIGNATURE-----
--=-8Tkoe+QuVrSP0+M4UfxY--