gtk-sharp 2.6.0.0 Gtk# is thread aware, but not thread safe; See the Gtk# Thread Programming for details. Creates popup windows. boxes are a convenient way to prompt the user for a small amount of input, eg. to display a message, ask a question, or anything else that does not require extensive effort by the user. Gtk# treats a dialog as a window split vertically. The top section is a , and is where widgets such as a or an should be packed. The bottom area is known as the . This is generally used for packing buttons into the dialog which may perform functions such as cancel, ok, or apply. The two areas are separated by a . 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; 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", ResponseType.Close); 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 (); } } } You also can subclass the when you want to use the same Dialog on several places in your application. using System; using Gtk; namespace GtkDialogSample { public class MyDialog:Dialog { public MyDialog(Window w,DialogFlags f ):base("Sample", w, f) { this.Modal = true; this.AddButton ("Close", ResponseType.Close); } protected override void OnResponse (ResponseType response_id){ Console.WriteLine (response_id); } } public class GtkDialogSample { MyDialog 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 MyDialog(win, Gtk.DialogFlags.DestroyWithParent); dialog.Run (); dialog.Destroy (); } void on_win_delete (object obj, DeleteEventArgs args) { Application.Quit (); } } } Gtk.Window Method System.Void Adds an activatable widget to the of a . an object of type . an object of type . Adds an activatable to the of a , connecting a signal handler that will on the when the is activated. The is appended to the end of the . If you want to add a non-activatable , simply pack it into the field of the . Method System.Int32 Waits for the event or the to be detroyed. an object of type . Waits for the event or the to be destroyed. If the is destroyed during the call to , returns . Otherwise, it returns the response ID from the event. Before entering the recursive main loop, calls on the for you. Note that you still need to show any children of the yourself. During , the default behavior of is disabled; if the receives , it will not be destroyed as usual, and will return . Also, during the will be modal. You can force to return at any time by calling to emit the event. Destroying the during is a very bad idea, because your post-run code will not know whether the was destroyed or not. After returns, you are responsible for hiding or destroying the if you wish to do so. Method System.Void Emits the event with the given response ID. an object of type . Emits the event with the given response ID. Used to indicate that the user has responded to the in some way; typically either you or will be monitoring the event and take appropriate action. Method Gtk.Widget Adds a with the given text. an object of type . an object of type . an object of type Adds a with the given text (or a stock button, if button_text is a stock ID) and sets things up so that clicking the will emit a with the given response_id. The is appended to the end of the . The is returned, but usually you do not need it. Constructor Internal constructor Pointer to the C object. This is an internal constructor, and should not be used by user code. Constructor Creates a new dialog box. Creates a new dialog box. This is an internal constructor, and should not be used by user code. Constructor System.ParamArray Creates a new dialog box. a title a parent , or for an unparented dialog. dialog characteristic such as modality and destruction policy. a list of button text/response pairs if desired. Creates a new with the specified title and parent widget. The argument can be used to make the dialog modal () and/or to have it destroyed along with its parent (). Property Gtk.VBox The that contains other widgets in this dialog. an object of type . Property System.Boolean Whether to display a . an object of type Whether to display a in the above the GLib.Property(Name="has_separator") Event Gtk.ResponseHandler Emitted when an action widget is clicked, the receives a delete event, or the application programmer calls . On a delete event, the response ID is . Otherwise, it depends on which action widget was clicked. GLib.Signal(CName="response") Event System.EventHandler Emitted when the dialog is closed. GLib.Signal(CName="close") Property Gtk.HButtonBox The area of the Dialog where the action widgets are placed. a Property GLib.GType GType Property. a Returns the native value for . Method System.Void Default handler for the event. Override this method in a subclass to provide a default handler for the event. Constructor Protected Constructor. a Chain to this constructor if you have manually registered a native value for your subclass. System.Obsolete(Message=null, IsError=False) Method System.Void Adds an activatable widget to the of a . a a Adds an activatable to the of a , connecting a signal handler that will on the when the is activated. The is appended to the end of the . If you want to add a non-activatable , simply pack it into the field of the . Method Gtk.Widget Adds a new response button to the dialog. a , text for the button a , the numeric response code emitted when the button is pressed. a representing the button added. Method System.Void Activate one of the responses. a , the chosen response. Property Gtk.ResponseType Sets the default response_id. a Sets the default response_id. Method System.Void Default handler for the event. a Override this method in a subclass to provide a default handler for the event. Method System.Void A convenient way to sensitize/desensitize dialog buttons. a a Sets = for each widget in the with the given response_id. A convenient way to sensitize/desensitize dialog buttons. Method System.Int32 To be added a a To be added