Create  Edit  FrontPage  Index  Search  Changes  History  RSS  Login

Gtk::MessageDialog

class Gtk::MessageDialog

Gtk::MessageDialog presents a dialog with an image representing the type of message (Error, Question, etc.) alongside some message text. It's simply a convenience widget; you could construct the equivalent of Gtk::MessageDialog from Gtk::Dialog without too much effort, but Gtk::MessageDialog saves typing.

The easiest way to do a modal message dialog is to use Gtk::Dialog#run, though you can also pass in the Gtk::Dialog::MODAL flag, Gtk::Dialog#run automatically makes the dialog modal and waits for the user to respond to it. Gtk::Dialog#run returns when any dialog button is clicked.

Exampl2 2. A modal dialog

dialog = Gtk::MessageDialog.new(main_app_window, 
                                Gtk::Dialog::DESTROY_WITH_PARENT,
                                Gtk::MessageDialog::QUESTION,
                                Gtk::MessageDialog::BUTTONS_CLOSE,
                                "Error loading file '%s'" % filename)
dialog.run
dialog.destroy

Class Methods

Gtk::MessageDialog.new(parent, flags, type, buttons, message = nil)
Creates a new message dialog, which is a simple dialog with an icon indicating the dialog type (error, warning, etc.) and some text the user may want to see. When the user clicks a button a "response" signal is emitted with response IDs from Gtk::Dialog#ResponseType. See Gtk::Dialog for more details.

Instance Methods

buttons=(button_type)
Set Gtk::MessageDialog#ButtonsType.
set_buttons(button_type)
Same as Gtk::MessageDialog#buttons=.
message_type
Get Gtk::MessageDialog#Type.
message_type=(message_type)
Set Gtk::MessageDialog#Type.
set_message_type(message_type)
Same as Gtk::MessageDialog#message_type=.
markup=(markup)
Sets the text of the message dialog to be str, which is marked up with the Pango text markup language. Since 2.4
set_markup(markup)
Same as Gtk::MessageDialog#markup=. Since 2.4
secondary_text=(text)
Sets the secondary text of the message dialog. Note that setting a secondary text makes the primary text become bold, unless you have provided explicit markup. Since 2.6
  • text: a String, or nil
  • Returns: text
set_secondary_text(text)
Same as Gtk::MessageDialog#secondary_text=. Since 2.6
  • text: a String, or nil
  • Returns: self
secondary_markup=(markup)
Sets the secondary text of the message dialog which is marked up with the Pango text markup language. Note that setting a secondary text makes the primary text become bold, unless you have provided explicit markup. Since 2.6
set_secondary_markup(markup)
Same as Gtk::MessageDialog#secondary_markup=. Since 2.6
image
Gets the dialog's image. Since 2.10
image=(image)
Sets the dialog's image. Since 2.10
set_image(image)
Same as image=. Since 2.10
  • image: The dialog's image (Gtk::Widget)
  • Returns: self
ref_accessible
See Atk::Implementor#ref_accessible.
secondary_text
Gets the secondary text of the message dialog.
  • Returns: The secondary text of the message dialog
secondary_use_markup=(secondary_use_markup)
Sets the secondary text includes Pango:: markup..
  • secondary_use_markup: The secondary text includes Pango:: markup.
  • Returns: secondary_use_markup
secondary_use_markup?
Gets the secondary text includes Pango:: markup..
  • Returns: The secondary text includes Pango:: markup.
set_secondary_use_markup(secondary_use_markup)
Same as secondary_use_markup=.
  • secondary_use_markup: The secondary text includes Pango:: markup.
  • Returns: self
set_text(text)
Same as text=.
  • text: The primary text of the message dialog
  • Returns: self
set_use_markup(use_markup)
Same as use_markup=.
  • use_markup: The primary text of the title includes Pango:: markup.
  • Returns: self
text
Gets the primary text of the message dialog.
  • Returns: The primary text of the message dialog
text=(text)
Sets the primary text of the message dialog.
  • text: The primary text of the message dialog
  • Returns: text
use_markup=(use_markup)
Sets the primary text of the title includes Pango:: markup..
  • use_markup: The primary text of the title includes Pango:: markup.
  • Returns: use_markup
use_markup?
Gets the primary text of the title includes Pango:: markup..
  • Returns: The primary text of the title includes Pango:: markup.
add_child
See Gtk::Buildable#add_child.
construct_child
See Gtk::Buildable#construct_child.
get_internal_child
See Gtk::Buildable#get_internal_child.
name
See Gtk::Buildable#name.
name=
See Gtk::Buildable#name=.
set_buildable_property
See Gtk::Buildable#set_buildable_property.
set_name
See Gtk::Buildable#set_name.
builder_name
See Gtk::Buildable#builder_name.
builder_name=
See Gtk::Buildable#builder_name=.
set_builder_name
See Gtk::Buildable#set_builder_name.

Constants

ButtonsType

Prebuilt sets of buttons for the dialog. If none of these choices are appropriate, simply use Gtk::MessageDialog::BUTTONS_NONE then call Gtk::Dialog#add_buttons method.

BUTTONS_CANCEL
a Cancel button.
BUTTONS_CLOSE
a Close button.
BUTTONS_NONE
no buttons at all.
BUTTONS_OK
an OK button.
BUTTONS_OK_CANCEL
OK and Cancel buttons.
BUTTONS_YES_NO
Yes and No buttons.

Type

The type of message being displayed in the dialog.

ERROR
Fatal error message.
INFO
Informational message.
QUESTION
Question requiring a choice.
WARNING
Nonfatal warning message.
OTHER

Properties

buttons: Gtk::MessageDialog::ButtonsType (Write)
The buttons shown in the message dialog
image: Gtk::Widget (Read/Write)
The image Since 2.10
message-type: Gtk::MessageDialog::Type (Read/Write)
The type of message
secondary-text: String (Read/Write)
The secondary text of the message dialog Since 2.10
  • Default value: nil
secondary-use-markup: true or false (Read/Write)
true if the secondary text of the dialog includes Pango markup. See Pango.parse_markup. Since 2.10
  • Default value: false
text: String (Read/Write)
The primary text of the message dialog. If the dialog has a secondary text, this will appear as the title. Since 2.10
  • Default value: nil
use-markup: true or false (Read/Write)
true if the primary text of the dialog includes Pango markup. See Pango.parse_markup. Since 2.10
  • Default value: false

Style Properties

message-border: Integer (Read)
Width of border around the label and image in the message dialog
  • Allowed values: >= 0
  • Default value: 12
use-separator: true or false (Read)
Whether to put a separator between the message dialog's text and the buttons Since 2.4
  • Default value: false

ChangeLog

  • 2007-02-13 Apply 2.10 - Masao
  • 2005-03-29 Added methods of 2.6 - Masao
  • 2004-05-25 Added methods of 2.4 - Masao
  • 2003-04-03 Initial upload - Masao