Author: mkestner
Date: 2008-01-17 09:06:59 -0500 (Thu, 17 Jan 2008)
New Revision: 93150

Added:
   trunk/gtk-sharp/sample/Assistant.cs
Modified:
   trunk/gtk-sharp/ChangeLog
   trunk/gtk-sharp/sample/Makefile.am
Log:

2008-01-17  Mike Kestner  <[EMAIL PROTECTED]>

        * sample/Assistant.cs: new Gtk.Assistant sample.
        * sample/Makefile.am: hook in new sample.


Modified: trunk/gtk-sharp/ChangeLog
===================================================================
--- trunk/gtk-sharp/ChangeLog   2008-01-17 13:04:41 UTC (rev 93149)
+++ trunk/gtk-sharp/ChangeLog   2008-01-17 14:06:59 UTC (rev 93150)
@@ -1,3 +1,8 @@
+2008-01-17  Mike Kestner  <[EMAIL PROTECTED]>
+
+       * sample/Assistant.cs: new Gtk.Assistant sample.
+       * sample/Makefile.am: hook in new sample.
+
 2008-01-11  Mike Kestner  <[EMAIL PROTECTED]>
 
        * bootstrap-2.12: update version to 2.11.90.

Added: trunk/gtk-sharp/sample/Assistant.cs
===================================================================
--- trunk/gtk-sharp/sample/Assistant.cs 2008-01-17 13:04:41 UTC (rev 93149)
+++ trunk/gtk-sharp/sample/Assistant.cs 2008-01-17 14:06:59 UTC (rev 93150)
@@ -0,0 +1,133 @@
+// Assistant.cs - Gtk.Assistant Sample App
+//
+// Author:  Mike Kestner <[EMAIL PROTECTED]>
+//
+// Copyright (c) 2008 Novell, Inc.
+//
+// Adapted to C# with modifications from a C tutorial sample at
+// 
http://www.linuxquestions.org/linux/articles/Technical/New_GTK_Widgets_GtkAssistant
+
+
+namespace GtkSharpSamples {
+
+       using System;
+       using Gtk;
+
+       public class SampleAssistant : Assistant {
+
+               public static int Main (string[] argv)
+               {
+                       Application.Init ();
+                       new SampleAssistant ().ShowAll ();
+                       Application.Run ();
+                       return 0;
+               }
+
+               ProgressBar progress_bar;
+   
+               public SampleAssistant () 
+               {
+                       SetSizeRequest (450, 300);
+                       Title = "Gtk.Assistant Sample";
+  
+                       Label lbl = new Label ("Click the forward button to 
continue.");
+                       AppendPage (lbl);
+                       SetPageTitle (lbl, "Introduction");
+                       SetPageType (lbl, AssistantPageType.Intro);
+                       SetPageComplete (lbl, true);
+
+                       HBox box = new HBox (false, 6);
+                       box.PackStart (new Label ("Enter some text: "), false, 
false, 6);
+                       Entry entry = new Entry ();
+                       entry.Changed += new EventHandler (EntryChanged);
+                       box.PackStart (entry, false, false, 6);
+                       AppendPage (box);
+                       SetPageTitle (box, "Getting Some Input");
+                       SetPageType (box, AssistantPageType.Content);
+
+                       CheckButton chk = new CheckButton ("I think Gtk# is 
awesome.");
+                       chk.Toggled += new EventHandler (ButtonToggled);
+                       AppendPage (chk);
+                       SetPageTitle (chk, "Provide Feedback");
+                       SetPageType (chk, AssistantPageType.Content);
+
+                       Alignment al = new Alignment (0.5f, 0.5f, 0.0f, 0.0f);
+                       box = new HBox (false, 6);
+                       progress_bar = new ProgressBar ();
+                       box.PackStart (progress_bar, true, true, 6);
+                       Button btn = new Button ("Make progress");
+                       btn.Clicked += new EventHandler (ButtonClicked);
+                       box.PackStart (btn, false, false, 6);
+                       al.Add (box);
+                       AppendPage (al);
+                       SetPageTitle (al, "Show Some Progress");
+                       SetPageType (al, AssistantPageType.Progress);
+
+                       lbl = new Label ("In addition to being able to 
type,\nYou obviously have great taste in software.");
+                       AppendPage (lbl);
+                       SetPageTitle (lbl, "Congratulations");
+                       SetPageType (lbl, AssistantPageType.Confirm);
+                       SetPageComplete (lbl, true);
+  
+                       Cancel += new EventHandler (AssistantCancel);
+                       Close += new EventHandler (AssistantClose);
+               }
+
+               protected override bool OnDeleteEvent (Gdk.Event ev)
+               {
+                       Console.WriteLine ("Assistant Destroyed prematurely");
+                       Application.Quit ();
+                       return true;
+               }
+
+               // If there is text in the GtkEntry, set the page as complete.
+               void EntryChanged (object o, EventArgs args)
+               {
+                       string text = (o as Gtk.Entry).Text;
+                       SetPageComplete (GetNthPage (CurrentPage), text.Length 
> 0);
+               }
+
+               // If check button is checked, set the page as complete.
+               void ButtonToggled (object o, EventArgs args)
+               {
+                       bool active = (o as ToggleButton).Active;
+                       SetPageComplete (o as Widget, active);
+               }
+
+               // Progress 10% per second after button clicked.
+               void ButtonClicked (object o, EventArgs args)
+               {
+                       (o as Widget).Sensitive = false;
+                       GLib.Timeout.Add (500, new GLib.TimeoutHandler 
(TimeoutCallback));
+               }
+
+               double fraction = 0.0;
+
+               bool TimeoutCallback ()
+               {
+                       fraction += 5.0;
+                       progress_bar.Fraction = fraction / 100.0;
+                       progress_bar.Text = String.Format ("{0}% Complete", 
fraction);
+                       if (fraction == 100.0) {
+                               SetPageComplete (progress_bar.Parent.Parent, 
true);
+                               return false;
+                       }
+                       return true;
+               }
+
+               void AssistantCancel (object o, EventArgs args)
+               {
+                       Console.WriteLine ("Assistant cancelled.");
+                       Destroy ();
+                       Application.Quit ();
+               }
+
+               void AssistantClose (object o, EventArgs args)
+               {
+                       Console.WriteLine ("Assistant ran to completion.");
+                       Destroy ();
+                       Application.Quit ();
+               }
+       }
+}
+

Modified: trunk/gtk-sharp/sample/Makefile.am
===================================================================
--- trunk/gtk-sharp/sample/Makefile.am  2008-01-17 13:04:41 UTC (rev 93149)
+++ trunk/gtk-sharp/sample/Makefile.am  2008-01-17 14:06:59 UTC (rev 93150)
@@ -16,7 +16,7 @@
 DOTNET_ASSEMBLY=
 endif
 
-TARGETS = polarfixed.exe custom-widget.exe custom-cellrenderer.exe 
gtk-hello-world.exe button.exe calendar.exe subclass.exe menu.exe size.exe 
scribble.exe scribble-xinput.exe treeviewdemo.exe managedtreeviewdemo.exe 
nodeviewdemo.exe treemodeldemo.exe testdnd.exe actions.exe spawn.exe 
$(GLADE_TARGETS) $(DOTNET_TARGETS)
+TARGETS = polarfixed.exe custom-widget.exe custom-cellrenderer.exe 
gtk-hello-world.exe button.exe calendar.exe subclass.exe menu.exe size.exe 
scribble.exe scribble-xinput.exe treeviewdemo.exe managedtreeviewdemo.exe 
nodeviewdemo.exe treemodeldemo.exe testdnd.exe actions.exe spawn.exe 
assistant.exe $(GLADE_TARGETS) $(DOTNET_TARGETS)
 
 DEBUGS = $(addsuffix .mdb, $(TARGETS))
 
@@ -94,8 +94,12 @@
 spawn.exe: $(srcdir)/SpawnTests.cs $(assemblies)
        $(CSC)  /out:spawn.exe $(references) $(srcdir)/SpawnTests.cs
 
+assistant.exe: $(srcdir)/Assistant.cs $(assemblies)
+       $(CSC)  /out:assistant.exe $(references) $(srcdir)/Assistant.cs
+
 EXTRA_DIST =                           \
        HelloWorld.cs                   \
+       Assistant.cs                    \
        ButtonApp.cs                    \
        CalendarApp.cs                  \
        Subclass.cs                     \

_______________________________________________
Mono-patches maillist  -  Mono-patches@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to