Advertisement
Guest User

PSEventCallback

a guest
Jan 11th, 2014
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. static void PSEventCallback(DescriptorEventID event, PIActionDescriptor inputDesc, PIDialogRecordOptions options, void *data)
  2. {
  3.     debugOut("Event: %s", PIUIDToChar(event));
  4.     unsigned int descCount = 0;
  5.     SPErr err = 0;
  6.     if ((err = sPSActionDescriptor->GetCount(inputDesc, &descCount)))
  7.     {
  8.         debugOutError("sPSActionDescriptor->GetCount() returned %d", err);
  9.         return;
  10.     }
  11.  
  12.     for (unsigned int c = 0; c < descCount; ++c)
  13.     {
  14.         // get the key for this item
  15.         DescriptorKeyID thisKeyID;
  16.         if ((err = sPSActionDescriptor->GetKey(inputDesc, c, &thisKeyID)))
  17.         {
  18.             debugOutError("sPSActionDescriptor->GetKey() returned %d", err);
  19.             continue;
  20.         }
  21.  
  22.         // get the type for this key
  23.         DescriptorTypeID typeID;
  24.         if ((err = sPSActionDescriptor->GetType(inputDesc, thisKeyID, &typeID)))
  25.         {
  26.             debugOutError("sPSActionDescriptor->GetType() returned %d", err);
  27.             continue;
  28.         }
  29.         debugOut("typeID: %d", typeID);
  30.         if (typeID != typeObjectSpecifier)
  31.             continue;
  32.        
  33.         // Pull the info
  34.         PIActionReference refValue = 0;
  35.         if ((err = sPSActionDescriptor->GetReference(inputDesc, thisKeyID, &refValue)))
  36.         {
  37.             debugOutError("sPSActionDescriptor->GetReference() returned %d", err);
  38.             continue;
  39.         }
  40.         if (!refValue)
  41.             continue;
  42.  
  43.         // Get class name
  44.         DescriptorClassID classID;
  45.         if ((err = sPSActionReference->GetDesiredClass(refValue, &classID)))
  46.         {
  47.             debugOutError("sPSActionReference->GetDesiredClass() returned %d", err);
  48.             continue;
  49.         }      
  50.         char classStr[255] = { 0 };
  51.         if ((err = sPSActionControl->TypeIDToStringID(classID, classStr, 255)))
  52.         {
  53.             debugOutError("sPSActionControl->TypeIDToStringID() returned %d", err);
  54.             continue;
  55.             }
  56.         if (strstr(classStr, "Tool"))
  57.             sendToolToPlugin(classStr);
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement