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, 10 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

# Content
1 /*
2 * $Id: prefs_macosx.mm,v 1.4 2010/01/02 22:08:51 asvitkine Exp $
3 *
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 // The _UINT64 define is needed to guard against a typedef mismatch with Snow Leopard headers.
28 #define _UINT64
29
30 #include <Cocoa/Cocoa.h>
31 #include "VMSettingsController.h"
32
33 @interface SheepShaverMain : NSObject
34 NSArray *nibObjects;
35 NSWindow *prefsWindow;
36 @end
37
38 @implementation SheepShaverMain
39
40
41 - (NSArray*) loadPrefsNibFile
42 {
43 NSNib *nib = [[NSNib alloc] initWithNibNamed:@"VMSettingsWindow" bundle:nil];
44 NSArray *objects = nil;
45
46 if (![nib instantiateNibWithOwner:[VMSettingsController sharedInstance] topLevelObjects:&objects]) {
47 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 NSAutoreleasePool *pool;
82
83 if (nibObjects == nil) {
84 nibObjects = [self loadPrefsNibFile];
85 if (nibObjects == nil)
86 return;
87 [nibObjects retain];
88 }
89
90 pool = [[NSAutoreleasePool alloc] init];
91 [[VMSettingsController sharedInstance] setupGUI];
92 [NSApp runModalForWindow:prefsWindow];
93 [pool release];
94 }
95
96 @end
97
98 /*
99 * Initialization
100 */
101
102 void prefs_init(void)
103 {
104 NSAutoreleasePool *pool;
105 NSMenu *appMenu;
106 NSMenuItem *menuItem;
107
108 pool = [[NSAutoreleasePool alloc] init];
109
110 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
118 [pool release];
119 }
120
121
122 /*
123 * Deinitialization
124 */
125
126 void prefs_exit(void)
127 {
128 }