Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorDamien Plisson <damien.plisson@yahoo.fr>2009-12-18 16:13:14 +0300
committerDamien Plisson <damien.plisson@yahoo.fr>2009-12-18 16:13:14 +0300
commitc836b0ae18cc49e5078420b58a70afee44727937 (patch)
tree1f3a15e5d99103934dae73b21a59bbabf240a16f /intern
parent955f7c92881c6b1d87b2aa71098dc8a989d6155b (diff)
Cocoa : add confirmation request before opening a .blend file (dropped on Blender icon or dbl-clicked in Finder)
Diffstat (limited to 'intern')
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.h30
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.mm31
2 files changed, 46 insertions, 15 deletions
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.h b/intern/ghost/intern/GHOST_SystemCocoa.h
index bcc5da72b2e..81eb8978588 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.h
+++ b/intern/ghost/intern/GHOST_SystemCocoa.h
@@ -140,6 +140,24 @@ public:
*/
GHOST_TUns8 handleQuitRequest();
+ /**
+ * Handle Cocoa openFile event
+ * Display confirmation request panel if changes performed since last save
+ */
+ bool handleOpenDocumentRequest(void *filepathStr);
+
+ /**
+ * Handles a drag'n'drop destination event. Called by GHOST_WindowCocoa window subclass
+ * @param eventType The type of drag'n'drop event
+ * @param draggedObjectType The type object concerned (currently array of file names, string, TIFF image)
+ * @param mouseX x mouse coordinate (in cocoa base window coordinates)
+ * @param mouseY y mouse coordinate
+ * @param window The window on which the event occured
+ * @return Indication whether the event was handled.
+ */
+ GHOST_TSuccess handleDraggingEvent(GHOST_TEventType eventType, GHOST_TDragnDropTypes draggedObjectType,
+ GHOST_WindowCocoa* window, int mouseX, int mouseY, void* data);
+
/***************************************************************************************
** Cursor management functionality
***************************************************************************************/
@@ -207,18 +225,6 @@ public:
GHOST_TSuccess handleApplicationBecomeActiveEvent();
- /**
- * Handles a drag'n'drop destination event. Called by GHOST_WindowCocoa window subclass
- * @param eventType The type of drag'n'drop event
- * @param draggedObjectType The type object concerned (currently array of file names, string, TIFF image)
- * @param mouseX x mouse coordinate (in cocoa base window coordinates)
- * @param mouseY y mouse coordinate
- * @param window The window on which the event occured
- * @return Indication whether the event was handled.
- */
- GHOST_TSuccess handleDraggingEvent(GHOST_TEventType eventType, GHOST_TDragnDropTypes draggedObjectType,
- GHOST_WindowCocoa* window, int mouseX, int mouseY, void* data);
-
protected:
/**
* Initializes the system.
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index 41601cd1c49..71465822bee 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -436,9 +436,7 @@ int cocoa_request_qtcodec_settings(bContext *C, wmOperator *op)
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
{
- NSLog(@"\nGet open file event from cocoa : %@",filename);
- systemCocoa->handleDraggingEvent(GHOST_kEventDraggingDropOnIcon, GHOST_kDragnDropTypeFilenames, nil, 0, 0, [NSArray arrayWithObject:filename]);
- return YES;
+ return systemCocoa->handleOpenDocumentRequest(filename);
}
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
@@ -1086,6 +1084,33 @@ GHOST_TUns8 GHOST_SystemCocoa::handleQuitRequest()
return GHOST_kExitCancel;
}
+bool GHOST_SystemCocoa::handleOpenDocumentRequest(void *filepathStr)
+{
+ NSString *filepath = (NSString*)filepathStr;
+ int confirmOpen = NSAlertAlternateReturn;
+ NSArray *windowsList;
+
+ //Check open windows if some changes are not saved
+ if (m_windowManager->getAnyModifiedState())
+ {
+ confirmOpen = NSRunAlertPanel([NSString stringWithFormat:@"Opening %@",[filepath lastPathComponent]],
+ @"Current document has not been saved.\nDo you really want to proceed?",
+ @"Cancel", @"Open", nil);
+ }
+
+ //Give back focus to the blender window
+ windowsList = [NSApp orderedWindows];
+ if ([windowsList count]) {
+ [[windowsList objectAtIndex:0] makeKeyAndOrderFront:nil];
+ }
+
+ if (confirmOpen == NSAlertAlternateReturn)
+ {
+ handleDraggingEvent(GHOST_kEventDraggingDropOnIcon,GHOST_kDragnDropTypeFilenames,NULL,0,0, [NSArray arrayWithObject:filepath]);
+ return YES;
+ }
+ else return NO;
+}
GHOST_TSuccess GHOST_SystemCocoa::handleTabletEvent(void *eventPtr, short eventType)
{