Пример #1
0
        public override bool IsModalDialogRunning()
        {
            var toplevels = GtkQuartz.GetToplevels();

            // Check GtkWindow's Modal flag or for a visible NSPanel
            return(toplevels.Any(t => (t.Value != null && t.Value.Modal && t.Value.Visible) || (t.Key.IsVisible && (t.Key is NSPanel))));
        }
Пример #2
0
        public override bool IsModalDialogRunning()
        {
            var toplevels = GtkQuartz.GetToplevels();

            // When we're looking for modal windows that don't belong to GTK, exclude
            // NSStatusBarWindow (which is visible on Mavericks when we're in fullscreen) and
            // NSToolbarFullscreenWindow (which is visible on Yosemite in fullscreen).
            return(toplevels.Any(t => t.Key.IsVisible && (t.Value == null || t.Value.Modal) &&
                                 !(t.Key.DebugDescription.StartsWith("<NSStatusBarWindow") ||
                                   t.Key.DebugDescription.StartsWith("<NSToolbarFullScreenWindow"))));
        }
Пример #3
0
        public override bool IsModalDialogRunning()
        {
            var toplevels = GtkQuartz.GetToplevels();

            // Check GtkWindow's Modal flag or for a visible NSPanel
            var ret = toplevels
                      .Where(x => !x.Key.DebugDescription.StartsWith("<_NSFullScreenTileDividerWindow", StringComparison.Ordinal))
                      .Any(t => (t.Value != null && t.Value.Modal && t.Value.Visible));

            return(ret);
        }
Пример #4
0
        public override bool IsModalDialogRunning()
        {
            var toplevels = GtkQuartz.GetToplevels();

            return(toplevels.Any(t => t.Key.IsVisible && (t.Value == null || t.Value.Modal) && !t.Key.DebugDescription.StartsWith("<NSStatusBarWindow")));
        }
Пример #5
0
        void GlobalSetup()
        {
            //FIXME: should we remove these when finalizing?
            try {
                ApplicationEvents.Quit += delegate(object sender, ApplicationQuitEventArgs e)
                {
                    // We can only attempt to quit safely if all windows are GTK windows and not modal
                    if (GtkQuartz.GetToplevels().All(t => t.Value != null && (!t.Value.Visible || !t.Value.Modal)))
                    {
                        e.UserCancelled = !IdeApp.Exit();
                        e.Handled       = true;
                        return;
                    }

                    // When a modal dialog is running, things are much harder. We can't just shut down MD behind the
                    // dialog, and aborting the dialog may not be appropriate.
                    //
                    // There's NSTerminateLater but I'm not sure how to access it from carbon, maybe
                    // we need to swizzle methods into the app's NSApplicationDelegate.
                    // Also, it stops the main CFRunLoop and enters a special runloop mode, not sure how that would
                    // interact with GTK+.

                    // For now, just bounce
                    NSApplication.SharedApplication.RequestUserAttention(NSRequestUserAttentionType.CriticalRequest);
                    // and abort the quit.
                    e.UserCancelled = true;
                    e.Handled       = true;
                };

                ApplicationEvents.Reopen += delegate(object sender, ApplicationEventArgs e) {
                    if (IdeApp.Workbench != null && IdeApp.Workbench.RootWindow != null)
                    {
                        IdeApp.Workbench.RootWindow.Deiconify();

                        // This is a workaround to a GTK+ bug. The HasTopLevelFocus flag is not properly
                        // set when the main window is restored. The workaround is to hide and re-show it.
                        // Since this happens before the next mainloop cycle, the window isn't actually affected.
                        IdeApp.Workbench.RootWindow.Hide();
                        IdeApp.Workbench.RootWindow.Show();

                        IdeApp.Workbench.RootWindow.Present();
                        e.Handled = true;
                    }
                };

                ApplicationEvents.OpenDocuments += delegate(object sender, ApplicationDocumentEventArgs e) {
                    //OpenFiles may pump the mainloop, but can't do that from an AppleEvent, so use a brief timeout
                    GLib.Timeout.Add(10, delegate {
                        IdeApp.OpenFiles(e.Documents.Select(doc =>
                                                            new FileOpenInformation(doc.Key, doc.Value, 1, OpenDocumentOptions.Default)));
                        return(false);
                    });
                    e.Handled = true;
                };

                //if not running inside an app bundle, assume usual MD build layout and load the app icon
                FilePath exePath  = System.Reflection.Assembly.GetExecutingAssembly().Location;
                string   iconFile = null;

                iconFile = BrandingService.GetString("ApplicationIcon");
                if (iconFile != null)
                {
                    iconFile = BrandingService.GetFile(iconFile);
                }
                else if (!exePath.ToString().Contains("MonoDevelop.app"))
                {
                    var mdSrcMain = exePath.ParentDirectory.ParentDirectory.ParentDirectory;
                    iconFile = mdSrcMain.Combine("theme-icons", "Mac", "monodevelop.icns");
                }
                else
                {
                    //HACK: override the app image
                    //NSApplication doesn't seem to pick up the image correctly, probably due to the
                    //getting confused about the bundle root because of the launch script
                    var bundleContents = exePath.ParentDirectory.ParentDirectory.ParentDirectory
                                         .ParentDirectory.ParentDirectory;
                    iconFile = bundleContents.Combine("Resources", "monodevelop.icns");
                }
                if (File.Exists(iconFile))
                {
                    NSApplication.SharedApplication.ApplicationIconImage = new NSImage(iconFile);
                }
            } catch (Exception ex) {
                LoggingService.LogError("Could not install app event handlers", ex);
                setupFail = true;
            }
        }
Пример #6
0
 public override bool IsModalDialogRunning()
 {
     return(GtkQuartz.GetToplevels().Any(t => t.Key.IsVisible && (t.Value == null || t.Value.Modal)));
 }