From d5982dd35f4287823d91ef111a14662f6eaec780 Mon Sep 17 00:00:00 2001 From: Chris Hamons Date: Mon, 19 Sep 2016 13:06:40 -0500 Subject: Port to Unified XM 4.5 (#1) --- .gitignore | 4 +++ AppDelegate.cs | 20 ++++++----- AppleDocMergeWindow.cs | 16 +++------ AppleDocMergeWindow.designer.cs | 8 ++--- AppleDocMergeWindowController.cs | 12 ++----- BookmarkAssistant.cs | 15 +++------ BookmarkAssistant.designer.cs | 8 ++--- BookmarkAssistantController.cs | 31 +++++++---------- BookmarkPopover.cs | 6 ++-- BookmarkPopover.designer.cs | 10 +++--- BookmarkPopoverController.cs | 14 +++----- FindBarExtraordinaire.cs | 14 +++----- FindBarExtraordinaire.designer.cs | 12 +++---- FindBarExtraordinaireController.cs | 14 +++----- Main.cs | 8 ++--- MainMenu.xib.designer.cs | 8 ++--- MonodocDataSources.cs | 34 +++++++++---------- MonodocDocumentController.cs | 6 ++-- MyDocument.cs | 44 +++++++++++------------- MyDocument.xib.designer.cs | 52 ++++++++++++++-------------- RootLauncher.cs | 69 +------------------------------------- WebViewExtraordinaire.cs | 18 ++++------ WebViewExtraordinaire.designer.cs | 2 +- history.cs | 2 +- macdoc.csproj | 18 ++++------ 25 files changed, 164 insertions(+), 281 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..83b31b0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +bin/* +obj/* +*.userprefs +.DS_Store diff --git a/AppDelegate.cs b/AppDelegate.cs index b7d584f..956e6c4 100644 --- a/AppDelegate.cs +++ b/AppDelegate.cs @@ -1,16 +1,16 @@ using System; using System.IO; using System.Linq; -using System.Drawing; +using CoreGraphics; using System.Threading; using System.Diagnostics; using System.Threading.Tasks; using System.Collections.Generic; using System.Runtime.InteropServices; -using MonoMac.Foundation; -using MonoMac.AppKit; -using MonoMac.ObjCRuntime; +using Foundation; +using AppKit; +using ObjCRuntime; using Monodoc; using System.Text; @@ -122,7 +122,7 @@ namespace macdoc } } - public override void FinishedLaunching (NSObject notification) + public override void DidFinishLaunching (NSNotification notification) { // Check if we are loaded with a search term and load a document for it var args = Environment.GetCommandLineArgs (); @@ -188,13 +188,14 @@ namespace macdoc public override void WillFinishLaunching (NSNotification notification) { - var selector = new MonoMac.ObjCRuntime.Selector ("handleGetURLEvent:withReplyEvent:"); + var selector = new ObjCRuntime.Selector ("handleGetURLEvent:withReplyEvent:"); NSAppleEventManager.SharedAppleEventManager.SetEventHandler (this, selector, AEEventClass.Internet, AEEventID.GetUrl); } - + + [Export ("handleGetURLEvent:withReplyEvent:")] public void HandleGetURLEvent (NSAppleEventDescriptor evt, NSAppleEventDescriptor replyEvt) { @@ -289,6 +290,9 @@ namespace macdoc mergeController.ShowWindow (this); mergeController.Window.Center (); } + + [DllImport (Constants.ObjectiveCLibrary, EntryPoint = "objc_msgSend")] + public extern static System.IntPtr IntPtr_objc_msgSend_IntPtr_bool_IntPtr (IntPtr receiver, IntPtr selector, IntPtr arg1, bool arg2, IntPtr arg3); // We use a working OpenDocument method that doesn't return anything because of MonoMac bug#3380 public void Call_OpenDocument (NSUrl absoluteUrl, bool displayDocument, out NSError outError) @@ -299,7 +303,7 @@ namespace macdoc IntPtr outErrorPtr = Marshal.AllocHGlobal(4); Marshal.WriteInt32(outErrorPtr, 0); - MonoMac.ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr_bool_IntPtr (controller.Handle, selOpenDocumentWithContentsOfURLDisplayError_, absoluteUrl.Handle, displayDocument, outErrorPtr); + IntPtr_objc_msgSend_IntPtr_bool_IntPtr (controller.Handle, selOpenDocumentWithContentsOfURLDisplayError_, absoluteUrl.Handle, displayDocument, outErrorPtr); } IntPtr selOpenDocumentWithContentsOfURLDisplayError_ = new Selector ("openDocumentWithContentsOfURL:display:error:").Handle; diff --git a/AppleDocMergeWindow.cs b/AppleDocMergeWindow.cs index c4f4d95..1aea668 100644 --- a/AppleDocMergeWindow.cs +++ b/AppleDocMergeWindow.cs @@ -1,28 +1,20 @@ - using System; using System.Collections.Generic; using System.Linq; -using MonoMac.Foundation; -using MonoMac.AppKit; +using Foundation; +using AppKit; namespace macdoc { - public partial class AppleDocMergeWindow : MonoMac.AppKit.NSWindow + public partial class AppleDocMergeWindow : AppKit.NSWindow { public AppleDocMergeWindow (IntPtr handle) : base (handle) { Initialize (); } - [Export ("initWithCoder:")] - public AppleDocMergeWindow (NSCoder coder) : base (coder) - { - Initialize (); - } - void Initialize () { } } -} - +} \ No newline at end of file diff --git a/AppleDocMergeWindow.designer.cs b/AppleDocMergeWindow.designer.cs index 1a11538..5c64520 100644 --- a/AppleDocMergeWindow.designer.cs +++ b/AppleDocMergeWindow.designer.cs @@ -4,7 +4,7 @@ // actions made in the Xcode designer. If it is removed, they will be lost. // Manual changes to this file may not be handled correctly. // -using MonoMac.Foundation; +using Foundation; namespace macdoc { @@ -12,13 +12,13 @@ namespace macdoc partial class AppleDocMergeWindowController { [Outlet] - MonoMac.AppKit.NSProgressIndicator ProgressWidget { get; set; } + AppKit.NSProgressIndicator ProgressWidget { get; set; } [Outlet] - MonoMac.AppKit.NSTextField WizardText { get; set; } + AppKit.NSTextField WizardText { get; set; } [Outlet] - MonoMac.AppKit.NSButton WizardButton { get; set; } + AppKit.NSButton WizardButton { get; set; } void ReleaseDesignerOutlets () { diff --git a/AppleDocMergeWindowController.cs b/AppleDocMergeWindowController.cs index 495e43a..50d9846 100644 --- a/AppleDocMergeWindowController.cs +++ b/AppleDocMergeWindowController.cs @@ -3,24 +3,18 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using MonoMac.Foundation; -using MonoMac.AppKit; +using Foundation; +using AppKit; namespace macdoc { - public partial class AppleDocMergeWindowController : MonoMac.AppKit.NSWindowController + public partial class AppleDocMergeWindowController : AppKit.NSWindowController { public AppleDocMergeWindowController (IntPtr handle) : base (handle) { Initialize (); } - [Export ("initWithCoder:")] - public AppleDocMergeWindowController (NSCoder coder) : base (coder) - { - Initialize (); - } - public AppleDocMergeWindowController () : base ("AppleDocMergeWindow") { Initialize (); diff --git a/BookmarkAssistant.cs b/BookmarkAssistant.cs index 0501f6a..199174f 100644 --- a/BookmarkAssistant.cs +++ b/BookmarkAssistant.cs @@ -1,24 +1,19 @@ using System; using System.Collections.Generic; using System.Linq; -using MonoMac.Foundation; -using MonoMac.AppKit; +using Foundation; +using AppKit; namespace macdoc { - public partial class BookmarkAssistant : MonoMac.AppKit.NSView + public partial class BookmarkAssistant : AppKit.NSView { public event Action BookmarkDeleted; public BookmarkAssistant (IntPtr handle) : base (handle) { } - - [Export ("initWithCoder:")] - public BookmarkAssistant (NSCoder coder) : base (coder) - { - } - + partial void DeleteButtonClicked (NSButton sender) { if (bookmarkTableView.SelectedRowCount != 1) @@ -29,7 +24,7 @@ namespace macdoc return; var temp = BookmarkDeleted; if (temp != null) - temp (index); + temp ((int)index); } public NSTableView TableView { diff --git a/BookmarkAssistant.designer.cs b/BookmarkAssistant.designer.cs index 2e796de..d95a1d0 100644 --- a/BookmarkAssistant.designer.cs +++ b/BookmarkAssistant.designer.cs @@ -4,7 +4,7 @@ // actions made in the Xcode designer. If it is removed, they will be lost. // Manual changes to this file may not be handled correctly. // -using MonoMac.Foundation; +using Foundation; namespace macdoc { @@ -12,13 +12,13 @@ namespace macdoc partial class BookmarkAssistant { [Outlet] - MonoMac.AppKit.NSTableView bookmarkTableView { get; set; } + AppKit.NSTableView bookmarkTableView { get; set; } [Outlet] - MonoMac.AppKit.NSButton deleteButton { get; set; } + AppKit.NSButton deleteButton { get; set; } [Action ("DeleteButtonClicked:")] - partial void DeleteButtonClicked (MonoMac.AppKit.NSButton sender); + partial void DeleteButtonClicked (AppKit.NSButton sender); void ReleaseDesignerOutlets () { diff --git a/BookmarkAssistantController.cs b/BookmarkAssistantController.cs index 86ba6d3..0c87dd5 100644 --- a/BookmarkAssistantController.cs +++ b/BookmarkAssistantController.cs @@ -1,12 +1,12 @@ using System; using System.Collections.Generic; using System.Linq; -using MonoMac.Foundation; -using MonoMac.AppKit; +using Foundation; +using AppKit; namespace macdoc { - public partial class BookmarkAssistantController : MonoMac.AppKit.NSViewController + public partial class BookmarkAssistantController : AppKit.NSViewController { IList entries; BookmarkDataSource source; @@ -14,12 +14,7 @@ namespace macdoc public BookmarkAssistantController (IntPtr handle) : base (handle) { } - - [Export ("initWithCoder:")] - public BookmarkAssistantController (NSCoder coder) : base (coder) - { - } - + public BookmarkAssistantController (IList entries) : base ("BookmarkAssistant", NSBundle.MainBundle) { this.entries = entries; @@ -53,32 +48,32 @@ namespace macdoc this.manager = manager; } - public override NSObject GetObjectValue (NSTableView tableView, NSTableColumn tableColumn, int row) + public override NSObject GetObjectValue (NSTableView tableView, NSTableColumn tableColumn, nint row) { if (tableColumn == null) return null; - int columnIndex = tableView.FindColumn ((NSString)tableColumn.Identifier); + var columnIndex = tableView.FindColumn ((NSString)tableColumn.Identifier); switch (columnIndex) { case 0: - return new NSString (entries[row].Name); + return new NSString (entries[(int)row].Name); case 1: - return new NSString (entries[row].Notes); + return new NSString (entries[(int)row].Notes); case 2: - return new NSString (entries[row].Url); + return new NSString (entries[(int)row].Url); default: return null; } } - public override void SetObjectValue (NSTableView tableView, NSObject theObject, NSTableColumn tableColumn, int row) + public override void SetObjectValue (NSTableView tableView, NSObject theObject, NSTableColumn tableColumn, nint row) { NSString newNSValue = theObject as NSString; if (newNSValue == null) return; string newValue = newNSValue.ToString (); - int columnIndex = tableView.FindColumn ((NSString)tableColumn.Identifier); - BookmarkManager.Entry entry = entries[row]; + var columnIndex = tableView.FindColumn ((NSString)tableColumn.Identifier); + BookmarkManager.Entry entry = entries[(int)row]; switch (columnIndex) { case 0: if (!string.IsNullOrWhiteSpace (newValue)) @@ -97,7 +92,7 @@ namespace macdoc manager.CommitBookmarkChange (entry); } - public override int GetRowCount (NSTableView tableView) + public override nint GetRowCount (NSTableView tableView) { return entries.Count; } diff --git a/BookmarkPopover.cs b/BookmarkPopover.cs index cbced4b..510776b 100644 --- a/BookmarkPopover.cs +++ b/BookmarkPopover.cs @@ -1,12 +1,12 @@ using System; using System.Collections.Generic; using System.Linq; -using MonoMac.Foundation; -using MonoMac.AppKit; +using Foundation; +using AppKit; namespace macdoc { - public partial class BookmarkPopover : MonoMac.AppKit.NSView + public partial class BookmarkPopover : AppKit.NSView { public class BookmarkEventArgs : EventArgs { diff --git a/BookmarkPopover.designer.cs b/BookmarkPopover.designer.cs index dc895bd..96b0145 100644 --- a/BookmarkPopover.designer.cs +++ b/BookmarkPopover.designer.cs @@ -4,7 +4,7 @@ // actions made in the Xcode designer. If it is removed, they will be lost. // Manual changes to this file may not be handled correctly. // -using MonoMac.Foundation; +using Foundation; namespace macdoc { @@ -12,16 +12,16 @@ namespace macdoc partial class BookmarkPopover { [Outlet] - MonoMac.AppKit.NSButton doneButton { get; set; } + AppKit.NSButton doneButton { get; set; } [Outlet] - MonoMac.AppKit.NSButton deleteButton { get; set; } + AppKit.NSButton deleteButton { get; set; } [Outlet] - MonoMac.AppKit.NSFormCell nameField { get; set; } + AppKit.NSFormCell nameField { get; set; } [Outlet] - MonoMac.AppKit.NSFormCell notesField { get; set; } + AppKit.NSFormCell notesField { get; set; } void ReleaseDesignerOutlets () { diff --git a/BookmarkPopoverController.cs b/BookmarkPopoverController.cs index 2373c55..cb2c34b 100644 --- a/BookmarkPopoverController.cs +++ b/BookmarkPopoverController.cs @@ -1,12 +1,12 @@ using System; using System.Collections.Generic; using System.Linq; -using MonoMac.Foundation; -using MonoMac.AppKit; +using Foundation; +using AppKit; namespace macdoc { - public partial class BookmarkPopoverController : MonoMac.AppKit.NSViewController + public partial class BookmarkPopoverController : AppKit.NSViewController { NSPopover parentPopover; BookmarkManager.Entry entry; @@ -15,13 +15,7 @@ namespace macdoc { Initialize (); } - - [Export ("initWithCoder:")] - public BookmarkPopoverController (NSCoder coder) : base (coder) - { - Initialize (); - } - + public BookmarkPopoverController (NSPopover popover, BookmarkManager.Entry entry) : base ("BookmarkPopover", NSBundle.MainBundle) { this.parentPopover = popover; diff --git a/FindBarExtraordinaire.cs b/FindBarExtraordinaire.cs index 42ed974..b0279dc 100644 --- a/FindBarExtraordinaire.cs +++ b/FindBarExtraordinaire.cs @@ -1,12 +1,12 @@ using System; using System.Collections.Generic; using System.Linq; -using MonoMac.Foundation; -using MonoMac.AppKit; +using Foundation; +using AppKit; namespace macdoc { - public partial class FindBarExtraordinaire : MonoMac.AppKit.NSView + public partial class FindBarExtraordinaire : AppKit.NSView { public event EventHandler FindTextChanged; public event EventHandler CloseFindPanel; @@ -16,17 +16,11 @@ namespace macdoc Initialize (); } - [Export ("initWithCoder:")] - public FindBarExtraordinaire (NSCoder coder) : base (coder) - { - Initialize (); - } - void Initialize () { } - public override void DrawRect (System.Drawing.RectangleF dirtyRect) + public override void DrawRect (CoreGraphics.CGRect dirtyRect) { NSColor.WindowBackground.Set (); NSBezierPath.FillRect (dirtyRect); diff --git a/FindBarExtraordinaire.designer.cs b/FindBarExtraordinaire.designer.cs index 2bf6cb4..36be332 100644 --- a/FindBarExtraordinaire.designer.cs +++ b/FindBarExtraordinaire.designer.cs @@ -4,7 +4,7 @@ // actions made in the Xcode designer. If it is removed, they will be lost. // Manual changes to this file may not be handled correctly. // -using MonoMac.Foundation; +using Foundation; namespace macdoc { @@ -12,19 +12,19 @@ namespace macdoc partial class FindBarExtraordinaire { [Outlet] - MonoMac.AppKit.NSButton caseSensitiveButton { get; set; } + AppKit.NSButton caseSensitiveButton { get; set; } [Outlet] - MonoMac.AppKit.NSSearchField searchField { get; set; } + AppKit.NSSearchField searchField { get; set; } [Outlet] - MonoMac.AppKit.NSButton wrapButton { get; set; } + AppKit.NSButton wrapButton { get; set; } [Action ("StartSearch:")] - partial void StartSearch (MonoMac.Foundation.NSObject sender); + partial void StartSearch (Foundation.NSObject sender); [Action ("CloseFind:")] - partial void CloseFind (MonoMac.Foundation.NSObject sender); + partial void CloseFind (Foundation.NSObject sender); void ReleaseDesignerOutlets () { diff --git a/FindBarExtraordinaireController.cs b/FindBarExtraordinaireController.cs index 41620f6..03fcf4b 100644 --- a/FindBarExtraordinaireController.cs +++ b/FindBarExtraordinaireController.cs @@ -1,24 +1,18 @@ using System; using System.Collections.Generic; using System.Linq; -using MonoMac.Foundation; -using MonoMac.AppKit; +using Foundation; +using AppKit; namespace macdoc { - public partial class FindBarExtraordinaireController : MonoMac.AppKit.NSViewController + public partial class FindBarExtraordinaireController : AppKit.NSViewController { public FindBarExtraordinaireController (IntPtr handle) : base (handle) { Initialize (); } - - [Export ("initWithCoder:")] - public FindBarExtraordinaireController (NSCoder coder) : base (coder) - { - Initialize (); - } - + public FindBarExtraordinaireController () : base ("FindBarExtraordinaire", NSBundle.MainBundle) { Initialize (); diff --git a/Main.cs b/Main.cs index 459a819..1e416e1 100644 --- a/Main.cs +++ b/Main.cs @@ -1,9 +1,9 @@ using System; using System.Linq; -using System.Drawing; -using MonoMac.Foundation; -using MonoMac.AppKit; -using MonoMac.ObjCRuntime; +using CoreGraphics; +using Foundation; +using AppKit; +using ObjCRuntime; namespace macdoc { diff --git a/MainMenu.xib.designer.cs b/MainMenu.xib.designer.cs index ca75856..a2495ec 100644 --- a/MainMenu.xib.designer.cs +++ b/MainMenu.xib.designer.cs @@ -4,7 +4,7 @@ // actions made in the Xcode designer. If it is removed, they will be lost. // Manual changes to this file may not be handled correctly. // -using MonoMac.Foundation; +using Foundation; namespace macdoc { @@ -12,13 +12,13 @@ namespace macdoc partial class AppDelegate { [Action ("HandlePrint:")] - partial void HandlePrint (MonoMac.Foundation.NSObject sender); + partial void HandlePrint (Foundation.NSObject sender); [Action ("HandleSearch:")] - partial void HandleSearch (MonoMac.Foundation.NSObject sender); + partial void HandleSearch (Foundation.NSObject sender); [Action ("HandleFind:")] - partial void HandleFind (MonoMac.AppKit.NSMenuItem sender); + partial void HandleFind (AppKit.NSMenuItem sender); void ReleaseDesignerOutlets () { diff --git a/MonodocDataSources.cs b/MonodocDataSources.cs index d5fc8ed..3dd6235 100644 --- a/MonodocDataSources.cs +++ b/MonodocDataSources.cs @@ -2,13 +2,13 @@ using System; using System.Collections.Generic; using System.Linq; using Monodoc; -using MonoMac.AppKit; -using MonoMac.Foundation; -using MonoMac.WebKit; +using AppKit; +using Foundation; +using WebKit; using System.IO; using System.Threading; using System.Threading.Tasks; -using System.Drawing; +using CoreGraphics; namespace macdoc { @@ -61,10 +61,10 @@ namespace macdoc nodeToWrapper = parent.nodeToWrapper; } - public override NSObject GetChild (NSOutlineView outlineView, int index, NSObject item) + public override NSObject GetChild (NSOutlineView outlineView, nint index, NSObject item) { WrapNode wrap; - Node n = (Node) (item == null ? Root.RootNode : (Node) GetNode (item)).ChildNodes [index]; + Node n = (Node) (item == null ? Root.RootNode : (Node) GetNode (item)).ChildNodes [(int)index]; if (nodeToWrapper.ContainsKey (n)) return nodeToWrapper [n]; @@ -80,7 +80,7 @@ namespace macdoc return GetNode (item).ChildNodes.Count > 0; } - public override int GetChildrenCount (NSOutlineView outlineView, NSObject item) + public override nint GetChildrenCount (NSOutlineView outlineView, NSObject item) { if (item == null) return Root.RootNode.ChildNodes.Count; @@ -107,16 +107,16 @@ namespace macdoc this.searcher = searcher; } - public override int GetRowCount (NSTableView tableView) + public override nint GetRowCount (NSTableView tableView) { if (searcher.Index == null) return 0; return searcher.Index.Rows; } - public override NSObject GetObjectValue (NSTableView tableView, NSTableColumn tableColumn, int row) + public override NSObject GetObjectValue (NSTableView tableView, NSTableColumn tableColumn, nint row) { - return new NSString (searcher.Index.GetValue (row)); + return new NSString (searcher.Index.GetValue ((int)row)); } } @@ -176,16 +176,16 @@ namespace macdoc sections.Clear (); } - public override int GetRowCount (NSTableView tableView) + public override nint GetRowCount (NSTableView tableView) { return data.Count; } - public override NSCell GetCell (NSTableView tableView, NSTableColumn tableColumn, int row) + public override NSCell GetCell (NSTableView tableView, NSTableColumn tableColumn, nint row) { if (tableView == null) return null; - var resultEntry = data[row]; + var resultEntry = data[(int)row]; return !string.IsNullOrEmpty (resultEntry.SectionName) ? headerCell : normalCell; } @@ -198,16 +198,16 @@ namespace macdoc return resultEntry.ResultSet == null ? null : resultEntry.ResultSet.GetUrl (resultEntry.Index); } - public override NSObject GetObjectValue (NSTableView tableView, NSTableColumn tableColumn, int row) + public override NSObject GetObjectValue (NSTableView tableView, NSTableColumn tableColumn, nint row) { - var resultEntry = data[row]; + var resultEntry = data[(int)row]; return new NSString (!string.IsNullOrEmpty (resultEntry.SectionName) ? resultEntry.SectionName : resultEntry.ResultSet.GetTitle (resultEntry.Index)); } - public override bool ShouldSelectRow (NSTableView tableView, int row) + public override bool ShouldSelectRow (NSTableView tableView, nint row) { // If it's a section, do not select - return string.IsNullOrEmpty (data[row].SectionName); + return string.IsNullOrEmpty (data[(int)row].SectionName); } // Keep the search term in memory so that heavy search can check if its result are still fresh enough diff --git a/MonodocDocumentController.cs b/MonodocDocumentController.cs index 2c76517..139f2bf 100644 --- a/MonodocDocumentController.cs +++ b/MonodocDocumentController.cs @@ -1,8 +1,8 @@ using System; using System.Linq; -using MonoMac.Foundation; -using MonoMac.AppKit; -using MonoMac.ObjCRuntime; +using Foundation; +using AppKit; +using ObjCRuntime; namespace macdoc { diff --git a/MyDocument.cs b/MyDocument.cs index a46126b..49ec9f4 100644 --- a/MyDocument.cs +++ b/MyDocument.cs @@ -3,17 +3,17 @@ using System; using System.Collections.Generic; using System.Linq; using Monodoc; -using MonoMac.AppKit; -using MonoMac.Foundation; -using MonoMac.WebKit; +using AppKit; +using Foundation; +using WebKit; using System.IO; using System.Threading; using System.Threading.Tasks; -using System.Drawing; +using CoreGraphics; namespace macdoc { - public partial class MyDocument : MonoMac.AppKit.NSDocument + public partial class MyDocument : AppKit.NSDocument { internal Dictionary nodeToWrapper = new Dictionary (); History history; @@ -35,12 +35,6 @@ namespace macdoc { } - // Called when created directly from a XIB file - [Export("initWithCoder:")] - public MyDocument (NSCoder coder) : base(coder) - { - } - public override string DisplayName { get { return "Mono Documentation Browser"; @@ -102,7 +96,7 @@ namespace macdoc var popover = new NSPopover (); popover.Behavior = NSPopoverBehavior.Transient; popover.ContentViewController = new BookmarkPopoverController (popover, entry); - popover.Show (new RectangleF (0, 0, 0, 0), (NSView)sender, NSRectEdge.MinYEdge); + popover.Show (new CGRect (0, 0, 0, 0), (NSView)sender, NSRectEdge.MinYEdge); } void HandleRemoveBookmarkBtnActivated (object sender, EventArgs e) @@ -143,7 +137,7 @@ namespace macdoc class SplitViewDelegate : NSSplitViewDelegate { - public override float ConstrainSplitPosition (NSSplitView splitView, float proposedPosition, int subviewDividerIndex) + public override nfloat ConstrainSplitPosition (NSSplitView splitView, nfloat proposedPosition, nint subviewDividerIndex) { if (subviewDividerIndex != 0) return proposedPosition; @@ -184,7 +178,7 @@ namespace macdoc var bmarks = manager.GetAllBookmarks (); var index = bookmarkSelector.IndexOfSelectedItem; if (index >= 0 && index < bmarks.Count) - LoadUrl (bmarks[index].Url, true); + LoadUrl (bmarks[(int)index].Url, true); }; bookmarkSelector.SelectItem (-1); } @@ -194,7 +188,7 @@ namespace macdoc var popover = new NSPopover (); popover.Behavior = NSPopoverBehavior.Transient; popover.ContentViewController = new BookmarkAssistantController (AppDelegate.BookmarkManager.GetAllBookmarks ()); - popover.Show (new RectangleF (0, 0, 0, 0), (NSView)sender, NSRectEdge.MinYEdge); + popover.Show (new CGRect (0, 0, 0, 0), (NSView)sender, NSRectEdge.MinYEdge); } void ToggleSearchCreationStatus (object sender, EventArgs e) @@ -217,13 +211,13 @@ namespace macdoc indexResults.ReloadData (); var splitViewFrame = splitView.Frame; - splitView.Frame = new RectangleF (splitViewFrame.X, + splitView.Frame = new CGRect (splitViewFrame.X, splitViewFrame.Y - indexSpinnerHeight, splitViewFrame.Width, splitViewFrame.Height + indexSpinnerHeight); var searchScrollViewFrame = searchScrollView.Frame; - searchScrollView.Frame = new RectangleF (searchScrollViewFrame.X, + searchScrollView.Frame = new CGRect (searchScrollViewFrame.X, searchScrollViewFrame.Y - searchSpinnerHeight, searchScrollViewFrame.Width, searchScrollViewFrame.Height + searchSpinnerHeight); @@ -352,20 +346,20 @@ namespace macdoc void ShowMultipleMatches () { - float middle = (splitView.MaxPositionOfDivider (0) - splitView.MinPositionOfDivider (0))/2; + float middle = (float)(splitView.MaxPositionOfDivider (0) - splitView.MinPositionOfDivider (0))/2; splitView.SetPositionOfDivider (middle, 0); } // Action: when the user clicks on the index table view partial void IndexItemClicked (NSTableView sender) { - OnIndexRowSelected (sender.ClickedRow); + OnIndexRowSelected ((int)sender.ClickedRow); } // Action: when the user clicks on the index table view partial void SearchItemClicked (NSTableView sender) { - OnSearchRowSelected (sender.ClickedRow); + OnSearchRowSelected ((int)sender.ClickedRow); } // Action: when the user clicks on the multiple matches table view @@ -373,7 +367,7 @@ namespace macdoc { string url = null; try { - url = current_entry [sender.ClickedRow].Url; + url = current_entry [(int)sender.ClickedRow].Url; } catch { return; } @@ -520,7 +514,7 @@ namespace macdoc var item = nodeToWrapper [n]; var row = outlineView.RowForItem (item); outlineView.ScrollRowToVisible (row); - return row; + return (int)row; } public class OutlineDelegate : NSOutlineViewDelegate { @@ -593,16 +587,16 @@ namespace macdoc this.doc = doc; } - public override int GetRowCount (NSTableView tableView) + public override nint GetRowCount (NSTableView tableView) { if (doc.current_entry == null) return 0; return doc.current_entry.Count; } - public override NSObject GetObjectValue (NSTableView tableView, NSTableColumn tableColumn, int row) + public override NSObject GetObjectValue (NSTableView tableView, NSTableColumn tableColumn, nint row) { - Topic topic = doc.current_entry [row]; + Topic topic = doc.current_entry [(int)row]; return new NSString (RenderTopicMatch (topic)); } diff --git a/MyDocument.xib.designer.cs b/MyDocument.xib.designer.cs index 61b51a1..215066f 100644 --- a/MyDocument.xib.designer.cs +++ b/MyDocument.xib.designer.cs @@ -4,7 +4,7 @@ // actions made in the Xcode designer. If it is removed, they will be lost. // Manual changes to this file may not be handled correctly. // -using MonoMac.Foundation; +using Foundation; namespace macdoc { @@ -12,79 +12,79 @@ namespace macdoc partial class MyDocument { [Outlet] - MonoMac.AppKit.NSSegmentedCell navigationCells { get; set; } + AppKit.NSSegmentedCell navigationCells { get; set; } [Outlet] - MonoMac.AppKit.NSOutlineView outlineView { get; set; } + AppKit.NSOutlineView outlineView { get; set; } [Outlet] - MonoMac.AppKit.NSTableView searchResults { get; set; } + AppKit.NSTableView searchResults { get; set; } [Outlet] - MonoMac.WebKit.WebView webView { get; set; } + WebKit.WebView webView { get; set; } [Outlet] - MonoMac.AppKit.NSTabView tabSelector { get; set; } + AppKit.NSTabView tabSelector { get; set; } [Outlet] - MonoMac.AppKit.NSView spinnerView { get; set; } + AppKit.NSView spinnerView { get; set; } [Outlet] - MonoMac.AppKit.NSProgressIndicator spinnerWidget { get; set; } + AppKit.NSProgressIndicator spinnerWidget { get; set; } [Outlet] - MonoMac.AppKit.NSView indexSpinnerView { get; set; } + AppKit.NSView indexSpinnerView { get; set; } [Outlet] - MonoMac.AppKit.NSProgressIndicator indexSpinnerWidget { get; set; } + AppKit.NSProgressIndicator indexSpinnerWidget { get; set; } [Outlet] - MonoMac.AppKit.NSButton addBookmarkBtn { get; set; } + AppKit.NSButton addBookmarkBtn { get; set; } [Outlet] - MonoMac.AppKit.NSPopUpButton bookmarkSelector { get; set; } + AppKit.NSPopUpButton bookmarkSelector { get; set; } [Outlet] - MonoMac.AppKit.NSButton viewBookmarksBtn { get; set; } + AppKit.NSButton viewBookmarksBtn { get; set; } [Outlet] - MonoMac.AppKit.NSSegmentedCell bookmarkToolbar { get; set; } + AppKit.NSSegmentedCell bookmarkToolbar { get; set; } [Outlet] - MonoMac.AppKit.NSSplitView splitView { get; set; } + AppKit.NSSplitView splitView { get; set; } [Outlet] - MonoMac.AppKit.NSTableView multipleMatchResults { get; set; } + AppKit.NSTableView multipleMatchResults { get; set; } [Outlet] - MonoMac.AppKit.NSTableView indexResults { get; set; } + AppKit.NSTableView indexResults { get; set; } [Outlet] - MonoMac.AppKit.NSSearchField indexSearchEntry { get; set; } + AppKit.NSSearchField indexSearchEntry { get; set; } [Outlet] - MonoMac.AppKit.NSSearchField toolbarSearchEntry { get; set; } + AppKit.NSSearchField toolbarSearchEntry { get; set; } [Outlet] - MonoMac.AppKit.NSScrollView searchScrollView { get; set; } + AppKit.NSScrollView searchScrollView { get; set; } [Action ("IndexItemClicked:")] - partial void IndexItemClicked (MonoMac.AppKit.NSTableView sender); + partial void IndexItemClicked (AppKit.NSTableView sender); [Action ("StartSearch:")] - partial void StartSearch (MonoMac.AppKit.NSSearchField sender); + partial void StartSearch (AppKit.NSSearchField sender); [Action ("MultipleMatchItemClicked:")] - partial void MultipleMatchItemClicked (MonoMac.AppKit.NSTableView sender); + partial void MultipleMatchItemClicked (AppKit.NSTableView sender); [Action ("SearchItemClicked:")] - partial void SearchItemClicked (MonoMac.AppKit.NSTableView sender); + partial void SearchItemClicked (AppKit.NSTableView sender); [Action ("StartIndexSearch:")] - partial void StartIndexSearch (MonoMac.AppKit.NSSearchField sender); + partial void StartIndexSearch (AppKit.NSSearchField sender); [Action ("BookmarkToolbarClicked:")] - partial void BookmarkToolbarClicked (MonoMac.Foundation.NSObject sender); + partial void BookmarkToolbarClicked (Foundation.NSObject sender); void ReleaseDesignerOutlets () { diff --git a/RootLauncher.cs b/RootLauncher.cs index a4851a5..eef0699 100644 --- a/RootLauncher.cs +++ b/RootLauncher.cs @@ -1,75 +1,8 @@ using System; -using System.IO; -using System.Linq; using System.Diagnostics; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using Mono.Unix; namespace macdoc { - public enum AuthorizationResultCode - { - Success = 0, - InvalidSet = -60001, - InvalidRef = -60002, - InvalidTag = -60003, - InvalidPointer = -60004, - Denied = -60005, - Canceled = -60006, - InteractionNotAllowed = -60007, - Internal = -60008, - ExternalizeNotAllowed = -60009, - InternalizeNotAllowed = -60010, - InvalidFlags = -60011, - ToolExecuteFailure = -60031, - ToolEnvironmentError = -60032, - BadAddress = -60033, - FileNotFound = -60035 // Addition - } - - public class RootLauncherException : ApplicationException - { - public RootLauncherException (string message) : base (message) - { - } - - public AuthorizationResultCode ResultCode { get; set; } - } - - // You were in need of some harsh reality? You have come to the right place - public static class RootLauncher - { - const string SecurityFramework = "/System/Library/Frameworks/Security.framework/Versions/Current/Security"; - - public static bool IsRootEnabled (string toolPath) - { - var stat = new UnixFileInfo (toolPath); - return stat.IsSetUser && stat.IsSetGroup && stat.OwnerUserId == 0; - } - - public static void LaunchExternalTool (string toolPath, string[] args) - { - if (!File.Exists (toolPath)) - throw new RootLauncherException ("[Launcher] Error, the tool doesn't exist and can't be launched") { ResultCode = AuthorizationResultCode.FileNotFound }; - - IntPtr authReference = IntPtr.Zero; - AuthorizationResultCode result = AuthorizationCreate (IntPtr.Zero, IntPtr.Zero, 0, out authReference); - if (result != AuthorizationResultCode.Success) - throw new RootLauncherException ("[Launcher] Error while creating Auth Reference") { ResultCode = result }; - - result = AuthorizationExecuteWithPrivileges (authReference, toolPath, 0, (args ?? Enumerable.Empty ()).Concat (Enumerable.Repeat ((string)null, 1)).ToArray (), IntPtr.Zero); - if (result != AuthorizationResultCode.Success) - throw new RootLauncherException ("[Launcher] Error while executing") { ResultCode = result }; - } - - [DllImport (SecurityFramework)] - extern static AuthorizationResultCode AuthorizationCreate (IntPtr autorizationRights, IntPtr environment, int authFlags, out IntPtr authRef); - - [DllImport (SecurityFramework)] - extern static AuthorizationResultCode AuthorizationExecuteWithPrivileges (IntPtr authRef, string pathToTool, int authFlags, string[] args, IntPtr pipe); - } - public static class UrlLauncher { public static void Launch (string url) @@ -79,4 +12,4 @@ namespace macdoc Process.Start (new ProcessStartInfo (url)); } } -} +} \ No newline at end of file diff --git a/WebViewExtraordinaire.cs b/WebViewExtraordinaire.cs index b5ac6d2..63b6726 100644 --- a/WebViewExtraordinaire.cs +++ b/WebViewExtraordinaire.cs @@ -1,10 +1,10 @@ using System; using System.Collections.Generic; using System.Linq; -using MonoMac.Foundation; -using MonoMac.AppKit; -using MonoMac.WebKit; -using MonoMac.ObjCRuntime; +using Foundation; +using AppKit; +using WebKit; +using ObjCRuntime; namespace macdoc { @@ -33,13 +33,7 @@ namespace macdoc { Initialize (); } - - [Export ("initWithCoder:")] - public WebViewExtraordinaire (NSCoder coder) : base (coder) - { - Initialize (); - } - + void Initialize () { // The initializations we do here are Lion-specific @@ -109,7 +103,7 @@ namespace macdoc if (ctrl == null) return; - InternalPerformFinderAction ((NSTextFinderAction)ctrl.Tag); + InternalPerformFinderAction ((NSTextFinderAction)(int)ctrl.Tag); } void InternalPerformFinderAction (NSTextFinderAction action) diff --git a/WebViewExtraordinaire.designer.cs b/WebViewExtraordinaire.designer.cs index 9a212ca..0e6eacd 100644 --- a/WebViewExtraordinaire.designer.cs +++ b/WebViewExtraordinaire.designer.cs @@ -3,7 +3,7 @@ namespace macdoc { // Should subclass MonoMac.AppKit.NSView - [MonoMac.Foundation.Register("WebViewExtraordinaire")] + [Foundation.Register("WebViewExtraordinaire")] public partial class WebViewExtraordinaire { } diff --git a/history.cs b/history.cs index d1fc726..9906cca 100644 --- a/history.cs +++ b/history.cs @@ -1,4 +1,4 @@ -using MonoMac.AppKit; +using AppKit; using System; using System.Collections.Generic; diff --git a/macdoc.csproj b/macdoc.csproj index cf9b573..972bda1 100644 --- a/macdoc.csproj +++ b/macdoc.csproj @@ -6,12 +6,13 @@ 10.0.0 2.0 {87641BCE-5461-4802-BEA4-53D1BCAC3D06} - {948B3504-5B70-4649-8FE4-BDE1FB46EC69};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + {A3F8F2AB-B479-4A4A-A458-A89E7DC349F1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} Exe macdoc macdoc 12/11/2012 10:17:55 PM - True + v4.5 + true True @@ -46,14 +47,10 @@ - - - ..\..\src\MonoMac.dll - lib\monodoc.dll - + @@ -110,8 +107,8 @@ - - + + @@ -120,10 +117,9 @@ - - + \ No newline at end of file -- cgit v1.2.3