Exemplo n.º 1
0
void
TestWidget::PrintFileNames
	(
	const Atom selectionName,
	const Time time
	)
	const
{
	JXSelectionManager* selMgr = GetSelectionManager();

	Atom returnType;
	unsigned char* data;
	JSize dataLength;
	JXSelectionManager::DeleteMethod delMethod;
	if (selMgr->GetData(selectionName, time, selMgr->GetURLXAtom(),
						&returnType, &data, &dataLength, &delMethod))
		{
		if (returnType == selMgr->GetURLXAtom())
			{
			JPtrArray<JString> fileNameList(JPtrArrayT::kDeleteAll),
							   urlList(JPtrArrayT::kDeleteAll);
			JXUnpackFileNames((char*) data, dataLength, &fileNameList, &urlList);

			const JSize fileCount = fileNameList.GetElementCount();
			if (fileCount > 0)
				{
				std::cout << "File/directory names:" << std::endl << std::endl;
				for (JIndex i=1; i<=fileCount; i++)
					{
					std::cout << *(fileNameList.NthElement(i)) << std::endl;
					}
				std::cout << std::endl << std::endl;
				}

			const JSize urlCount = urlList.GetElementCount();
			if (urlCount > 0)
				{
				std::cout << "Unconvertable URLs:" << std::endl << std::endl;
				for (JIndex i=1; i<=urlCount; i++)
					{
					std::cout << *(urlList.NthElement(i)) << std::endl;
					}
				std::cout << std::endl << std::endl;
				}

			JXReportUnreachableHosts(urlList);
			}

		selMgr->DeleteData(&data, delMethod);
		}
}
Exemplo n.º 2
0
JBoolean
JXPathInput::GetDroppedDirectory
	(
	const Time		time,
	const JBoolean	reportErrors,
	JString*		dirName
	)
{
	dirName->Clear();

	JXSelectionManager* selMgr = GetSelectionManager();

	Atom returnType;
	unsigned char* data;
	JSize dataLength;
	JXSelectionManager::DeleteMethod delMethod;
	if (selMgr->GetData(GetDNDManager()->GetDNDSelectionName(),
						time, selMgr->GetURLXAtom(),
						&returnType, &data, &dataLength, &delMethod))
		{
		if (returnType == selMgr->GetURLXAtom())
			{
			JPtrArray<JString> fileNameList(JPtrArrayT::kDeleteAll),
							   urlList(JPtrArrayT::kDeleteAll);
			JXUnpackFileNames((char*) data, dataLength, &fileNameList, &urlList);
			if (fileNameList.GetElementCount() == 1 &&
				(JDirectoryExists(*(fileNameList.FirstElement())) ||
				 JFileExists(*(fileNameList.FirstElement()))))
				{
				*dirName = *(fileNameList.FirstElement());

				JString homeDir;
				if (JGetHomeDirectory(&homeDir) &&
					dirName->BeginsWith(homeDir))
					{
					dirName->ReplaceSubstring(1, homeDir.GetLength(), "~" ACE_DIRECTORY_SEPARATOR_STR);
					}
				}
			JXReportUnreachableHosts(urlList);
			}

		selMgr->DeleteData(&data, delMethod);
		}

	return !dirName->IsEmpty();
}
Exemplo n.º 3
0
JBoolean
JXFileInput::GetDroppedFileName
	(
	const Time		time,
	const JBoolean	reportErrors,
	JString*		fileName
	)
{
	fileName->Clear();

	JXSelectionManager* selMgr = GetSelectionManager();

	Atom returnType;
	unsigned char* data;
	JSize dataLength;
	JXSelectionManager::DeleteMethod delMethod;
	if (selMgr->GetData((GetDNDManager())->GetDNDSelectionName(),
						time, selMgr->GetURLXAtom(),
						&returnType, &data, &dataLength, &delMethod))
		{
		if (returnType == selMgr->GetURLXAtom())
			{
			JPtrArray<JString> fileNameList(JPtrArrayT::kDeleteAll),
							   urlList(JPtrArrayT::kDeleteAll);
			JXUnpackFileNames((char*) data, dataLength, &fileNameList, &urlList);
			if (fileNameList.GetElementCount() == 1 &&
				(JFileExists(*(fileNameList.FirstElement())) ||
				 JDirectoryExists(*(fileNameList.FirstElement()))))
				{
				*fileName = *(fileNameList.FirstElement());
				}
			JXReportUnreachableHosts(urlList);
			}

		selMgr->DeleteData(&data, delMethod);
		}

	return JNegate( fileName->IsEmpty() );
}
Exemplo n.º 4
0
void
TestWidget::HandleDNDDrop
	(
	const JPoint&		pt,
	const JArray<Atom>&	typeList,
	const Atom			action,
	const Time			time,
	const JXWidget*		source
	)
{
	JXDisplay* display         = GetDisplay();
	JXSelectionManager* selMgr = GetSelectionManager();

	std::cout << std::endl;
	std::cout << "Data types available from DND source:" << std::endl;
	std::cout << std::endl;

//	(JGetUserNotification())->DisplayMessage("testing");

	Atom textType = None;
	JBoolean url  = kJFalse;
	const JSize typeCount = typeList.GetElementCount();
	for (JIndex i=1; i<=typeCount; i++)
		{
		const Atom type = typeList.GetElement(i);
		std::cout << XGetAtomName(*display, type) << std::endl;
		if (type == selMgr->GetMimePlainTextXAtom())
			{
			textType = type;
			}
		else if (type == selMgr->GetURLXAtom())
			{
			url = kJTrue;
			}
		}
	std::cout << std::endl;

	if (textType != None)
		{
		PrintSelectionText(GetDNDManager()->GetDNDSelectionName(), time, textType);
		}

	if (url)
		{
		PrintFileNames(GetDNDManager()->GetDNDSelectionName(), time);
		}
}