Example #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
SyGFindFileDialog::SearchExpr
	(
	const JCharacter* path,
	const JCharacter* expr
	)
{
	JString e = "( ";
	e        += expr;
	e        += " )";

	const JCharacter** vcsDirName;
	const JSize vcsDirNameCount = JGetVCSDirectoryNames(&vcsDirName);
	for (JIndex i=0; i<vcsDirNameCount; i++)
		{
		e += " -a ! -path */";
		e += vcsDirName[i];
		e += "/*";
		}

	SyGTreeDir* dir;
	if ((SyGGetApplication())->OpenDirectory(path, &dir, NULL, kJTrue, kJTrue, kJFalse, kJTrue))
		{
		SyGFindFileTask* task;
		SyGFindFileTask::Create(dir, path, e, &task);
		}
}
SyGTreeDir::~SyGTreeDir()
{
    if (itsAutoMountFlag)
    {
        (SyGGetApplication())->DisplayBusyCursor();		// can take time to flush buffers
        JMount(GetDirectory(), kJFalse);
    }
}
Example #4
0
void
SyGUpdateTrash()
{
	if (theTrashDirInfo != NULL)
		{
		theTrashDirInfo->ForceUpdate();
		(SyGGetApplication())->UpdateTrash();
		}
}
SyGTreeDir::SyGTreeDir
(
    const JCharacter* startPath
)
    :
    JXWindowDirector(JXGetApplication()),
    itsAutoMountFlag(kJFalse)
{
    if ((SyGGetApplication())->IsMountPoint(startPath) &&
            !JIsMounted(startPath))
    {
        itsAutoMountFlag = kJTrue;
        (SyGGetApplication())->DisplayBusyCursor();
        JMount(startPath, kJTrue, kJTrue);
    }

    BuildWindow(startPath);
}
void
SyGTreeDir::BuildWindow
(
    const JCharacter* startPath
)
{
    JXCurrentPathMenu* pathMenu = NULL;

// begin JXLayout

    JXWindow* window = new JXWindow(this, 420,500, "");
    assert( window != NULL );

    JXMenuBar* menuBar =
        new JXMenuBar(window,
                      JXWidget::kHElastic, JXWidget::kFixedTop, 0,0, 420,30);
    assert( menuBar != NULL );

    itsToolBar =
        new JXToolBar(SyGGetPrefsMgr(), kSMainToolBarID, menuBar, 200,200, window,
                      JXWidget::kHElastic, JXWidget::kVElastic, 0,30, 420,450);
    assert( itsToolBar != NULL );

    itsPathInput =
        new SyGPathInput(window,
                         JXWidget::kHElastic, JXWidget::kFixedBottom, 20,480, 340,20);
    assert( itsPathInput != NULL );

    SyGTrashButton* trashButton =
        new SyGTrashButton(window,
                           JXWidget::kFixedRight, JXWidget::kFixedBottom, 390,480, 30,20);
    assert( trashButton != NULL );

    itsDragSrc =
        new SyGFolderDragSource(itsPathInput, &pathMenu, window,
                                JXWidget::kFixedLeft, JXWidget::kFixedBottom, 0,480, 20,20);
    assert( itsDragSrc != NULL );

    itsUpButton =
        new JXTextButton(JGetString("itsUpButton::SyGTreeDir::JXLayout"), window,
                         JXWidget::kFixedRight, JXWidget::kFixedBottom, 360,480, 30,20);
    assert( itsUpButton != NULL );

// end JXLayout

    // folder setup

    JString prefsFile = JCombinePathAndName(startPath, kDirPrefsName);
    prefsFile += JGetUserName();
    if (!JFileExists(prefsFile))
    {
        const JString origPrefsFile = JCombinePathAndName(startPath, kOrigDirPrefsName);
        JRenameFile(origPrefsFile, prefsFile);
    }

    istream* input       = NULL;
    const JString* prefs = NULL;
    std::string s;
    if (!JFileReadable(prefsFile) &&
            (SyGGetApplication())->GetMountPointPrefs(startPath, &prefs))
    {
        s.assign(prefs->GetCString(), prefs->GetLength());
        input = new std::istringstream(s);
    }
    else
    {
        input = new ifstream(prefsFile);
    }
    assert( input != NULL );

    JFileVersion vers = 0;
    JSize w, h;
    if (input->good())
    {
        *input >> vers;

        if (vers <= kSyGCurrentDirSetupVersion)
        {
            window->ReadGeometry(*input);
        }
        else
        {
            delete input;
            input = NULL;
        }
    }