ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/MacOSX/prefs_macosx.mm
Revision: 1.5
Committed: 2010-07-27T02:55:09Z (13 years, 11 months ago) by asvitkine
Branch: MAIN
Changes since 1.4: +4 -1 lines
Log Message:
Fix prefs_macosx.mm compile issue with Snow Leopard.

File Contents

# User Rev Content
1 asvitkine 1.1 /*
2 asvitkine 1.5 * $Id: prefs_macosx.mm,v 1.4 2010/01/02 22:08:51 asvitkine Exp $
3 asvitkine 1.1 *
4     * prefs_macosx.mm - Enables access to SheepShaver preferences while
5     * SheepShaver is running (on Mac OS X).
6     *
7     * Copyright (C) 2007 Alexei Svitkine
8     *
9     * This program is free software; you can redistribute it and/or modify
10     * it under the terms of the GNU General Public License as published by
11     * the Free Software Foundation; either version 2 of the License, or
12     * (at your option) any later version.
13     *
14     * This program is distributed in the hope that it will be useful,
15     * but WITHOUT ANY WARRANTY; without even the implied warranty of
16     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17     * GNU General Public License for more details.
18     *
19     * You should have received a copy of the GNU General Public License
20     * along with this program; if not, write to the Free Software
21     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22     */
23    
24    
25     #include "sysdeps.h"
26    
27 asvitkine 1.5 // The _UINT64 define is needed to guard against a typedef mismatch with Snow Leopard headers.
28     #define _UINT64
29    
30 asvitkine 1.1 #include <Cocoa/Cocoa.h>
31 asvitkine 1.2 #include "VMSettingsController.h"
32 asvitkine 1.1
33     @interface SheepShaverMain : NSObject
34     NSArray *nibObjects;
35     NSWindow *prefsWindow;
36     @end
37    
38     @implementation SheepShaverMain
39    
40    
41     - (NSArray*) loadPrefsNibFile
42     {
43 asvitkine 1.2 NSNib *nib = [[NSNib alloc] initWithNibNamed:@"VMSettingsWindow" bundle:nil];
44 asvitkine 1.1 NSArray *objects = nil;
45    
46 asvitkine 1.2 if (![nib instantiateNibWithOwner:[VMSettingsController sharedInstance] topLevelObjects:&objects]) {
47 asvitkine 1.1 NSLog(@"Could not load Prefs NIB file!\n");
48     return nil;
49     }
50    
51     NSLog(@"%d objects loaded\n", [objects count]);
52    
53     // Release the raw nib data.
54     [nib release];
55    
56     // Release the top-level objects so that they are just owned by the array.
57     [objects makeObjectsPerformSelector:@selector(release)];
58    
59     prefsWindow = nil;
60     for (int i = 0; i < [objects count]; i++) {
61     NSObject *object = [objects objectAtIndex:i];
62     NSLog(@"Got %@", object);
63    
64     if ([object isKindOfClass:[NSWindow class]]) {
65     prefsWindow = (NSWindow *) object;
66     break;
67     }
68     }
69    
70     if (prefsWindow == nil) {
71     NSLog(@"Could not find NSWindow in Prefs NIB file!\n");
72     return nil;
73     }
74    
75     return objects;
76     }
77    
78    
79     - (void) openPreferences:(id)sender
80     {
81 asvitkine 1.3 NSAutoreleasePool *pool;
82    
83 asvitkine 1.1 if (nibObjects == nil) {
84     nibObjects = [self loadPrefsNibFile];
85     if (nibObjects == nil)
86     return;
87     [nibObjects retain];
88     }
89    
90 asvitkine 1.3 pool = [[NSAutoreleasePool alloc] init];
91 asvitkine 1.2 [[VMSettingsController sharedInstance] setupGUI];
92 asvitkine 1.1 [NSApp runModalForWindow:prefsWindow];
93 asvitkine 1.3 [pool release];
94 asvitkine 1.1 }
95    
96     @end
97    
98     /*
99     * Initialization
100     */
101    
102     void prefs_init(void)
103     {
104 asvitkine 1.4 NSAutoreleasePool *pool;
105 asvitkine 1.1 NSMenu *appMenu;
106     NSMenuItem *menuItem;
107    
108 asvitkine 1.4 pool = [[NSAutoreleasePool alloc] init];
109    
110 asvitkine 1.1 appMenu = [[[NSApp mainMenu] itemAtIndex:0] submenu];
111     menuItem = [[NSMenuItem alloc] initWithTitle:@"Preferences..." action:@selector(openPreferences:) keyEquivalent:@","];
112     [appMenu insertItem:menuItem atIndex:2];
113     [appMenu insertItem:[NSMenuItem separatorItem] atIndex:3];
114     [menuItem release];
115    
116     [NSApp setDelegate:[[SheepShaverMain alloc] init]];
117 asvitkine 1.4
118     [pool release];
119 asvitkine 1.1 }
120    
121    
122     /*
123     * Deinitialization
124     */
125    
126     void prefs_exit(void)
127     {
128     }