Inheritance: MonoDevelop.Ide.Desktop.PlatformService
        static CarbonEventHandlerStatus HandleMenuCommand(IntPtr callRef, IntPtr eventRef, IntPtr userData)
        {
            try
            {
                CarbonHICommand hiCmd  = GetCarbonHICommand(eventRef);
                uint            refCon = HIToolbox.GetMenuItemReferenceConstant(hiCmd.MenuItem);

                //link commands
                if (hiCmd.CommandID == linkCommandId)
                {
                    string url = "";
                    try
                    {
                        url = linkCommands[(int)refCon];
                        MacPlatformService.OpenUrl(url);
                    }
                    catch (Exception ex)
                    {
                        Gtk.Application.Invoke(delegate
                        {
                            MonoDevelop.Ide.MessageService.ShowException(ex, MonoDevelop.Core.GettextCatalog.GetString("Could not open the url {0}", url));
                        });
                    }
                    DestroyOldMenuObjects();
                    return(CarbonEventHandlerStatus.Handled);
                }

                //normal commands
                object cmdID = GetCommandID(hiCmd);
                if (cmdID != null)
                {
                    if (refCon > 0)
                    {
                        object data = objectsToDestroyOnMenuClose[(int)refCon - 1];
                        //need to return before we execute the command, so that the menu unhighlights
                        Gtk.Application.Invoke(delegate
                        {
                            manager.DispatchCommand(cmdID, data, CommandSource.MainMenu);
                        });
                    }
                    else
                    {
                        Gtk.Application.Invoke(delegate
                        {
                            manager.DispatchCommand(cmdID, CommandSource.MainMenu);
                        });
                    }
                    DestroyOldMenuObjects();
                    return(CarbonEventHandlerStatus.Handled);
                }
            }
            catch (Exception ex)
            {
                MonoDevelop.Core.LoggingService.LogError("Unhandled error handling menu command", ex);
            }
            return(CarbonEventHandlerStatus.NotHandled);
        }
        public override void Initialize()
        {
            base.Initialize();

            var image = Xwt.Drawing.Image.FromResource(typeof(MacPlatformService).Assembly, "maintoolbarbg.png");

            Window.Realized += delegate {
                NSWindow w = GtkQuartz.GetWindow(Window);
                w.IsOpaque        = false;
                w.BackgroundColor = NSColor.FromPatternImage(image.ToBitmap().ToNSImage());
                w.StyleMask      |= NSWindowStyle.TexturedBackground;
            };

            toolbar                = new CustomToolbar();
            toolbar.Background     = (Gdk.Pixbuf)Xwt.Toolkit.Load(Xwt.ToolkitType.Gtk).GetNativeImage(image);
            toolbar.TitleBarHeight = MacPlatformService.GetTitleBarHeight();
            MainBox.PackStart(toolbar, false, false, 0);
            ((Gtk.Box.BoxChild)MainBox [toolbar]).Position = 0;
        }
Exemple #3
0
        public override void Initialize()
        {
            base.Initialize();

            var resource = "maintoolbarbg.png";

            Window.Realized += delegate {
                NSWindow w = GtkQuartz.GetWindow(Window);
                w.IsOpaque = false;
                NSImage img = MacPlatformService.LoadImage(resource);
                w.BackgroundColor = NSColor.FromPatternImage(img);
                w.StyleMask      |= NSWindowStyle.TexturedBackground;
            };

            toolbar                = new CustomToolbar();
            toolbar.Background     = MonoDevelop.Components.CairoExtensions.LoadImage(typeof(MacPlatformService).Assembly, resource);
            toolbar.TitleBarHeight = MacPlatformService.GetTitleBarHeight();
            MainBox.PackStart(toolbar, false, false, 0);
            ((Gtk.Box.BoxChild)MainBox [toolbar]).Position = 0;
        }
		public LaunchServicesTests ()
		{
			platformService = new MacPlatformService ();
		}