1 // GladeViewer.cs - Tests for LibGlade in C#
2 //
3 // Author: Ricardo Fern�ndez Pascual <ric@users.sourceforge.net>
4 //
5 // (c) 2002 Ricardo Fern�ndez Pascual
6 
7 namespace GladeSamples {
8 	using System;
9 
10 	using Gtk;
11 	using Glade;
12 
13 	public class GladeTest
14 	{
15 		[Glade.Widget]
16 		Gtk.Window main_window;
17 
Main(string[] args)18 		public static void Main (string[] args)
19 		{
20 			Application.Init ();
21 
22 			new GladeTest ();
23 
24 			Application.Run ();
25 		}
26 
GladeTest()27 		public GladeTest ()
28 		{
29 			/* Note that we load the XML info from the assembly instead of using
30 			   an external file. You don't have to distribute the .glade file if
31 			   you don't want */
32 			Glade.XML gxml = new Glade.XML (null, "test.glade", "main_window", null);
33 			gxml.Autoconnect (this);
34 
35 			if (main_window != null)
36 				Console.WriteLine ("Main Window Title: \"{0}\"", main_window.Title);
37 			else
38 				Console.WriteLine ("WidgetAttribute is broken.");
39 		}
40 
OnWindowDeleteEvent(object o, DeleteEventArgs args)41 		public void OnWindowDeleteEvent (object o, DeleteEventArgs args)
42 		{
43 			Application.Quit ();
44 			args.RetVal = true;
45 		}
46 
OnButton1Clicked(System.Object b, EventArgs e)47 		public void OnButton1Clicked (System.Object b, EventArgs e)
48 		{
49 			Console.WriteLine ("Button 1 clicked");
50 		}
51 
OnButton2Clicked(System.Object b, EventArgs e)52 		public static void OnButton2Clicked (System.Object b, EventArgs e)
53 		{
54 			Console.WriteLine ("Button 2 clicked");
55 		}
56 
OnButton2Entered(System.Object b, EventArgs e)57 		public void OnButton2Entered (System.Object b, EventArgs e)
58 		{
59 			Console.WriteLine ("Button 2 entered");
60 		}
61 
OnQuitActivated(object o, EventArgs args)62 		public void OnQuitActivated (object o, EventArgs args)
63 		{
64 			Application.Quit ();
65 		}
66 	}
67 }
68 
69