Changeset View
Changeset View
Standalone View
Standalone View
intern/ghost/intern/GHOST_SystemCocoa.mm
| Context not available. | |||||
| bool GHOST_SystemCocoa::handleOpenDocumentRequest(void *filepathStr) | bool GHOST_SystemCocoa::handleOpenDocumentRequest(void *filepathStr) | ||||
| { | { | ||||
| NSString *filepath = (NSString *)filepathStr; | NSString *filepath = (NSString *)filepathStr; | ||||
| bool confirmOpen = true; | |||||
| NSArray *windowsList; | NSArray *windowsList; | ||||
| char *temp_buff; | char *temp_buff; | ||||
| size_t filenameTextSize; | size_t filenameTextSize; | ||||
| /* Check for blender opened windows and make the frontmost key. In case blender | |||||
| * is minimized, opened on another desktop space, or in full-screen mode. */ | |||||
| windowsList = [NSApp orderedWindows]; | |||||
| if ([windowsList count]) { | |||||
| [[windowsList objectAtIndex:0] makeKeyAndOrderFront:nil]; | |||||
| } | |||||
| GHOST_Window *window = (GHOST_Window *)m_windowManager->getActiveWindow(); | GHOST_Window *window = (GHOST_Window *)m_windowManager->getActiveWindow(); | ||||
| if (!window) { | if (!window) { | ||||
| Context not available. | |||||
| } | } | ||||
| /* Discard event if we are in cursor grab sequence, | /* Discard event if we are in cursor grab sequence, | ||||
| * it'll lead to "stuck cursor" situation if the alert panel is raised */ | * it'll lead to "stuck cursor" situation if the alert panel is raised. */ | ||||
| if (window && window->getCursorGrabModeIsWarp()) | if (window && window->getCursorGrabModeIsWarp()) { | ||||
| return NO; | return NO; | ||||
| // Check open windows if some changes are not saved | |||||
| if (m_windowManager->getAnyModifiedState()) { | |||||
| @autoreleasepool { | |||||
| NSAlert *alert = [[NSAlert alloc] init]; | |||||
| NSString *title = [NSString stringWithFormat:@"Opening %@", [filepath lastPathComponent]]; | |||||
| NSString *text = @"Current document has not been saved.\nDo you really want to proceed?"; | |||||
| [alert addButtonWithTitle:@"Open"]; | |||||
| [alert addButtonWithTitle:@"Cancel"]; | |||||
| [alert setMessageText:title]; | |||||
| [alert setInformativeText:text]; | |||||
| [alert setAlertStyle:NSAlertStyleInformational]; | |||||
| confirmOpen = [alert runModal] == NSAlertFirstButtonReturn; | |||||
| } | |||||
| } | |||||
| // Give back focus to the blender window | |||||
| windowsList = [NSApp orderedWindows]; | |||||
| if ([windowsList count]) { | |||||
| [[windowsList objectAtIndex:0] makeKeyAndOrderFront:nil]; | |||||
| } | } | ||||
| if (confirmOpen) { | filenameTextSize = [filepath lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; | ||||
| filenameTextSize = [filepath lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; | temp_buff = (char *)malloc(filenameTextSize + 1); | ||||
| temp_buff = (char *)malloc(filenameTextSize + 1); | |||||
| if (temp_buff == NULL) { | |||||
| return GHOST_kFailure; | |||||
| } | |||||
| strncpy(temp_buff, [filepath cStringUsingEncoding:NSUTF8StringEncoding], filenameTextSize); | if (temp_buff == NULL) { | ||||
| return GHOST_kFailure; | |||||
| } | |||||
| temp_buff[filenameTextSize] = '\0'; | strncpy(temp_buff, [filepath cStringUsingEncoding:NSUTF8StringEncoding], filenameTextSize); | ||||
| temp_buff[filenameTextSize] = '\0'; | |||||
| pushEvent(new GHOST_EventString( | pushEvent(new GHOST_EventString( | ||||
| getMilliSeconds(), GHOST_kEventOpenMainFile, window, (GHOST_TEventDataPtr)temp_buff)); | getMilliSeconds(), GHOST_kEventOpenMainFile, window, (GHOST_TEventDataPtr)temp_buff)); | ||||
| return YES; | return YES; | ||||
| } | |||||
| else | |||||
| return NO; | |||||
| } | } | ||||
| GHOST_TSuccess GHOST_SystemCocoa::handleTabletEvent(void *eventPtr, short eventType) | GHOST_TSuccess GHOST_SystemCocoa::handleTabletEvent(void *eventPtr, short eventType) | ||||
| Context not available. | |||||