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); }
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 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 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); } }
static WelcomePageBranding() { try { using (var stream = BrandingService.GetStream("WelcomePageContent.xml")) { Content = XDocument.Load(stream); } } catch (Exception ex) { LoggingService.LogError("Error while reading welcome page contents.", ex); using (var stream = typeof(WelcomePageBranding).Assembly.GetManifestResourceStream("WelcomePageContent.xml")) { Content = XDocument.Load(stream); } } try { HeaderTextSize = BrandingService.GetString("WelcomePage", "HeaderTextSize") ?? HeaderTextSize; HeaderTextColor = BrandingService.GetString("WelcomePage", "HeaderTextColor") ?? HeaderTextColor; BackgroundColor = BrandingService.GetString("WelcomePage", "BackgroundColor") ?? BackgroundColor; TextColor = BrandingService.GetString("WelcomePage", "TextColor") ?? TextColor; TextSize = BrandingService.GetString("WelcomePage", "TextSize") ?? TextSize; LinkColor = BrandingService.GetString("WelcomePage", "LinkColor") ?? LinkColor; Spacing = BrandingService.GetInt("WelcomePage", "Spacing") ?? Spacing; LogoHeight = BrandingService.GetInt("WelcomePage", "LogoHeight") ?? LogoHeight; } catch (Exception e) { LoggingService.LogError("Error while reading welcome page branding.", e); } }
void LoadBranding() { try { var textColStr = BrandingService.GetString("AboutBox", "TextColor"); if (textColStr != null) { Gdk.Color.Parse(textColStr, ref textColor); } var bgColStr = BrandingService.GetString("AboutBox", "BackgroundColor"); if (bgColStr != null) { Gdk.Color.Parse(bgColStr, ref bgColor); } //branders may provide either fg image or bg image, or both using (var stream = BrandingService.GetStream("AboutImage.png", false)) { image = (stream != null ? new Gdk.Pixbuf(stream) : null); } using (var streamBg = BrandingService.GetStream("AboutImageBg.png", false)) { imageBg = (streamBg != null ? new Gdk.Pixbuf(streamBg) : null); } //if branding did not provide any image, use the built-in one if (imageBg == null && image == null) { image = Gdk.Pixbuf.LoadFromResource("AboutImage.png"); } } catch (Exception ex) { LoggingService.LogError("Error loading about box branding", ex); } }
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); } }
void LoadBranding() { try { var textColStr = BrandingService.GetString("AboutBox", "TextColor"); if (textColStr != null) { Gdk.Color.Parse(textColStr, ref textColor); } var bgColStr = BrandingService.GetString("AboutBox", "BackgroundColor"); if (bgColStr != null) { Gdk.Color.Parse(bgColStr, ref bgColor); } } catch (Exception ex) { LoggingService.LogError("Error loading about box branding", ex); } }
Pango.Layout TextLayout(Pango.Context context) { var layout = new Pango.Layout(context); layout.FontDescription = Pango.FontDescription.FromString(Platform.IsMac ? Styles.WelcomeScreen.FontFamilyMac : Styles.WelcomeScreen.FontFamilyWindows); layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels(15); layout.Width = Pango.Units.FromPixels(420); layout.Wrap = Pango.WrapMode.Word; Pango.AttrRise rise = new Pango.AttrRise(Pango.Units.FromPixels(7)); layout.Attributes = new Pango.AttrList(); layout.Attributes.Insert(rise); string description = BrandingService.GetString("FirstRunDescription"); if (description != null) { description = description.Replace("\\n", "\n"); } layout.SetText(description ?? "No Text Set"); return(layout); }
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; } }