[Contents] [Back] [Prev] [Up] [Next] [Forward]

# Package Gtk.Dialog

Dialog 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 on the user's part.

Gtkada treats a dialog as a window split horizontally. The top section is a Gtk_Vbox, and is where widgets such as a Gtk_Label or a Gtk_Entry should be packed. The second area is known as the action_area. 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 Gtk_Hseparator.

If 'dialog' is a newly created dialog, the two primary areas of the window can be accessed using Get_Vbox and Get_Action_Area as can be seen from the example, below.

A 'modal' dialog (that is, one which freezes the rest of the application from user input), can be created by calling Set_Modal on the dialog.

see section Package Gtkada.Dialogs for a higher level dialog interface.

- Gtk.Dialog Widget Hierarchy
- Gtk.Dialog Signals
- Gtk.Dialog Types
- Gtk.Dialog Subprograms

## Widget Hierarchy

    GObject                       (see section Package Glib.Object)
    Gtk_Object                    (see section Package Gtk.Object)
       \___ Gtk_Widget            (see section Package Gtk.Widget)
          \___ Gtk_Container      (see section Package Gtk.Container)
             \___ Gtk_Bin         (see section Package Gtk.Bin)
                \___ Gtk_Window   (see section Package Gtk.Window)
                   \___ Gtk_Dialog (see section Package Gtk.Dialog)

## Signals

- "close" procedure Handler (Dialog : access Gtk_Fialog_Record'Class);
  Emit this signal to force a closing of the dialog.
- "response" procedure Handler
  (Dialog : access Gtk_Fialog_Record'Class;
  Response_Id : Gint);

## Types

    type Gtk_Dialog_Flags is mod 3;

    type Gtk_Response_Type is new Gint;

| Type used for Response_Id's. Positive values are totally user-interpreted. GtkAda will sometimes return Gtk_Response_None if no Response_Id is available. Typical usage is: if Gtk.Dialog.Run (Dialog) = Gtk_Response_Accept then blah; end if;

## Subprograms

    procedure Gtk_New
      (Dialog             : out    Gtk_Dialog);

| Create a new dialog. Widgets should not be packed into this widget directly, but into the vbox and action_area, as described above.

    procedure Gtk_New
      (Dialog             : out    Gtk_Dialog;
       Title              :        UTF8_String;
       Parent             :        Gtk.Window.Gtk_Window;
       Flags              :        Gtk_Dialog_Flags);

| Create a new dialog with a specific title, and specific attributes. Parent is the transient parent for the dialog (ie the one that is used for reference for the flag Destroy_With_Parent, or to compute the initial position of the dialog).

    function Get_Type              return Gtk.Gtk_Type;

| Return the internal value associated with a Gtk_Dialog.

    function Get_Action_Area
      (Dialog             : access Gtk_Dialog_Record)
       return Gtk.Box.Gtk_Box;

| Return the action area box associated with a Dialog.

    function Get_Vbox
      (Dialog             : access Gtk_Dialog_Record)
       return Gtk.Box.Gtk_Box;

| Return the vertical box associated with a Dialog.

    procedure Add_Action_Widget
      (Dialog             : access Gtk_Dialog_Record;
       Child              : access Gtk.Widget.Gtk_Widget_Record'Class;
       Response_Id        :        Gtk_Response_Type);

| Add an activatable widget to the action area of Dialog. When the widget is activated (ie emits the "activate" signal), Dialog will emit the "response" signal with Response_Id.

    function Add_Button
      (Dialog             : access Gtk_Dialog_Record;
       Text               :        UTF8_String;
       Response_Id        :        Gtk_Response_Type)
       return Gtk.Widget.Gtk_Widget;

| Add a button with the given text to the dialog. Note that you can also pass one of the constants defined in Gtk.Stock for the predefined buttons. When the button is clicked, Dialog will emit the "response" signal. The button widget is returned.

    procedure Set_Response_Sensitive
      (Dialog             : access Gtk_Dialog_Record;
       Response_Id        :        Gtk_Response_Type;
       Setting            :        Boolean);

| Call Gtk.Widget.Set_Sensitive for all the buttons in the dialog associated with Response_Id.

    procedure Set_Default_Response
      (Dialog             : access Gtk_Dialog_Record;
       Response_Id        :        Gtk_Response_Type);

| Set the last widget in the dialog's action area with the given Response_Id as the default widget for Dialog. Pressing Enter will activate this default widget.

    procedure Set_Has_Separator
      (Dialog             : access Gtk_Dialog_Record;
       Setting            :        Boolean);

| Set whether the dialog has a separator above the buttons.

    function Get_Has_Separator
      (Dialog             : access Gtk_Dialog_Record)
       return Boolean;

| Return True if the dialog has a separator above the buttons.

    function Run
      (Dialog             : access Gtk_Dialog_Record)
       return Gtk_Response_Type;

Block in a recursive main loop until Dialog emits the "response"
signal, or is destroyed. If the dialog is destroyed, Gtk_Response_None is returned. Otherwise, the response_id from the "response" signal is returned. Run will call Show on the dialog automatically. However, it is your responsability to call Show for any child you have inserted in the dialog. The dialog is automatically set to modal when this function is called. You can exit at any time from this function by emitting the "response" signal directly. When Run returns, you are responsible for hiding or destroying the dialog if necessary.

### Signals

    procedure Response
      (Dialog             : access Gtk_Dialog_Record;
       Response_Id        :        Gtk_Response_Type);

| Emit the "response" signal

[Contents] [Back] [Prev] [Up] [Next] [Forward]