+ WX_HOOK_MODAL_DIALOG();
+
+ 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
+
+#if GTK_CHECK_VERSION(2,10,0)
+ unsigned sigId = 0;
+ gulong hookId = 0;
+#ifndef __WXGTK3__
+ // Ubuntu overlay scrollbar uses at least GTK 2.24
+ if (gtk_check_version(2,24,0) == NULL)
+#endif
+ {
+ sigId = g_signal_lookup("realize", GTK_TYPE_WIDGET);
+ hookId = g_signal_add_emission_hook(sigId, 0, realize_hook, NULL, NULL);
+ }
+#endif
+
+ Show( true );
+
+ m_modalShowing = true;
+
+ wxOpenModalDialogLocker modalLock;
+
+ // 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();
+ }
+
+#if GTK_CHECK_VERSION(2,10,0)
+ if (sigId)
+ g_signal_remove_emission_hook(sigId, hookId);
+#endif
+
+ gtk_window_set_modal(GTK_WINDOW(m_widget), FALSE);
+
+ return GetReturnCode();
+}