Made a *lot* of controls less technical

Completely did away with the config window (not needed except for its own development)
Shortened shutdown time when asked to quit by some other source than system shutdown


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19450 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm
2006-12-09 03:42:10 +00:00
parent b82780cfed
commit c9c63ff858
+62 -56
View File
@@ -544,11 +544,11 @@ directory, available from http://sourceforge.net/projects/bemaildaemon/ */
*/ */
static float g_MarginBetweenControls; /* Space of a letter "M" between them. */ static float g_MarginBetweenControls; /* Space of a letter "M" between them. */
static float g_LineOfTextHeight; /* Height of text the current font. */ //static float g_LineOfTextHeight; /* Height of text the current font. */
static float g_StringViewHeight; /* Height of a string view text box. */ static float g_StringViewHeight; /* Height of a string view text box. */
static float g_ButtonHeight; /* How many pixels tall buttons are. */ static float g_ButtonHeight; /* How many pixels tall buttons are. */
static float g_CheckBoxHeight; /* Same for check boxes. */ static float g_CheckBoxHeight; /* Same for check boxes. */
static float g_RadioButtonHeight; /* Also for radio buttons. */ //static float g_RadioButtonHeight; /* Also for radio buttons. */
static float g_PopUpMenuHeight; /* Again for pop-up menus. */ static float g_PopUpMenuHeight; /* Again for pop-up menus. */
static float g_TextBoxHeight; /* Ditto for editable text controls. */ static float g_TextBoxHeight; /* Ditto for editable text controls. */
@@ -896,14 +896,14 @@ typedef enum TokenizeModeEnum
static char * g_TokenizeModeNames [TM_MAX] = static char * g_TokenizeModeNames [TM_MAX] =
{ {
"Whole", "All",
"PlainText", "Plain Text",
"PlainTextAndHeader", "Plain Text and Header",
"AnyText", "Any Text",
"AnyTextAndHeader", "Any Text and Header",
"AllParts", "All Parts",
"AllPartsAndHeader", "All Parts and Header",
"JustHeader" "Just Header"
}; };
@@ -2878,7 +2878,8 @@ void ABSApp::DefaultSettings ()
strcpy (TempString, DatabasePath.Path ()); strcpy (TempString, DatabasePath.Path ());
m_DatabaseFileName.SetTo (TempString); m_DatabaseFileName.SetTo (TempString);
m_IgnorePreviousClassification = false; // Users need to be allowed to undo their mistakes...
m_IgnorePreviousClassification = true;
g_ServerMode = true; g_ServerMode = true;
m_PurgeAge = 2000; m_PurgeAge = 2000;
m_PurgePopularity = 2; m_PurgePopularity = 2;
@@ -4695,7 +4696,8 @@ bool ABSApp::QuitRequested ()
return BApplication::QuitRequested (); return BApplication::QuitRequested ();
if (g_QuitCountdown < 0) if (g_QuitCountdown < 0)
g_QuitCountdown = 10; /* Start the countdown. */ // g_QuitCountdown = 10; /* Start the countdown. */
g_QuitCountdown = 5; /* Quit more quickly */
return false; return false;
} }
@@ -4760,6 +4762,8 @@ status_t ABSApp::PurgeOldWords (char *ErrorMessage)
void ABSApp::ReadyToRun () void ABSApp::ReadyToRun ()
{ {
#if 0
DatabaseWindow *DatabaseWindowPntr; DatabaseWindow *DatabaseWindowPntr;
float JunkFloat; float JunkFloat;
BButton *TempButtonPntr; BButton *TempButtonPntr;
@@ -4913,6 +4917,11 @@ void ABSApp::ReadyToRun ()
else else
DatabaseWindowPntr->Show (); /* Starts the window's message loop. */ DatabaseWindowPntr->Show (); /* Starts the window's message loop. */
} }
#endif // end all the unnecessary #if 0'ed code
SetPulseRate (500000);
g_AppReadyToRunCompleted = true; g_AppReadyToRunCompleted = true;
} }
@@ -6150,7 +6159,7 @@ void ControlsView::AttachedToWindow ()
TempRect.bottom = TempRect.top + g_ButtonHeight; TempRect.bottom = TempRect.top + g_ButtonHeight;
m_BrowseButtonPntr = new BButton (TempRect, "Browse Button", m_BrowseButtonPntr = new BButton (TempRect, "Browse Button",
"Browse", new BMessage (MSG_BROWSE_BUTTON), B_FOLLOW_RIGHT | B_FOLLOW_TOP); "Browse…", new BMessage (MSG_BROWSE_BUTTON), B_FOLLOW_RIGHT | B_FOLLOW_TOP);
if (m_BrowseButtonPntr == NULL) goto ErrorExit; if (m_BrowseButtonPntr == NULL) goto ErrorExit;
AddChild (m_BrowseButtonPntr); AddChild (m_BrowseButtonPntr);
m_BrowseButtonPntr->SetTarget (this); m_BrowseButtonPntr->SetTarget (this);
@@ -6167,7 +6176,7 @@ void ControlsView::AttachedToWindow ()
TempRect.bottom = TempRect.top + g_TextBoxHeight; TempRect.bottom = TempRect.top + g_TextBoxHeight;
TempRect.right = X; TempRect.right = X;
StringPntr = "Database File Name:"; StringPntr = "Word Database:";
strcpy (m_DatabaseFileNameCachedValue, "Unknown..."); strcpy (m_DatabaseFileNameCachedValue, "Unknown...");
m_DatabaseFileNameTextboxPntr = new BTextControl (TempRect, m_DatabaseFileNameTextboxPntr = new BTextControl (TempRect,
"File Name", "File Name",
@@ -6191,8 +6200,7 @@ void ControlsView::AttachedToWindow ()
RowHeight = g_TextBoxHeight; RowHeight = g_TextBoxHeight;
RowHeight = ceilf (RowHeight * 1.1); RowHeight = ceilf (RowHeight * 1.1);
StringPntr = "Purge Age (words added this many or more messages " StringPntr = "Number of occurrences needed to store a word:";
"ago may get deleted):";
m_PurgeAgeCachedValue = 12345678; m_PurgeAgeCachedValue = 12345678;
Margin = ceilf ((RowHeight - g_TextBoxHeight) / 2); Margin = ceilf ((RowHeight - g_TextBoxHeight) / 2);
@@ -6226,8 +6234,7 @@ void ControlsView::AttachedToWindow ()
RowHeight = g_TextBoxHeight; RowHeight = g_TextBoxHeight;
RowHeight = ceilf (RowHeight * 1.1); RowHeight = ceilf (RowHeight * 1.1);
StringPntr = "Purge Popularity (words that occur in this many or fewer " StringPntr = "Number of messages to store words from:";
"e-mail messages may get deleted):";
m_PurgePopularityCachedValue = 87654321; m_PurgePopularityCachedValue = 87654321;
Margin = ceilf ((RowHeight - g_TextBoxHeight) / 2); Margin = ceilf ((RowHeight - g_TextBoxHeight) / 2);
TempRect.top = RowTop + Margin; TempRect.top = RowTop + Margin;
@@ -6255,7 +6262,7 @@ void ControlsView::AttachedToWindow ()
/* Make the purge button, which will take up space in the 2nd and 3rd rows, /* Make the purge button, which will take up space in the 2nd and 3rd rows,
on the right side. Twice as tall as a regular button too. */ on the right side. Twice as tall as a regular button too. */
StringPntr = "Purge!"; StringPntr = "Remove Old Words";
Margin = ceilf ((((RowTop + RowHeight) - BigPurgeButtonTop) - Margin = ceilf ((((RowTop + RowHeight) - BigPurgeButtonTop) -
2 * g_TextBoxHeight) / 2); 2 * g_TextBoxHeight) / 2);
TempRect.top = BigPurgeButtonTop + Margin; TempRect.top = BigPurgeButtonTop + Margin;
@@ -6269,6 +6276,7 @@ void ControlsView::AttachedToWindow ()
m_PurgeButtonPntr = new BButton (TempRect, "Purge Button", m_PurgeButtonPntr = new BButton (TempRect, "Purge Button",
StringPntr, new BMessage (CommandMessage), B_FOLLOW_LEFT | B_FOLLOW_TOP); StringPntr, new BMessage (CommandMessage), B_FOLLOW_LEFT | B_FOLLOW_TOP);
if (m_PurgeButtonPntr == NULL) goto ErrorExit; if (m_PurgeButtonPntr == NULL) goto ErrorExit;
m_PurgeButtonPntr->ResizeToPreferred();
AddChild (m_PurgeButtonPntr); AddChild (m_PurgeButtonPntr);
m_PurgeButtonPntr->SetTarget (be_app); m_PurgeButtonPntr->SetTarget (be_app);
@@ -6280,9 +6288,7 @@ void ControlsView::AttachedToWindow ()
RowHeight = g_CheckBoxHeight; RowHeight = g_CheckBoxHeight;
RowHeight = ceilf (RowHeight * 1.1); RowHeight = ceilf (RowHeight * 1.1);
StringPntr = "Ignore Previous Classification (so that previously classified " StringPntr = "Allow Retraining on a Message";
"messages can be added again, otherwise only a change in classification "
"is recognized)";
m_IgnorePreviousClassCachedValue = false; m_IgnorePreviousClassCachedValue = false;
Margin = ceilf ((RowHeight - g_CheckBoxHeight) / 2); Margin = ceilf ((RowHeight - g_CheckBoxHeight) / 2);
@@ -6308,8 +6314,7 @@ void ControlsView::AttachedToWindow ()
RowHeight = g_CheckBoxHeight; RowHeight = g_CheckBoxHeight;
RowHeight = ceilf (RowHeight * 1.1); RowHeight = ceilf (RowHeight * 1.1);
StringPntr = "Server Mode (errors printed on the standard error stream " StringPntr = "Print errors to Terminal";
"rather than in alert boxes, window minimized)";
m_ServerModeCachedValue = false; m_ServerModeCachedValue = false;
Margin = ceilf ((RowHeight - g_CheckBoxHeight) / 2); Margin = ceilf ((RowHeight - g_CheckBoxHeight) / 2);
@@ -6363,47 +6368,35 @@ void ControlsView::AttachedToWindow ()
switch (TokenizeMode) switch (TokenizeMode)
{ {
case TM_WHOLE: case TM_WHOLE:
strcat (TempString, " - Looks for words in the whole file, so it " strcat (TempString, " - Scan everything");
"sees everything! Use this for non-Email files too. Also does "
"a rough quoted-printable decoding.");
break; break;
case TM_PLAIN_TEXT: case TM_PLAIN_TEXT:
strcat (TempString, " - Only examines text/plain parts of the " strcat (TempString, " - Scan e-mail body text except rich text");
"e-mail (no HTML parts). But does decode base64 etc. and do "
"character set conversions (all but Whole also do that).");
break; break;
case TM_PLAIN_TEXT_HEADER: case TM_PLAIN_TEXT_HEADER:
strcat (TempString, " - Examines text/plain parts of the " strcat (TempString, " - Scan entire e-mail text except rich text");
"e-mail (no HTML parts), and also looks at the headers (from, to, "
"subject, names of attached files, etc).");
break; break;
case TM_ANY_TEXT: case TM_ANY_TEXT:
strcat (TempString, " - Examines all text/* parts of the " strcat (TempString, " - Scan e-mail body text and text attachments");
"e-mail, including HTML parts.");
break; break;
case TM_ANY_TEXT_HEADER: case TM_ANY_TEXT_HEADER:
strcat (TempString, " - Examines all text/* parts of the " strcat (TempString, " - Scan entire e-mail text and text attachments (Recommended)");
"e-mail, including HTML parts. Also examines the headers.");
break; break;
case TM_ALL_PARTS: case TM_ALL_PARTS:
strcat (TempString, " - Examines all parts of the e-mail, including " strcat (TempString, " - Scan e-mail body and all attachments");
"HTML parts and binary attachments (mostly useless garbage words).");
break; break;
case TM_ALL_PARTS_HEADER: case TM_ALL_PARTS_HEADER:
strcat (TempString, " - Examines all parts of the e-mail, including " strcat (TempString, " - Scan all parts of the e-mail");
"HTML parts and binary attachments, plus the headers.");
break; break;
case TM_JUST_HEADER: case TM_JUST_HEADER:
strcat (TempString, " - Only examines the first header part of the " strcat (TempString, " - Scan just the header (mail routing information)");
"e-mail (from, to, subject, but not MIME subheaders (names of "
"attached files and other attachment info)).");
break; break;
default: default:
@@ -6451,19 +6444,30 @@ void ControlsView::AttachedToWindow ()
CommandMessage.what = B_SET_PROPERTY; CommandMessage.what = B_SET_PROPERTY;
CommandMessage.AddSpecifier (g_PropertyNames[PN_SCORING_MODE]); CommandMessage.AddSpecifier (g_PropertyNames[PN_SCORING_MODE]);
CommandMessage.AddString (g_DataName, g_ScoringModeNames[ScoringMode]); CommandMessage.AddString (g_DataName, g_ScoringModeNames[ScoringMode]);
/*
strcpy (TempString, g_ScoringModeNames[ScoringMode]); strcpy (TempString, g_ScoringModeNames[ScoringMode]);
switch (ScoringMode) switch (ScoringMode)
{ {
case SM_ROBINSON: case SM_ROBINSON:
strcat (TempString, " - Gary Robinson's invention. Score varies " strcat (TempString, " - Learning Method 1: Naive Bayesian");
"evenly between 0 and 1, so you get shades of spaminess. Cutoff "
"point varies depending on your training examples.");
break; break;
case SM_CHISQUARED: case SM_CHISQUARED:
strcat (TempString, " - Uses Chi-Squared statistics test. Score " strcat (TempString, " - Learning Method 2: Chi-Squared");
"near 0 for genuine, near 1 for spam and inbetween if it is " break;
"unsure. No shades of spaminess.");
default:
break;
}
*/
switch (ScoringMode)
{
case SM_ROBINSON:
strcpy (TempString, "Learning Method 1: Naive Bayesian");
break;
case SM_CHISQUARED:
strcpy (TempString, "Learning Method 2: Chi-Squared");
break; break;
default: default:
@@ -6494,7 +6498,7 @@ void ControlsView::AttachedToWindow ()
CommandMessage.what = B_EXECUTE_PROPERTY; CommandMessage.what = B_EXECUTE_PROPERTY;
CommandMessage.AddSpecifier (g_PropertyNames[PN_INSTALL_THINGS]); CommandMessage.AddSpecifier (g_PropertyNames[PN_INSTALL_THINGS]);
m_InstallThingsButtonPntr = new BButton (TempRect, "Install Button", m_InstallThingsButtonPntr = new BButton (TempRect, "Install Button",
"Install MIME Types & Make Indices on All Drives", "Install Spam Types",
new BMessage (CommandMessage), new BMessage (CommandMessage),
B_FOLLOW_LEFT | B_FOLLOW_TOP); B_FOLLOW_LEFT | B_FOLLOW_TOP);
if (m_InstallThingsButtonPntr == NULL) goto ErrorExit; if (m_InstallThingsButtonPntr == NULL) goto ErrorExit;
@@ -6513,7 +6517,7 @@ void ControlsView::AttachedToWindow ()
CommandMessage.what = B_EXECUTE_PROPERTY; CommandMessage.what = B_EXECUTE_PROPERTY;
CommandMessage.AddSpecifier (g_PropertyNames[PN_RESET_TO_DEFAULTS]); CommandMessage.AddSpecifier (g_PropertyNames[PN_RESET_TO_DEFAULTS]);
m_ResetToDefaultsButtonPntr = new BButton (TempRect, "Reset Button", m_ResetToDefaultsButtonPntr = new BButton (TempRect, "Reset Button",
"Reset Settings to Defaults", new BMessage (CommandMessage), "Default Settings", new BMessage (CommandMessage),
B_FOLLOW_RIGHT | B_FOLLOW_TOP); B_FOLLOW_RIGHT | B_FOLLOW_TOP);
if (m_ResetToDefaultsButtonPntr == NULL) goto ErrorExit; if (m_ResetToDefaultsButtonPntr == NULL) goto ErrorExit;
AddChild (m_ResetToDefaultsButtonPntr); AddChild (m_ResetToDefaultsButtonPntr);
@@ -6536,7 +6540,7 @@ void ControlsView::AttachedToWindow ()
TempRect.left = X; TempRect.left = X;
m_EstimateSpamButtonPntr = new BButton (TempRect, "Estimate Button", m_EstimateSpamButtonPntr = new BButton (TempRect, "Estimate Button",
"Estimate Spam Ratio of a New Message", "Scan a Message",
new BMessage (MSG_ESTIMATE_BUTTON), new BMessage (MSG_ESTIMATE_BUTTON),
B_FOLLOW_LEFT | B_FOLLOW_TOP); B_FOLLOW_LEFT | B_FOLLOW_TOP);
if (m_EstimateSpamButtonPntr == NULL) goto ErrorExit; if (m_EstimateSpamButtonPntr == NULL) goto ErrorExit;
@@ -6554,7 +6558,7 @@ void ControlsView::AttachedToWindow ()
TempRect.left = X; TempRect.left = X;
m_AddExampleButtonPntr = new BButton (TempRect, "Example Button", m_AddExampleButtonPntr = new BButton (TempRect, "Example Button",
"Add Example of Spam/Genuine", "Train Spam Filter on a Message",
new BMessage (MSG_BROWSE_BUTTON), new BMessage (MSG_BROWSE_BUTTON),
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,
B_WILL_DRAW | B_NAVIGABLE | B_FULL_UPDATE_ON_RESIZE); B_WILL_DRAW | B_NAVIGABLE | B_FULL_UPDATE_ON_RESIZE);
@@ -6573,7 +6577,7 @@ void ControlsView::AttachedToWindow ()
TempRect.left = X; TempRect.left = X;
m_AboutButtonPntr = new BButton (TempRect, "About Button", m_AboutButtonPntr = new BButton (TempRect, "About Button",
"About this fine program...", "About",
new BMessage (B_ABOUT_REQUESTED), new BMessage (B_ABOUT_REQUESTED),
B_FOLLOW_RIGHT | B_FOLLOW_TOP); B_FOLLOW_RIGHT | B_FOLLOW_TOP);
if (m_AboutButtonPntr == NULL) goto ErrorExit; if (m_AboutButtonPntr == NULL) goto ErrorExit;
@@ -7046,7 +7050,7 @@ void ControlsView::Pulse ()
DatabaseWindow::DatabaseWindow () DatabaseWindow::DatabaseWindow ()
: BWindow (BRect (30, 30, 620, 400), : BWindow (BRect (30, 30, 620, 400),
"Alexander G. M. Smith's Bayesian Spam Database Server", "Haiku Spam Filter Server",
B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS) B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS)
{ {
BRect TempRect; BRect TempRect;
@@ -7060,6 +7064,7 @@ DatabaseWindow::DatabaseWindow ()
/* Add the word view in the remaining space under the controls view. */ /* Add the word view in the remaining space under the controls view. */
TempRect = Bounds (); TempRect = Bounds ();
TempRect.top = m_ControlsViewPntr->Frame().bottom + 1; TempRect.top = m_ControlsViewPntr->Frame().bottom + 1;
m_WordsViewPntr = new WordsView (TempRect); m_WordsViewPntr = new WordsView (TempRect);
@@ -7067,6 +7072,7 @@ DatabaseWindow::DatabaseWindow ()
goto ErrorExit; goto ErrorExit;
AddChild (m_WordsViewPntr); AddChild (m_WordsViewPntr);
/* Minimize the window if we are starting up in server mode. This is done /* Minimize the window if we are starting up in server mode. This is done
before the window is open so it doesn't flash onto the screen, and possibly before the window is open so it doesn't flash onto the screen, and possibly
steal a keystroke or two. The ControlsView will further update the minimize steal a keystroke or two. The ControlsView will further update the minimize