public void Dispose() { if (label != null) { label.Realized -= HandleStyleUpdate; label.StyleSet -= HandleStyleUpdate; label.Destroy(); label = null; } }
protected override void Dispose(bool disposing) { if (disposing && labelWidget != null) { labelWidget.Realized -= HandleStyleUpdate; labelWidget.StyleSet -= HandleStyleUpdate; labelWidget.Destroy(); labelWidget = null; } base.Dispose(disposing); }
public static string FilterFontName (string name) { if (name == "_DEFAULT_MONOSPACE") return DesktopService.DefaultMonospaceFont; if (name == "_DEFAULT_SANS") { var label = new Gtk.Label (""); string result = label.Style.FontDescription.Family + " " + ((int)label.Style.FontDesc.Size / Pango.Scale.PangoScale); label.Destroy (); return result; } return name; }
public static string FilterFontName(string name) { if (name == "_DEFAULT_MONOSPACE") { return(DesktopService.DefaultMonospaceFont); } if (name == "_DEFAULT_SANS") { var label = new Gtk.Label(""); string result = label.Style.FontDescription.Family + " " + ((int)label.Style.FontDesc.Size / Pango.Scale.PangoScale); label.Destroy(); return(result); } return(name); }
static void LoadDefaults () { if (defaultMonospaceFont != null) { defaultMonospaceFont.Dispose (); defaultSansFont.Dispose (); } #pragma warning disable 618 defaultMonospaceFontName = DesktopService.DefaultMonospaceFont; defaultMonospaceFont = FontDescription.FromString (defaultMonospaceFontName); #pragma warning restore 618 var label = new Gtk.Label (""); defaultSansFont = label.Style.FontDescription.Copy (); label.Destroy (); defaultSansFontName = defaultSansFont.ToString (); }
static void LoadDefaults() { if (defaultMonospaceFont != null) { defaultMonospaceFont.Dispose(); defaultSansFont.Dispose(); } #pragma warning disable 618 defaultMonospaceFontName = DesktopService.DefaultMonospaceFont; defaultMonospaceFont = FontDescription.FromString(defaultMonospaceFontName); #pragma warning restore 618 var label = new Gtk.Label(""); defaultSansFont = label.Style.FontDescription.Copy(); label.Destroy(); defaultSansFontName = defaultSansFont.ToString(); }
// Constructor /// <summary> /// Create a <see cref="CoverDatabase"/ > object. /// </summary> /// <param name="version"> /// Version of the database to use. /// </param> public CoverDatabase(int version) { db = new Database(FileUtils.CoversDBFile, version); covers = new Hashtable(); // Hack to get the GtkStyle Gtk.Label label = new Gtk.Label(String.Empty); label.EnsureStyle(); downloading_pixbuf = label.RenderIcon ("muine-cover-downloading", StockIcons.CoverSize, null); label.Destroy(); getter = new CoverGetter(this); }
void EnsureLayoutCreated (TextEditor editor) { if (editor.ColorStyle != null) { bool isError = errors.Any (e => e.IsError); string typeString = isError ? "error" : "warning"; gc = (HslColor)(editor.ColorStyle.GetChunkStyle ("bubble." + typeString + ".text").Color); gcSelected = (HslColor)editor.ColorStyle.Selection.Color; gcLight = new Cairo.Color (1, 1, 1); colorMatrix[0, 0, 0, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor (editor.ColorStyle.GetChunkStyle ("bubble." + typeString + ".light.color1").Color); colorMatrix[0, 1, 0, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor (editor.ColorStyle.GetChunkStyle ("bubble." + typeString + ".light.color2").Color); colorMatrix[0, 0, 1, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor (editor.ColorStyle.GetChunkStyle ("bubble." + typeString + ".dark.color1").Color); colorMatrix[0, 1, 1, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor (editor.ColorStyle.GetChunkStyle ("bubble." + typeString + ".dark.color2").Color); colorMatrix[0, 0, 2, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor (editor.ColorStyle.GetChunkStyle ("bubble." + typeString + ".line.top").Color); colorMatrix[0, 1, 2, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor (editor.ColorStyle.GetChunkStyle ("bubble." + typeString + ".line.bottom").Color); colorMatrix[1, 0, 0, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor (editor.ColorStyle.GetChunkStyle ("bubble.inactive." + typeString + ".light.color1").Color); colorMatrix[1, 1, 0, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor (editor.ColorStyle.GetChunkStyle ("bubble.inactive." + typeString + ".light.color2").Color); colorMatrix[1, 0, 1, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor (editor.ColorStyle.GetChunkStyle ("bubble.inactive." + typeString + ".dark.color1").Color); colorMatrix[1, 1, 1, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor (editor.ColorStyle.GetChunkStyle ("bubble.inactive." + typeString + ".dark.color2").Color); colorMatrix[1, 0, 2, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor (editor.ColorStyle.GetChunkStyle ("bubble.inactive." + typeString + ".line.top").Color); colorMatrix[1, 1, 2, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor (editor.ColorStyle.GetChunkStyle ("bubble.inactive." + typeString + ".line.bottom").Color); double factor = 1.03; for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { for (int k = 0; k < 3; k++) { HslColor color = colorMatrix[i, j, k, 0, 0]; color.L *= factor; colorMatrix[i, j, k, 1, 0] = color; } } } var selectionColor = Style.ToCairoColor (editor.ColorStyle.Selection.BackgroundColor); for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { for (int k = 0; k < 3; k++) { for (int l = 0; l < 2; l++) { var color = colorMatrix[i, j, k, l, 0]; colorMatrix[i, j, k, l, 1] = new Cairo.Color ((color.R + selectionColor.R * 1.5) / 2.5, (color.G + selectionColor.G * 1.5) / 2.5, (color.B + selectionColor.B * 1.5) / 2.5); } } } } } if (layouts != null) return; layouts = new List<LayoutDescriptor> (); fontDescription = Pango.FontDescription.FromString (editor.Options.FontName); var label = new Gtk.Label (""); fontDescription.Family = label.Style.FontDescription.Family; label.Destroy (); fontDescription.Size = (int)(fontDescription.Size * 0.9f * editor.Options.Zoom); foreach (ErrorText errorText in errors) { Pango.Layout layout = new Pango.Layout (editor.PangoContext); layout.FontDescription = fontDescription; layout.SetText (errorText.ErrorMessage); KeyValuePair<int, int> textSize; if (!textWidthDictionary.TryGetValue (errorText.ErrorMessage, out textSize)) { int w, h; layout.GetPixelSize (out w, out h); textSize = new KeyValuePair<int, int> (w, h); textWidthDictionary[errorText.ErrorMessage] = textSize; } layouts.Add (new LayoutDescriptor (layout, textSize.Key, textSize.Value)); } if (errorCountLayout == null && errors.Count > 1) { errorCountLayout = new Pango.Layout (editor.PangoContext); errorCountLayout.FontDescription = fontDescription; errorCountLayout.SetText (errors.Count.ToString ()); } }
void EnsureLayoutCreated(TextEditor editor) { if (editor.ColorStyle != null && gc == null) { bool isError = errors.Any(e => e.IsError); string typeString = isError ? "error" : "warning"; gc = new Gdk.GC(editor.GdkWindow); gc.RgbFgColor = editor.ColorStyle.GetChunkStyle("bubble." + typeString + ".text").Color; gcSelected = new Gdk.GC(editor.GdkWindow); gcSelected.RgbFgColor = editor.ColorStyle.Selection.Color; gcLight = new Gdk.GC(editor.GdkWindow); gcLight.RgbFgColor = new Gdk.Color(255, 255, 255); colorMatrix[0, 0, 0, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(editor.ColorStyle.GetChunkStyle("bubble." + typeString + ".light.color1").Color); colorMatrix[0, 1, 0, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(editor.ColorStyle.GetChunkStyle("bubble." + typeString + ".light.color2").Color); colorMatrix[0, 0, 1, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(editor.ColorStyle.GetChunkStyle("bubble." + typeString + ".dark.color1").Color); colorMatrix[0, 1, 1, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(editor.ColorStyle.GetChunkStyle("bubble." + typeString + ".dark.color2").Color); colorMatrix[0, 0, 2, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(editor.ColorStyle.GetChunkStyle("bubble." + typeString + ".line.top").Color); colorMatrix[0, 1, 2, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(editor.ColorStyle.GetChunkStyle("bubble." + typeString + ".line.bottom").Color); colorMatrix[1, 0, 0, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(editor.ColorStyle.GetChunkStyle("bubble.inactive." + typeString + ".light.color1").Color); colorMatrix[1, 1, 0, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(editor.ColorStyle.GetChunkStyle("bubble.inactive." + typeString + ".light.color2").Color); colorMatrix[1, 0, 1, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(editor.ColorStyle.GetChunkStyle("bubble.inactive." + typeString + ".dark.color1").Color); colorMatrix[1, 1, 1, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(editor.ColorStyle.GetChunkStyle("bubble.inactive." + typeString + ".dark.color2").Color); colorMatrix[1, 0, 2, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(editor.ColorStyle.GetChunkStyle("bubble.inactive." + typeString + ".line.top").Color); colorMatrix[1, 1, 2, 0, 0] = Mono.TextEditor.Highlighting.Style.ToCairoColor(editor.ColorStyle.GetChunkStyle("bubble.inactive." + typeString + ".line.bottom").Color); double factor = 1.03; for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { for (int k = 0; k < 3; k++) { HslColor color = colorMatrix[i, j, k, 0, 0]; color.L *= factor; colorMatrix[i, j, k, 1, 0] = color; } } } var selectionColor = Style.ToCairoColor(editor.ColorStyle.Selection.BackgroundColor); for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { for (int k = 0; k < 3; k++) { for (int l = 0; l < 2; l++) { var color = colorMatrix[i, j, k, l, 0]; colorMatrix[i, j, k, l, 1] = new Cairo.Color((color.R + selectionColor.R * 1.5) / 2.5, (color.G + selectionColor.G * 1.5) / 2.5, (color.B + selectionColor.B * 1.5) / 2.5); } } } } } if (layouts != null) { return; } layouts = new List <LayoutDescriptor> (); fontDescription = Pango.FontDescription.FromString(editor.Options.FontName); var label = new Gtk.Label(""); fontDescription.Family = label.Style.FontDescription.Family; label.Destroy(); fontDescription.Size = (int)(fontDescription.Size * 0.9f * editor.Options.Zoom); foreach (ErrorText errorText in errors) { Pango.Layout layout = new Pango.Layout(editor.PangoContext); layout.FontDescription = fontDescription; layout.SetText(errorText.ErrorMessage); KeyValuePair <int, int> textSize; if (!textWidthDictionary.TryGetValue(errorText.ErrorMessage, out textSize)) { int w, h; layout.GetPixelSize(out w, out h); textSize = new KeyValuePair <int, int> (w, h); textWidthDictionary[errorText.ErrorMessage] = textSize; } layouts.Add(new LayoutDescriptor(layout, textSize.Key, textSize.Value)); } if (errorCountLayout == null && errors.Count > 1) { errorCountLayout = new Pango.Layout(editor.PangoContext); errorCountLayout.FontDescription = fontDescription; errorCountLayout.SetText(errors.Count.ToString()); } }