/*
* Copyright 2004 Perforce Software. All rights reserved.
*
* Developed by Data Shades Ltd.
*/
/*
* Handle Photoshop event callbacks
*/
#include <windows.h>
#include "P4GTPhotoshop.h"
#include "InterfaceUtils.h"
#include "PITerminology.h"
CallbackManager::CallbackManager( struct SPPlugin *plugin )
{
sPSActionControl->AddNotify( plugin, eventOpen, OpenFile, NULL );
sPSActionControl->AddNotify( plugin, eventClose, CloseFile, NULL );
sPSActionControl->AddNotify( plugin, eventSelect, SelectFile, NULL );
sPSActionControl->AddNotify( plugin, eventSave, SelectFile, NULL );
// This gets sent when the user does File>>New
// sPSActionControl->AddNotify( plugin, eventMake, SelectFile, NULL );
// sPSActionControl->AddNotify(plugin, eventAll, EventAll, NULL);
}
void CallbackManager::Remove( struct SPPlugin *plugin )
{
sPSActionControl->RemoveNotify( plugin, eventOpen );
sPSActionControl->RemoveNotify( plugin, eventClose );
sPSActionControl->RemoveNotify( plugin, eventSelect );
sPSActionControl->RemoveNotify( plugin, eventSave );
// sPSActionControl->RemoveNotify( plugin, eventMake );
// sPSActionControl->RemoveNotify(plugin, eventAll);
}
void CallbackManager::SelectFile( DescriptorEventID eventID,
PIActionDescriptor descriptor,
PIDialogRecordOptions options,
void* data )
{
char file[MAX_PATH];
UTIL_CurrFilePath( file );
// Quickly validate Windows path.
if (strncmp((char *)file+1, ":\\", 2) == 0 ) {
host->SetCurrentDocPath( file );
}
}
void CallbackManager::OpenFile( DescriptorEventID eventID,
PIActionDescriptor descriptor,
PIDialogRecordOptions options,
void* data )
{
char file[MAX_PATH];
if ( UTIL_PathFromDesc( descriptor, file ) ) {
// Quickly validate Windows path.
if (strncmp((char *)file+1, ":\\", 2) == 0 ) {
host->SetCurrentDocPath( file );
perforceOps->FileOpenEvent();
}
}
}
void CallbackManager::CloseFile( DescriptorEventID eventID,
PIActionDescriptor descriptor,
PIDialogRecordOptions options,
void* data )
{
/*
* Don't bother prompting user to check file in
* as our parent window has already gone.
*/
HWND win = GetParent( host->GetWin() );
if ( IsWindowVisible( win ) )
{
perforceOps->FileCloseEvent();
char file[MAX_PATH];
UTIL_CurrFilePath( file );
// Quickly validate Windows path.
if (strncmp((char *)file+1, ":\\", 2) == 0 ) {
host->SetCurrentDocPath( file );
}
}
}
/*
#include "PSConstantArray.cpp"
void CallbackManager::EventAll(DescriptorEventID eventID, PIActionDescriptor descriptor, PIDialogRecordOptions options, void* data) {
char buff[512];
for (int i=0; i < sizeof(PSConstA); i++) {
if (eventID == PSConstA[i].longVal) {
sprintf(buff, "Got event %s", PSConstA[i].strStr);
DBG_output(buff);
break;
}
}
}
*/