[Gtk-sharp-list] Wizard

Slug toddglodek at hotmail.com
Sun May 3 23:34:45 EDT 2009



Brad Taylor wrote:
> 
> 
> Check out Gtk.Assistant instead -- it's the new, Gtk approved wizard
> API.  Gnome Druid has been a depreciated API for a while now.
> 
> 

Great suggestion...  I pasted in this 
http://www.mail-archive.com/mono-patches@lists.ximian.com/msg46474.html code
sample for the Gtk.Assistant  which worked great and looked awesome.  



So I tried to write my own sample.  However mine fails with the comment in
the Application Output window:

   Gtk-CRITICAL **: gtk_assistant_set_page_complete: assertion
`GTK_IS_ASSISTANT (assistant)' failed

It happens when I try to use an event handler to call the SetPageComplete()
method.   I cant find anything like that on Google anywhere.  What exactly
is that, and what am I missing?



namespace GtkSharpSamples {

   using System;
   using Gtk;

    public static class MainClass {
		
    	public static int Main (string[] argv) {
	       Application.Init ();
	       new MainWindow().Show();
	       Application.Run ();
	       return 0;
	}
		
    }
	
	//  This is the basic MainWindow you get when creating a GTK Project
	public partial class MainWindow: Gtk.Window 	{	
		
		public MainWindow (): base (Gtk.WindowType.Toplevel)
		{
			Build ();
			new MyLittleAssistantTest().ShowAll();    //  I added this command to
load the Assistant
			
		}
		
		protected void OnDeleteEvent (object sender, DeleteEventArgs a)
		{
			Application.Quit ();
			a.RetVal = true;
		}
	}
	


	public class MyLittleAssistantTest : Gtk.Assistant	{				
		
		public MyLittleAssistantTest()		{
			SetSizeRequest( 200, 200 );
			Title = "My Little Assistant Test";
			Modal = true;


			{  // Set up the intro page....
				Label lbl = new Label(" Welcome Everyone. " );
				AppendPage( lbl );
				SetPageType ( lbl , AssistantPageType.Intro );
				SetPageComplete( lbl, true );
			}


			{  //  Set up the second page.
				Gtk.Button tBtn = new Gtk.Button( "Click Me" );
				tBtn.Clicked += new EventHandler(ButtonClicked);		
				
				HBox tbox = new HBox (false, 6);
				tbox.PackStart ( tBtn, false, false, 6);
								
				Gtk.Alignment tAlign = new Gtk.Alignment (0.5f, 0.5f, 0.0f, 0.0f);
				tAlign.Name = "RememberMe";
				tAlign.Add( tbox );
				
				AppendPage( tAlign );
				SetPageType( tAlign , AssistantPageType.Content );
			}

			{  //  Set up the second page.
				Gtk.Button tBtn = new Gtk.Button();
				tBtn.Label = "We're All Done ";
				
				AppendPage( tBtn );
				SetPageType( tBtn , AssistantPageType.Summary );
				SetPageComplete( tBtn, true );
			}

			Close += HandleClose;
			Cancel += HandleClose;
			
		}

		void ButtonClicked (object sender, EventArgs args) {
			Alignment tAlign = ( (sender as Widget).Parent.Parent as Alignment );
			if ( tAlign.Name == "RememberMe" ) {
				SetPageComplete( tAlign as Widget , true );     // IT FAILS HERE  
			}
	     }
		
		void HandleClose(object sender, EventArgs e) {
			Destroy();			
		}

		protected override bool OnDeleteEvent (Gdk.Event evnt) {
			bool rtnVal = base.OnDeleteEvent (evnt);
			Destroy();
			return rtnVal;		
		}
	}
}


-- 
View this message in context: http://www.nabble.com/Wizard-tp22957928p23362570.html
Sent from the Mono - Gtk# mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20090503/e6db1451/attachment.html 


More information about the Gtk-sharp-list mailing list