diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSWorkspace.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,331 @@
+/*******************************************************************************
+ * 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;
+    }
+
+}