static void SetupWithoutBundle() { // set a bundle IDE to prevent NSProgress crash // https://bugzilla.xamarin.com/show_bug.cgi?id=8850 NSBundle.MainBundle.InfoDictionary ["CFBundleIdentifier"] = new NSString("com.xamarin.monodevelop"); FilePath exePath = System.Reflection.Assembly.GetExecutingAssembly().Location; string iconFile = null; iconFile = BrandingService.GetString("ApplicationIcon"); if (iconFile != null) { iconFile = BrandingService.GetFile(iconFile); } else { var bundleRoot = GetAppBundleRoot(exePath); if (bundleRoot.IsNotNull) { //running from inside an app bundle, use its icon iconFile = bundleRoot.Combine("Contents", "Resources", "monodevelop.icns"); } else { // assume running from build directory var mdSrcMain = exePath.ParentDirectory.ParentDirectory.ParentDirectory; iconFile = mdSrcMain.Combine("theme-icons", "Mac", "monodevelop.icns"); } } if (File.Exists(iconFile)) { NSApplication.SharedApplication.ApplicationIconImage = new NSImage(iconFile); } }
static IdeCustomizer LoadBrandingCustomizer() { var pathsString = BrandingService.GetString("CustomizerAssemblyPath"); if (string.IsNullOrEmpty(pathsString)) { return(null); } var paths = pathsString.Split(new [] { ';' }, StringSplitOptions.RemoveEmptyEntries); var type = BrandingService.GetString("CustomizerType"); if (!string.IsNullOrEmpty(type)) { foreach (var path in paths) { var file = BrandingService.GetFile(path.Replace('/', Path.DirectorySeparatorChar)); if (File.Exists(file)) { Assembly asm = Runtime.LoadAssemblyFrom(file); var t = asm.GetType(type, true); var c = Activator.CreateInstance(t) as IdeCustomizer; if (c == null) { throw new InvalidOperationException("Customizer class specific in the branding file is not an IdeCustomizer subclass"); } return(c); } } } return(null); }
static void SetupDockIcon() { NSObject initialBundleIconFileValue; // Don't do anything if we're inside an app bundle. if (NSBundle.MainBundle.InfoDictionary.TryGetValue(new NSString("CFBundleIconFile"), out initialBundleIconFileValue)) { return; } // Setup without bundle. FilePath exePath = System.Reflection.Assembly.GetExecutingAssembly().Location; string iconName = BrandingService.GetString("ApplicationIcon"); string iconFile = null; if (iconName != null) { iconFile = BrandingService.GetFile(iconName); } else { // assume running from build directory var mdSrcMain = exePath.ParentDirectory.ParentDirectory.ParentDirectory; iconFile = mdSrcMain.Combine("theme-icons", "Mac", "monodevelop.icns"); } if (File.Exists(iconFile)) { var image = new NSImage(); var imageFile = new NSString(iconFile); IntPtr p = IntPtr_objc_msgSend_IntPtr(image.Handle, Selector.GetHandle("initByReferencingFile:"), imageFile.Handle); NSApplication.SharedApplication.ApplicationIconImage = ObjCRuntime.Runtime.GetNSObject <NSImage> (p); } }
public WelcomePageFirstRun() { VisibleWindow = false; SetSizeRequest(WidgetSize.Width, WidgetSize.Height); string iconFile = BrandingService.GetString("ApplicationIcon"); if (iconFile != null) { iconFile = BrandingService.GetFile(iconFile); brandedIcon = Xwt.Drawing.Image.FromFile(iconFile); } TitleOffset = TextOffset = IconOffset = new Gdk.Point(); tracker = new MouseTracker(this); tracker.MouseMoved += (sender, e) => { ButtonHovered = new Gdk.Rectangle(ButtonPosistion, ButtonSize).Contains(tracker.MousePosition); }; tracker.HoveredChanged += (sender, e) => { if (!tracker.Hovered) { ButtonHovered = false; } }; }
static void SetupDockIcon() { FilePath exePath = System.Reflection.Assembly.GetExecutingAssembly().Location; NSObject initialBundleIconFileValue; string iconFile = null; // Try setting a dark variant of the application dock icon if one exists in the app bundle. if (NSBundle.MainBundle.InfoDictionary.TryGetValue(new NSString("CFBundleIconFile"), out initialBundleIconFileValue)) { FilePath bundleIconRoot = GetAppBundleRoot(exePath).Combine("Contents", "Resources"); NSString initialBundleIconFile = (NSString)initialBundleIconFileValue; if (IdeApp.Preferences.UserInterfaceSkin == Skin.Dark) { iconFile = bundleIconRoot.Combine(Path.GetFileNameWithoutExtension(initialBundleIconFile) + "~dark" + Path.GetExtension(initialBundleIconFile)); } // There is no monodevelop~dark.icns, fallback to monodevelop.icns if (IdeApp.Preferences.UserInterfaceSkin == Skin.Light || iconFile == null || !File.Exists(iconFile)) { iconFile = bundleIconRoot.Combine(initialBundleIconFile); } } else { // Setup without bundle. string iconName = BrandingService.GetString("ApplicationIcon"); if (iconName != null) { if (IdeApp.Preferences.UserInterfaceSkin == Skin.Dark) { string darkIconName = Path.GetFileNameWithoutExtension(iconName) + "~dark" + Path.GetExtension(iconName); iconFile = BrandingService.GetFile(darkIconName); } if (IdeApp.Preferences.UserInterfaceSkin == Skin.Light || iconFile == null) { iconFile = BrandingService.GetFile(iconName); } } else { // assume running from build directory var mdSrcMain = exePath.ParentDirectory.ParentDirectory.ParentDirectory; iconFile = mdSrcMain.Combine("theme-icons", "Mac", "monodevelop.icns"); } } if (File.Exists(iconFile)) { NSApplication.SharedApplication.ApplicationIconImage = new NSImage(iconFile); } }
//this is a popup so it behaves like other splashes on Windows, i.e. doesn't show up as a second window in the taskbar. public SplashScreenForm() : base(WindowType.Popup) { AppPaintable = true; this.Decorated = false; this.WindowPosition = WindowPosition.Center; this.TypeHint = Gdk.WindowTypeHint.Splashscreen; this.showVersionInfo = BrandingService.GetBool("SplashScreen", "ShowVersionInfo") ?? true; var file = BrandingService.GetFile("SplashScreen.png"); if (file != null) { bitmap = Xwt.Drawing.Image.FromFile(file); } else { bitmap = Xwt.Drawing.Image.FromResource("SplashScreen.png"); } this.Resize((int)bitmap.Width, (int)bitmap.Height); MessageService.PopupDialog += HandlePopupDialog; }
public AboutMonoDevelopTabPage() { BorderWidth = 0; var aboutFile = BrandingService.GetFile("AboutImage.png"); if (aboutFile != null) { imageSep = Xwt.Drawing.Image.FromFile(aboutFile); } else { imageSep = Xwt.Drawing.Image.FromResource("AboutImage.png"); } PackStart(new ImageView(imageSep), false, false, 0); Xwt.VBox infoBox = new Xwt.VBox(); Xwt.FrameBox mbox = new Xwt.FrameBox(infoBox); infoBox.Spacing = 6; infoBox.Margin = 12; PackStart(mbox.ToGtkWidget(), false, false, 0); infoBox.PackStart(new Xwt.Label() { Text = GettextCatalog.GetString("Version"), Font = infoBox.Font.WithWeight(Xwt.Drawing.FontWeight.Bold) }); infoBox.PackStart(new Xwt.Label() { Text = IdeVersionInfo.MonoDevelopVersion, MarginLeft = 12 }); infoBox.PackStart(new Xwt.Label() { Text = GettextCatalog.GetString("License"), Font = infoBox.Font.WithWeight(Xwt.Drawing.FontWeight.Bold) }); infoBox.PackStart(new Xwt.Label() { Text = GettextCatalog.GetString("Released under the GNU Lesser General Public License."), MarginLeft = 12 }); infoBox.PackStart(new Xwt.Label() { Text = GettextCatalog.GetString("Copyright"), Font = infoBox.Font.WithWeight(Xwt.Drawing.FontWeight.Bold) }); var cbox = new Xwt.HBox() { Spacing = 0, MarginLeft = 12 }; cbox.PackStart(new Xwt.Label("© 2011-" + DateTime.Now.Year + " ")); cbox.PackStart(new Xwt.LinkLabel() { Text = string.Format("Xamarin Inc."), Uri = new Uri("http://www.xamarin.com") }); infoBox.PackStart(cbox); infoBox.PackStart(new Xwt.Label() { Text = "© 2004-" + DateTime.Now.Year + " MonoDevelop contributors", MarginLeft = 12 }); cbox = new Xwt.HBox() { Spacing = 0, MarginLeft = 12 }; cbox.PackStart(new Xwt.Label("Some icons by ")); cbox.PackStart(new Xwt.LinkLabel() { Text = string.Format("Yusuke Kamiyamane"), Uri = new Uri("http://p.yusukekamiyamane.com") }); infoBox.PackStart(cbox); cbox = new Xwt.HBox() { Spacing = 0, MarginLeft = 12 }; cbox.PackStart(new Xwt.Label("Some icons from the ")); cbox.PackStart(new Xwt.LinkLabel() { Text = string.Format("Silk icon set"), Uri = new Uri("http://www.famfamfam.com/") }); infoBox.PackStart(cbox); this.ShowAll(); }
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; } }
public AboutMonoDevelopTabPage() { BorderWidth = 0; var aboutFile = BrandingService.GetFile(AboutDialogImage.Name); if (aboutFile != null) { imageSep = Xwt.Drawing.Image.FromFile(aboutFile); } else { imageSep = Xwt.Drawing.Image.FromResource(AboutDialogImage.Name); } var iv = new ImageView(imageSep); iv.SetCommonAccessibilityAttributes("AboutImage", BrandingService.ApplicationLongName, ""); PackStart(iv, false, false, 0); Xwt.VBox infoBox = new Xwt.VBox(); Xwt.FrameBox mbox = new Xwt.FrameBox(infoBox); infoBox.Spacing = 6; infoBox.Margin = 12; PackStart(mbox.ToGtkWidget(), false, false, 0); infoBox.PackStart(new Xwt.Label() { Markup = string.Format("<b>{0}</b>", GettextCatalog.GetString("Version")), MarginTop = 6, }); infoBox.PackStart(new Xwt.Label() { Text = IdeVersionInfo.MonoDevelopVersion, MarginLeft = 12 }); if (BrandingService.LicenseTermsUrl != null) { infoBox.PackStart(new Xwt.Label() { Markup = string.Format("<b>{0}</b>", GettextCatalog.GetString("License")), MarginTop = 6, }); var linkLabel = new Xwt.Label { Markup = "<span underline='true'>License Terms</span>", Cursor = Xwt.CursorType.Hand, MarginLeft = 12 }; if (IdeTheme.UserInterfaceTheme == Theme.Light) { linkLabel.Markup = string.Format("<span color='#5C2D91'>{0}</span>", linkLabel.Markup); } linkLabel.ButtonReleased += (sender, e) => DesktopService.ShowUrl(BrandingService.LicenseTermsUrl); infoBox.PackStart(linkLabel); if (BrandingService.PrivacyStatementUrl != null) { linkLabel = new Xwt.Label { Markup = string.Format("<span underline='true'>{0}</span>", GettextCatalog.GetString("Privacy Statement")), Cursor = Xwt.CursorType.Hand, MarginLeft = 12 }; if (IdeTheme.UserInterfaceTheme == Theme.Light) { linkLabel.Markup = string.Format("<span color='#5C2D91'>{0}</span>", linkLabel.Markup); } linkLabel.ButtonReleased += (sender, e) => DesktopService.ShowUrl(BrandingService.PrivacyStatementUrl); infoBox.PackStart(linkLabel); } } infoBox.PackStart(new Xwt.Label() { Markup = string.Format("<b>{0}</b>", GettextCatalog.GetString("Copyright")), MarginTop = 6, }); infoBox.PackStart(new Xwt.Label() { Text = (DateTime.Now.Year == 2016 ? "© 2016" : "© 2016–" + DateTime.Now.Year) + " Microsoft Corp.", MarginLeft = 12 }); infoBox.PackStart(new Xwt.Label() { Text = "© 2004–" + DateTime.Now.Year + " Xamarin Inc.", MarginLeft = 12 }); infoBox.PackStart(new Xwt.Label() { Text = "© 2004–" + DateTime.Now.Year + " MonoDevelop contributors", MarginLeft = 12 }); this.ShowAll(); }
public AboutMonoDevelopTabPage() { BorderWidth = 0; var aboutFile = BrandingService.GetFile(AboutDialogImage.Name); if (aboutFile != null) { imageSep = Xwt.Drawing.Image.FromFile(aboutFile); } else { imageSep = Xwt.Drawing.Image.FromResource(AboutDialogImage.Name); } PackStart(new ImageView(imageSep), false, false, 0); Xwt.VBox infoBox = new Xwt.VBox(); Xwt.FrameBox mbox = new Xwt.FrameBox(infoBox); infoBox.Spacing = 6; infoBox.Margin = 12; PackStart(mbox.ToGtkWidget(), false, false, 0); infoBox.PackStart(new Xwt.Label() { Markup = string.Format("<b>{0}</b>", GettextCatalog.GetString("Version")), MarginTop = 6, }); infoBox.PackStart(new Xwt.Label() { Text = IdeVersionInfo.MonoDevelopVersion, MarginLeft = 12 }); infoBox.PackStart(new Xwt.Label() { Markup = string.Format("<b>{0}</b>", GettextCatalog.GetString("License")), MarginTop = 6, }); var cbox = new Xwt.HBox() { Spacing = 0, MarginLeft = 12 }; var linkLabel = new Xwt.Label { Markup = "<span underline='true'>License Terms</span>", Cursor = Xwt.CursorType.Hand, }; if (IdeTheme.UserInterfaceTheme == Theme.Light) { linkLabel.Markup = string.Format("<span color='#5C2D91'>{0}</span>", linkLabel.Markup); } linkLabel.ButtonReleased += (sender, e) => { var binDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); string licensePath = System.IO.Path.Combine(binDir, "branding", "License.txt"); if (Platform.IsMac) { var appDir = System.IO.Path.GetFullPath(System.IO.Path.Combine(binDir, "..", "..", "..", "..", "..")); if (appDir.EndsWith(".app", StringComparison.Ordinal)) { licensePath = System.IO.Path.Combine(appDir, "Contents", "License.txt"); } } if (!File.Exists(licensePath)) { MessageService.ShowError("License file is missing"); } else { DesktopService.OpenFile(licensePath); } }; cbox.PackStart(linkLabel); infoBox.PackStart(cbox); linkLabel = new Xwt.Label { Markup = string.Format("<span underline='true'>{0}</span>", GettextCatalog.GetString("Privacy Statement")), Cursor = Xwt.CursorType.Hand, MarginLeft = 12 }; //TODO: factor out const string PRIVACY_URL = "https://go.microsoft.com/fwlink/?LinkID=824704"; if (IdeTheme.UserInterfaceTheme == Theme.Light) { linkLabel.Markup = string.Format("<span color='#5C2D91'>{0}</span>", linkLabel.Markup); } linkLabel.ButtonReleased += (sender, e) => DesktopService.ShowUrl(PRIVACY_URL); infoBox.PackStart(linkLabel); infoBox.PackStart(new Xwt.Label() { Markup = string.Format("<b>{0}</b>", GettextCatalog.GetString("Copyright")), MarginTop = 6, }); infoBox.PackStart(new Xwt.Label() { Text = (DateTime.Now.Year == 2016 ? "© 2016" : "© 2016–" + DateTime.Now.Year) + " Microsoft Corp.", MarginLeft = 12 }); infoBox.PackStart(new Xwt.Label() { Text = "© 2004–" + DateTime.Now.Year + " Xamarin Inc.", MarginLeft = 12 }); infoBox.PackStart(new Xwt.Label() { Text = "© 2004–" + DateTime.Now.Year + " MonoDevelop contributors", MarginLeft = 12 }); this.ShowAll(); }
public AboutMonoDevelopTabPage() { BorderWidth = 0; var aboutFile = BrandingService.GetFile(AboutDialogImage.Name); if (aboutFile != null) { imageSep = Xwt.Drawing.Image.FromFile(aboutFile); } else { imageSep = Xwt.Drawing.Image.FromResource(AboutDialogImage.Name); } PackStart(new ImageView(imageSep), false, false, 0); Xwt.VBox infoBox = new Xwt.VBox(); Xwt.FrameBox mbox = new Xwt.FrameBox(infoBox); infoBox.Spacing = 6; infoBox.Margin = 12; PackStart(mbox.ToGtkWidget(), false, false, 0); infoBox.PackStart(new Xwt.Label() { Text = GettextCatalog.GetString("Version"), Font = infoBox.Font.WithWeight(Xwt.Drawing.FontWeight.Bold) }); infoBox.PackStart(new Xwt.Label() { Text = IdeVersionInfo.MonoDevelopVersion, MarginLeft = 12 }); infoBox.PackStart(new Xwt.Label() { Text = GettextCatalog.GetString("License"), Font = infoBox.Font.WithWeight(Xwt.Drawing.FontWeight.Bold) }); var cbox = new Xwt.HBox() { Spacing = 0, MarginLeft = 12 }; cbox.PackStart(new Xwt.Label() { Text = GettextCatalog.GetString("License is available at ") }); cbox.PackStart(new Xwt.LinkLabel() { Text = string.Format("http://xamarin.com/xamarin-studio-license"), Uri = new Uri("http://xamarin.com/xamarin-studio-license") }); infoBox.PackStart(cbox); infoBox.PackStart(new Xwt.Label() { Text = GettextCatalog.GetString("Copyright"), Font = infoBox.Font.WithWeight(Xwt.Drawing.FontWeight.Bold) }); cbox = new Xwt.HBox() { Spacing = 0, MarginLeft = 12 }; cbox.PackStart(new Xwt.Label("© 2011-" + DateTime.Now.Year + " ")); cbox.PackStart(new Xwt.LinkLabel() { Text = string.Format("Xamarin Inc."), Uri = new Uri("http://www.xamarin.com") }); infoBox.PackStart(cbox); infoBox.PackStart(new Xwt.Label() { Text = "© 2004-" + DateTime.Now.Year + " MonoDevelop contributors", MarginLeft = 12 }); this.ShowAll(); }