diff --git a/doc/ChangeLog b/doc/ChangeLog index fd269f755..927df66bc 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,5 +1,5 @@ 2003-06-15 John Luke - * en/Gtk/Dialog.xml: add more info + * en/Gtk/Dialog.xml: add more info, add example * en/Gtk/DialogFlags: add first draft 2003-06-13 John Luke diff --git a/doc/en/Gtk/Dialog.xml b/doc/en/Gtk/Dialog.xml index 1abcb833b..581aab4af 100644 --- a/doc/en/Gtk/Dialog.xml +++ b/doc/en/Gtk/Dialog.xml @@ -14,6 +14,63 @@ The two primary areas of a dialog can be accessed as the property and the property. To set the dialog to be modal, use the property. If you want to block waiting for a dialog to return before returning control flow to your code, you can call . This function enters a recursive main loop and waits for the user to respond to the dialog, returning the corresponding to the the user clicked. For a simple dialog, you would probably use to save yourself some effort. However, you would need to create the contents manually if you had more than a simple message in the . + + +using System; +using Gtk; +using GtkSharp; + +namespace GtkDialogSample +{ + public class GtkDialogSample + { + Dialog dialog; + Window win; + + static void Main() + { + new GtkDialogSample (); + } + + GtkDialogSample () + { + Application.Init (); + win = new Window ("Test"); + win.SetDefaultSize (250, 250); + win.DeleteEvent += new DeleteEventHandler (on_win_delete); + + Button btn = new Button ("Show About"); + btn.Clicked += new EventHandler (on_btn_clicked); + win.Add (btn); + + win.ShowAll (); + Application.Run (); + } + + void on_btn_clicked (object obj, EventArgs args) + { + dialog = new Dialog + ("Sample", win, Gtk.DialogFlags.DestroyWithParent); + dialog.Modal = true; + dialog.AddButton ("Close", 5); + dialog.Response += new ResponseHandler (on_dialog_response); + dialog.Run (); + dialog.Destroy (); + } + + void on_dialog_response (object obj, ResponseArgs args) + { + Console.WriteLine (args.ResponseId); + } + + void on_win_delete (object obj, DeleteEventArgs args) + { + Application.Quit (); + } + } +} + +