[Gtk-sharp-list] Accessing data from one window by another

Brad Taylor brad@getcoded.net
Mon, 15 Nov 2004 21:24:56 -0800


--=-ncFFSmht1Z8N3vUhc8+u
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

On Mon, 2004-11-15 at 23:52 -0500, Ryan wrote:
> I don't know if the subject is quite but here goes
>=20
> If I have Window1 open then the user wants to do something in WizardWindo=
w.
> When the user finishes enter the data and clicks ok how can I get the=20
> TreeView widget
> in Window1 to refresh (either appending or deleting the item)

The way I would do it would be to make WizardWindow its own class.  Move
all the code that deals with it into that class and set up an event in
WizardWindow that will be raised when the user completes the assistant.
For example:

public class Window1
{
	[...]
	public void ShowWizard()
	{
		WizardWindow w =3D new WizardWindow();

		w.Finished +=3D new FinishedHandler(WizardFinishedCb);
		w.Show();
	}
=09
	private void WizardFinisihedCb(object o, EventArgs args)
	{
		// update tree view
	}
}

public delegate void FinishedHandler(object o, EventArgs args);

public class WizardWindow
{
	public event FinishedHandler Finished;

	public WizardWindow()
	{
		// Set up the window
	=09
		Button FinishButton =3D new Button("Finish");
		FinishButton.Clicked +=3D new
		     ButtonClickedEventHandler(FinishButtonClickedCb);
	}

	public void Show()
	{
		// Show the window
	}

	public void FinishButtonClickedCb(object o, EventArgs args)
	{
		// destroy the window
		window.Destroy();

		// raise the event
		if(Finished !=3D null)
			Finished(this, new EventArgs());
	}
}


Let me know if you need any clarification on this code.

-Brad

--=20
Brad Taylor
Genome Software LLC
http://www.getcoded.net

--=-ncFFSmht1Z8N3vUhc8+u
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQBBmY8nWZT8MXyJ2AURAt04AJ9Pkq0u+Bui86yeu+/8HsTJMv3UGwCfeR92
La9uytsNlxc7w38I3nsSRKE=
=b6Sf
-----END PGP SIGNATURE-----

--=-ncFFSmht1Z8N3vUhc8+u--