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; }
JBoolean SyGIsTrashDirectory ( const JCharacter* path ) { JString dir; return JI2B(SyGGetTrashDirectory(&dir, kJFalse) && JSameDirEntry(dir, path)); }
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 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); } }
JBoolean SyGEmptyTrashDirectory() { JString trashDir; const JBoolean hasTrash = SyGGetTrashDirectory(&trashDir, kJFalse); if (hasTrash && JKillDirectory(trashDir)) { JCreateDirectory(trashDir, kTrashCanPerms); SyGUpdateTrash(); return kJTrue; } else if (hasTrash) { (JGetUserNotification())->ReportError(JGetString(kEmptyTrashErrorID)); return kJFalse; } else { return kJTrue; } }
void SyGApplication::OpenShortcut ( const JIndex index ) { const JString* path = NULL; JString trashDir; const JBoolean hasTrashDir = SyGGetTrashDirectory(&trashDir, kJFalse); const JSize mpCount = itsMountPointList->GetElementCount(); const JIndex shortcutOffset = mpCount + (hasTrashDir ? 1 : 0); if (index <= mpCount) { path = (itsMountPointList->GetElement(index)).path; } else if (hasTrashDir && index == mpCount+1) { path = &trashDir; } else { path = itsShortcutList->NthElement(index - shortcutOffset); } if (!OpenDirectory(*path, NULL, NULL, kJTrue, kJFalse) && index > shortcutOffset) { JString msg = "\""; msg += *path; msg += "\" does not exist or is unreadable. Do you want to remove this shortcut?"; if (JGetUserNotification()->AskUserYes(msg)) { itsShortcutList->DeleteElement(index - shortcutOffset); } } }