gtkmm  4.10.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions | List of all members
Gtk::AlertDialog Class Reference

A Gtk::AlertDialog object collects the arguments that are needed to present a message to the user. More...

#include <gtkmm/alertdialog.h>

Inheritance diagram for Gtk::AlertDialog:
Inheritance graph
[legend]

Public Member Functions

 AlertDialog (AlertDialog && src) noexcept
 
AlertDialogoperator= (AlertDialog && src) noexcept
 
 ~AlertDialog () noexcept override
 
GtkAlertDialog * gobj ()
 Provides access to the underlying C GObject. More...
 
const GtkAlertDialog * gobj () const
 Provides access to the underlying C GObject. More...
 
GtkAlertDialog * gobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
 
bool get_modal () const
 Returns whether the alert blocks interaction with the parent window while it is presented. More...
 
void set_modal (bool modal=true)
 Sets whether the alert blocks interaction with the parent window while it is presented. More...
 
Glib::ustring get_message () const
 Returns the message that will be shown in the alert. More...
 
void set_message (const Glib::ustring & message)
 Sets the message that will be shown in the alert. More...
 
Glib::ustring get_detail () const
 Returns the detail text that will be shown in the alert. More...
 
void set_detail (const Glib::ustring & detail)
 Sets the detail text that will be shown in the alert. More...
 
std::vector< Glib::ustring > get_buttons () const
 Returns the button labels for the alert. More...
 
void set_buttons (const std::vector< Glib::ustring > & labels) const
 Sets the button labels for the alert. More...
 
int get_cancel_button () const
 Returns the index of the cancel button. More...
 
void set_cancel_button (int button)
 Sets the index of the cancel button. More...
 
int get_default_button () const
 Returns the index of the default button. More...
 
void set_default_button (int button)
 Sets the index of the default button. More...
 
void choose (Window & parent, const Gio::SlotAsyncReady & slot, const Glib::RefPtr< Gio::Cancellable > & cancellable={}) const
 This function shows the alert to the user. More...
 
void choose (const Gio::SlotAsyncReady & slot, const Glib::RefPtr< Gio::Cancellable > & cancellable={}) const
 A choose() convenience overload. More...
 
int choose_finish (const Glib::RefPtr< Gio::AsyncResult > & result) const
 Finishes the choose() call and returns the index of the button that was clicked. More...
 
void show (Window & parent)
 Show the alert to the user. More...
 
void show ()
 A show() convenience overload. More...
 
Glib::PropertyProxy< bool > property_modal ()
 Whether the alert is modal. More...
 
Glib::PropertyProxy_ReadOnly< bool > property_modal () const
 Whether the alert is modal. More...
 
Glib::PropertyProxy< Glib::ustring > property_message ()
 The message for the alert. More...
 
Glib::PropertyProxy_ReadOnly< Glib::ustring > property_message () const
 The message for the alert. More...
 
Glib::PropertyProxy< Glib::ustring > property_detail ()
 The detail text for the alert. More...
 
Glib::PropertyProxy_ReadOnly< Glib::ustring > property_detail () const
 The detail text for the alert. More...
 
Glib::PropertyProxy< std::vector< Glib::ustring > > property_buttons ()
 Labels for buttons to show in the alert. More...
 
Glib::PropertyProxy_ReadOnly< std::vector< Glib::ustring > > property_buttons () const
 Labels for buttons to show in the alert. More...
 
Glib::PropertyProxy< int > property_cancel_button ()
 This property determines what happens when the Escape key is pressed while the alert is shown. More...
 
Glib::PropertyProxy_ReadOnly< int > property_cancel_button () const
 This property determines what happens when the Escape key is pressed while the alert is shown. More...
 
Glib::PropertyProxy< int > property_default_button ()
 This property determines what happens when the Return key is pressed while the alert is shown. More...
 
Glib::PropertyProxy_ReadOnly< int > property_default_button () const
 This property determines what happens when the Return key is pressed while the alert is shown. More...
 

Static Public Member Functions

static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system. More...
 
static Glib::RefPtr< AlertDialogcreate ()
 
static Glib::RefPtr< AlertDialogcreate (const Glib::ustring & message)
 Creates a new Gtk::AlertDialog with the given message. More...
 

Protected Member Functions

 AlertDialog ()
 
 AlertDialog (const Glib::ustring & message)
 Creates a new Gtk::AlertDialog with the given message. More...
 

Related Functions

(Note that these are not member functions.)

Glib::RefPtr< Gtk::AlertDialogwrap (GtkAlertDialog * object, bool take_copy=false)
 A Glib::wrap() method for this object. More...
 

Detailed Description

A Gtk::AlertDialog object collects the arguments that are needed to present a message to the user.

The message is shown with the choose() method. This API follows the GIO async pattern, and the result can be obtained by calling choose_finish().

If you don't need to wait for a button to be clicked, you can use show().

Since gtkmm 4.10:

Constructor & Destructor Documentation

◆ AlertDialog() [1/3]

Gtk::AlertDialog::AlertDialog ( AlertDialog &&  src)
noexcept

◆ ~AlertDialog()

