Beispiel #1
0
JBoolean
SyGCreateGlobals
	(
	SyGApplication* app
	)
{
	theApplication = app;

	SyGCreateIcons();

	JString oldPrefsFile, newPrefsFile;
	if (JGetPrefsDirectory(&oldPrefsFile))
		{
		oldPrefsFile = JCombinePathAndName(oldPrefsFile, ".gSystemG.pref");
		if (JFileExists(oldPrefsFile) &&
			(JPrefsFile::GetFullName(app->GetSignature(), &newPrefsFile)).OK() &&
			!JFileExists(newPrefsFile))
			{
			JRenameFile(oldPrefsFile, newPrefsFile);
			}
		}

	JBoolean isNew;
	thePrefsMgr = new SyGPrefsMgr(&isNew);
	assert(thePrefsMgr != NULL);

	JXInitHelp(kSyGTOCHelpName, kSyGHelpSectionCount, kSyGHelpSectionName);

	JXWDManager* wdMgr = new JXWDManager(app->GetCurrentDisplay(), kJTrue);
	assert( wdMgr != NULL );
	// registers itself

	theMDIServer = new SyGMDIServer;
	assert( theMDIServer != NULL );

	theManPageDialog = new SyGViewManPageDialog(JXGetPersistentWindowOwner());
	assert( theManPageDialog != NULL );

	theFindFileDialog = new SyGFindFileDialog(JXGetPersistentWindowOwner());
	assert( theFindFileDialog != NULL );

	theAltChooseSaveFile = new SyGChooseSaveFile(thePrefsMgr, kSAltCSSetupID);
	assert( theAltChooseSaveFile != NULL );

	JString trashDir;
	SyGGetTrashDirectory(&trashDir, kJFalse);	// silently creates it

	return isNew;
}
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;
        }
    }