From ab6e95415e09483649b9362b26e204676a20a2a8 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Fri, 22 Dec 2017 11:57:36 +0100 Subject: [PATCH] mac: Fix crash due to inaccessible system font --- SparkleShare/Mac/UserInterface/EventLog.cs | 34 +++++++++--------- SparkleShare/Mac/UserInterface/Note.cs | 2 +- SparkleShare/Mac/UserInterface/Setup.cs | 36 +++++++++---------- SparkleShare/Mac/UserInterface/SetupWindow.cs | 3 +- .../Mac/UserInterface/UserInterface.cs | 1 + 5 files changed, 36 insertions(+), 40 deletions(-) diff --git a/SparkleShare/Mac/UserInterface/EventLog.cs b/SparkleShare/Mac/UserInterface/EventLog.cs index 2f7e7516..52aa690d 100644 --- a/SparkleShare/Mac/UserInterface/EventLog.cs +++ b/SparkleShare/Mac/UserInterface/EventLog.cs @@ -115,10 +115,10 @@ namespace SparkleShare { Bordered = false, Editable = false, Frame = new CGRect ( - new CGPoint (60, ContentView.Frame.Height - 27), + new CGPoint (60, ContentView.Frame.Height - 31), new CGSize (60, 20)), StringValue = "…", - Font = NSFont.FromFontName (UserInterface.FontName + " Bold", NSFont.SystemFontSize) + Font = NSFont.BoldSystemFontOfSize (12) }; @@ -139,11 +139,11 @@ namespace SparkleShare { Bordered = false, Editable = false, Frame = new CGRect ( - new CGPoint (190, ContentView.Frame.Height - 27), + new CGPoint (190, ContentView.Frame.Height - 31), new CGSize (60, 20) ), StringValue = "…", - Font = NSFont.FromFontName (UserInterface.FontName + " Bold", NSFont.SystemFontSize) + Font = NSFont.BoldSystemFontOfSize (12) }; this.popup_button = new NSPopUpButton () { @@ -302,17 +302,17 @@ namespace SparkleShare { this.popup_button.AddItem ("Summary"); this.popup_button.Menu.AddItem (NSMenuItem.SeparatorItem); - - int row = 2; - foreach (string folder in folders) { + + int row = 2; + foreach (string folder in folders) { this.popup_button.AddItem (folder); - - if (folder.Equals (Controller.SelectedFolder)) - this.popup_button.SelectItem (row); - - row++; - } - + + if (folder.Equals (Controller.SelectedFolder)) + this.popup_button.SelectItem (row); + + row++; + } + this.popup_button.AddItems (folders); this.popup_button.Activated += delegate { @@ -328,8 +328,8 @@ namespace SparkleShare { public void UpdateContent (string html) { - string pixmaps_path = "file://" + NSBundle.MainBundle.ResourcePath; - + string pixmaps_path = "file://" + NSBundle.MainBundle.ResourcePath; + html = html.Replace ("", UserInterface.FontName); html = html.Replace ("", "13.6px"); html = html.Replace ("", "13.4px"); @@ -344,7 +344,7 @@ namespace SparkleShare { html = html.Replace ("", pixmaps_path + "/document-deleted-12.png"); html = html.Replace ("", pixmaps_path + "/document-edited-12.png"); html = html.Replace ("", pixmaps_path + "/document-moved-12.png"); - + this.web_view = new WebView (new CGRect (0, 0, 481, 579), "", "") { Frame = new CGRect (new CGPoint (0, 0), new CGSize (ContentView.Frame.Width, ContentView.Frame.Height - 39)) }; diff --git a/SparkleShare/Mac/UserInterface/Note.cs b/SparkleShare/Mac/UserInterface/Note.cs index 75d0a910..9e5c2472 100644 --- a/SparkleShare/Mac/UserInterface/Note.cs +++ b/SparkleShare/Mac/UserInterface/Note.cs @@ -101,7 +101,7 @@ namespace SparkleShare { new CGPoint (85, ContentView.Frame.Height - 41), new CGSize (320, 22)), StringValue = SparkleShare.Controller.CurrentUser.Name, - Font = NSFont.FromFontName (UserInterface.FontName + " Bold", NSFont.SystemFontSize) + Font = NSFont.BoldSystemFontOfSize (12) }; this.user_email_text_field = new NSTextField () { diff --git a/SparkleShare/Mac/UserInterface/Setup.cs b/SparkleShare/Mac/UserInterface/Setup.cs index 720658dd..75aca2a6 100644 --- a/SparkleShare/Mac/UserInterface/Setup.cs +++ b/SparkleShare/Mac/UserInterface/Setup.cs @@ -154,16 +154,15 @@ namespace SparkleShare { AddressLabel = new SparkleLabel ("Address:", NSTextAlignment.Right); AddressLabel.Frame = new CGRect (165, Frame.Height - 238, 160, 17); - AddressLabel.Font = NSFont.FromFontName (UserInterface.FontName + " Bold", NSFont.SystemFontSize); - + AddressLabel.Font = NSFont.BoldSystemFontOfSize (12); + AddressTextField = new SparkleLabel (Controller.PendingInvite.Address, NSTextAlignment.Left) { Frame = new CGRect (330, Frame.Height - 240, 260, 17) }; PathLabel = new SparkleLabel ("Remote Path:", NSTextAlignment.Right); PathLabel.Frame = new CGRect (165, Frame.Height - 262, 160, 17); - PathLabel.Font = NSFont.FromFontName (UserInterface.FontName + " Bold", NSFont.SystemFontSize); - + PathLabel.Font = NSFont.BoldSystemFontOfSize (12); PathTextField = new SparkleLabel (Controller.PendingInvite.RemotePath, NSTextAlignment.Left) { Frame = new CGRect (330, Frame.Height - 264, 260, 17) @@ -191,8 +190,8 @@ namespace SparkleShare { Description = ""; AddressLabel = new SparkleLabel ("Address:", NSTextAlignment.Left) { - Frame = new CGRect (190, Frame.Height - 308, 160, 17), - Font = NSFont.FromFontName (UserInterface.FontName + " Bold", NSFont.SystemFontSize) + Frame = new CGRect (190, Frame.Height - 310, 160, 17), + Font = NSFont.BoldSystemFontOfSize (12) }; AddressTextField = new NSTextField () { @@ -205,8 +204,8 @@ namespace SparkleShare { AddressTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail; PathLabel = new SparkleLabel ("Remote Path:", NSTextAlignment.Left) { - Frame = new CGRect (190 + 196 + 16, Frame.Height - 308, 160, 17), - Font = NSFont.FromFontName (UserInterface.FontName + " Bold", NSFont.SystemFontSize) + Frame = new CGRect (190 + 196 + 16, Frame.Height - 310, 160, 17), + Font = NSFont.BoldSystemFontOfSize (12) }; PathTextField = new NSTextField () { @@ -256,9 +255,6 @@ namespace SparkleShare { Editable = false }; - DescriptionColumn.DataCell.Font = NSFontManager.SharedFontManager.FontWithFamily ( - UserInterface.FontName, NSFontTraitMask.Condensed, 0, 11); - TableView.AddColumn (IconColumn); TableView.AddColumn (DescriptionColumn); @@ -411,7 +407,7 @@ namespace SparkleShare { string html = "