SyGApplication::SyGApplication ( int* argc, char* argv[], JBoolean* displayAbout, JString* prevVersStr ) : JXApplication(argc, argv, kAppSignature, kSyGDefaultStringData), JPrefObject(NULL, kSAppID), itsTermCmd(kDefaultTermCmd), itsGitStatusCmd(kDefaultGitStatusCmd), itsGitHistoryCmd(kDefaultGitHistoryCmd), itsPostCheckoutCmd(kDefaultPostCheckoutCmd) { // Create itsWindowList first so DirectorClosed() won't crash when // warn that prefs are unreadable. itsWindowList = new JPtrArray<SyGTreeDir>(JPtrArrayT::kForgetAll); assert( itsWindowList != NULL ); *displayAbout = SyGCreateGlobals(this); if (!*displayAbout) { *prevVersStr = (SyGGetPrefsMgr())->GetSystemGVersionStr(); if (*prevVersStr == SyGGetVersionNumberStr()) { prevVersStr->Clear(); } else { *displayAbout = kJTrue; } } else { prevVersStr->Clear(); } itsMountPointList = new JMountPointList(JPtrArrayT::kDeleteAll); assert( itsMountPointList != NULL ); JGetUserMountPointList(itsMountPointList, &itsMountPointTime); itsShortcutList = new JPtrArray<JString>(JPtrArrayT::kDeleteAll); assert( itsShortcutList != NULL ); itsShortcutList->SetCompareFunction(CompareShortcuts); itsShortcutList->SetSortOrder(JOrderedSetT::kSortAscending); itsMountPointPrefs = new JStringPtrMap<JString>(JPtrArrayT::kDeleteAll); assert( itsMountPointPrefs != NULL ); SetPrefInfo(SyGGetPrefsMgr(), kSAppID); JPrefObject::ReadPrefs(); ListenTo(itsShortcutList); // don't write taskbar file unless it doesn't exist }
JBoolean SyGApplication::RestoreProgramState() { JPtrArray<JString> children(JPtrArrayT::kDeleteAll); if (!(SyGGetPrefsMgr())->RestoreProgramState(&children)) { return kJFalse; } const JSize count = children.GetElementCount(); for (JIndex i=1; i<=count; i++) { const JString* str = children.NthElement(i); OpenDirectory(*str, NULL, NULL, kJFalse, kJFalse); } if (itsWindowList->IsEmpty()) { JString path; if (!JGetHomeDirectory(&path) || !JFSFileTreeNode::CanHaveChildren(path)) { path = JGetRootDirectory(); } OpenDirectory(path); SyGTreeDir* dir; if (SyGGetTrashDirectory(&path, kJFalse) && OpenDirectory(path, &dir)) { (dir->GetWindow())->Iconify(); } } return kJTrue; }
void SyGApplication::SaveProgramState() { JPtrArray<JString> children(JPtrArrayT::kDeleteAll); const JSize count = itsWindowList->GetElementCount(); for (JIndex i=1; i<=count; i++) { children.Append((itsWindowList->NthElement(i))->GetDirectory()); } (SyGGetPrefsMgr())->SaveProgramState(children); }
SyGFindFileDialog::SyGFindFileDialog ( JXDirector* supervisor ) : JXWindowDirector(supervisor), JPrefObject(SyGGetPrefsMgr(), kSFindFilePrefID) { BuildWindow(); JPrefObject::ReadPrefs(); }
SyGViewManPageDialog::SyGViewManPageDialog ( JXDirector* supervisor ) : JXWindowDirector(supervisor), JPrefObject(SyGGetPrefsMgr(), kSViewManPagePrefID) { BuildWindow(); JPrefObject::ReadPrefs(); }
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; } }