e6ea0015b5
[ Patch from Ricardo Fernandez Pascual <rfp1@ono.com> for libglade support (slightly modified) ] * configure.in: Conditionally compile glade support. * makefile: Add glade directory. * glade/: Added. * sample/makefile.in: Add (conditional) glade example. * sample/GladeViewer.cs: Added. * glue/gladexml.c: Added. * glue/Makefile.am: Updated. * parser/build.pl: Parse libglade-2.0.0. * parser/README: Update requirements. 2002-08-12 Rachel Hestilow <hestilow@ximian.com> * parser/gapi_pp.pl: Handle "typedef struct {...}" construct. * glue/canvaspoints.c: Added. * glue/Makefile.am: Updated. * gnome/CanvasPoints.custom: Added. (Doesn't seem to work right yet, looking into this.) svn path=/trunk/gtk-sharp/; revision=6601
61 lines
1.7 KiB
C#
61 lines
1.7 KiB
C#
// GladeViewer.cs - Silly tests for LibGlade in C#
|
||
//
|
||
// Author: Ricardo Fern<72>ndez Pascual <ric@users.sourceforge.net>
|
||
//
|
||
// (c) 2002 Ricardo Fern<72>ndez Pascual
|
||
|
||
namespace GladeSamples {
|
||
using System;
|
||
using System.Runtime.InteropServices;
|
||
|
||
using Gtk;
|
||
using Gnome;
|
||
using Glade;
|
||
|
||
public class GladeDemo {
|
||
|
||
// temporary hack until GList is wrapped
|
||
[DllImport("glib-2.0")]
|
||
static extern IntPtr g_list_nth_data (IntPtr l, int i);
|
||
[DllImport("glib-2.0")]
|
||
static extern int g_list_length (IntPtr l);
|
||
|
||
public static void Main (string[] args)
|
||
{
|
||
if (args.Length < 2) {
|
||
Console.WriteLine ("Use: mono ./glade-viewer.exe \"fname\" \"root\"");
|
||
return;
|
||
}
|
||
|
||
Program viewer = new Program ("GladeViewer", "0.1", Modules.UI, args);
|
||
|
||
string fname = args [0];
|
||
string root = args [1];
|
||
|
||
Glade.XML gxml = new Glade.XML (fname, root, null);
|
||
Widget wid = gxml [root];
|
||
wid.Show ();
|
||
|
||
Console.WriteLine ("The filename: {0}", gxml.Filename);
|
||
Console.WriteLine ("A relative filename: {0}", gxml.RelativeFile ("image.png"));
|
||
|
||
Console.WriteLine ("The name of the root widget: {0}", Glade.XML.GetWidgetName (wid));
|
||
Console.WriteLine ("BTW, it's {0} that it was created using from a Glade.XML object",
|
||
Glade.XML.GetWidgetTree (wid) != null);
|
||
|
||
Console.WriteLine ("\nList of created widgets:");
|
||
// this is a hack, until GList is wrapped
|
||
IntPtr l = gxml.GetWidgetPrefix ("");
|
||
int len = g_list_length (l);
|
||
for (int i = 0; i < len; ++i) {
|
||
Widget w = GLib.Object.GetObject (g_list_nth_data (l, i)) as Widget;
|
||
Console.WriteLine ("{0} {1}",
|
||
w.GetType (),
|
||
Glade.XML.GetWidgetName (w));
|
||
}
|
||
|
||
viewer.Run ();
|
||
}
|
||
|
||
}
|
||
}
|