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
JDirInfo::ForceUpdate()
{
	if (JDirectoryExists(*itsCWD))
		{
		Broadcast(ContentsWillBeUpdated());

		const JError err = BuildInfo();
		if (err.OK())
			{
			return kJTrue;
			}
		}

	if (itsSwitchIfInvalidFlag)
		{
		JString path;
		if (!JGetHomeDirectory(&path) || !OKToCreate(path))
			{
			path = JGetRootDirectory();
			}
		GoTo(path);
		}
	else
		{
		itsIsValidFlag    = kJFalse;
		itsIsWritableFlag = kJFalse;
		itsDirEntries->CleanOut();
		itsVisEntries->CleanOut();
		itsAlphaEntries->CleanOut();
		}

	return kJFalse;
}
예제 #3
0
JBoolean
JGetPrefsDirectory
	(
	JString* prefsDir
	)
{
	return JGetHomeDirectory(prefsDir);
}
예제 #4
0
JBoolean
JGetPrefsDirectory
	(
	const JCharacter*	user,
	JString*			prefsDir
	)
{
	return JGetHomeDirectory(user, prefsDir);
}
예제 #5
0
JBoolean
JXPathInput::GetDroppedDirectory
	(
	const Time		time,
	const JBoolean	reportErrors,
	JString*		dirName
	)
{
	dirName->Clear();

	JXSelectionManager* selMgr = GetSelectionManager();

	Atom returnType;
	unsigned char* data;
	JSize dataLength;
	JXSelectionManager::DeleteMethod delMethod;
	if (selMgr->GetData(GetDNDManager()->GetDNDSelectionName(),
						time, selMgr->GetURLXAtom(),
						&returnType, &data, &dataLength, &delMethod))
		{
		if (returnType == selMgr->GetURLXAtom())
			{
			JPtrArray<JString> fileNameList(JPtrArrayT::kDeleteAll),
							   urlList(JPtrArrayT::kDeleteAll);
			JXUnpackFileNames((char*) data, dataLength, &fileNameList, &urlList);
			if (fileNameList.GetElementCount() == 1 &&
				(JDirectoryExists(*(fileNameList.FirstElement())) ||
				 JFileExists(*(fileNameList.FirstElement()))))
				{
				*dirName = *(fileNameList.FirstElement());

				JString homeDir;
				if (JGetHomeDirectory(&homeDir) &&
					dirName->BeginsWith(homeDir))
					{
					dirName->ReplaceSubstring(1, homeDir.GetLength(), "~" ACE_DIRECTORY_SEPARATOR_STR);
					}
				}
			JXReportUnreachableHosts(urlList);
			}

		selMgr->DeleteData(&data, delMethod);
		}

	return !dirName->IsEmpty();
}
JString
CBCommandPathInput::GetTextForChoosePath()
	const
{
	if (!GetText().IsEmpty() && GetText().GetFirstCharacter() == '@')
		{
		JString s;
		if (!GetBasePath(&s) &&
			!JGetHomeDirectory(&s))
			{
			s = JGetRootDirectory();
			}
		return s;
		}
	else
		{
		return JXPathInput::GetTextForChoosePath();
		}
}
JString
GPrefsMgr::GetCurrentOutbox()
{
	JString homeDir;
	JBoolean fileok = JGetHomeDirectory(&homeDir);
	JAppendDirSeparator(&homeDir);
	JString outbox = homeDir + ".outbox";
	return outbox;

	std::string data;
	const JBoolean ok = GetData(kGCurrentOutboxID, &data);
	assert( ok );

	std::istringstream dataStream(data);

	JString mbox;
	dataStream >> mbox;
	return mbox;
}
예제 #8
0
JString
JGetCurrentDirectory()
{
	char buf[1024];
	char* result = getcwd(buf, 1024);

	JString dirName;
	if (result == buf)
		{
		dirName = buf;
		}
	else if (!JGetHomeDirectory(&dirName) || !(JChangeDirectory(dirName)).OK())
		{
		dirName = JGetRootDirectory();
		JChangeDirectory(dirName);
		}

	JAppendDirSeparator(&dirName);
	return dirName;
}
예제 #9
0
GMApp::GMApp
(
    int*		argc,
    char*		argv[],
    JBoolean*	displayAbout,
    JString*	prevVersStr
)
    :
    JXApplication(argc, argv, kAppSignature, kGMDefaultStringData),
    itsTableDirs(NULL),
    itsHasFileDirectory(kJFalse),
    itsOpenPrefsAfterAbout(kJFalse),
    itsPrefsNew(kJFalse),
    itsAboutDialog(NULL)
{
    *displayAbout = GMCreateGlobals(this);

    if (!*displayAbout)
    {
        *prevVersStr = (GGetPrefsMgr())->GetArrowVersionStr();
        if (*prevVersStr == GMGetVersionNumberStr())
        {
            prevVersStr->Clear();
        }
        else
        {
            *displayAbout = kJTrue;
            if (prevVersStr->BeginsWith("1") ||
                    prevVersStr->BeginsWith("0") ||
                    prevVersStr->BeginsWith("2.0b"))
            {
                itsOpenPrefsAfterAbout	= kJTrue;
            }
        }
    }
    else
    {
        itsPrefsNew				= kJTrue;
        itsOpenPrefsAfterAbout	= kJTrue;
        prevVersStr->Clear();
    }

    GMMDIServer* mdi = new GMMDIServer(this);
    assert(mdi != NULL);

    itsTableDirs = new JPtrArray<GMessageTableDir>(JPtrArrayT::kForgetAll);
    assert(itsTableDirs != NULL);

    itsEditDirs = new JPtrArray<GMessageEditDir>(JPtrArrayT::kForgetAll);
    assert(itsEditDirs != NULL);

    itsLockTasks = new JPtrArray<GLockFileTask>(JPtrArrayT::kForgetAll);
    assert(itsLockTasks != NULL);

    if (*displayAbout)
    {
        if (!(JGetUserNotification())->AcceptLicense())
        {
            exit(0);
        }
    }

    JString home;
    if (JGetHomeDirectory(&home))
    {
        JAppendDirSeparator(&home);
        home += kArrowFilesDir;
        if (!JDirectoryExists(home))
        {
            JError err = JCreateDirectory(home);
            if (err.OK())
            {
                itsFileDirectory	= home;
                itsHasFileDirectory	= kJTrue;
            }
        }
        else
        {
            if (JKillDirectory(home))
            {
                JCreateDirectory(home);
            }
            if (JDirectoryExists(home))
            {
                itsFileDirectory	= home;
                itsHasFileDirectory	= kJTrue;
            }
        }
    }

    JBoolean ok = OpenSession();

    if (*argc > 1)
    {
        mdi->HandleCmdLineOptions(*argc, argv);
    }
    else if (!ok)
    {
        OpenSystemMailbox();
    }

    OpenMailboxWindowIfNeeded();

    ListenTo(GGetPrefsMgr());

    /*	JString test("pulp");
    	JPtrArray<JString> names;
    	GParseNameList(test, names);
    	JPtrArray<JString> aliases;
    	aliases.SetCompareFunction(JCompareStringsCaseSensitive);
    	JSize i = 1;
    	while (i <= names.GetElementCount())
    		{
    		JString& name = *(names.NthElement(i));
    		JString alias;
    		JString fcc;
    		if (GGetAddressBookMgr()->NameIsAlias(name, alias, fcc))
    			{
    			JIndex findex;
    			if (!aliases.SearchSorted(&name, JOrderedSetT::kAnyMatch, &findex))
    				{
    				GParseNameList(alias, names);
    				aliases.InsertSorted(names.NthElement(i));
    				names.RemoveElement(i);
    				}
    			else
    				{
    				names.DeleteElement(i);
    				}
    			}
    		else
    			{
    			i++;
    			}
    		}
    	aliases.DeleteAll();
    	const JSize count	= names.GetElementCount();
    	for (JIndex i = 1; i <= count; i++)
    		{
    		cout << *(names.NthElement(i)) << endl;
    		}*/
}
void
GPrefsMgr::UpgradeData
	(
	const JBoolean		isNew,
	const JFileVersion	currentVersion
	)
{
	if (isNew)
		{
		JString homeDir;
		JBoolean fileok = JGetHomeDirectory(&homeDir);
		JAppendDirSeparator(&homeDir);
		JString outbox = homeDir + ".outbox";
		SetCurrentOutbox(outbox);

		JString username = JGetUserName();

		JString inbox = "/var/spool/mail/" + username;
		SetDefaultInbox(inbox);

		ShowStateInTitle(kJTrue);
		SetPopServer(JString("pop-server"));
		UsePopServer(kJFalse);
		SetLeaveOnServer(kJFalse);
		SetPopUserName(JString("name"));
		SetPopPasswd(JString(""));
		SetRememberPasswd(kJFalse);
		UseAPop(kJFalse);
		AutoInsertQuote(kJTrue);
		AutoCheckMail(kJFalse);
		SetCheckMailDelay(30);
		SetDefaultMonoFont(JGetMonospaceFontName());
		JCharacter* var = getenv("REPLYTO");
		if (var != NULL)
			{
			JString varStr(var);
			SetReplyTo(varStr);
			}
		ShowSenderString(kJTrue);
		SetSenderString("On $d, $f wrote:");
		JXGetWebBrowser()->SetComposeMailCmd(kGMDefaultMailtoString);
		SetFilterFile(".procmailrc");
		}
	else
		{
		if (currentVersion < 2)
			{
			ShowStateInTitle(kJTrue);
			}
		if (currentVersion < 3)
			{
			UseAPop(kJFalse);
			AutoInsertQuote(kJTrue);
			AutoCheckMail(kJFalse);
			SetCheckMailDelay(30);
			}
		if (currentVersion < 4)
			{
			JCharacter* var = getenv("REPLYTO");
			if (var != NULL)
				{
				JString varStr(var);
				SetReplyTo(varStr);
				}
			ShowSenderString(kJTrue);
			SetSenderString("On $d, $f wrote:");
			}
		if (currentVersion < 5)
			{
			RemoveData(kGHelpSetupID);
			JXGetWebBrowser()->SetComposeMailCmd(kGMDefaultMailtoString);
			}
		if (currentVersion < 7)
			{
			SetFilterFile(".procmailrc");
			}
		if (currentVersion < 10)
			{
			RemoveData(42);
			RemoveData(45);
			}
		}
}
예제 #11
0
JBoolean
JExpandHomeDirShortcut
	(
	const JCharacter*	path,
	JString*			result,
	JString*			homeDir,
	JSize*				homeLength
	)
{
	assert( !JStringEmpty(path) && result != NULL );

	JBoolean ok = kJTrue;
	if (path[0] == '~' && path[1] == '\0')
		{
		ok = JGetHomeDirectory(result);
		if (ok && homeDir != NULL)
			{
			*homeDir = *result;
			}
		if (ok && homeLength != NULL)
			{
			*homeLength = 1;
			}
		}
	else if (path[0] == '~' && path[1] == '/')
		{
		ok = JGetHomeDirectory(result);
		if (ok && homeDir != NULL)
			{
			*homeDir = *result;
			}
		if (ok && homeLength != NULL)
			{
			*homeLength = 2;
			}
		if (ok && path[2] != '\0')
			{
			*result = JCombinePathAndName(*result, path+2);
			}
		}
	else if (path[0] == '~')
		{
		JString userName = path+1;
		JIndex i;
		const JBoolean found = userName.LocateSubstring("/", &i);
		if (found)
			{
			userName.RemoveSubstring(i, userName.GetLength());
			}

		ok = JGetHomeDirectory(userName, result);
		if (ok && homeDir != NULL)
			{
			*homeDir = *result;
			}
		if (ok && homeLength != NULL)
			{
			*homeLength = found ? i+1 : strlen(path);
			}
		if (ok && found && path[i+1] != '\0')
			{
			*result = JCombinePathAndName(*result, path+i+1);
			}
		}
	else
		{
		*result = path;
		if (homeDir != NULL)
			{
			homeDir->Clear();
			}
		if (homeLength != NULL)
			{
			*homeLength = 0;
			}
		}

	if (ok)
		{
		return kJTrue;
		}
	else
		{
		result->Clear();
		if (homeDir != NULL)
			{
			homeDir->Clear();
			}
		if (homeLength != NULL)
			{
			*homeLength = 0;
			}
		return kJFalse;
		}
}
void
GMailPrefsDialog::BuildWindow
	(
	const JBoolean	showstate,
	const JBoolean	autoQuote,
	const JBoolean	showSender,
	const JString&	senderString,
	const JString&	fontname,
	const JSize	fontsize,
	const JSize		maxQuotedReply,
	const JBoolean	reportSCErrors,
	const JSize		spacesPerTab,
	const JBoolean	beepOnNewMail,
	const JIndex	encType,
	const JString&	filterFile,
	const JString&	defInbox,
	const JBoolean 	openMailboxWindow
	)
{

// begin JXLayout

	JXWindow* window = new JXWindow(this, 360,550, "");
	assert( window != NULL );

	itsMaxReplyInput =
		new JXIntegerInput(window,
					JXWidget::kHElastic, JXWidget::kVElastic, 270,335, 40,20);
	assert( itsMaxReplyInput != NULL );

	itsSenderStringInput =
		new JXInputField(window,
					JXWidget::kHElastic, JXWidget::kVElastic, 100,385, 240,20);
	assert( itsSenderStringInput != NULL );

	itsSpacesPerTabInput =
		new JXIntegerInput(window,
					JXWidget::kHElastic, JXWidget::kVElastic, 140,80, 40,20);
	assert( itsSpacesPerTabInput != NULL );

	JXTextButton* okButton =
		new JXTextButton(JGetString("okButton::GMailPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 260,515, 70,20);
	assert( okButton != NULL );
	okButton->SetShortcuts(JGetString("okButton::GMailPrefsDialog::shortcuts::JXLayout"));

	JXTextButton* cancelButton =
		new JXTextButton(JGetString("cancelButton::GMailPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 30,515, 70,20);
	assert( cancelButton != NULL );
	cancelButton->SetShortcuts(JGetString("cancelButton::GMailPrefsDialog::shortcuts::JXLayout"));

	itsShowStateInTitle =
		new JXTextCheckbox(JGetString("itsShowStateInTitle::GMailPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,310, 250,20);
	assert( itsShowStateInTitle != NULL );

	itsAutoQuote =
		new JXTextCheckbox(JGetString("itsAutoQuote::GMailPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,335, 250,20);
	assert( itsAutoQuote != NULL );

	itsShowSenderString =
		new JXTextCheckbox(JGetString("itsShowSenderString::GMailPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,360, 250,20);
	assert( itsShowSenderString != NULL );

	itsSenderText =
		new JXStaticText(JGetString("itsSenderText::GMailPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 50,385, 50,20);
	assert( itsSenderText != NULL );
	itsSenderText->SetToLabel();

	itsHelpButton =
		new JXTextButton(JGetString("itsHelpButton::GMailPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 145,515, 70,20);
	assert( itsHelpButton != NULL );

	itsFontMenu =
		new JXChooseMonoFont(window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,10, 310,60);
	assert( itsFontMenu != NULL );

	JXStaticText* obj1_JXLayout =
		new JXStaticText(JGetString("obj1_JXLayout::GMailPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 315,335, 30,20);
	assert( obj1_JXLayout != NULL );
	obj1_JXLayout->SetToLabel();

	itsReportSCErrorsCB =
		new JXTextCheckbox(JGetString("itsReportSCErrorsCB::GMailPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,420, 250,20);
	assert( itsReportSCErrorsCB != NULL );

	JXStaticText* obj2_JXLayout =
		new JXStaticText(JGetString("obj2_JXLayout::GMailPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 40,80, 100,20);
	assert( obj2_JXLayout != NULL );
	obj2_JXLayout->SetToLabel();

	itsBeepOnNewMailCB =
		new JXTextCheckbox(JGetString("itsBeepOnNewMailCB::GMailPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,285, 250,20);
	assert( itsBeepOnNewMailCB != NULL );

	itsEncryptionType =
		new JXRadioGroup(window,
					JXWidget::kHElastic, JXWidget::kVElastic, 45,175, 145,70);
	assert( itsEncryptionType != NULL );

	JXTextRadioButton* obj3_JXLayout =
		new JXTextRadioButton(1, JGetString("obj3_JXLayout::GMailPrefsDialog::JXLayout"), itsEncryptionType,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,15, 100,20);
	assert( obj3_JXLayout != NULL );

	JXTextRadioButton* obj4_JXLayout =
		new JXTextRadioButton(2, JGetString("obj4_JXLayout::GMailPrefsDialog::JXLayout"), itsEncryptionType,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,35, 100,20);
	assert( obj4_JXLayout != NULL );

	JXStaticText* obj5_JXLayout =
		new JXStaticText(JGetString("obj5_JXLayout::GMailPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 55,168, 120,20);
	assert( obj5_JXLayout != NULL );
	obj5_JXLayout->SetToLabel();

	JXStaticText* obj6_JXLayout =
		new JXStaticText(JGetString("obj6_JXLayout::GMailPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,480, 90,20);
	assert( obj6_JXLayout != NULL );
	obj6_JXLayout->SetToLabel();

	itsFilterButton =
		new JXTextButton(JGetString("itsFilterButton::GMailPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 290,480, 60,20);
	assert( itsFilterButton != NULL );

	itsDefaultInbox =
		new JXFileInput(window,
					JXWidget::kHElastic, JXWidget::kVElastic, 110,450, 180,20);
	assert( itsDefaultInbox != NULL );

	itsInboxButton =
		new JXTextButton(JGetString("itsInboxButton::GMailPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kFixedTop, 290,450, 60,20);
	assert( itsInboxButton != NULL );

	JXStaticText* obj7_JXLayout =
		new JXStaticText(JGetString("obj7_JXLayout::GMailPrefsDialog::JXLayout"), window,
					JXWidget::kFixedLeft, JXWidget::kFixedTop, 20,450, 90,20);
	assert( obj7_JXLayout != NULL );
	obj7_JXLayout->SetToLabel();

	itsFilterFileInput =
		new JXFileInput(window,
					JXWidget::kHElastic, JXWidget::kVElastic, 110,480, 180,20);
	assert( itsFilterFileInput != NULL );

	itsCopySelectedCB =
		new JXTextCheckbox(JGetString("itsCopySelectedCB::GMailPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,110, 270,20);
	assert( itsCopySelectedCB != NULL );

	itsHomeEndCB =
		new JXTextCheckbox(JGetString("itsHomeEndCB::GMailPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,135, 270,20);
	assert( itsHomeEndCB != NULL );

	itsOpenMailTreeCB =
		new JXTextCheckbox(JGetString("itsOpenMailTreeCB::GMailPrefsDialog::JXLayout"), window,
					JXWidget::kHElastic, JXWidget::kVElastic, 20,260, 250,20);
	assert( itsOpenMailTreeCB != NULL );

// end JXLayout

	window->SetTitle("Mail Preferences");
	SetButtons(okButton, cancelButton);

	ListenTo(itsShowSenderString);
	ListenTo(itsHelpButton);
	ListenTo(itsAutoQuote);

	itsShowStateInTitle->SetState(showstate);
	itsAutoQuote->SetState(autoQuote);

	itsSenderStringInput->SetText(senderString);
	itsShowSenderString->SetState(showSender);

	itsFontMenu->SetFont(fontname, fontsize);

	itsMaxReplyInput->SetValue(maxQuotedReply);

	itsSpacesPerTabInput->SetValue(spacesPerTab);

	itsReportSCErrorsCB->SetState(reportSCErrors);

	itsBeepOnNewMailCB->SetState(beepOnNewMail);
	itsOpenMailTreeCB->SetState(openMailboxWindow);

	AdjustForSenderString(showSender);
	AdjustForQuotedReply(autoQuote);

	itsEncryptionType->SelectItem(encType);

	JString home;
	if (JGetHomeDirectory(&home))
		{
		JAppendDirSeparator(&home);
		itsDefaultInbox->SetBasePath(home);
		itsFilterFileInput->SetBasePath(home);
		}

	itsDefaultInbox->SetText(defInbox);
	itsDefaultInbox->ShouldAllowInvalidFile();
	ListenTo(itsInboxButton);

	itsFilterFileInput->SetText(filterFile);
	itsFilterFileInput->ShouldAllowInvalidFile();
	ListenTo(itsFilterButton);

	itsCopySelectedCB->SetState(JTextEditor::WillCopyWhenSelect());
	itsHomeEndCB->SetState(JXTEBase::WillUseWindowsHomeEnd());
}
예제 #13
0
JIndex
SyGGetMountPointLargeIcon
	(
	const JCharacter*	path,
	SyGFileTreeList*	fileList,
	JXPM*				plainIcon,
	JXPM*				selectedIcon
	)
{
	JMountType type;
	const JBoolean isMP = theApplication->IsMountPoint(path, &type);

	if (!isMP)
		{
		JBoolean writable, isTop;
		JString device, fsTypeString;
		JFileSystemType fsType;
		if (JIsMounted(path, &writable, &isTop, &device, &fsType, &fsTypeString))
			{
			type = JGetUserMountPointType(path, device, fsTypeString);
			}
		else
			{
			type = kJHardDisk;
			}
		}

	const JBoolean writable = JDirectoryWritable(path);

	JString dir;
	if (JGetHomeDirectory(&dir) && JSameDirEntry(dir, path))
		{
		*plainIcon    = syg_home_folder_large;
		*selectedIcon = syg_home_folder_selected_large;
		return 1;
		}
	else if (SyGIsTrashDirectory(path))
		{
		(fileList->GetSyGFileTree())->Update();
		if (fileList->IsEmpty())
			{
			*plainIcon    = jx_trash_can_empty_large;
			*selectedIcon = jx_trash_can_empty_selected_large;
			return 2;
			}
		else
			{
			*plainIcon    = jx_trash_can_full_large;
			*selectedIcon = jx_trash_can_full_selected_large;
			return 3;
			}
		}
	else if (!isMP && type == kJFloppyDisk && !writable)
		{
		*plainIcon    = syg_floppy_folder_read_only_large;
		*selectedIcon = syg_floppy_folder_read_only_large;
		return 4;
		}
	else if (!isMP && type == kJFloppyDisk)
		{
		*plainIcon    = syg_floppy_folder_large;
		*selectedIcon = syg_floppy_folder_large;
		return 5;
		}
	else if (!isMP && type == kJCDROM && !writable)
		{
		*plainIcon    = syg_cdrom_folder_read_only_large;
		*selectedIcon = syg_cdrom_folder_read_only_large;
		return 4;
		}
	else if (!isMP && type == kJCDROM)
		{
		*plainIcon    = syg_cdrom_folder_large;
		*selectedIcon = syg_cdrom_folder_large;
		return 5;
		}
	else if (!isMP && !writable)
		{
		*plainIcon    = jx_folder_read_only_large;
		*selectedIcon = jx_folder_read_only_selected_large;
		return 6;
		}
	else if (!isMP)
		{
		*plainIcon    = jx_folder_large;
		*selectedIcon = jx_folder_selected_large;
		return 7;
		}
	else if (type == kJFloppyDisk)
		{
		*plainIcon    = jx_floppy_disk_large;
		*selectedIcon = jx_floppy_disk_selected_large;
		return 8;
		}
	else if (type == kJCDROM)
		{
		*plainIcon    = jx_cdrom_disk_large;
		*selectedIcon = jx_cdrom_disk_selected_large;
		return 9;
		}
	else
		{
		*plainIcon    = jx_hard_disk_large;
		*selectedIcon = jx_hard_disk_selected_large;
		return 11;
		}
}
예제 #14
0
void
TestWidget::HandleMouseDown
	(
	const JPoint&			pt,
	const JXMouseButton		button,
	const JSize				clickCount,
	const JXButtonStates&	buttonStates,
	const JXKeyModifiers&	modifiers
	)
{
	if (button == kJXLeftButton && clickCount == 1 && itsHomeRect.Contains(pt))
		{
		JString dir;
		if (JGetHomeDirectory(&dir))
			{
			JPtrArray<JString> list(JPtrArrayT::kForgetAll);
			list.Append(&dir);

			// Normally, you should use the other constructor and then
			// override JXWidget::GetSelectionData().

			JXFileSelection* data = jnew JXFileSelection(GetDisplay(), list);
			assert( data != NULL );

			BeginDND(pt, buttonStates, modifiers, data);
			}
		}
	else if (button == kJXLeftButton && clickCount == 1)
		{
		JPainter* p = CreateDragInsidePainter();
		p->Rect(JRect(pt, pt));
		}
	else if (button == kJXMiddleButton && clickCount == 1)
		{
		itsAnimButton->Place(pt.x, pt.y);
		}
	else if (button == kJXRightButton && clickCount == 1 && !modifiers.meta())
		{
		JRect r = itsAnimButton->GetFrame();
		if (pt.x > r.left && pt.y > r.top)
			{
			itsAnimButton->SetSize(pt.x-r.left, pt.y-r.top);
			}
		}
	else if (button == kJXRightButton && clickCount == 1 && modifiers.meta())
		{
		if (itsSecretMenu->PopUp(this, pt, buttonStates, modifiers))
			{
			return;
			}
		else
			{
			(JGetUserNotification())->ReportError("Unable to open secret menu!");
			}
		}
	else if (ScrollForWheel(button, modifiers))
		{
		// work has been done
		}
	else if ((clickCount == 2 && its2Rect.Contains(pt)) ||
			 (clickCount == 3 && its3Rect.Contains(pt)))
		{
		GetNewSize();
		}

	itsStartPt = itsPrevPt = pt;
}
예제 #15
0
JBoolean
GMApp::OpenSession()
{
	JBoolean success = kJFalse;

	JString homeDir;
	if (JGetHomeDirectory(&homeDir))
		{
		JAppendDirSeparator(&homeDir);
		JString session = homeDir + kStateFileName;
		if (JFileExists(session) && JFileReadable(session))
			{
			JFileArray* fileArray;
			JError err = JFileArray::Create(session, kStateFileSignature, &fileArray);
			if (err.OK())
				{
				JFileVersion version = fileArray->GetVersion();
				if (0 < version && version <= kCurrentSessionVersion)
					{
					JFAID id = 1;
					JSize count;
					{
					std::string data;
					fileArray->GetElement(id, &data);
					std::istringstream is(data);
					is >> count;
					id.SetID(id.GetID() + 1);
					}

					if (count == 0)
						{
						delete fileArray;
						JRemoveFile(session);
						return kJFalse;
						}

					for (JSize i = 1; i <= count; i++)
						{
						JFileArray* embed;
						err = JFileArray::Create(fileArray, id, &embed);
						GMessageTableDir* dir;
						if (GMessageTableDir::Create(this, *embed, &dir, version))
							{
							itsTableDirs->Append(dir);
							}
						id.SetID(id.GetID() + 1);
						delete embed;
						}

					{
					std::string data;
					fileArray->GetElement(id, &data);
					std::istringstream is(data);
					is >> count;
					id.SetID(id.GetID() + 1);
					}

					for (JSize i = 1; i <= count; i++)
						{
						std::string data;
						fileArray->GetElement(id, &data);
						std::istringstream is(data);
						GMessageEditDir* dir = new GMessageEditDir(JXGetApplication());
						assert(dir != NULL);
						dir->ReadState(is, version);
						dir->Activate();
						id.SetID(id.GetID() + 1);
						}

					{
					std::string data;
					fileArray->GetElement(id, &data);
					std::istringstream is(data);
					GGetInboxMgr()->ReadState(is);
					}

					success = kJTrue;
					}
예제 #16
0
void
GMApp::SaveState()
{
	JString homeDir;
	if (JGetHomeDirectory(&homeDir))
		{
		JAppendDirSeparator(&homeDir);
		JString session = homeDir + kStateFileName;
		if (JFileExists(session))
			{
			JRemoveFile(session);
			}
		JFileArray* fileArray;
		JError err = JFileArray::Create(session, kStateFileSignature, &fileArray);
		if (!err.OK())
			{
			if (JFileExists(session))
				{
				JRemoveFile(session);
				}
			delete fileArray;
			return;
			}
		fileArray->SetVersion(kCurrentSessionVersion);

		JSize count;
		{
		std::ostringstream dataStream;
		count = itsTableDirs->GetElementCount();
		dataStream << count;
		fileArray->AppendElement(dataStream);
		}

		JFAID_t id = 2;
		for (JSize i = 1; i <= count; i++)
			{
			JFileArray* embed;
			err = JFileArray::Create(fileArray, id, &embed);
			itsTableDirs->NthElement(i)->GetData()->Save();
			itsTableDirs->NthElement(i)->SaveState(*embed);
			delete embed;
			id ++;
			}

		for (JSize i = itsEditDirs->GetElementCount(); i >= 1; i--)
			{
			itsEditDirs->NthElement(i)->CheckForPendingMessage();
			}

		{
		std::ostringstream dataStream;
		count = itsEditDirs->GetElementCount();
		dataStream << count;
		fileArray->AppendElement(dataStream);
		}

		for (JSize i = 1; i <= count; i++)
			{
			std::ostringstream dataStream;
			itsEditDirs->NthElement(i)->SaveState(dataStream);
			fileArray->AppendElement(dataStream);
			}

		{
		std::ostringstream dataStream;
		GGetInboxMgr()->SaveState(dataStream);
		fileArray->AppendElement(dataStream);
		}

		delete fileArray;
		}
}