Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xamarin/macdoc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremie Laval <jeremie.laval@gmail.com>2012-02-15 20:02:32 +0400
committerJeremie Laval <jeremie.laval@gmail.com>2012-02-15 21:29:51 +0400
commitafd38eb21dece511ff4456d7f1e57292f7f8ca68 (patch)
tree61d49868337a751bbca5937dcc65696d74e1f677 /AppDelegate.cs
parenta1dc1fcf7d1042b42a35c11dc60e5cfa1c25f14a (diff)
[macdoc] Prevent untitle window from opening when already launched or initially launched with an URL
Diffstat (limited to 'AppDelegate.cs')
-rw-r--r--AppDelegate.cs35
1 files changed, 25 insertions, 10 deletions
diff --git a/AppDelegate.cs b/AppDelegate.cs
index 2360fa3..383136c 100644
--- a/AppDelegate.cs
+++ b/AppDelegate.cs
@@ -16,6 +16,7 @@ namespace macdoc
static public string MonodocDir;
static public NSUrl MonodocBaseUrl;
static MonodocDocumentController controller;
+ bool shouldOpenInitialFile = true;
static void PrepareCache ()
{
@@ -102,6 +103,8 @@ namespace macdoc
public void HandleGetURLEvent (NSAppleEventDescriptor evt, NSAppleEventDescriptor replyEvt)
{
NSError error;
+ shouldOpenInitialFile = evt.NumberOfItems == 0;
+
// Received event is a list (1-based) of URL strings
for (int i = 1; i <= evt.NumberOfItems; i++) {
var innerDesc = evt.DescriptorAtIndex (i);
@@ -111,6 +114,28 @@ namespace macdoc
}
}
+ // If the application was launched with an url, we don't open a default window
+ public override bool ApplicationShouldOpenUntitledFile (NSApplication sender)
+ {
+ return shouldOpenInitialFile;
+ }
+
+ // Prevent new document from being created when already launched
+ public override bool ApplicationShouldHandleReopen (NSApplication sender, bool hasVisibleWindows)
+ {
+ return false;
+ }
+
+ partial void HandlePrint (NSObject sender)
+ {
+ controller.CurrentDocument.PrintDocument (sender);
+ }
+
+ public override void WillTerminate (NSNotification notification)
+ {
+ BookmarkManager.SaveBookmarks ();
+ }
+
// 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)
{
@@ -124,16 +149,6 @@ namespace macdoc
}
IntPtr selOpenDocumentWithContentsOfURLDisplayError_ = new Selector ("openDocumentWithContentsOfURL:display:error:").Handle;
-
- partial void HandlePrint (NSObject sender)
- {
- controller.CurrentDocument.PrintDocument (sender);
- }
-
- public override void WillTerminate (NSNotification notification)
- {
- BookmarkManager.SaveBookmarks ();
- }
}
}