2002-09-13 11:38:36 +00:00
|
|
|
|
// GladeViewer.cs - 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 Gtk;
|
|
|
|
|
using Glade;
|
|
|
|
|
|
2003-09-07 10:56:40 +00:00
|
|
|
|
public class GladeTest
|
2002-09-13 11:38:36 +00:00
|
|
|
|
{
|
2003-09-07 10:56:40 +00:00
|
|
|
|
[Glade.Widget]
|
2003-01-01 21:37:45 +00:00
|
|
|
|
Gtk.Window main_window;
|
|
|
|
|
|
2002-09-13 11:38:36 +00:00
|
|
|
|
public static void Main (string[] args)
|
|
|
|
|
{
|
2003-09-07 10:56:40 +00:00
|
|
|
|
Application.Init ();
|
|
|
|
|
|
2004-12-21 18:46:42 +00:00
|
|
|
|
new GladeTest ();
|
2003-09-07 10:56:40 +00:00
|
|
|
|
|
|
|
|
|
Application.Run ();
|
2002-09-13 11:38:36 +00:00
|
|
|
|
}
|
2003-09-07 10:56:40 +00:00
|
|
|
|
|
|
|
|
|
public GladeTest ()
|
2002-09-13 11:38:36 +00:00
|
|
|
|
{
|
2002-09-15 19:40:46 +00:00
|
|
|
|
/* Note that we load the XML info from the assembly instead of using
|
|
|
|
|
an external file. You don't have to distribute the .glade file if
|
|
|
|
|
you don't want */
|
|
|
|
|
Glade.XML gxml = new Glade.XML (null, "test.glade", "main_window", null);
|
2002-09-13 11:38:36 +00:00
|
|
|
|
gxml.Autoconnect (this);
|
2003-09-07 10:56:40 +00:00
|
|
|
|
|
2003-01-01 21:37:45 +00:00
|
|
|
|
if (main_window != null)
|
|
|
|
|
Console.WriteLine ("Main Window Title: \"{0}\"", main_window.Title);
|
|
|
|
|
else
|
2003-03-15 21:02:25 +00:00
|
|
|
|
Console.WriteLine ("WidgetAttribute is broken.");
|
2003-01-01 21:37:45 +00:00
|
|
|
|
}
|
2002-09-13 11:38:36 +00:00
|
|
|
|
|
|
|
|
|
public void OnWindowDeleteEvent (object o, DeleteEventArgs args)
|
|
|
|
|
{
|
2003-09-07 10:56:40 +00:00
|
|
|
|
Application.Quit ();
|
2002-09-13 11:38:36 +00:00
|
|
|
|
args.RetVal = true;
|
|
|
|
|
}
|
|
|
|
|
|
2002-09-24 03:52:04 +00:00
|
|
|
|
public void OnButton1Clicked (System.Object b, EventArgs e)
|
2002-09-13 11:38:36 +00:00
|
|
|
|
{
|
|
|
|
|
Console.WriteLine ("Button 1 clicked");
|
|
|
|
|
}
|
|
|
|
|
|
2002-09-24 03:52:04 +00:00
|
|
|
|
public static void OnButton2Clicked (System.Object b, EventArgs e)
|
2002-09-13 11:38:36 +00:00
|
|
|
|
{
|
|
|
|
|
Console.WriteLine ("Button 2 clicked");
|
|
|
|
|
}
|
|
|
|
|
|
2002-09-24 03:52:04 +00:00
|
|
|
|
public void OnButton2Entered (System.Object b, EventArgs e)
|
2002-09-13 11:38:36 +00:00
|
|
|
|
{
|
|
|
|
|
Console.WriteLine ("Button 2 entered");
|
|
|
|
|
}
|
2005-06-22 21:44:34 +00:00
|
|
|
|
|
|
|
|
|
public void OnQuitActivated (object o, EventArgs args)
|
|
|
|
|
{
|
|
|
|
|
Application.Quit ();
|
|
|
|
|
}
|
2002-09-13 11:38:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|