diff --git a/program/SoundWindow.cs b/program/SoundWindow.cs index 4f53b6f..21def8c 100644 --- a/program/SoundWindow.cs +++ b/program/SoundWindow.cs @@ -242,6 +242,8 @@ SoundButtonGrid.Valign = Align.Center; SoundButtonGrid.ColumnSpacing = 28; SoundButtonGrid.RowSpacing = 28; + SoundButtonGrid.ColumnHomogeneous = false; + SoundButtonGrid.RowHomogeneous = false; int i = 0; foreach (string text in list) @@ -261,6 +263,10 @@ SoundButtonGrid.Valign = Align.Start; SoundButtonGrid.ColumnSpacing = 10; SoundButtonGrid.RowSpacing = 10; + // English: some names wrap to 2 lines — make every button the same + // width and height so the grid stays even. Japanese layout unchanged. + SoundButtonGrid.ColumnHomogeneous = En; + SoundButtonGrid.RowHomogeneous = En; int rows = (list.Count + ListColumns - 1) / ListColumns; bool compact = rows > ListRowsFit; @@ -360,9 +366,22 @@ var col = new Box(Orientation.Vertical, 2); col.Valign = Align.Center; - var l1 = new Label(main); + Label l1; + if (En) + { + // Long English names ("Hypertrophic obstructive cardiomyopathy") wrap + // to a 2nd line; "…" only if 2 lines still aren't enough. + l1 = new MultiLineLabel(main, 2); + l1.LineWrap = true; + l1.LineWrapMode = Pango.WrapMode.Word; + l1.MaxWidthChars = 1; // don't let long text widen its column + } + else + { + l1 = new Label(main); // Japanese: unchanged, 1 line + } l1.Xalign = 0; - l1.Ellipsize = Pango.EllipsizeMode.End; + l1.Ellipsize = Pango.EllipsizeMode.End; // GTK's "lines" needs this set l1.StyleContext.AddClass("clip-main"); col.PackStart(l1, false, false, 0); @@ -524,3 +543,14 @@ cr.LineTo(50, 30); } } + +/// Gtk.Label with GTK3's "lines" property (max lines before ellipsizing). +/// This gtk-sharp binding has no Label.Lines and SetProperty is protected, +/// so it is set from a subclass. CSS still matches it as a normal "label". +public class MultiLineLabel : Label +{ + public MultiLineLabel(string text, int lines) : base(text) + { + SetProperty("lines", new GLib.Value(lines)); + } +}