[Gtk-sharp-list] Glade# and resources.

Miguel de Icaza miguel@ximian.com
12 Sep 2002 14:01:09 -0400

Hey guys,

    In the .NET universe you can "embed" into your executable resources
files, like for instance the .glade files, could we add a constructor
that would allow a developer to load the glade file from its resource?

    The resource is embedded like this:

	mcs test.cs -resource:file.glade

    Then we can retrieve the XML like this:


using System;
using System.Reflection;
using System.IO;

class X {

        static void Main ()
                Assembly a = AppDomain.CurrentDomain.GetAssemblies ()[0];

                Console.WriteLine ("Assembly: " + a.ToString ());
                Stream s = a.GetManifestResourceStream ("file.glade");
                if (s != null){
                        StreamReader sr = new StreamReader (s);

                        Console.WriteLine (sr.ReadToEnd ());

We could then use the glade_xml_new_from_buffer.   

With this we can ship a standalone .exe file, and not worry about the
installation prefix or how to locate our data files: everything can be
embedded into the executable.

best wishes,