gtk-sharp0.0.0.0neutralGtk# 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", 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 ();
}
}
}
Gtk.WindowAtk.ImplementorGLib.IWrapperGLib.IWrapperSystem.IDisposableMethodSystem.VoidAdds 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 .
MethodSystem.Int32Waits 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.
MethodSystem.VoidEmits 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.
MethodGtk.WidgetAdds 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.
MethodSystem.VoidDisposes the resources associated with the object.ConstructorInternal constructor
Pointer to the C object.
An instance of Dialog, wrapping the C object.This is an internal constructor, and should not be used by user code.ConstructorCreates a new dialog box.an object of type .
Creates a new dialog box.
This is an internal constructor, and should not be used by user code.
ConstructorCreates a new dialog box.
an object of type .
an object of type .
an object of type .
an object of type .
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 ().
PropertyGtk.VBoxTo be addedan object of type .To be addedPropertySystem.BooleanWhether to display a .
an object of type an object of type Whether to display a in the above the EventGtk.ResponseHandlerTo be added
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.
EventSystem.EventHandlerTo be addedTo be addedPropertyGtk.HButtonBoxTo be addeda To be addedPropertyGLib.GTypeTo be addeda To be addedMethodSystem.VoidDefault handler for the event.Override this method in a subclass to provide a default handler for the event.ConstructorTo be added
a a To be addedMethodSystem.VoidAdds 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 .
MethodSystem.VoidTo be added
a
a To be addedMethodSystem.VoidTo be added
a To be addedPropertyGtk.ResponseTypeSets the default response_id.a Sets the default response_id.MethodSystem.VoidDefault handler for the event.
a Override this method in a subclass to provide a default handler for the event.MethodSystem.VoidA 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.