g
Atk.ImplementorIface
Atk.ImplementorIface
Gtk.Widget
Gtk.Widget
Atk.ImplementorIface->Gtk.Widget
GObject.GInterface
GObject.GInterface
GObject.GInterface->Atk.ImplementorIface
Gtk.Buildable
Gtk.Buildable
GObject.GInterface->Gtk.Buildable
GObject.InitiallyUnowned
GObject.InitiallyUnowned
GObject.InitiallyUnowned->Gtk.Widget
GObject.Object
GObject.Object
GObject.Object->GObject.InitiallyUnowned
Gtk.Bin
Gtk.Bin
Gtk.Window
Gtk.Window
Gtk.Bin->Gtk.Window
Gtk.Buildable->Gtk.Widget
Gtk.Container
Gtk.Container
Gtk.Container->Gtk.Bin
Gtk.Dialog
Gtk.Dialog
Gtk.MessageDialog
Gtk.MessageDialog
Gtk.Dialog->Gtk.MessageDialog
Gtk.Widget->Gtk.Container
Gtk.Window->Gtk.Dialog
Example¶
Subclasses: | None |
---|
Class Details¶
-
class
Gtk.
MessageDialog
(*args, **kwargs)¶ -
Bases: Gtk.Dialog
Abstract: No Structure: Gtk.MessageDialogClass
Gtk.MessageDialog
presents a dialog with some message text. It’s simply a
convenience widget; you could construct the equivalent ofGtk.MessageDialog
fromGtk.Dialog
without too much effort, butGtk.MessageDialog
saves typing.One difference from
Gtk.Dialog
is thatGtk.MessageDialog
sets the
Gtk.Window
:skip-taskbar-hint
property toTrue
, so that the dialog is hidden
from the taskbar by default.The easiest way to do a modal message dialog is to use
Gtk.Dialog.run
(), though
you can also pass in theGtk.DialogFlags.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.An example for using a modal dialog:
GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT; dialog = gtk_message_dialog_new (parent_window, flags, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Error reading “%s”: %s", filename, g_strerror (errno)); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog);
You might do a non-modal
Gtk.MessageDialog
as follows:An example for a non-modal dialog:
GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT; dialog = gtk_message_dialog_new (parent_window, flags, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Error reading “%s”: %s", filename, g_strerror (errno)); // Destroy the dialog when the user responds to it // (e.g. clicks a button) g_signal_connect_swapped (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog);
Gtk.MessageDialog
asGtk.Buildable
The
Gtk.MessageDialog
implementation of theGtk.Buildable
interface exposes
the message area as an internal child with the name “message_area”.-
format_secondary_markup
(message_format)[source]¶ -
Sets the secondary text of the message dialog to be message_format (with
printf()-style), which is marked up with the
Pango text markup language.Due to an oversight, this function does not escape special XML characters
like gtk_message_dialog_new_with_markup() does. Thus, if the arguments
may contain special XML characters, you should use g_markup_printf_escaped()
to escape it.gchar *msg; msg = g_markup_printf_escaped (message_format, ...); gtk_message_dialog_format_secondary_markup (message_dialog, "%s", msg); g_free (msg);
New in version 2.6.
-
format_secondary_text
(message_format)[source]¶ -
Sets the secondary text of the message dialog to be message_format
(with printf()-style).New in version 2.6.
-
get_image
()[source]¶ -
Returns: the dialog’s image Return type: Gtk.Widget
Gets the dialog’s image.
New in version 2.14.
Deprecated since version 3.12: Use
Gtk.Dialog
for dialogs with images
-
get_message_area
()[source]¶ -
Returns: A Gtk.Box
corresponding to the
“message area” in the self.Return type: Gtk.Widget
Returns the message area of the dialog. This is the box where the
dialog’s primary and secondary labels are packed. You can add your
own extra content to that box and it will appear below those labels.
SeeGtk.Dialog.get_content_area
() for the corresponding
function in the parentGtk.Dialog
.New in version 2.22.
-
set_image
(image)[source]¶ -
Parameters: image ( Gtk.Widget
) – the imageSets the dialog’s image to image.
New in version 2.10.
Deprecated since version 3.12: Use
Gtk.Dialog
to create dialogs with images
-
set_markup
(str)[source]¶ -
Parameters: str ( str
) – markup string (see Pango markup format)Sets the text of the message dialog to be str, which is marked
up with the Pango text markup language.New in version 2.4.
Property Details¶
-
Gtk.MessageDialog.props.
buttons
¶ -
Name: buttons
Type: Gtk.ButtonsType
Default Value: Gtk.ButtonsType.NONE
Flags: WRITABLE
,CONSTRUCT_ONLY
The buttons shown in the message dialog
-
Gtk.MessageDialog.props.
image
¶ -
Name: image
Type: Gtk.Widget
Default Value: None
Flags: DEPRECATED
,READABLE
,WRITABLE
The image for this dialog.
New in version 2.10.
Deprecated since version 3.12: Use
Gtk.Dialog
to create dialogs with images
-
Gtk.MessageDialog.props.
message_area
¶ -
Name: message-area
Type: Gtk.Widget
Default Value: None
Flags: READABLE
The
Gtk.Box
that corresponds to the message area of this dialog. See
Gtk.MessageDialog.get_message_area
() for a detailed description of this
area.New in version 2.22.
-
Gtk.MessageDialog.props.
message_type
¶ -
Name: message-type
Type: Gtk.MessageType
Default Value: Gtk.MessageType.INFO
Flags: READABLE
,WRITABLE
,CONSTRUCT
,EXPLICIT_NOTIFY
The type of the message.
-
Gtk.MessageDialog.props.
secondary_text
¶ -
Name: secondary-text
Type: str
Default Value: None
Flags: READABLE
,WRITABLE
The secondary text of the message dialog.
New in version 2.10.
-
Gtk.MessageDialog.props.
secondary_use_markup
¶ -
Name: secondary-use-markup
Type: bool
Default Value: False
Flags: READABLE
,WRITABLE
,EXPLICIT_NOTIFY
True
if the secondary text of the dialog includes Pango markup.
SeePango.parse_markup
().New in version 2.10.
-
Gtk.MessageDialog.props.
text
¶ -
Name: text
Type: str
Default Value: ''
Flags: READABLE
,WRITABLE
The primary text of the message dialog. If the dialog has
a secondary text, this will appear as the title.New in version 2.10.
-
Gtk.MessageDialog.props.
use_markup
¶ -
Name: use-markup
Type: bool
Default Value: False
Flags: READABLE
,WRITABLE
,EXPLICIT_NOTIFY
True
if the primary text of the dialog includes Pango markup.
SeePango.parse_markup
().New in version 2.10.
GtkWidget::accel-closures-changed
No description available.
GtkWidget::button-press-event
The ::button-press-event signal will be emitted when a button
(typically from a mouse) is pressed.
GtkWidget::button-release-event
The ::button-release-event signal will be emitted when a button
(typically from a mouse) is released.
GtkWidget::can-activate-accel
Determines whether an accelerator that activates the signal
identified by signal_id
can currently be activated.
This signal is present to allow applications and derived
widgets to override the default GtkWidget
handling
for determining whether an accelerator can be activated.
GtkWidget::child-notify
The ::child-notify signal is emitted for each
[child property][child-properties] that has
changed on an object. The signal’s detail holds the property name.
GtkWidget::composited-changed
The ::composited-changed signal is emitted when the composited
status of widgets
screen changes.
See gdk_screen_is_composited().
deprecated: 3.22
GtkWidget::configure-event
The ::configure-event signal will be emitted when the size, position or
stacking of the widget
‘s window has changed.
GtkWidget::damage-event
Emitted when a redirected window belonging to widget
gets drawn into.
The region/area members of the event shows what area of the redirected
drawable was drawn into.
since: 2.14
GtkWidget::delete-event
The ::delete-event signal is emitted if a user requests that
a toplevel window is closed. The default handler for this signal
destroys the window. Connecting gtk_widget_hide_on_delete()
to
this signal will cause the window to be hidden instead, so that
it can later be shown again without reconstructing it.
GtkWidget::destroy
Signals that all holders of a reference to the widget should release
the reference that they hold. May result in finalization of the widget
if all references are released.
GtkWidget::destroy-event
The ::destroy-event signal is emitted when a GdkWindow
is destroyed.
You rarely get this signal, because most widgets disconnect themselves
from their window before they destroy it, so no widget owns the
window at destroy time.
GtkWidget::direction-changed
The ::direction-changed signal is emitted when the text direction
of a widget changes.
GtkWidget::drag-begin
The ::drag-begin signal is emitted on the drag source when a drag is
started. A typical reason to connect to this signal is to set up a
custom drag icon with e.g. gtk_drag_source_set_icon_pixbuf().
GtkWidget::drag-data-delete
The ::drag-data-delete signal is emitted on the drag source when a drag
with the action GDK_ACTION_MOVE
is successfully completed. The signal
handler is responsible for deleting the data that has been dropped. What
“delete” means depends on the context of the drag operation.
GtkWidget::drag-data-get
The ::drag-data-get signal is emitted on the drag source when the drop
site requests the data which is dragged. It is the responsibility of
the signal handler to fill data
with the data in the format which
is indicated by info
. See gtk_selection_data_set()
and gtk_selection_data_set_text().
GtkWidget::drag-data-received
The ::drag-data-received signal is emitted on the drop site when the
dragged data has been received. If the data was received in order to
determine whether the drop will be accepted, the handler is expected
to call gdk_drag_status()
and not finish the drag.
If the data was received in response to a GtkWidget::drag-drop
signal
(and this is the last target to be received), the handler for this
signal is expected to process the received data and then call
gtk_drag_finish(), setting the success
parameter depending on
whether the data was processed successfully.
GtkWidget::drag-drop
The ::drag-drop signal is emitted on the drop site when the user drops
the data onto the widget. The signal handler must determine whether
the cursor position is in a drop zone or not. If it is not in a drop
zone, it returns FALSE
and no further processing is necessary.
Otherwise, the handler returns TRUE
. In this case, the handler must
ensure that gtk_drag_finish()
is called to let the source know that
the drop is done. The call to gtk_drag_finish()
can be done either
directly or in a GtkWidget::drag-data-received
handler which gets
triggered by calling gtk_drag_get_data()
to receive the data for one
or more of the supported targets.
GtkWidget::drag-end
The ::drag-end signal is emitted on the drag source when a drag is
finished. A typical reason to connect to this signal is to undo
things done in GtkWidget::drag-begin
.
GtkWidget::drag-failed
The ::drag-failed signal is emitted on the drag source when a drag has
failed. The signal handler may hook custom code to handle a failed DnD
operation based on the type of error, it returns TRUE
is the failure has
been already handled (not showing the default “drag operation failed”
animation), otherwise it returns FALSE
.
since: 2.12
GtkWidget::drag-leave
The ::drag-leave signal is emitted on the drop site when the cursor
leaves the widget. A typical reason to connect to this signal is to
undo things done in GtkWidget::drag-motion
, e.g. undo highlighting
with gtk_drag_unhighlight().
GtkWidget::drag-motion
The ::drag-motion signal is emitted on the drop site when the user
moves the cursor over the widget during a drag. The signal handler
must determine whether the cursor position is in a drop zone or not.
If it is not in a drop zone, it returns FALSE
and no further processing
is necessary. Otherwise, the handler returns TRUE
. In this case, the
handler is responsible for providing the necessary information for
displaying feedback to the user, by calling gdk_drag_status().
GtkWidget::draw
This signal is emitted when a widget is supposed to render itself.
The widget
‘s top left corner must be painted at the origin of
the passed in context and be sized to the values returned by
gtk_widget_get_allocated_width()
and gtk_widget_get_allocated_height().
since: 3.0
GtkWidget::enter-notify-event
The ::enter-notify-event will be emitted when the pointer enters
the widget
‘s window.
GtkWidget::event
The GTK+ main loop will emit three signals for each GDK event delivered
to a widget: one generic ::event signal, another, more specific,
signal that matches the type of event delivered (e.g.
GtkWidget::key-press-event
) and finally a generic
GtkWidget::event-after
signal.
GtkWidget::event-after
After the emission of the GtkWidget::event
signal and (optionally)
the second more specific signal, ::event-after will be emitted
regardless of the previous two signals handlers return values.
GtkWidget::focus
No description available.
GtkWidget::focus-in-event
The ::focus-in-event signal will be emitted when the keyboard focus
enters the widget
‘s window.
GtkWidget::focus-out-event
The ::focus-out-event signal will be emitted when the keyboard focus
leaves the widget
‘s window.
GtkWidget::grab-broken-event
Emitted when a pointer or keyboard grab on a window belonging
to widget
gets broken.
since: 2.8
GtkWidget::grab-focus
No description available.
GtkWidget::grab-notify
The ::grab-notify signal is emitted when a widget becomes
shadowed by a GTK+ grab (not a pointer or keyboard grab) on
another widget, or when it becomes unshadowed due to a grab
being removed.
GtkWidget::hide
The ::hide signal is emitted when widget
is hidden, for example with gtk_widget_hide().
GtkWidget::hierarchy-changed
The ::hierarchy-changed signal is emitted when the
anchored state of a widget changes. A widget is
“anchored” when its toplevel
ancestor is a GtkWindow
. This signal is emitted when
a widget changes from un-anchored to anchored or vice-versa.
GtkWidget::key-press-event
The ::key-press-event signal is emitted when a key is pressed. The signal
emission will reoccur at the key-repeat rate when the key is kept pressed.
GtkWidget::key-release-event
The ::key-release-event signal is emitted when a key is released.
GtkWidget::keynav-failed
Gets emitted if keyboard navigation fails.
See gtk_widget_keynav_failed()
for details.
since: 2.12
GtkWidget::leave-notify-event
The ::leave-notify-event will be emitted when the pointer leaves
the widget
‘s window.
GtkWidget::map
The ::map signal is emitted when widget
is going to be mapped, that is
when the widget is visible (which is controlled with
gtk_widget_set_visible()) and all its parents up to the toplevel widget
are also visible. Once the map has occurred, GtkWidget::map-event
will
be emitted.
GtkWidget::map-event
The ::map-event signal will be emitted when the widget
‘s window is
mapped. A window is mapped when it becomes visible on the screen.
GtkWidget::mnemonic-activate
The default handler for this signal activates widget
if group_cycling
is FALSE
, or just makes widget
grab focus if group_cycling
is TRUE
.
GtkWidget::motion-notify-event
The ::motion-notify-event signal is emitted when the pointer moves
over the widget’s GdkWindow
.
GtkWidget::move-focus
No description available.
GtkWidget::parent-set
The ::parent-set signal is emitted when a new parent
has been set on a widget.
GtkWidget::popup-menu
This signal gets emitted whenever a widget should pop up a context
menu. This usually happens through the standard key binding mechanism;
by pressing a certain key while a widget is focused, the user can cause
the widget to pop up a menu. For example, the GtkEntry
widget creates
a menu with clipboard commands. See the
[Popup Menu Migration Checklist][checklist-popup-menu]
for an example of how to use this signal.
GtkWidget::property-notify-event
The ::property-notify-event signal will be emitted when a property on
the widget
‘s window has been changed or deleted.
GtkWidget::proximity-in-event
To receive this signal the GdkWindow
associated to the widget needs
to enable the #GDK_PROXIMITY_IN_MASK mask.
GtkWidget::proximity-out-event
To receive this signal the GdkWindow
associated to the widget needs
to enable the #GDK_PROXIMITY_OUT_MASK mask.
GtkWidget::query-tooltip
Emitted when GtkWidget:has-tooltip
is TRUE
and the hover timeout
has expired with the cursor hovering “above” widget
; or emitted when widget
got
focus in keyboard mode.
since: 2.12
GtkWidget::realize
The ::realize signal is emitted when widget
is associated with a
GdkWindow
, which means that gtk_widget_realize()
has been called or the
widget has been mapped (that is, it is going to be drawn).
GtkWidget::screen-changed
The ::screen-changed signal gets emitted when the
screen of a widget has changed.
GtkWidget::scroll-event
The ::scroll-event signal is emitted when a button in the 4 to 7
range is pressed. Wheel mice are usually configured to generate
button press events for buttons 4 and 5 when the wheel is turned.
GtkWidget::selection-clear-event
The ::selection-clear-event signal will be emitted when the
the widget
‘s window has lost ownership of a selection.
GtkWidget::selection-get
No description available.
GtkWidget::selection-notify-event
No description available.
GtkWidget::selection-received
No description available.
GtkWidget::selection-request-event
The ::selection-request-event signal will be emitted when
another client requests ownership of the selection owned by
the widget
‘s window.
GtkWidget::show
The ::show signal is emitted when widget
is shown, for example with gtk_widget_show().
GtkWidget::show-help
No description available.
GtkWidget::size-allocate
No description available.
GtkWidget::state-changed
The ::state-changed signal is emitted when the widget state changes.
See gtk_widget_get_state().
deprecated: 3.0
GtkWidget::state-flags-changed
The ::state-flags-changed signal is emitted when the widget state
changes, see gtk_widget_get_state_flags().
since: 3.0
GtkWidget::style-set
The ::style-set signal is emitted when a new style has been set
on a widget. Note that style-modifying functions like
gtk_widget_modify_base()
also cause this signal to be emitted.
deprecated: 3.0
GtkWidget::style-updated
The ::style-updated signal is a convenience signal that is emitted when the
GtkStyleContext::changed
signal is emitted on the widget
‘s associated
GtkStyleContext
as returned by gtk_widget_get_style_context().
since: 3.0
GtkWidget::touch-event
No description available.
GtkWidget::unmap
The ::unmap signal is emitted when widget
is going to be unmapped, which
means that either it or any of its parents up to the toplevel widget have
been set as hidden.
GtkWidget::unmap-event
The ::unmap-event signal will be emitted when the widget
‘s window is
unmapped. A window is unmapped when it becomes invisible on the screen.
GtkWidget::unrealize
The ::unrealize signal is emitted when the GdkWindow
associated with
widget
is destroyed, which means that gtk_widget_unrealize()
has been
called or the widget has been unmapped (that is, it is going to be hidden).
GtkWidget::visibility-notify-event
The ::visibility-notify-event will be emitted when the widget
‘s
window is obscured or unobscured.
deprecated: 3.12
GtkWidget::window-state-event
The ::window-state-event will be emitted when the state of the
toplevel window associated to the widget
changes.
Gtk2::MessageDialog(3)
wrapper for GtkMessageDialog
SYNOPSIS
#
# A modal dialog. Note that the message is a printf-style format.
#
$dialog = Gtk2::MessageDialog->new ($main_application_window,
‘destroy-with-parent’,
‘question’, # message type
‘yes-no’, # which set of buttons?
«Pay me $%.2f?», $amount);
$response = $dialog->run;
if ($response eq ‘yes’) {
send_bill ();
}
$dialog->destroy;
#
# A non-modal dialog.
#
$dialog = Gtk2::MessageDialog->new ($main_application_window,
‘destroy-with-parent’,
‘question’, # message type
‘ok-cancel’, # which set of buttons?
«Self-destruct now?»);
# react whenever the user responds.
$dialog->signal_connect (response => sub {
my ($self, $response) = @_;
if ($response eq ‘ok’) {
do_the_thing ();
}
$self->destroy;
});
$dialog->show_all;
DESCRIPTION
Gtk2::MessageDialog is 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 Gtk2::MessageDialog from Gtk2::Dialog
without too much effort, but Gtk2::MessageDialog saves typing and helps create a
consistent look and feel for your application.
The easiest way to do a modal message dialog is to use «$dialog->run», which
automatically makes your dialog modal and waits for the user to respond to it.
You can also pass in the GTK_DIALOG_MODAL flag when creating the MessageDialog.
HIERARCHY
Glib::Object +----Glib::InitiallyUnowned +----Gtk2::Object +----Gtk2::Widget +----Gtk2::Container +----Gtk2::Bin +----Gtk2::Window +----Gtk2::Dialog +----Gtk2::MessageDialog
INTERFACES
Glib::Object::_Unregistered::AtkImplementorIface Gtk2::Buildable
METHODS
widget = Gtk2::MessageDialog->new ($parent, $flags, $type, $buttons, $format, …)
- $parent (Gtk2::Window or undef)
- $flags (Gtk2::DialogFlags)
- $type (Gtk2::MessageType)
- $buttons (Gtk2::ButtonsType)
- $format (scalar)
- … (list)
widget = Gtk2::MessageDialog->new_with_markup ($parent, $flags, $type, $buttons, $message)
- $parent (Gtk2::Window or undef)
- $flags (Gtk2::DialogFlags)
- $type (Gtk2::MessageType)
- $buttons (Gtk2::ButtonsType)
- $message (string or undef) a string containing Pango markup
Like «new», but allowing Pango markup tags in the message. Note that this
version is not variadic.
Since: gtk+ 2.4
$message_dialog->format_secondary_markup ($message_format, …)
- $message_format (scalar)
- … (list)
Since: gtk+ 2.6
$message_dialog->format_secondary_text ($message_format, …)
- $message_format (scalar)
- … (list)
Since: gtk+ 2.6
widget = $dialog->get_image
Since: gtk+ 2.14
$dialog->set_image ($image)
- $image (Gtk2::Widget)
Since: gtk+ 2.10
$message_dialog->set_markup ($str)
- $str (string)
Since: gtk+ 2.4
widget = $message_dialog->get_message_area
Since: gtk+ 2.22
PROPERTIES
- ‘buttons’ (Gtk2::ButtonsType : default «none» : writable / construct-only / private)
- The buttons shown in the message dialog
- ‘image’ (Gtk2::Widget : default undef : readable / writable / private)
- The image
- ‘message-area’ (Gtk2::Widget : default undef : readable / private)
- GtkVBox that holds the dialog’s primary and secondary labels
- ‘message-type’ (Gtk2::MessageType : default «info» : readable / writable / construct / private)
- The type of message
- ‘secondary-text’ (string : default undef : readable / writable / private)
- The secondary text of the message dialog
- ‘secondary-use-markup’ (boolean : default false : readable / writable / private)
- The secondary text includes Pango markup.
- ‘text’ (string : default «» : readable / writable / private)
- The primary text of the message dialog
- ‘use-markup’ (boolean : default false : readable / writable / private)
- The primary text of the title includes Pango markup.
STYLE PROPERTIES
- ‘message-border’ (integer : default 12 : readable / private)
- Width of border around the label and image in the message dialog
- ‘use-separator’ (boolean : default false : readable / private)
- Whether to put a separator between the message dialog’s text and the buttons
ENUMS AND FLAGS
enum Gtk2::ButtonsType
- ‘none’ / ‘GTK_BUTTONS_NONE‘
- ‘ok’ / ‘GTK_BUTTONS_OK‘
- ‘close’ / ‘GTK_BUTTONS_CLOSE‘
- ‘cancel’ / ‘GTK_BUTTONS_CANCEL‘
- ‘yes-no’ / ‘GTK_BUTTONS_YES_NO‘
- ‘ok-cancel’ / ‘GTK_BUTTONS_OK_CANCEL‘
flags Gtk2::DialogFlags
- ‘modal’ / ‘GTK_DIALOG_MODAL‘
- ‘destroy-with-parent’ / ‘GTK_DIALOG_DESTROY_WITH_PARENT‘
- ‘no-separator’ / ‘GTK_DIALOG_NO_SEPARATOR‘
enum Gtk2::MessageType
- ‘info’ / ‘GTK_MESSAGE_INFO‘
- ‘warning’ / ‘GTK_MESSAGE_WARNING‘
- ‘question’ / ‘GTK_MESSAGE_QUESTION‘
- ‘error’ / ‘GTK_MESSAGE_ERROR‘
- ‘other’ / ‘GTK_MESSAGE_OTHER‘
COPYRIGHT
Copyright (C) 2003-2011 by the gtk2-perl team.
This software is licensed under the LGPL. See Gtk2 for a full notice.