1 /* 2 NSWorkspace.h 3 4 Interface for workspace. 5 6 Copyright (C) 1996-2016 Free Software Foundation, Inc. 7 8 Author: Scott Christley <scottc@net-community.com> 9 Date: 1996 10 11 This file is part of the GNUstep GUI Library. 12 13 This library is free software; you can redistribute it and/or 14 modify it under the terms of the GNU Lesser General Public 15 License as published by the Free Software Foundation; either 16 version 2 of the License, or (at your option) any later version. 17 18 This library is distributed in the hope that it will be useful, 19 but WITHOUT ANY WARRANTY; without even the implied warranty of 20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 Lesser General Public License for more details. 22 23 You should have received a copy of the GNU Lesser General Public 24 License along with this library; see the file COPYING.LIB. 25 If not, see <http://www.gnu.org/licenses/> or write to the 26 Free Software Foundation, 51 Franklin Street, Fifth Floor, 27 Boston, MA 02110-1301, USA. 28 */ 29 30 #ifndef _GNUstep_H_NSWorkspace 31 #define _GNUstep_H_NSWorkspace 32 33 #import <Foundation/NSObject.h> 34 #import <Foundation/NSGeometry.h> 35 #import <AppKit/AppKitDefines.h> 36 37 #if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST) 38 #import <Foundation/NSAppleEventDescriptor.h> 39 #endif 40 41 @class NSString; 42 @class NSNumber; 43 @class NSArray; 44 @class NSMutableArray; 45 @class NSMutableDictionary; 46 @class NSNotificationCenter; 47 @class NSImage; 48 @class NSView; 49 @class NSURL; 50 51 52 #if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST) 53 enum { 54 NSWorkspaceLaunchAndPrint = 0x2, 55 NSWorkspaceLaunchInhibitingBackgroundOnly = 0x80, 56 NSWorkspaceLaunchWithoutAddingToRecents = 0x100, 57 NSWorkspaceLaunchWithoutActivation = 0x200, 58 NSWorkspaceLaunchAsync = 0x10000, 59 NSWorkspaceLaunchAllowingClassicStartup = 0x20000, 60 NSWorkspaceLaunchPreferringClassic = 0x40000, 61 NSWorkspaceLaunchNewInstance = 0x80000, 62 NSWorkspaceLaunchAndHide = 0x100000, 63 NSWorkspaceLaunchAndHideOthers = 0x200000, 64 NSWorkspaceLaunchDefault = NSWorkspaceLaunchAsync | NSWorkspaceLaunchAllowingClassicStartup 65 }; 66 67 typedef NSUInteger NSWorkspaceLaunchOptions; 68 #endif 69 70 #if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) 71 enum { 72 NSExcludeQuickDrawElementsIconCreationOption = 1 << 1, 73 NSExclude10_4ElementsIconCreationOption = 1 << 2 74 }; 75 76 typedef NSUInteger NSWorkspaceIconCreationOptions; 77 #endif 78 79 @interface NSWorkspace : NSObject 80 { 81 NSMutableDictionary *_iconMap; 82 NSMutableDictionary *_launched; 83 NSNotificationCenter *_workspaceCenter; 84 BOOL _fileSystemChanged; 85 BOOL _userDefaultsChanged; 86 } 87 88 // 89 // Creating a Workspace 90 // 91 + (NSWorkspace*) sharedWorkspace; 92 93 // 94 // Opening Files 95 // 96 - (BOOL) openFile: (NSString*)fullPath; 97 - (BOOL) openFile: (NSString*)fullPath 98 fromImage: (NSImage*)anImage 99 at: (NSPoint)point 100 inView: (NSView*)aView; 101 - (BOOL) openFile: (NSString*)fullPath 102 withApplication: (NSString*)appName; 103 - (BOOL) openFile: (NSString*)fullPath 104 withApplication: (NSString*)appName 105 andDeactivate: (BOOL)flag; 106 - (BOOL) openTempFile: (NSString*)fullPath; 107 #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) 108 - (BOOL) openURL: (NSURL*)url; 109 #endif 110 111 // 112 // Manipulating Files 113 // 114 - (BOOL) performFileOperation: (NSString*)operation 115 source: (NSString*)source 116 destination: (NSString*)destination 117 files: (NSArray*)files 118 tag: (NSInteger*)tag; 119 - (BOOL) selectFile: (NSString*)fullPath 120 inFileViewerRootedAtPath: (NSString*)rootFullpath; 121 122 // 123 // Requesting Information about Files 124 // 125 - (NSString*) fullPathForApplication: (NSString*)appName; 126 - (BOOL) getFileSystemInfoForPath: (NSString*)fullPath 127 isRemovable: (BOOL*)removableFlag 128 isWritable: (BOOL*)writableFlag 129 isUnmountable: (BOOL*)unmountableFlag 130 description: (NSString**)description 131 type: (NSString**)fileSystemType; 132 - (BOOL) getInfoForFile: (NSString*)fullPath 133 application: (NSString**)appName 134 type: (NSString**)type; 135 - (NSImage*) iconForFile: (NSString*)fullPath; 136 - (NSImage*) iconForFiles: (NSArray*)pathArray; 137 - (NSImage*) iconForFileType: (NSString*)fileType; 138 #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) 139 - (BOOL) isFilePackageAtPath: (NSString*)fullPath; 140 #endif 141 #if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST) 142 - (BOOL) setIcon: (NSImage *)image 143 forFile: (NSString *)fullPath 144 options: (NSWorkspaceIconCreationOptions)options; 145 #endif 146 147 // 148 // Tracking Changes to the File System 149 // 150 - (BOOL) fileSystemChanged; 151 - (void) noteFileSystemChanged; 152 #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) 153 - (void) noteFileSystemChanged: (NSString*)path; 154 #endif 155 156 // 157 // Updating Registered Services and File Types 158 // 159 - (void) findApplications; 160 161 // 162 // Launching and Manipulating Applications 163 // 164 - (void) hideOtherApplications; 165 - (BOOL) launchApplication: (NSString*)appName; 166 - (BOOL) launchApplication: (NSString*)appName 167 showIcon: (BOOL)showIcon 168 autolaunch: (BOOL)autolaunch; 169 170 #if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST) 171 - (NSString *) absolutePathForAppBundleWithIdentifier: (NSString *)bundleIdentifier; 172 173 - (BOOL) launchAppWithBundleIdentifier: (NSString *)bundleIdentifier 174 options: (NSWorkspaceLaunchOptions)options 175 additionalEventParamDescriptor: (NSAppleEventDescriptor *)descriptor 176 launchIdentifier: (NSNumber **)identifier; 177 - (BOOL) openURLs: (NSArray *)urls 178 withAppBundleIdentifier: (NSString *)bundleIdentifier 179 options: (NSWorkspaceLaunchOptions)options 180 additionalEventParamDescriptor: (NSAppleEventDescriptor *)descriptor 181 launchIdentifiers: (NSArray **)identifiers; 182 #endif 183 184 #if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST) 185 - (BOOL) filenameExtension: (NSString *)filenameExtension 186 isValidForType: (NSString*)typeName; 187 - (NSString *) localizedDescriptionForType: (NSString *)typeName; 188 - (NSString *) preferredFilenameExtensionForType: (NSString *)typeName; 189 - (BOOL) type: (NSString *)firstTypeName 190 conformsToType: (NSString *)secondTypeName; 191 - (NSString *) typeOfFile: (NSString *)absoluteFilePath 192 error: (NSError **)outError; 193 #endif 194 195 #if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST) 196 - (NSDictionary*) activeApplication; 197 - (NSArray*) launchedApplications; 198 #endif 199 200 // 201 // Unmounting a Device 202 // 203 - (BOOL) unmountAndEjectDeviceAtPath: (NSString*)path; 204 205 // 206 // Tracking Status Changes for Devices 207 // 208 - (void) checkForRemovableMedia; 209 - (NSArray*) mountNewRemovableMedia; 210 - (NSArray*) mountedRemovableMedia; 211 #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) 212 - (NSArray*) mountedLocalVolumePaths; 213 #endif 214 215 // 216 // Notification Center 217 // 218 - (NSNotificationCenter*) notificationCenter; 219 220 // 221 // Tracking Changes to the User Defaults Database 222 // 223 - (void) noteUserDefaultsChanged; 224 - (BOOL) userDefaultsChanged; 225 226 // 227 // Animating an Image 228 // 229 - (void) slideImage: (NSImage*)image 230 from: (NSPoint)fromPoint 231 to: (NSPoint)toPoint; 232 233 // 234 // Requesting Additional Time before Power Off or Logout 235 // 236 - (int) extendPowerOffBy: (int)requested; 237 238 @end 239 240 #if OS_API_VERSION(GS_API_NONE, GS_API_NONE) 241 242 @class NSBundle; 243 244 @interface NSWorkspace (GNUstep) 245 - (NSString*) getBestAppInRole: (NSString*)role 246 forExtension: (NSString*)ext; 247 - (NSString*) getBestIconForExtension: (NSString*)ext; 248 - (NSDictionary*) infoForExtension: (NSString*)ext; 249 - (NSBundle*) bundleForApp:(NSString*)appName; 250 - (NSImage*) appIconForApp:(NSString*)appName; 251 - (NSString*) locateApplicationBinary: (NSString*)appName; 252 - (void) setBestApp: (NSString*)appName 253 inRole: (NSString*)role 254 forExtension: (NSString*)ext; 255 - (void) setBestIcon: (NSString*)iconPath forExtension: (NSString*)ext; 256 - (NSDictionary*) infoForScheme: (NSString*)scheme; 257 - (NSString*) getBestAppInRole: (NSString*)role 258 forScheme: (NSString*)scheme; 259 - (void) setBestApp: (NSString*)appName 260 inRole: (NSString*)role 261 forScheme: (NSString*)scheme; 262 @end 263 #endif 264 265 /* Notifications */ 266 267 /** 268 * This notification is sent by applications when they launch, 269 * the notification userInfo dictionary contains the following - 270 * <deflist> 271 * <term>NSApplicationName</term> 272 * <desc>The name of the launched application. 273 * A string. 274 * </desc> 275 * <term>NSApplicationPath</term> 276 * <desc>The full path to the launched application. 277 * A string. 278 * </desc> 279 * <term>NSApplicationProcessIdentifier</term> 280 * <desc>The process identifier (pid) of the launched application. 281 * </desc> 282 * <term>NSApplicationProcessSerialNumberHigh</term> 283 * <desc>MacOS-X specific ... not present in GNUstep. 284 * </desc> 285 * <term>NSApplicationProcessSerialNumberLow</term> 286 * <desc>MacOS-X specific ... not present in GNUstep. 287 * </desc> 288 * </deflist> 289 */ 290 APPKIT_EXPORT NSString *NSWorkspaceDidLaunchApplicationNotification; 291 292 APPKIT_EXPORT NSString *NSWorkspaceDidMountNotification; 293 APPKIT_EXPORT NSString *NSWorkspaceDidPerformFileOperationNotification; 294 APPKIT_EXPORT NSString *NSWorkspaceDidTerminateApplicationNotification; 295 APPKIT_EXPORT NSString *NSWorkspaceDidUnmountNotification; 296 APPKIT_EXPORT NSString *NSWorkspaceWillLaunchApplicationNotification; 297 APPKIT_EXPORT NSString *NSWorkspaceWillPowerOffNotification; 298 APPKIT_EXPORT NSString *NSWorkspaceWillUnmountNotification; 299 #if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST) 300 APPKIT_EXPORT NSString *NSWorkspaceDidWakeNotification; 301 APPKIT_EXPORT NSString *NSWorkspaceSessionDidBecomeActiveNotification; 302 APPKIT_EXPORT NSString *NSWorkspaceSessionDidResignActiveNotification; 303 APPKIT_EXPORT NSString *NSWorkspaceWillSleepNotification; 304 #endif 305 306 // 307 // Workspace File Type Globals 308 // 309 APPKIT_EXPORT NSString *NSPlainFileType; 310 APPKIT_EXPORT NSString *NSDirectoryFileType; 311 APPKIT_EXPORT NSString *NSApplicationFileType; 312 APPKIT_EXPORT NSString *NSFilesystemFileType; 313 APPKIT_EXPORT NSString *NSShellCommandFileType; 314 315 // 316 // Workspace File Operation Globals 317 // 318 APPKIT_EXPORT NSString *NSWorkspaceCompressOperation; 319 APPKIT_EXPORT NSString *NSWorkspaceCopyOperation; 320 APPKIT_EXPORT NSString *NSWorkspaceDecompressOperation; 321 APPKIT_EXPORT NSString *NSWorkspaceDecryptOperation; 322 APPKIT_EXPORT NSString *NSWorkspaceDestroyOperation; 323 APPKIT_EXPORT NSString *NSWorkspaceDuplicateOperation; 324 APPKIT_EXPORT NSString *NSWorkspaceEncryptOperation; 325 APPKIT_EXPORT NSString *NSWorkspaceLinkOperation; 326 APPKIT_EXPORT NSString *NSWorkspaceMoveOperation; 327 APPKIT_EXPORT NSString *NSWorkspaceRecycleOperation; 328 329 #endif // _GNUstep_H_NSWorkspace 330