Gtk::AlertDialog::~AlertDialog ( )
overridenoexcept

◆ AlertDialog() [2/3]

Gtk::AlertDialog::AlertDialog ( )
protected

◆ AlertDialog() [3/3]

Gtk::AlertDialog::AlertDialog ( const Glib::ustring &  message)
explicitprotected

Creates a new Gtk::AlertDialog with the given message.

Parameters
messageThe message.

Member Function Documentation

◆ choose() [1/2]

void Gtk::AlertDialog::choose ( const Gio::SlotAsyncReady &  slot,
const Glib::RefPtr< Gio::Cancellable > &  cancellable = {} 
) const

A choose() convenience overload.

◆ choose() [2/2]

void Gtk::AlertDialog::choose ( Window parent,
const Gio::SlotAsyncReady &  slot,
const Glib::RefPtr< Gio::Cancellable > &  cancellable = {} 
) const

This function shows the alert to the user.

The slot will be called when the alert is dismissed. It should call choose_finish() to obtain the result.

It is ok to pass nullptr for the callback if the alert does not have more than one button. A simpler API for this case is show().

Since gtkmm 4.10:
Parameters
parentThe parent Gtk::Window.
cancellableA Cancellable to cancel the operation.
slotA callback to call when the operation is complete.

◆ choose_finish()

int Gtk::AlertDialog::choose_finish ( const Glib::RefPtr< Gio::AsyncResult > &  result) const

Finishes the choose() call and returns the index of the button that was clicked.

