[Gtk-sharp-list] Null args handling

Duncan Mak duncan@ximian.com
12 Jul 2002 00:39:52 +0800


--=-nSX1zfyNoiorS6CBWtME
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Heya,

I know Rachel was gonna start working on the NULL args handling stuff,
it's badly needed for writing code involving Radio Buttons.

The snippet of code doesn't work right now and reports the following
error:

** (<unknown>:4837): WARNING **: Failed to load library libgtksharp.so
(gtksharp)

** (<unknown>:4837): WARNING **: Failed to load library libgtksharp.so
(gtksharp)

** (<unknown>:4837): WARNING **: unhandled exception
System.NullReferenceException: "Object reference not set to an instance
of an object"
in <0x0005a> (runtime) WidgetViewer.Viewer:Main (object,intptr,intptr)


-- 
Duncan Mak <duncan@ximian.com>

--=-nSX1zfyNoiorS6CBWtME
Content-Disposition: attachment; filename=radio.cs
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; name=radio.cs; charset=ISO-8859-1

using System;

using Gtk;
using GtkSharp;

namespace WidgetViewer {
	public class TestRadioButton
	{
		static Window window =3D null;
		static RadioButton radio_button =3D null;
	=09
		public static Gtk.Window Create ()
		{
			window =3D new Window ("GtkRadioButton");
			window.DeleteEvent +=3D new EventHandler (Window_Delete);
			window.SetDefaultSize (200, 100);

			VBox box1 =3D new VBox (false, 0);
			window.Add (box1);

			VBox box2 =3D new VBox (false, 10);
			box2.BorderWidth =3D 10;
			box1.PackStart (box2, true, true, 0);

			radio_button =3D new RadioButton (new GLib.SList (IntPtr.Zero), "Button =
1");
			box2.PackStart (radio_button, true, true, 0);

			radio_button =3D new RadioButton (radio_button.Group, "Button 2");
			radio_button.Active =3D true;
			box2.PackStart (radio_button, true, true, 0);

			box1.PackStart (new HSeparator (), false, true, 0);

			box2 =3D new VBox (false, 10);
			box2.BorderWidth =3D 10;
			box1.PackStart (box2, false, true, 0);

			Button button =3D new Button ("_Close");
			button.Clicked +=3D new EventHandler (Close_Button);
			box2.PackStart (button, true, true, 0);
			button.CanDefault =3D true;
			button.GrabDefault ();

			return window;
		}

		static void Window_Delete (object o, EventArgs args)
		{
			SignalArgs sa =3D (SignalArgs) args;
			window.Destroy ();
			sa.RetVal =3D true;
		}

		static void Close_Button (object o, EventArgs args)
		{
			Window_Delete (o, args);
		}	=09
	}
}

--=-nSX1zfyNoiorS6CBWtME--