示例#1
0
JXImage*
SyGGetDirectorySmallIcon
	(
	const JCharacter* path
	)
{
	JMountType type;
	JXImage* image;
	if ((SyGGetApplication())->IsMountPoint(path, &type) &&
		SyGGetMountPointSmallIcon(type, &image))
		{
		return image;
		}
	else if (SyGIsTrashDirectory(path))
		{
		return SyGGetTrashSmallIcon();
		}
	else if (!JFSFileTreeNode::CanHaveChildren(path))
		{
		return SyGGetLockedFolderSmallIcon();
		}
	else if (!JDirectoryWritable(path))
		{
		return SyGGetReadOnlyFolderSmallIcon();
		}
	else
		{
		return SyGGetFolderSmallIcon();
		}
}
void
SyGApplication::UpdateShortcutMenu
	(
	JXTextMenu* menu
	)
	const
{
	UpdateMountPointList();

	JIndex shortcutIndex = 1;

	JSize count = itsMountPointList->GetElementCount();
	for (JIndex i=1; i<=count; i++)
		{
		const JMountPoint mp = itsMountPointList->GetElement(i);
		menu->AppendItem(*(mp.path), JXMenu::kPlainType, NULL,
						 GetNMShortcut(&shortcutIndex), *(mp.path));

		JXImage* image;
		if (SyGGetMountPointSmallIcon(mp.type, &image))
			{
			menu->SetItemImage(menu->GetItemCount(), image, kJFalse);
			}
		}

	JString trashDir;
	if (SyGGetTrashDirectory(&trashDir, kJFalse))
		{
		menu->AppendItem("Trash", JXMenu::kPlainType, NULL,
						 GetNMShortcut(&shortcutIndex), trashDir);
		menu->SetItemImage(menu->GetItemCount(), SyGGetTrashSmallIcon(), kJFalse);
		}

	menu->ShowSeparatorAfter(menu->GetItemCount());

	JXImage* folderIcon = SyGGetFolderSmallIcon();

	count = itsShortcutList->GetElementCount();
	for (JIndex i=1; i<=count; i++)
		{
		const JString* path = itsShortcutList->NthElement(i);
		menu->AppendItem(*path, JXMenu::kPlainType, NULL,
						 GetNMShortcut(&shortcutIndex), *path);
		menu->SetItemImage(menu->GetItemCount(), folderIcon, kJFalse);
		}
}