Since gtkmm 4.10:
Parameters
resultA Gio::AsyncResult.
Returns
The index of the button that was clicked, or -1 if the dialog was cancelled and `property_cancel_button() is not set.
Exceptions
Gtk::DialogError

◆ create() [1/2]

static Glib::RefPtr<AlertDialog> Gtk::AlertDialog::create ( )
static

◆ create() [2/2]

static Glib::RefPtr<AlertDialog> Gtk::AlertDialog::create ( const Glib::ustring &  message)
static

Creates a new Gtk::AlertDialog with the given message.

Parameters
messageThe message.

◆ get_buttons()

std::vector<Glib::ustring> Gtk::AlertDialog::get_buttons ( ) const

Returns the button labels for the alert.

Since gtkmm 4.10:
Returns
The button labels.

◆ get_cancel_button()

int Gtk::AlertDialog::get_cancel_button ( ) const

Returns the index of the cancel button.

Since gtkmm 4.10:
Returns
The index of the cancel button, or -1.

◆ get_default_button()

int Gtk::AlertDialog::get_default_button ( ) const

Returns the index of the default button.

Since gtkmm 4.10:
Returns
The index of the default button, or -1.

◆ get_detail()

Glib::ustring Gtk::AlertDialog::get_detail ( ) const

Returns the detail text that will be shown in the alert.

Since gtkmm 4.10:
Returns
The detail text.

◆ get_message()

Glib::ustring Gtk::AlertDialog::get_message ( ) const

Returns the message that will be shown in the alert.

Since gtkmm 4.10:
Returns
The message.

◆ get_modal()

bool Gtk::AlertDialog::get_modal ( ) const

Returns whether the alert blocks interaction with the parent window while it is presented.

Since gtkmm 4.10:
Returns
true if the alert is modal.

◆ get_type()

static GType Gtk::AlertDialog::get_type ( )
static

Get the GType for this class, for use with the underlying GObject type system.

◆ gobj() [1/2]

GtkAlertDialog* Gtk::AlertDialog::gobj ( )
inline

Provides access to the underlying C GObject.

◆ gobj() [2/2]

const GtkAlertDialog* Gtk::AlertDialog::gobj ( ) const
inline

Provides access to the underlying C GObject.

◆ gobj_copy()

GtkAlertDialog* Gtk::AlertDialog::gobj_copy ( )

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

◆ operator=()

AlertDialog& Gtk::AlertDialog::operator= ( AlertDialog &&  src)
noexcept

◆ property_buttons() [1/2]

Glib::PropertyProxy< std::vector<Glib::ustring> > Gtk::AlertDialog::property_buttons ( )

Labels for buttons to show in the alert.

The labels should be translated and may contain a _ to indicate the mnemonic character.

If this property is not set, then a 'Close' button is automatically created.

Since gtkmm 4.10:
Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_buttons() [2/2]

Glib::PropertyProxy_ReadOnly< std::vector<Glib::ustring> > Gtk::AlertDialog::property_buttons ( ) const

Labels for buttons to show in the alert.

The labels should be translated and may contain a _ to indicate the mnemonic character.

If this property is not set, then a 'Close' button is automatically created.

Since gtkmm 4.10:
Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_cancel_button() [1/2]

Glib::PropertyProxy< int > Gtk::AlertDialog::property_cancel_button ( )

This property determines what happens when the Escape key is pressed while the alert is shown.

If this property holds the index of a button in property_buttons(), then pressing Escape is treated as if that button was pressed. If it is -1 or not a valid index for the buttons array, then an error is returned.

If buttons is nullptr, then the automatically created 'Close' button is treated as both cancel and default button, so 0 is returned.

Since gtkmm 4.10:

Default value: -1

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_cancel_button() [2/2]

Glib::PropertyProxy_ReadOnly< int > Gtk::AlertDialog::property_cancel_button ( ) const

This property determines what happens when the Escape key is pressed while the alert is shown.

If this property holds the index of a button in property_buttons(), then pressing Escape is treated as if that button was pressed. If it is -1 or not a valid index for the buttons array, then an error is returned.

If buttons is nullptr, then the automatically created 'Close' button is treated as both cancel and default button, so 0 is returned.

Since gtkmm 4.10:

Default value: -1

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_default_button() [1/2]

Glib::PropertyProxy< int > Gtk::AlertDialog::property_default_button ( )

This property determines what happens when the Return key is pressed while the alert is shown.

If this property holds the index of a button in property_buttons(), then pressing Return is treated as if that button was pressed. If it is -1 or not a valid index for the buttons array, then nothing happens.

If buttons is nullptr, then the automatically created 'Close' button is treated as both cancel and default button, so 0 is returned.

Since gtkmm 4.10:

Default value: -1

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_default_button() [2/2]

Glib::PropertyProxy_ReadOnly< int > Gtk::AlertDialog::property_default_button ( ) const

This property determines what happens when the Return key is pressed while the alert is shown.

If this property holds the index of a button in property_buttons(), then pressing Return is treated as if that button was pressed. If it is -1 or not a valid index for the buttons array, then nothing happens.

If buttons is nullptr, then the automatically created 'Close' button is treated as both cancel and default button, so 0 is returned.

Since gtkmm 4.10:

Default value: -1

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_detail() [1/2]

Glib::PropertyProxy< Glib::ustring > Gtk::AlertDialog::property_detail ( )

The detail text for the alert.

Since gtkmm 4.10:

Default value: ""

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_detail() [2/2]

Glib::PropertyProxy_ReadOnly< Glib::ustring > Gtk::AlertDialog::property_detail ( ) const

The detail text for the alert.

Since gtkmm 4.10:

Default value: ""

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_message() [1/2]

Glib::PropertyProxy< Glib::ustring > Gtk::AlertDialog::property_message ( )

The message for the alert.

Since gtkmm 4.10:

Default value: ""

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_message() [2/2]

Glib::PropertyProxy_ReadOnly< Glib::ustring > Gtk::AlertDialog::property_message ( ) const

The message for the alert.

Since gtkmm 4.10:

Default value: ""

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_modal() [1/2]

Glib::PropertyProxy< bool > Gtk::AlertDialog::property_modal ( )

Whether the alert is modal.

Since gtkmm 4.10:

Default value: true

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_modal() [2/2]

Glib::PropertyProxy_ReadOnly< bool > Gtk::AlertDialog::property_modal ( ) const

Whether the alert is modal.

Since gtkmm 4.10:

Default value: true

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ set_buttons()

void Gtk::AlertDialog::set_buttons ( const std::vector< Glib::ustring > &  labels) const

Sets the button labels for the alert.

Since gtkmm 4.10:
Parameters
labelsThe new button labels.

◆ set_cancel_button()

void Gtk::AlertDialog::set_cancel_button ( int  button)

Sets the index of the cancel button.

See property_cancel_button() for details of how this value is used.

Since gtkmm 4.10:
Parameters
buttonThe new cancel button.

◆ set_default_button()

void Gtk::AlertDialog::set_default_button ( int  button)

Sets the index of the default button.

See property_default_button() for details of how this value is used.

Since gtkmm 4.10:
Parameters
buttonThe new default button.

◆ set_detail()

void Gtk::AlertDialog::set_detail ( const Glib::ustring &  detail)

Sets the detail text that will be shown in the alert.

Since gtkmm 4.10:
Parameters
detailThe new detail text.

◆ set_message()

void Gtk::AlertDialog::set_message ( const Glib::ustring &  message)

Sets the message that will be shown in the alert.

Since gtkmm 4.10:
Parameters
messageThe new message.

◆ set_modal()

void Gtk::AlertDialog::set_modal ( bool  modal = true)

Sets whether the alert blocks interaction with the parent window while it is presented.

Since gtkmm 4.10:
Parameters
modalThe new value.

◆ show() [1/2]

void Gtk::AlertDialog::show ( )

A show() convenience overload.

◆ show() [2/2]

void Gtk::AlertDialog::show ( Window parent)

Show the alert to the user.

This function is a simple version of choose() intended for dialogs with a single button. If you want to cancel the dialog or if the alert has more than one button, you should use that function instead and provide it with a Cancellable or callback respectively.

Since gtkmm 4.10:
Parameters
parentThe parent Gtk::Window.

Friends And Related Function Documentation

◆ wrap()

Glib::RefPtr< Gtk::AlertDialog > wrap ( GtkAlertDialog *  object,
bool  take_copy = false 
)
related

A Glib::wrap() method for this object.

Parameters
objectThe C instance.
take_copyFalse if the result should take ownership of the C instance. True if it should take a new copy or ref.
Returns
A C++ instance that wraps this C instance.