+
+ // we need to add buttons manually if we use custom labels or always for
+ // Yes/No/Cancel dialog as GTK+ doesn't support it natively and when using
+ // Hildon we add all the buttons manually as it doesn't support too many of
+ // the combinations we may have
+#if wxUSE_LIBHILDON || wxUSE_LIBHILDON2
+ static const bool addButtons = true;
+#else // !wxUSE_LIBHILDON
+ const bool addButtons = buttons == GTK_BUTTONS_NONE;
+#endif // wxUSE_LIBHILDON/!wxUSE_LIBHILDON
+
+
+ if ( addButtons )
+ {
+ if ( m_dialogStyle & wxHELP )
+ {
+ gtk_dialog_add_button(dlg, wxGTK_CONV(GetHelpLabel()),
+ GTK_RESPONSE_HELP);
+ }
+
+ if ( m_dialogStyle & wxYES_NO ) // Yes/No or Yes/No/Cancel dialog
+ {
+ // Add the buttons in the correct order which is, according to
+ // http://library.gnome.org/devel/hig-book/stable/windows-alert.html.en
+ // the following one:
+ //
+ // [Help] [Alternative] [Cancel] [Affirmative]
+
+ gtk_dialog_add_button(dlg, wxGTK_CONV(GetNoLabel()),
+ GTK_RESPONSE_NO);
+
+ if ( m_dialogStyle & wxCANCEL )
+ {
+ gtk_dialog_add_button(dlg, wxGTK_CONV(GetCancelLabel()),
+ GTK_RESPONSE_CANCEL);
+ }
+
+ gtk_dialog_add_button(dlg, wxGTK_CONV(GetYesLabel()),
+ GTK_RESPONSE_YES);
+ }
+ else // Ok or Ok/Cancel dialog
+ {
+ gtk_dialog_add_button(dlg, wxGTK_CONV(GetOKLabel()), GTK_RESPONSE_OK);
+ if ( m_dialogStyle & wxCANCEL )
+ {
+ gtk_dialog_add_button(dlg, wxGTK_CONV(GetCancelLabel()),
+ GTK_RESPONSE_CANCEL);
+ }
+ }
+ }
+
+ gint defaultButton;
+ if ( m_dialogStyle & wxCANCEL_DEFAULT )
+ defaultButton = GTK_RESPONSE_CANCEL;
+ else if ( m_dialogStyle & wxNO_DEFAULT )
+ defaultButton = GTK_RESPONSE_NO;
+ else if ( m_dialogStyle & wxYES_NO )
+ defaultButton = GTK_RESPONSE_YES;
+ else // No need to change the default value, whatever it is.
+ defaultButton = GTK_RESPONSE_NONE;
+
+ if ( defaultButton != GTK_RESPONSE_NONE )
+ gtk_dialog_set_default_response(dlg, defaultButton);
+}
+
+int wxMessageDialog::ShowModal()
+{
+ // break the mouse capture as it would interfere with modal dialog (see
+ // wxDialog::ShowModal)
+ wxWindow * const win = wxWindow::GetCapture();
+ if ( win )
+ win->GTKReleaseMouseAndNotify();
+
+ if ( !m_widget )
+ {
+ GTKCreateMsgDialog();
+ wxCHECK_MSG( m_widget, wxID_CANCEL,
+ wxT("failed to create GtkMessageDialog") );
+ }
+
+ // This should be necessary, but otherwise the
+ // parent TLW will disappear..
+ if (m_parent)
+ gtk_window_present( GTK_WINDOW(m_parent->m_widget) );
+
+ gint result = gtk_dialog_run(GTK_DIALOG(m_widget));
+ gtk_widget_destroy(m_widget);
+ g_object_unref(m_widget);
+ m_widget = NULL;