+ WX_TESTING_SHOW_MODAL_HOOK();
+
+ wxASSERT_MSG( !IsModal(), "ShowModal() can't be called twice" );
+
+ // release the mouse if it's currently captured as the window having it
+ // will be disabled when this dialog is shown -- but will still keep the
+ // capture making it impossible to do anything in the modal dialog itself
+ wxWindow * const win = wxWindow::GetCapture();
+ if ( win )
+ win->GTKReleaseMouseAndNotify();
+
+ wxWindow * const parent = GetParentForModalDialog();
+ if ( parent )
+ {
+ gtk_window_set_transient_for( GTK_WINDOW(m_widget),
+ GTK_WINDOW(parent->m_widget) );
+ }
+
+ wxBusyCursorSuspender cs; // temporarily suppress the busy cursor
+
+ Show( true );
+
+ m_modalShowing = true;
+
+ wxOpenModalDialogsCount++;
+
+ // NOTE: gtk_window_set_modal internally calls gtk_grab_add() !
+ gtk_window_set_modal(GTK_WINDOW(m_widget), TRUE);
+
+ // Run modal dialog event loop.
+ {
+ wxGUIEventLoopTiedPtr modal(&m_modalLoop, new wxGUIEventLoop());
+ m_modalLoop->Run();
+ }
+
+ gtk_window_set_modal(GTK_WINDOW(m_widget), FALSE);
+
+ wxOpenModalDialogsCount--;
+
+ return GetReturnCode();
+}