Mercurial > projects > dwt-mac
view dwt/internal/cocoa/NSWorkspace.d @ 13:f565d3a95c0a
Ported dwt.internal
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Fri, 22 Aug 2008 16:46:34 +0200 |
parents | 8b48be5454ce |
children | d8635bb48c7c |
line wrap: on
line source
/******************************************************************************* * Copyright (c) 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation * * Port to the D programming language: * Jacob Carlborg <jacob.carlborg@gmail.com> *******************************************************************************/ module dwt.internal.cocoa.NSWorkspace; import dwt.internal.cocoa.NSAppleEventDescriptor; import dwt.internal.cocoa.NSArray; import dwt.internal.cocoa.NSDictionary; import dwt.internal.cocoa.NSImage; import dwt.internal.cocoa.NSInteger; import dwt.internal.cocoa.NSNotificationCenter; import dwt.internal.cocoa.NSObject; import dwt.internal.cocoa.NSPoint; import dwt.internal.cocoa.NSString; import dwt.internal.cocoa.NSURL; import dwt.internal.cocoa.NSView; import dwt.internal.cocoa.OS; import objc = dwt.internal.objc.runtime; enum NSWorkspaceLaunchOptions : uint { NSWorkspaceLaunchAndPrint = 0x00000002, NSWorkspaceLaunchInhibitingBackgroundOnly = 0x00000080, NSWorkspaceLaunchWithoutAddingToRecents = 0x00000100, NSWorkspaceLaunchWithoutActivation = 0x00000200, NSWorkspaceLaunchAsync = 0x00010000, NSWorkspaceLaunchAllowingClassicStartup = 0x00020000, NSWorkspaceLaunchPreferringClassic = 0x00040000, NSWorkspaceLaunchNewInstance = 0x00080000, NSWorkspaceLaunchAndHide = 0x00100000, NSWorkspaceLaunchAndHideOthers = 0x00200000, NSWorkspaceLaunchDefault = NSWorkspaceLaunchAsync | NSWorkspaceLaunchAllowingClassicStartup } alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchAndPrint NSWorkspaceLaunchAndPrint; alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchInhibitingBackgroundOnly NSWorkspaceLaunchInhibitingBackgroundOnly; alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchWithoutAddingToRecents NSWorkspaceLaunchWithoutAddingToRecents; alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchWithoutActivation NSWorkspaceLaunchWithoutActivation; alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchAsync NSWorkspaceLaunchAsync; alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchAllowingClassicStartup NSWorkspaceLaunchAllowingClassicStartup; alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchPreferringClassic NSWorkspaceLaunchPreferringClassic; alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchNewInstance NSWorkspaceLaunchNewInstance; alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchAndHide NSWorkspaceLaunchAndHide; alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchAndHideOthers NSWorkspaceLaunchAndHideOthers; alias NSWorkspaceLaunchOptions.NSWorkspaceLaunchDefault NSWorkspaceLaunchDefault; enum NSWorkspaceIconCreationOptions : NSUInteger { NSExcludeQuickDrawElementsIconCreationOption = 1 << 1, NSExclude10_4ElementsIconCreationOption = 1 << 2 } alias NSWorkspaceIconCreationOptions.NSExcludeQuickDrawElementsIconCreationOption NSExcludeQuickDrawElementsIconCreationOption; alias NSWorkspaceIconCreationOptions.NSExclude10_4ElementsIconCreationOption NSExclude10_4ElementsIconCreationOption; public class NSWorkspace : NSObject { public this () { super(); } public this (objc.id id) { super(id); } public NSString absolutePathForAppBundleWithIdentifier (NSString bundleIdentifier) { objc.id result = OS.objc_msgSend(this.id_, OS.sel_absolutePathForAppBundleWithIdentifier_1, bundleIdentifier !is null ? bundleIdentifier.id_ : null); return result !is null ? new NSString(result) : null; } public NSDictionary activeApplication () { objc.id result = OS.objc_msgSend(this.id_, OS.sel_activeApplication); return result !is null ? new NSDictionary(result) : null; } public void checkForRemovableMedia () { OS.objc_msgSend(this.id_, OS.sel_checkForRemovableMedia); } public NSInteger extendPowerOffBy (NSInteger requested) { return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_extendPowerOffBy_1, requested); } public bool fileSystemChanged () { return OS.objc_msgSend(this.id_, OS.sel_fileSystemChanged) !is null; } public bool filenameExtension (NSString filenameExtension, NSString typeName) { return OS.objc_msgSend(this.id_, OS.sel_filenameExtension_1isValidForType_1, filenameExtension !is null ? filenameExtension.id_ : null, typeName !is null ? typeName.id_ : null) !is null; } public void findApplications () { OS.objc_msgSend(this.id_, OS.sel_findApplications); } public NSString fullPathForApplication (NSString appName) { objc.id result = OS.objc_msgSend(this.id_, OS.sel_fullPathForApplication_1, appName !is null ? appName.id_ : null); return result !is null ? new NSString(result) : null; } public bool getFileSystemInfoForPath (NSString fullPath, bool* removableFlag, bool* writableFlag, bool* unmountableFlag, /*NSString** */objc.id** description, /*NSString** */objc.id** fileSystemType) { return OS.objc_msgSend(this.id_, OS.sel_getFileSystemInfoForPath_1isRemovable_1isWritable_1isUnmountable_1description_1type_1, fullPath !is null ? fullPath.id_ : null, removableFlag, writableFlag, unmountableFlag, description, fileSystemType) !is null; } public bool getInfoForFile (NSString fullPath, /*NSString** */objc.id** appName, /*NSString** */objc.id** type) { return OS.objc_msgSend(this.id_, OS.sel_getInfoForFile_1application_1type_1, fullPath !is null ? fullPath.id_ : null, appName, type) !is null; } public void hideOtherApplications () { OS.objc_msgSend(this.id_, OS.sel_hideOtherApplications); } public NSImage iconForFile (NSString fullPath) { objc.id result = OS.objc_msgSend(this.id_, OS.sel_iconForFile_1, fullPath !is null ? fullPath.id_ : null); return result !is null ? new NSImage(result) : null; } public NSImage iconForFileType (NSString fileType) { objc.id result = OS.objc_msgSend(this.id_, OS.sel_iconForFileType_1, fileType !is null ? fileType.id_ : null); return result !is null ? new NSImage(result) : null; } public NSImage iconForFiles (NSArray fullPaths) { objc.id result = OS.objc_msgSend(this.id_, OS.sel_iconForFiles_1, fullPaths !is null ? fullPaths.id_ : null); return result !is null ? new NSImage(result) : null; } public bool isFilePackageAtPath (NSString fullPath) { return OS.objc_msgSend(this.id_, OS.sel_isFilePackageAtPath_1, fullPath !is null ? fullPath.id_ : null) !is null; } public bool launchAppWithBundleIdentifier (NSString bundleIdentifier, NSWorkspaceLaunchOptions options, NSAppleEventDescriptor descriptor, /*NSNumber** */objc.id** identifier) { return OS.objc_msgSend(this.id_, OS.sel_launchAppWithBundleIdentifier_1options_1additionalEventParamDescriptor_1launchIdentifier_1, bundleIdentifier !is null ? bundleIdentifier.id_ : null, options, descriptor !is null ? descriptor.id_ : null, identifier) !is null; } public bool launchApplication_ (NSString appName) { return OS.objc_msgSend(this.id_, OS.sel_launchApplication_1, appName !is null ? appName.id_ : null) !is null; } public bool launchApplication_showIcon_autolaunch_ (NSString appName, bool showIcon, bool autolaunch) { return OS.objc_msgSend(this.id_, OS.sel_launchApplication_1showIcon_1autolaunch_1, appName !is null ? appName.id_ : null, showIcon, autolaunch) !is null; } public NSArray launchedApplications () { objc.id result = OS.objc_msgSend(this.id_, OS.sel_launchedApplications); return result !is null ? new NSArray(result) : null; } public NSString localizedDescriptionForType (NSString typeName) { objc.id result = OS.objc_msgSend(this.id_, OS.sel_localizedDescriptionForType_1, typeName !is null ? typeName.id_ : null); return result !is null ? new NSString(result) : null; } public NSArray mountNewRemovableMedia () { objc.id result = OS.objc_msgSend(this.id_, OS.sel_mountNewRemovableMedia); return result !is null ? new NSArray(result) : null; } public NSArray mountedLocalVolumePaths () { objc.id result = OS.objc_msgSend(this.id_, OS.sel_mountedLocalVolumePaths); return result !is null ? new NSArray(result) : null; } public NSArray mountedRemovableMedia () { objc.id result = OS.objc_msgSend(this.id_, OS.sel_mountedRemovableMedia); return result !is null ? new NSArray(result) : null; } public void noteFileSystemChanged () { OS.objc_msgSend(this.id_, OS.sel_noteFileSystemChanged); } public void noteFileSystemChanged_ (NSString path) { OS.objc_msgSend(this.id_, OS.sel_noteFileSystemChanged_1, path !is null ? path.id_ : null); } public void noteUserDefaultsChanged () { OS.objc_msgSend(this.id_, OS.sel_noteUserDefaultsChanged); } public NSNotificationCenter notificationCenter () { objc.id result = OS.objc_msgSend(this.id_, OS.sel_notificationCenter); return result !is null ? new NSNotificationCenter(result) : null; } public bool openFile_ (NSString fullPath) { return OS.objc_msgSend(this.id_, OS.sel_openFile_1, fullPath !is null ? fullPath.id_ : null) !is null; } public bool openFile_fromImage_at_inView_ (NSString fullPath, NSImage anImage, NSPoint point, NSView aView) { return OS.objc_msgSend(this.id_, OS.sel_openFile_1fromImage_1at_1inView_1, fullPath !is null ? fullPath.id_ : null, anImage !is null ? anImage.id_ : null, point, aView !is null ? aView.id_ : null) !is null; } public bool openFile_withApplication_ (NSString fullPath, NSString appName) { return OS.objc_msgSend(this.id_, OS.sel_openFile_1withApplication_1, fullPath !is null ? fullPath.id_ : null, appName !is null ? appName.id_ : null) !is null; } public bool openFile_withApplication_andDeactivate_ (NSString fullPath, NSString appName, bool flag) { return OS.objc_msgSend(this.id_, OS.sel_openFile_1withApplication_1andDeactivate_1, fullPath !is null ? fullPath.id_ : null, appName !is null ? appName.id_ : null, flag) !is null; } public bool openTempFile (NSString fullPath) { return OS.objc_msgSend(this.id_, OS.sel_openTempFile_1, fullPath !is null ? fullPath.id_ : null) !is null; } public bool openURL (NSURL url) { return OS.objc_msgSend(this.id_, OS.sel_openURL_1, url !is null ? url.id_ : null) !is null; } public bool openURLs (NSArray urls, NSString bundleIdentifier, NSWorkspaceLaunchOptions options, NSAppleEventDescriptor descriptor, /*NSArray** */objc.id** identifiers) { return OS.objc_msgSend(this.id_, OS.sel_openURLs_1withAppBundleIdentifier_1options_1additionalEventParamDescriptor_1launchIdentifiers_1, urls !is null ? urls.id_ : null, bundleIdentifier !is null ? bundleIdentifier.id_ : null, options, descriptor !is null ? descriptor.id_ : null, identifiers) !is null; } public bool performFileOperation (NSString operation, NSString source, NSString destination, NSArray files, NSInteger* tag) { return OS.objc_msgSend(this.id_, OS.sel_performFileOperation_1source_1destination_1files_1tag_1, operation !is null ? operation.id_ : null, source !is null ? source.id_ : null, destination !is null ? destination.id_ : null, files !is null ? files.id_ : null, tag) !is null; } public NSString preferredFilenameExtensionForType (NSString typeName) { objc.id result = OS.objc_msgSend(this.id_, OS.sel_preferredFilenameExtensionForType_1, typeName !is null ? typeName.id_ : null); return result !is null ? new NSString(result) : null; } public bool selectFile (NSString fullPath, NSString rootFullpath) { return OS.objc_msgSend(this.id_, OS.sel_selectFile_1inFileViewerRootedAtPath_1, fullPath !is null ? fullPath.id_ : null, rootFullpath !is null ? rootFullpath.id_ : null) !is null; } public bool setIcon (NSImage image, NSString fullPath, NSWorkspaceIconCreationOptions options) { return OS.objc_msgSend(this.id_, OS.sel_setIcon_1forFile_1options_1, image !is null ? image.id_ : null, fullPath !is null ? fullPath.id_ : null, options) !is null; } public static NSWorkspace sharedWorkspace () { objc.id result = OS.objc_msgSend(OS.class_NSWorkspace, OS.sel_sharedWorkspace); return result !is null ? new NSWorkspace(result) : null; } public void slideImage (NSImage image, NSPoint fromPoint, NSPoint toPoint) { OS.objc_msgSend(this.id_, OS.sel_slideImage_1from_1to_1, image !is null ? image.id_ : null, fromPoint, toPoint); } public bool type (NSString firstTypeName, NSString secondTypeName) { return OS.objc_msgSend(this.id_, OS.sel_type_1conformsToType_1, firstTypeName !is null ? firstTypeName.id_ : null, secondTypeName !is null ? secondTypeName.id_ : null) !is null; } public NSString typeOfFile (NSString absoluteFilePath, /*NSError** */objc.id** outError) { objc.id result = OS.objc_msgSend(this.id_, OS.sel_typeOfFile_1error_1, absoluteFilePath !is null ? absoluteFilePath.id_ : null, outError); return result !is null ? new NSString(result) : null; } public bool unmountAndEjectDeviceAtPath (NSString path) { return OS.objc_msgSend(this.id_, OS.sel_unmountAndEjectDeviceAtPath_1, path !is null ? path.id_ : null) !is null; } public bool userDefaultsChanged () { return OS.objc_msgSend(this.id_, OS.sel_userDefaultsChanged) !is null; } }