コード例 #1
0
        /// <summary>
        /// Places and runs a transient dialog. Does not destroy it, so values can be retrieved from its widgets.
        /// </summary>
        public static int RunCustomDialog(Dialog dlg, Window parent)
        {
            // if dialog is modal, make sure it's parented on any existing modal dialog
            Gtk.Dialog dialog = dlg;
            if (dialog.Modal)
            {
                parent = GetDefaultModalParent();
            }

            //ensure the dialog has a parent
            if (parent == null)
            {
                if (dialog.TransientFor != null)
                {
                    parent = dialog.TransientFor;
                }
                else
                {
                    parent = RootWindow;
                }
            }

            //TODO: use native parenting API for native windows
            if (parent.nativeWidget is Gtk.Window)
            {
                dialog.TransientFor      = parent;
                dialog.DestroyWithParent = true;
            }

            MonoDevelop.Components.IdeTheme.ApplyTheme(dialog);

            if (dialog.Title == null)
            {
                dialog.Title = BrandingService.ApplicationName;
            }

                        #if MAC
            Runtime.RunInMainThread(() => {
                // If there is a native NSWindow model window running, we need
                // to show the new dialog over that window.
                if (NSApplication.SharedApplication.ModalWindow != null)
                {
                    dialog.Shown += HandleShown;
                }
                else
                {
                    PlaceDialog(dialog, parent);
                }
            }).Wait();
                        #endif

            try {
                IdeApp.DisableIdleActions();
                return(GtkWorkarounds.RunDialogWithNotification(dialog));
            } finally {
                IdeApp.EnableIdleActions();
            }
        }
コード例 #2
0
 /// <summary>
 /// Places and runs a transient dialog. Does not destroy it, so values can be retrieved from its widgets.
 /// </summary>
 public static int RunCustomDialog(Gtk.Dialog dialog, Gtk.Window parent)
 {
     if (parent == null)
     {
         if (dialog.TransientFor != null)
         {
             parent = dialog.TransientFor;
         }
         else
         {
             parent = GetDefaultParent(dialog);
         }
     }
     dialog.TransientFor      = parent;
     dialog.DestroyWithParent = true;
     PlaceDialog(dialog, parent);
     return(GtkWorkarounds.RunDialogWithNotification(dialog));
 }
コード例 #3
0
        /// <summary>
        /// Places and runs a transient dialog. Does not destroy it, so values can be retrieved from its widgets.
        /// </summary>
        public static int RunCustomDialog(Dialog dlg, Window parent)
        {
            // if dialog is modal, make sure it's parented on any existing modal dialog
            Gtk.Dialog dialog = dlg;
            if (dialog.Modal)
            {
                parent = GetDefaultModalParent();
            }

            //ensure the dialog has a parent
            if (parent == null)
            {
                parent = dialog.TransientFor ?? RootWindow;
            }

            dialog.TransientFor      = parent;
            dialog.DestroyWithParent = true;

            if (dialog.Title == null)
            {
                dialog.Title = BrandingService.ApplicationName;
            }

                        #if MAC
            Runtime.RunInMainThread(() => {
                // If there is a native NSWindow model window running, we need
                // to show the new dialog over that window.
                if (NSApplication.SharedApplication.ModalWindow != null)
                {
                    dialog.Shown += HandleShown;
                }
                else
                {
                    PlaceDialog(dialog, parent);
                }
            }).Wait();
                        #endif
            return(GtkWorkarounds.RunDialogWithNotification(dialog));
        }
コード例 #4
0
        /// <summary>
        /// Places and runs a transient dialog. Does not destroy it, so values can be retrieved from its widgets.
        /// </summary>
        public static int RunCustomDialog(Dialog dlg, Window parent)
        {
            // if dialog is modal, make sure it's parented on any existing modal dialog
            Gtk.Dialog dialog = dlg;
            if (dialog.Modal)
            {
                parent = IdeServices.DesktopService.GetParentForModalWindow();
            }

            //ensure the dialog has a parent
            if (parent == null)
            {
                if (dialog.TransientFor != null)
                {
                    parent = dialog.TransientFor;
                }
                else
                {
                    parent = IdeServices.DesktopService.GetFocusedTopLevelWindow();
                }
            }

            //TODO: use native parenting API for native windows
            if (parent?.nativeWidget is Gtk.Window)
            {
                dialog.TransientFor      = parent;
                dialog.DestroyWithParent = true;
            }

            MonoDevelop.Components.IdeTheme.ApplyTheme(dialog);

            if (dialog.Title == null)
            {
                dialog.Title = BrandingService.ApplicationName;
            }

                        #if MAC
            Runtime.RunInMainThread(() => {
                // If there is a native NSWindow model window running, we need
                // to show the new dialog over that window.
                if (NSApplication.SharedApplication.ModalWindow != null || parent?.nativeWidget is NSWindow)
                {
                    if (dialog.Modal)
                    {
                        EventHandler shownHandler = null;
                        shownHandler = (s, e) => {
                            ShowCustomModalDialog(dialog, parent);
                            dialog.Shown -= shownHandler;
                        };
                        dialog.Shown += shownHandler;
                    }
                    else
                    {
                        // If parent is a native NSWindow, run the dialog modally anyway
                        ShowCustomModalDialog(dialog, parent);
                    }
                }
                else
                {
                    PlaceDialog(dialog, parent);
                }
            }).Wait();
                        #endif

            var initialRootWindow = Xwt.MessageDialog.RootWindow;
            try {
                Xwt.MessageDialog.RootWindow = Xwt.Toolkit.CurrentEngine.WrapWindow(dialog);
                IdeApp.DisableIdleActions();
                int result = GtkWorkarounds.RunDialogWithNotification(dialog);
                // Focus parent window once the dialog is ran, as focus gets lost
                if (parent != null)
                {
                    IdeServices.DesktopService.FocusWindow(parent);
                }

                return(result);
            } finally {
                Xwt.MessageDialog.RootWindow = initialRootWindow;
                IdeApp.EnableIdleActions();
            }
        }