comparison dwt/internal/cocoa/NSWorkspace.d @ 0:380af2bdd8e5

Upload of whole dwt tree
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Sat, 09 Aug 2008 17:00:02 +0200
parents
children 8b48be5454ce
comparison
equal deleted inserted replaced
-1:000000000000 0:380af2bdd8e5
1 /*******************************************************************************
2 * Copyright (c) 2007 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 *
11 * Port to the D Programming language:
12 * Jacob Carlborg <jacob.carlborg@gmail.com>
13 *******************************************************************************/
14 module dwt.internal.cocoa.NSWorkspace;
15
16 import dwt.internal.cocoa.NSAppleEventDescriptor;
17 import dwt.internal.cocoa.NSArray;
18 import dwt.internal.cocoa.NSDictionary;
19 import dwt.internal.cocoa.NSImage;
20 import dwt.internal.cocoa.NSInteger;
21 import dwt.internal.cocoa.NSNotificationCenter;
22 import dwt.internal.cocoa.NSObject;
23 import dwt.internal.cocoa.NSPoint;
24 import dwt.internal.cocoa.NSString;
25 import dwt.internal.cocoa.NSURL;
26 import dwt.internal.cocoa.NSView;
27 import dwt.internal.cocoa.OS;
28 import objc = dwt.internal.objc.runtime;
29
30 enum NSWorkspaceLaunchOptions : uint
31 {
32 NSWorkspaceLaunchAndPrint = 0x00000002,
33 NSWorkspaceLaunchInhibitingBackgroundOnly = 0x00000080,
34 NSWorkspaceLaunchWithoutAddingToRecents = 0x00000100,
35 NSWorkspaceLaunchWithoutActivation = 0x00000200,
36 NSWorkspaceLaunchAsync = 0x00010000,
37 NSWorkspaceLaunchAllowingClassicStartup = 0x00020000,
38 NSWorkspaceLaunchPreferringClassic = 0x00040000,
39 NSWorkspaceLaunchNewInstance = 0x00080000,
40 NSWorkspaceLaunchAndHide = 0x00100000,
41 NSWorkspaceLaunchAndHideOthers = 0x00200000,
42 NSWorkspaceLaunchDefault = NSWorkspaceLaunchAsync | NSWorkspaceLaunchAllowingClassicStartup
43 }
44
45 alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchAndPrint NSWorkspaceLaunchAndPrint;
46 alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchInhibitingBackgroundOnly NSWorkspaceLaunchInhibitingBackgroundOnly;
47 alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchWithoutAddingToRecents NSWorkspaceLaunchWithoutAddingToRecents;
48 alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchWithoutActivation NSWorkspaceLaunchWithoutActivation;
49 alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchAsync NSWorkspaceLaunchAsync;
50 alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchAllowingClassicStartup NSWorkspaceLaunchAllowingClassicStartup;
51 alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchPreferringClassic NSWorkspaceLaunchPreferringClassic;
52 alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchNewInstance NSWorkspaceLaunchNewInstance;
53 alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchAndHide NSWorkspaceLaunchAndHide;
54 alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchAndHideOthers NSWorkspaceLaunchAndHideOthers;
55 alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchDefault NSWorkspaceLaunchDefault;
56
57 enum NSWorkspaceIconCreationOptions : NSUInteger
58 {
59 NSExcludeQuickDrawElementsIconCreationOption = 1 << 1,
60 NSExclude10_4ElementsIconCreationOption = 1 << 2
61 }
62
63 alias NSWorkspaceIconCreationOptions.NSExcludeQuickDrawElementsIconCreationOption NSExcludeQuickDrawElementsIconCreationOption;
64 alias NSWorkspaceIconCreationOptions.NSExclude10_4ElementsIconCreationOption NSExclude10_4ElementsIconCreationOption;
65
66 public class NSWorkspace : NSObject
67 {
68
69 public this ()
70 {
71 super();
72 }
73
74 public this (objc.id id)
75 {
76 super(id);
77 }
78
79 public NSString absolutePathForAppBundleWithIdentifier (NSString bundleIdentifier)
80 {
81 objc.id result = OS.objc_msgSend(this.id, OS.sel_absolutePathForAppBundleWithIdentifier_1,
82 bundleIdentifier !is null ? bundleIdentifier.id : null);
83 return result !is null ? new NSString(result) : null;
84 }
85
86 public NSDictionary activeApplication ()
87 {
88 objc.id result = OS.objc_msgSend(this.id, OS.sel_activeApplication);
89 return result !is null ? new NSDictionary(result) : null;
90 }
91
92 public void checkForRemovableMedia ()
93 {
94 OS.objc_msgSend(this.id, OS.sel_checkForRemovableMedia);
95 }
96
97 public NSInteger extendPowerOffBy (NSInteger requested)
98 {
99 return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_extendPowerOffBy_1, requested);
100 }
101
102 public bool fileSystemChanged ()
103 {
104 return OS.objc_msgSend(this.id, OS.sel_fileSystemChanged) !is null;
105 }
106
107 public bool filenameExtension (NSString filenameExtension, NSString typeName)
108 {
109 return OS.objc_msgSend(this.id, OS.sel_filenameExtension_1isValidForType_1, filenameExtension !is null ? filenameExtension.id : null,
110 typeName !is null ? typeName.id : null) !is null;
111 }
112
113 public void findApplications ()
114 {
115 OS.objc_msgSend(this.id, OS.sel_findApplications);
116 }
117
118 public NSString fullPathForApplication (NSString appName)
119 {
120 objc.id result = OS.objc_msgSend(this.id, OS.sel_fullPathForApplication_1, appName !is null ? appName.id : null);
121 return result !is null ? new NSString(result) : null;
122 }
123
124 public bool getFileSystemInfoForPath (NSString fullPath, bool* removableFlag, bool* writableFlag, bool* unmountableFlag,
125 /*NSString** */objc.id** description,
126 /*NSString** */objc.id** fileSystemType)
127 {
128 return OS.objc_msgSend(this.id, OS.sel_getFileSystemInfoForPath_1isRemovable_1isWritable_1isUnmountable_1description_1type_1,
129 fullPath !is null ? fullPath.id : null, removableFlag, writableFlag, unmountableFlag, description, fileSystemType) !is null;
130 }
131
132 public bool getInfoForFile (NSString fullPath, /*NSString** */objc.id** appName, /*NSString** */objc.id** type)
133 {
134 return OS.objc_msgSend(this.id, OS.sel_getInfoForFile_1application_1type_1, fullPath !is null ? fullPath.id : null, appName, type) !is null;
135 }
136
137 public void hideOtherApplications ()
138 {
139 OS.objc_msgSend(this.id, OS.sel_hideOtherApplications);
140 }
141
142 public NSImage iconForFile (NSString fullPath)
143 {
144 objc.id result = OS.objc_msgSend(this.id, OS.sel_iconForFile_1, fullPath !is null ? fullPath.id : null);
145 return result !is null ? new NSImage(result) : null;
146 }
147
148 public NSImage iconForFileType (NSString fileType)
149 {
150 objc.id result = OS.objc_msgSend(this.id, OS.sel_iconForFileType_1, fileType !is null ? fileType.id : null);
151 return result !is null ? new NSImage(result) : null;
152 }
153
154 public NSImage iconForFiles (NSArray fullPaths)
155 {
156 objc.id result = OS.objc_msgSend(this.id, OS.sel_iconForFiles_1, fullPaths !is null ? fullPaths.id : null);
157 return result !is null ? new NSImage(result) : null;
158 }
159
160 public bool isFilePackageAtPath (NSString fullPath)
161 {
162 return OS.objc_msgSend(this.id, OS.sel_isFilePackageAtPath_1, fullPath !is null ? fullPath.id : null) !is null;
163 }
164
165 public bool launchAppWithBundleIdentifier (NSString bundleIdentifier, NSWorkspaceLaunchOptions options, NSAppleEventDescriptor descriptor,
166 /*NSNumber** */objc.id** identifier)
167 {
168 return OS.objc_msgSend(this.id, OS.sel_launchAppWithBundleIdentifier_1options_1additionalEventParamDescriptor_1launchIdentifier_1,
169 bundleIdentifier !is null ? bundleIdentifier.id : null, options, descriptor !is null ? descriptor.id : null, identifier) !is null;
170 }
171
172 public bool launchApplication_ (NSString appName)
173 {
174 return OS.objc_msgSend(this.id, OS.sel_launchApplication_1, appName !is null ? appName.id : null) !is null;
175 }
176
177 public bool launchApplication_showIcon_autolaunch_ (NSString appName, bool showIcon, bool autolaunch)
178 {
179 return OS.objc_msgSend(this.id, OS.sel_launchApplication_1showIcon_1autolaunch_1, appName !is null ? appName.id : null, showIcon, autolaunch) !is null;
180 }
181
182 public NSArray launchedApplications ()
183 {
184 objc.id result = OS.objc_msgSend(this.id, OS.sel_launchedApplications);
185 return result !is null ? new NSArray(result) : null;
186 }
187
188 public NSString localizedDescriptionForType (NSString typeName)
189 {
190 objc.id result = OS.objc_msgSend(this.id, OS.sel_localizedDescriptionForType_1, typeName !is null ? typeName.id : null);
191 return result !is null ? new NSString(result) : null;
192 }
193
194 public NSArray mountNewRemovableMedia ()
195 {
196 objc.id result = OS.objc_msgSend(this.id, OS.sel_mountNewRemovableMedia);
197 return result !is null ? new NSArray(result) : null;
198 }
199
200 public NSArray mountedLocalVolumePaths ()
201 {
202 objc.id result = OS.objc_msgSend(this.id, OS.sel_mountedLocalVolumePaths);
203 return result !is null ? new NSArray(result) : null;
204 }
205
206 public NSArray mountedRemovableMedia ()
207 {
208 objc.id result = OS.objc_msgSend(this.id, OS.sel_mountedRemovableMedia);
209 return result !is null ? new NSArray(result) : null;
210 }
211
212 public void noteFileSystemChanged ()
213 {
214 OS.objc_msgSend(this.id, OS.sel_noteFileSystemChanged);
215 }
216
217 public void noteFileSystemChanged_ (NSString path)
218 {
219 OS.objc_msgSend(this.id, OS.sel_noteFileSystemChanged_1, path !is null ? path.id : null);
220 }
221
222 public void noteUserDefaultsChanged ()
223 {
224 OS.objc_msgSend(this.id, OS.sel_noteUserDefaultsChanged);
225 }
226
227 public NSNotificationCenter notificationCenter ()
228 {
229 objc.id result = OS.objc_msgSend(this.id, OS.sel_notificationCenter);
230 return result !is null ? new NSNotificationCenter(result) : null;
231 }
232
233 public bool openFile_ (NSString fullPath)
234 {
235 return OS.objc_msgSend(this.id, OS.sel_openFile_1, fullPath !is null ? fullPath.id : null) !is null;
236 }
237
238 public bool openFile_fromImage_at_inView_ (NSString fullPath, NSImage anImage, NSPoint point, NSView aView)
239 {
240 return OS.objc_msgSend(this.id, OS.sel_openFile_1fromImage_1at_1inView_1, fullPath !is null ? fullPath.id : null,
241 anImage !is null ? anImage.id : null, point, aView !is null ? aView.id : null) !is null;
242 }
243
244 public bool openFile_withApplication_ (NSString fullPath, NSString appName)
245 {
246 return OS.objc_msgSend(this.id, OS.sel_openFile_1withApplication_1, fullPath !is null ? fullPath.id : null,
247 appName !is null ? appName.id : null) !is null;
248 }
249
250 public bool openFile_withApplication_andDeactivate_ (NSString fullPath, NSString appName, bool flag)
251 {
252 return OS.objc_msgSend(this.id, OS.sel_openFile_1withApplication_1andDeactivate_1, fullPath !is null ? fullPath.id : null,
253 appName !is null ? appName.id : null, flag) !is null;
254 }
255
256 public bool openTempFile (NSString fullPath)
257 {
258 return OS.objc_msgSend(this.id, OS.sel_openTempFile_1, fullPath !is null ? fullPath.id : null) !is null;
259 }
260
261 public bool openURL (NSURL url)
262 {
263 return OS.objc_msgSend(this.id, OS.sel_openURL_1, url !is null ? url.id : null) !is null;
264 }
265
266 public bool openURLs (NSArray urls, NSString bundleIdentifier, NSWorkspaceLaunchOptions options, NSAppleEventDescriptor descriptor,
267 /*NSArray** */objc.id** identifiers)
268 {
269 return OS.objc_msgSend(this.id, OS.sel_openURLs_1withAppBundleIdentifier_1options_1additionalEventParamDescriptor_1launchIdentifiers_1,
270 urls !is null ? urls.id : null, bundleIdentifier !is null ? bundleIdentifier.id : null, options,
271 descriptor !is null ? descriptor.id : null, identifiers) !is null;
272 }
273
274 public bool performFileOperation (NSString operation, NSString source, NSString destination, NSArray files, NSInteger* tag)
275 {
276 return OS.objc_msgSend(this.id, OS.sel_performFileOperation_1source_1destination_1files_1tag_1, operation !is null ? operation.id : null,
277 source !is null ? source.id : null, destination !is null ? destination.id : null, files !is null ? files.id : null, tag) !is null;
278 }
279
280 public NSString preferredFilenameExtensionForType (NSString typeName)
281 {
282 objc.id result = OS.objc_msgSend(this.id, OS.sel_preferredFilenameExtensionForType_1, typeName !is null ? typeName.id : null);
283 return result !is null ? new NSString(result) : null;
284 }
285
286 public bool selectFile (NSString fullPath, NSString rootFullpath)
287 {
288 return OS.objc_msgSend(this.id, OS.sel_selectFile_1inFileViewerRootedAtPath_1, fullPath !is null ? fullPath.id : null,
289 rootFullpath !is null ? rootFullpath.id : null) !is null;
290 }
291
292 public bool setIcon (NSImage image, NSString fullPath, NSWorkspaceIconCreationOptions options)
293 {
294 return OS.objc_msgSend(this.id, OS.sel_setIcon_1forFile_1options_1, image !is null ? image.id : null, fullPath !is null ? fullPath.id : null,
295 options) !is null;
296 }
297
298 public static NSWorkspace sharedWorkspace ()
299 {
300 objc.id result = OS.objc_msgSend(OS.class_NSWorkspace, OS.sel_sharedWorkspace);
301 return result !is null ? new NSWorkspace(result) : null;
302 }
303
304 public void slideImage (NSImage image, NSPoint fromPoint, NSPoint toPoint)
305 {
306 OS.objc_msgSend(this.id, OS.sel_slideImage_1from_1to_1, image !is null ? image.id : null, fromPoint, toPoint);
307 }
308
309 public bool type (NSString firstTypeName, NSString secondTypeName)
310 {
311 return OS.objc_msgSend(this.id, OS.sel_type_1conformsToType_1, firstTypeName !is null ? firstTypeName.id : null,
312 secondTypeName !is null ? secondTypeName.id : null) !is null;
313 }
314
315 public NSString typeOfFile (NSString absoluteFilePath, /*NSError** */objc.id** outError)
316 {
317 objc.id result = OS.objc_msgSend(this.id, OS.sel_typeOfFile_1error_1, absoluteFilePath !is null ? absoluteFilePath.id : null, outError);
318 return result !is null ? new NSString(result) : null;
319 }
320
321 public bool unmountAndEjectDeviceAtPath (NSString path)
322 {
323 return OS.objc_msgSend(this.id, OS.sel_unmountAndEjectDeviceAtPath_1, path !is null ? path.id : null) !is null;
324 }
325
326 public bool userDefaultsChanged ()
327 {
328 return OS.objc_msgSend(this.id, OS.sel_userDefaultsChanged) !is null;
329 }
330
331 }