Revision: 3194
          http://skim-app.svn.sourceforge.net/skim-app/?rev=3194&view=rev
Author:   hofman
Date:     2007-11-11 02:42:50 -0800 (Sun, 11 Nov 2007)

Log Message:
-----------
Check system version at startup.

Modified Paths:
--------------
    trunk/main.m

Modified: trunk/main.m
===================================================================
--- trunk/main.m        2007-11-11 01:27:17 UTC (rev 3193)
+++ trunk/main.m        2007-11-11 10:42:50 UTC (rev 3194)
@@ -9,8 +9,45 @@
 //
 
 #import <Cocoa/Cocoa.h>
+#import <Carbon/Carbon.h>
 
 int main(int argc, char *argv[])
 {
+    // Runtime check for system version
+    // - uses Carbon dialog since we don't have NSApp yet
+    // - uses Gestalt so we can check for a specific minor version (if it gets 
this far, anyway)
+    // - Gestalt header says to read a plist, but mailing lists (and Ali Ozer) 
say to avoid that
+    long version;
+    OSStatus err = Gestalt(gestaltSystemVersion, &version);
+    
+    if (noErr != err || version < 0x00001040) {
+        DialogRef alert;
+        
+        // pool required for NSLocalizedString
+        NSAutoreleasePool *pool = [NSAutoreleasePool new];
+        
+        AlertStdCFStringAlertParamRec alertParamRec = {
+            kStdCFStringAlertVersionOne,
+            TRUE,
+            FALSE,
+            (CFStringRef)NSLocalizedString(@"Quit", @""),
+            NULL, // cancel button text
+            NULL, // other button text
+            kAlertStdAlertOKButton,
+            kAlertStdAlertCancelButton,
+            kWindowDefaultPosition,
+            0
+        };
+        
+        err = CreateStandardAlert(kAlertStopAlert, 
(CFStringRef)NSLocalizedString(@"Unsupported System Version", @""), 
(CFStringRef)NSLocalizedString(@"This version of Skim requires Mac OS X 10.4 or 
greater to run.", @""), &alertParamRec, &alert);
+        DialogItemIndex idx;
+        
+        if (noErr == err) {
+            // this will dispose of the alert (not that a leak is a big deal 
at this point)
+            err = RunStandardAlert(alert, NULL, &idx);
+        }
+        [pool release];
+        return err;
+    }
     return NSApplicationMain(argc, (const char **) argv);
 }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to