6 Copyright (c) 1991-2001, Be Incorporated. All rights reserved.
8 Permission is hereby granted, free of charge, to any person obtaining a copy of
9 this software and associated documentation files (the "Software"), to deal in
10 the Software without restriction, including without limitation the rights to
11 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12 of the Software, and to permit persons to whom the Software is furnished to do
13 so, subject to the following conditions:
15 The above copyright notice and this permission notice applies to all licensees
16 and shall be included in all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN
23 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 Except as contained in this notice, the name of Be Incorporated shall not be
26 used in advertising or otherwise to promote the sale, use or other dealings in
27 this Software without prior written authorization from Be Incorporated.
29 BeMail(TM), Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or
30 registered trademarks of Be Incorporated in the United States and other
31 countries. Other brand product names are registered trademarks or trademarks
32 of their respective holders. All rights reserved.
42 #include <Application.h>
43 #include <CharacterSet.h>
44 #include <CharacterSetRoster.h>
47 #include <LayoutBuilder.h>
48 #include <InterfaceKit.h>
50 #include <MailSettings.h>
51 #include <mail_encoding.h>
52 #include <StorageKit.h>
55 using namespace BPrivate
;
58 #include "MailSupport.h"
59 #include "MailWindow.h"
62 #include "Signature.h"
65 #define B_TRANSLATION_CONTEXT "Mail"
68 P_OK
= 128, P_CANCEL
, P_REVERT
, P_FONT
,
69 P_SIZE
, P_LEVEL
, P_WRAP
, P_ATTACH_ATTRIBUTES
,
70 P_SIG
, P_ENC
, P_WARN_UNENCODABLE
,
71 P_SPELL_CHECK_START_ON
, P_BUTTON_BAR
,
72 P_ACCOUNT
, P_REPLYTO
, P_REPLY_PREAMBLE
,
73 P_COLORED_QUOTES
, P_MARK_READ
78 add_menu_to_layout(BMenuField
* menu
, BGridLayout
* layout
, int32
& row
)
80 menu
->SetAlignment(B_ALIGN_RIGHT
);
81 layout
->AddItem(menu
->CreateLabelLayoutItem(), 0, row
);
82 layout
->AddItem(menu
->CreateMenuBarLayoutItem(), 1, row
, 2);
90 TPrefsWindow::TPrefsWindow(BPoint leftTop
, BFont
* font
, int32
* level
,
91 bool* wrap
, bool* attachAttributes
, bool* cquotes
, int32
* account
,
92 int32
* replyTo
, char** preamble
, char** sig
, uint32
* encoding
,
93 bool* warnUnencodable
, bool* spellCheckStartOn
, bool* autoMarkRead
,
96 BWindow(BRect(leftTop
.x
, leftTop
.y
, leftTop
.x
+ 100, leftTop
.y
+ 100),
97 B_TRANSLATE("Mail preferences"),
98 B_TITLED_WINDOW
, B_NOT_RESIZABLE
| B_NOT_ZOOMABLE
99 | B_AUTO_UPDATE_SIZE_LIMITS
),
104 fNewAttachAttributes(attachAttributes
),
105 fAttachAttributes(*fNewAttachAttributes
),
107 fNewButtonBar(buttonBar
),
108 fButtonBar(*fNewButtonBar
),
110 fNewColoredQuotes(cquotes
),
111 fColoredQuotes(*fNewColoredQuotes
),
113 fNewAccount(account
),
114 fAccount(*fNewAccount
),
116 fNewReplyTo(replyTo
),
117 fReplyTo(*fNewReplyTo
),
119 fNewPreamble(preamble
),
122 fSignature((char*)malloc(strlen(*fNewSignature
) + 1)),
127 fNewEncoding(encoding
),
128 fEncoding(*fNewEncoding
),
130 fNewWarnUnencodable(warnUnencodable
),
131 fWarnUnencodable(*fNewWarnUnencodable
),
133 fNewSpellCheckStartOn(spellCheckStartOn
),
134 fSpellCheckStartOn(*fNewSpellCheckStartOn
),
136 fNewAutoMarkRead(autoMarkRead
),
137 fAutoMarkRead(*autoMarkRead
)
139 strcpy(fSignature
, *fNewSignature
);
145 BGridView
* interfaceView
= new BGridView();
146 BGridLayout
* interfaceLayout
= interfaceView
->GridLayout();
147 BGridView
* mailView
= new BGridView();
148 BGridLayout
* mailLayout
= mailView
->GridLayout();
150 interfaceLayout
->SetInsets(B_USE_DEFAULT_SPACING
);
151 interfaceLayout
->AlignLayoutWith(mailLayout
, B_HORIZONTAL
);
152 mailLayout
->SetInsets(B_USE_DEFAULT_SPACING
);
154 BBox
* interfaceBox
= new BBox(B_FANCY_BORDER
, interfaceView
);
155 interfaceBox
->SetLabel(B_TRANSLATE("User interface"));
156 BBox
* mailBox
= new BBox(B_FANCY_BORDER
, mailView
);
157 mailBox
->SetLabel(B_TRANSLATE("Mailing"));
159 // revert, ok & cancel
161 BButton
* okButton
= new BButton("ok", B_TRANSLATE("OK"),
163 okButton
->MakeDefault(true);
165 BButton
* cancelButton
= new BButton("cancel", B_TRANSLATE("Cancel"),
166 new BMessage(P_CANCEL
));
168 fRevert
= new BButton("revert", B_TRANSLATE("Revert"),
169 new BMessage(P_REVERT
));
170 fRevert
->SetEnabled(false);
175 fButtonBarMenu
= _BuildButtonBarMenu(*buttonBar
);
176 menu
= new BMenuField("bar", B_TRANSLATE("Button bar:"), fButtonBarMenu
);
177 add_menu_to_layout(menu
, interfaceLayout
, layoutRow
);
179 fFontMenu
= _BuildFontMenu(font
);
180 menu
= new BMenuField("font", B_TRANSLATE("Font:"), fFontMenu
);
181 add_menu_to_layout(menu
, interfaceLayout
, layoutRow
);
183 fSizeMenu
= _BuildSizeMenu(font
);
184 menu
= new BMenuField("size", B_TRANSLATE("Size:"), fSizeMenu
);
185 add_menu_to_layout(menu
, interfaceLayout
, layoutRow
);
187 fColoredQuotesMenu
= _BuildColoredQuotesMenu(fColoredQuotes
);
188 menu
= new BMenuField("cquotes", B_TRANSLATE("Colored quotes:"),
190 add_menu_to_layout(menu
, interfaceLayout
, layoutRow
);
192 fSpellCheckStartOnMenu
= _BuildSpellCheckStartOnMenu(fSpellCheckStartOn
);
193 menu
= new BMenuField("spellCheckStartOn",
194 B_TRANSLATE("Initial spell check mode:"),
195 fSpellCheckStartOnMenu
);
196 add_menu_to_layout(menu
, interfaceLayout
, layoutRow
);
198 fAutoMarkReadMenu
= _BuildAutoMarkReadMenu(fAutoMarkRead
);
199 menu
= new BMenuField("autoMarkRead",
200 B_TRANSLATE("Automatically mark mail as read:"),
202 add_menu_to_layout(menu
, interfaceLayout
, layoutRow
);
207 fAccountMenu
= _BuildAccountMenu(fAccount
);
208 menu
= new BMenuField("account", B_TRANSLATE("Default account:"),
210 add_menu_to_layout(menu
, mailLayout
, layoutRow
);
212 fReplyToMenu
= _BuildReplyToMenu(fReplyTo
);
213 menu
= new BMenuField("replyTo", B_TRANSLATE("Reply account:"),
215 add_menu_to_layout(menu
, mailLayout
, layoutRow
);
219 fReplyPreamble
= new BTextControl("replytext",
220 B_TRANSLATE("Reply preamble:"),
221 *preamble
, new BMessage(P_REPLY_PREAMBLE
));
222 fReplyPreamble
->SetAlignment(B_ALIGN_RIGHT
, B_ALIGN_LEFT
);
224 fReplyPreambleMenu
= _BuildReplyPreambleMenu();
225 menu
= new BMenuField("replyPreamble", NULL
, fReplyPreambleMenu
);
226 menu
->SetExplicitMaxSize(BSize(menu
->MinSize().width
, B_SIZE_UNSET
));
228 mailLayout
->AddItem(fReplyPreamble
->CreateLabelLayoutItem(), 0, layoutRow
);
229 mailLayout
->AddItem(fReplyPreamble
->CreateTextViewLayoutItem(), 1,
231 mailLayout
->AddView(menu
, 2, layoutRow
);
234 fSignatureMenu
= _BuildSignatureMenu(*sig
);
235 menu
= new BMenuField("sig", B_TRANSLATE("Auto signature:"),
237 add_menu_to_layout(menu
, mailLayout
, layoutRow
);
239 fEncodingMenu
= _BuildEncodingMenu(fEncoding
);
240 menu
= new BMenuField("enc", B_TRANSLATE("Encoding:"), fEncodingMenu
);
241 add_menu_to_layout(menu
, mailLayout
, layoutRow
);
243 fWarnUnencodableMenu
= _BuildWarnUnencodableMenu(fWarnUnencodable
);
244 menu
= new BMenuField("warnUnencodable", B_TRANSLATE("Warn unencodable:"),
245 fWarnUnencodableMenu
);
246 add_menu_to_layout(menu
, mailLayout
, layoutRow
);
248 fWrapMenu
= _BuildWrapMenu(*wrap
);
249 menu
= new BMenuField("wrap", B_TRANSLATE("Text wrapping:"), fWrapMenu
);
250 add_menu_to_layout(menu
, mailLayout
, layoutRow
);
252 fAttachAttributesMenu
= _BuildAttachAttributesMenu(*attachAttributes
);
253 menu
= new BMenuField("attachAttributes", B_TRANSLATE("Attach attributes:"),
254 fAttachAttributesMenu
);
255 add_menu_to_layout(menu
, mailLayout
, layoutRow
);
257 BLayoutBuilder::Group
<>(this, B_VERTICAL
)
260 .AddGroup(B_HORIZONTAL
)
266 .SetInsets(B_USE_WINDOW_SPACING
);
272 TPrefsWindow::~TPrefsWindow()
274 BMessage
msg(WINDOW_CLOSED
);
275 msg
.AddInt32("kind", PREFS_WINDOW
);
276 msg
.AddPoint("window pos", Frame().LeftTop());
277 be_app
->PostMessage(&msg
);
282 TPrefsWindow::MessageReceived(BMessage
* msg
)
286 const char* signature
;
291 font_family new_family
;
292 font_family old_family
;
293 font_style new_style
;
294 font_style old_style
;
300 if (strcmp(fReplyPreamble
->Text(), *fNewPreamble
)) {
303 = (char *)malloc(strlen(fReplyPreamble
->Text()) + 1);
304 strcpy(*fNewPreamble
, fReplyPreamble
->Text());
306 be_app
->PostMessage(PREFS_CHANGED
);
312 // supposed to fall through
314 fFont
.GetFamilyAndStyle(&old_family
, &old_style
);
315 fNewFont
->GetFamilyAndStyle(&new_family
, &new_style
);
316 old_size
= (int32
)fFont
.Size();
317 new_size
= (int32
)fNewFont
->Size();
318 if (strcmp(old_family
, new_family
) || strcmp(old_style
, new_style
)
319 || old_size
!= new_size
) {
320 fNewFont
->SetFamilyAndStyle(old_family
, old_style
);
322 sprintf(label
, "%s %s", old_family
, old_style
);
323 item
= fFontMenu
->FindItem(label
);
325 item
->SetMarked(true);
328 fNewFont
->SetSize(old_size
);
330 sprintf(label
, "%" B_PRId32
, old_size
);
331 item
= fSizeMenu
->FindItem(label
);
333 item
->SetMarked(true);
335 message
.what
= M_FONT
;
336 be_app
->PostMessage(&message
);
339 *fNewAttachAttributes
= fAttachAttributes
;
341 if (strcmp(fSignature
, *fNewSignature
)) {
342 free(*fNewSignature
);
343 *fNewSignature
= (char*)malloc(strlen(fSignature
) + 1);
344 strcpy(*fNewSignature
, fSignature
);
347 *fNewEncoding
= fEncoding
;
348 *fNewWarnUnencodable
= fWarnUnencodable
;
349 *fNewSpellCheckStartOn
= fSpellCheckStartOn
;
350 *fNewAutoMarkRead
= fAutoMarkRead
;
351 *fNewButtonBar
= fButtonBar
;
353 be_app
->PostMessage(PREFS_CHANGED
);
356 for (int i
= fAccountMenu
->CountItems(); --i
> 0;) {
357 BMenuItem
*item
= fAccountMenu
->ItemAt(i
);
358 BMessage
* itemMessage
= item
->Message();
359 if (itemMessage
!= NULL
360 && itemMessage
->FindInt32("id") == *(int32
*)&fAccount
) {
361 item
->SetMarked(true);
366 strcpy(label
,fReplyTo
== ACCOUNT_USE_DEFAULT
367 ? B_TRANSLATE("Use default account")
368 : B_TRANSLATE("Account from mail"));
369 if ((item
= fReplyToMenu
->FindItem(label
)) != NULL
)
370 item
->SetMarked(true);
372 strcpy(label
, fWrap
? B_TRANSLATE("On") : B_TRANSLATE("Off"));
373 if ((item
= fWrapMenu
->FindItem(label
)) != NULL
)
374 item
->SetMarked(true);
376 strcpy(label
, fAttachAttributes
377 ? B_TRANSLATE("Include file attributes in attachments")
378 : B_TRANSLATE("No file attributes, just plain data"));
379 if ((item
= fAttachAttributesMenu
->FindItem(label
)) != NULL
)
380 item
->SetMarked(true);
382 strcpy(label
, fColoredQuotes
? B_TRANSLATE("On") : B_TRANSLATE("Off"));
383 if ((item
= fColoredQuotesMenu
->FindItem(label
)) != NULL
)
384 item
->SetMarked(true);
386 if (strcmp(fReplyPreamble
->Text(), *fNewPreamble
))
387 fReplyPreamble
->SetText(*fNewPreamble
);
389 item
= fSignatureMenu
->FindItem(fSignature
);
391 item
->SetMarked(true);
394 while ((item
= fEncodingMenu
->ItemAt(index
++)) != NULL
) {
395 BMessage
* itemMessage
= item
->Message();
396 if (itemMessage
== NULL
)
400 if (itemMessage
->FindInt32("encoding", &encoding
) == B_OK
401 && (uint32
)encoding
== *fNewEncoding
) {
402 item
->SetMarked(true);
407 strcpy(label
, fWarnUnencodable
? B_TRANSLATE("On") : B_TRANSLATE("Off"));
408 if ((item
= fWarnUnencodableMenu
->FindItem(label
)) != NULL
)
409 item
->SetMarked(true);
411 strcpy(label
, fSpellCheckStartOn
? B_TRANSLATE("On") : B_TRANSLATE("Off"));
412 if ((item
= fSpellCheckStartOnMenu
->FindItem(label
)) != NULL
)
413 item
->SetMarked(true);
421 int32 family_menu_index
;
422 if (msg
->FindString("font", &family
) == B_OK
) {
423 msg
->FindString("style", &style
);
424 fNewFont
->SetFamilyAndStyle(family
, style
);
425 message
.what
= M_FONT
;
426 be_app
->PostMessage(&message
);
429 /* grab this little tidbit so we can set the correct Family */
430 if (msg
->FindInt32("parent_index", &family_menu_index
) == B_OK
)
431 fFontMenu
->ItemAt(family_menu_index
)->SetMarked(true);
435 old_size
= (int32
) fNewFont
->Size();
436 msg
->FindInt32("size", &new_size
);
437 if (old_size
!= new_size
) {
438 fNewFont
->SetSize(new_size
);
439 message
.what
= M_FONT
;
440 be_app
->PostMessage(&message
);
445 msg
->FindBool("wrap", fNewWrap
);
447 case P_ATTACH_ATTRIBUTES
:
448 msg
->FindBool("attachAttributes", fNewAttachAttributes
);
450 case P_COLORED_QUOTES
:
451 msg
->FindBool("cquotes", fNewColoredQuotes
);
454 msg
->FindInt32("id",(int32
*)fNewAccount
);
457 msg
->FindInt32("replyTo", fNewReplyTo
);
459 case P_REPLY_PREAMBLE
:
462 if (msg
->FindInt32("index", &index
) < B_OK
)
464 BMenuItem
*item
= fReplyPreambleMenu
->ItemAt(index
);
466 msg
->PrintToStream();
470 BTextView
*text
= fReplyPreamble
->TextView();
471 int32 selectionStart
;
473 text
->GetSelection(&selectionStart
, &selectionEnd
);
474 if (selectionStart
!= selectionEnd
)
475 text
->Delete(selectionStart
, selectionEnd
);
476 text
->Insert(item
->Label(), 2);
479 free(*fNewSignature
);
480 if (msg
->FindString("signature", &signature
) == B_NO_ERROR
) {
481 *fNewSignature
= (char*)malloc(strlen(signature
) + 1);
482 strcpy(*fNewSignature
, signature
);
484 *fNewSignature
= (char*)malloc(
485 strlen(B_TRANSLATE("None")) + 1);
486 strcpy(*fNewSignature
, B_TRANSLATE("None"));
490 msg
->FindInt32("encoding", (int32
*)fNewEncoding
);
492 case P_WARN_UNENCODABLE
:
493 msg
->FindBool("warnUnencodable", fNewWarnUnencodable
);
495 case P_SPELL_CHECK_START_ON
:
496 msg
->FindBool("spellCheckStartOn", fNewSpellCheckStartOn
);
499 msg
->FindBool("autoMarkRead", fNewAutoMarkRead
);
500 be_app
->PostMessage(PREFS_CHANGED
);
503 msg
->FindInt8("bar", (int8
*)fNewButtonBar
);
504 be_app
->PostMessage(PREFS_CHANGED
);
508 BWindow::MessageReceived(msg
);
511 fFont
.GetFamilyAndStyle(&old_family
, &old_style
);
512 fNewFont
->GetFamilyAndStyle(&new_family
, &new_style
);
513 old_size
= (int32
) fFont
.Size();
514 new_size
= (int32
) fNewFont
->Size();
515 bool changed
= old_size
!= new_size
516 || fWrap
!= *fNewWrap
517 || fAttachAttributes
!= *fNewAttachAttributes
518 || fColoredQuotes
!= *fNewColoredQuotes
519 || fAccount
!= *fNewAccount
520 || fReplyTo
!= *fNewReplyTo
521 || strcmp(old_family
, new_family
)
522 || strcmp(old_style
, new_style
)
523 || strcmp(fReplyPreamble
->Text(), *fNewPreamble
)
524 || strcmp(fSignature
, *fNewSignature
)
525 || fEncoding
!= *fNewEncoding
526 || fWarnUnencodable
!= *fNewWarnUnencodable
527 || fSpellCheckStartOn
!= *fNewSpellCheckStartOn
528 || fAutoMarkRead
!= *fNewAutoMarkRead
529 || fButtonBar
!= *fNewButtonBar
;
530 fRevert
->SetEnabled(changed
);
535 TPrefsWindow::_BuildFontMenu(BFont
* font
)
537 font_family def_family
;
538 font_style def_style
;
539 font_family f_family
;
542 BPopUpMenu
*menu
= new BPopUpMenu("");
543 font
->GetFamilyAndStyle(&def_family
, &def_style
);
545 int32 family_menu_index
= 0;
546 int family_count
= count_font_families();
547 for (int family_loop
= 0; family_loop
< family_count
; family_loop
++) {
548 get_font_family(family_loop
, &f_family
);
549 BMenu
*family_menu
= new BMenu(f_family
);
551 int style_count
= count_font_styles(f_family
);
552 for (int style_loop
= 0; style_loop
< style_count
; style_loop
++) {
553 get_font_style(f_family
, style_loop
, &f_style
);
555 BMessage
*msg
= new BMessage(P_FONT
);
556 msg
->AddString("font", f_family
);
557 msg
->AddString("style", f_style
);
558 // we send this to make setting the Family easier when things
560 msg
->AddInt32("parent_index", family_menu_index
);
562 BMenuItem
*item
= new BMenuItem(f_style
, msg
);
563 family_menu
->AddItem(item
);
564 if ((strcmp(def_family
, f_family
) == 0)
565 && (strcmp(def_style
, f_style
) == 0)) {
566 item
->SetMarked(true);
569 item
->SetTarget(this);
572 menu
->AddItem(family_menu
);
573 BMenuItem
*item
= menu
->ItemAt(family_menu_index
);
574 BMessage
*msg
= new BMessage(P_FONT
);
575 msg
->AddString("font", f_family
);
577 item
->SetMessage(msg
);
578 item
->SetTarget(this);
579 if (strcmp(def_family
, f_family
) == 0)
580 item
->SetMarked(true);
589 TPrefsWindow::_BuildLevelMenu(int32 level
)
595 menu
= new BPopUpMenu("");
596 msg
= new BMessage(P_LEVEL
);
597 msg
->AddInt32("level", L_BEGINNER
);
598 menu
->AddItem(item
= new BMenuItem(B_TRANSLATE("Beginner"), msg
));
599 if (level
== L_BEGINNER
)
600 item
->SetMarked(true);
602 msg
= new BMessage(P_LEVEL
);
603 msg
->AddInt32("level", L_EXPERT
);
604 menu
->AddItem(item
= new BMenuItem(B_TRANSLATE("Expert"), msg
));
605 if (level
== L_EXPERT
)
606 item
->SetMarked(true);
613 TPrefsWindow::_BuildAccountMenu(int32 account
)
615 BPopUpMenu
* menu
= new BPopUpMenu("");
618 //menu->SetRadioMode(true);
619 BMailAccounts accounts
;
620 if (accounts
.CountAccounts() == 0) {
621 menu
->AddItem(item
= new BMenuItem(B_TRANSLATE("<no account found>"), NULL
));
622 item
->SetEnabled(false);
627 for (int32 i
= 0; i
< accounts
.CountAccounts(); i
++) {
628 BMailAccountSettings
* settings
= accounts
.AccountAt(i
);
629 item
= new BMenuItem(settings
->Name(), msg
= new BMessage(P_ACCOUNT
));
631 msg
->AddInt32("id", settings
->AccountID());
633 if (account
== settings
->AccountID())
634 item
->SetMarked(true);
643 TPrefsWindow::_BuildReplyToMenu(int32 account
)
645 BPopUpMenu
* menu
= new BPopUpMenu(B_EMPTY_STRING
);
649 menu
->AddItem(item
= new BMenuItem(B_TRANSLATE("Use default account"),
650 msg
= new BMessage(P_REPLYTO
)));
651 msg
->AddInt32("replyTo", ACCOUNT_USE_DEFAULT
);
652 if (account
== ACCOUNT_USE_DEFAULT
)
653 item
->SetMarked(true);
655 menu
->AddItem(item
= new BMenuItem(B_TRANSLATE("Account from mail"),
656 msg
= new BMessage(P_REPLYTO
)));
657 msg
->AddInt32("replyTo", ACCOUNT_FROM_MAIL
);
658 if (account
== ACCOUNT_FROM_MAIL
)
659 item
->SetMarked(true);
666 TPrefsWindow::_BuildReplyPreambleMenu()
668 BMenu
*menu
= new BMenu(B_EMPTY_STRING
);
670 menu
->AddItem(new BMenuItem(B_TRANSLATE("%n - Full name"),
671 new BMessage(P_REPLY_PREAMBLE
)));
673 menu
->AddItem(new BMenuItem(B_TRANSLATE("%e - E-mail address"),
674 new BMessage(P_REPLY_PREAMBLE
)));
676 menu
->AddItem(new BMenuItem(B_TRANSLATE("%d - Date"),
677 new BMessage(P_REPLY_PREAMBLE
)));
679 menu
->AddSeparatorItem();
681 menu
->AddItem(new BMenuItem(B_TRANSLATE("\\n - Newline"),
682 new BMessage(P_REPLY_PREAMBLE
)));
689 TPrefsWindow::_BuildSignatureMenu(char* sig
)
691 char name
[B_FILE_NAME_LENGTH
];
698 BVolumeRoster volume
;
700 BPopUpMenu
* menu
= new BPopUpMenu("");
702 msg
= new BMessage(P_SIG
);
703 msg
->AddString("signature", B_TRANSLATE("None"));
704 menu
->AddItem(item
= new BMenuItem(B_TRANSLATE("None"), msg
));
705 if (!strcmp(sig
, B_TRANSLATE("None")))
706 item
->SetMarked(true);
708 msg
= new BMessage(P_SIG
);
709 msg
->AddString("signature", B_TRANSLATE("Random"));
710 menu
->AddItem(item
= new BMenuItem(B_TRANSLATE("Random"), msg
));
711 if (!strcmp(sig
, B_TRANSLATE("Random")))
712 item
->SetMarked(true);
713 menu
->AddSeparatorItem();
715 volume
.GetBootVolume(&vol
);
716 query
.SetVolume(&vol
);
717 query
.SetPredicate("_signature = *");
720 while (query
.GetNextEntry(&entry
) == B_NO_ERROR
) {
721 file
.SetTo(&entry
, O_RDONLY
);
722 if (file
.InitCheck() == B_NO_ERROR
) {
723 msg
= new BMessage(P_SIG
);
724 file
.ReadAttr("_signature", B_STRING_TYPE
, 0, name
, sizeof(name
));
725 msg
->AddString("signature", name
);
726 menu
->AddItem(item
= new BMenuItem(name
, msg
));
727 if (!strcmp(sig
, name
))
728 item
->SetMarked(true);
736 TPrefsWindow::_BuildSizeMenu(BFont
* font
)
740 int32 sizes
[] = {9, 10, 11, 12, 14, 18, 24};
746 menu
= new BPopUpMenu("");
748 for (loop
= 0; loop
< sizeof(sizes
) / sizeof(int32
); loop
++) {
749 msg
= new BMessage(P_SIZE
);
750 msg
->AddInt32("size", sizes
[loop
]);
751 sprintf(label
, "%" B_PRId32
, sizes
[loop
]);
752 menu
->AddItem(item
= new BMenuItem(label
, msg
));
753 if (sizes
[loop
] == (int32
)size
)
754 item
->SetMarked(true);
761 TPrefsWindow::_BuildBoolMenu(uint32 what
, const char* boolItem
, bool isTrue
)
767 menu
= new BPopUpMenu("");
768 msg
= new BMessage(what
);
769 msg
->AddBool(boolItem
, true);
770 menu
->AddItem(item
= new BMenuItem(B_TRANSLATE("On"), msg
));
772 item
->SetMarked(true);
774 msg
= new BMessage(what
);
775 msg
->AddInt32(boolItem
, false);
776 menu
->AddItem(item
= new BMenuItem(B_TRANSLATE("Off"), msg
));
778 item
->SetMarked(true);
785 TPrefsWindow::_BuildWrapMenu(bool wrap
)
787 return _BuildBoolMenu(P_WRAP
, "wrap", wrap
);
792 TPrefsWindow::_BuildAttachAttributesMenu(bool attachAttributes
)
798 menu
= new BPopUpMenu("");
799 msg
= new BMessage(P_ATTACH_ATTRIBUTES
);
800 msg
->AddBool("attachAttributes", true);
801 menu
->AddItem(item
= new BMenuItem(
802 B_TRANSLATE("Include file attributes in attachments"), msg
));
803 if (attachAttributes
)
804 item
->SetMarked(true);
806 msg
= new BMessage(P_ATTACH_ATTRIBUTES
);
807 msg
->AddInt32("attachAttributes", false);
808 menu
->AddItem(item
= new BMenuItem(
809 B_TRANSLATE("No file attributes, just plain data"), msg
));
810 if (!attachAttributes
)
811 item
->SetMarked(true);
818 TPrefsWindow::_BuildColoredQuotesMenu(bool quote
)
820 return _BuildBoolMenu(P_COLORED_QUOTES
, "cquotes", quote
);
825 TPrefsWindow::_BuildEncodingMenu(uint32 encoding
)
831 menu
= new BPopUpMenu("");
833 BCharacterSetRoster roster
;
834 BCharacterSet charset
;
835 while (roster
.GetNextCharacterSet(&charset
) == B_NO_ERROR
) {
836 BString
name(charset
.GetPrintName());
837 const char* mime
= charset
.GetMIMEName();
839 name
<< " (" << mime
<< ")";
840 msg
= new BMessage(P_ENC
);
842 if ((mime
== 0) || (strcasecmp(mime
, "UTF-8") != 0))
843 convert_id
= charset
.GetConversionID();
845 convert_id
= B_MAIL_UTF8_CONVERSION
;
846 msg
->AddInt32("encoding", convert_id
);
847 menu
->AddItem(item
= new BMenuItem(name
.String(), msg
));
848 if (convert_id
== encoding
)
849 item
->SetMarked(true);
852 msg
= new BMessage(P_ENC
);
853 msg
->AddInt32("encoding", B_MAIL_US_ASCII_CONVERSION
);
854 menu
->AddItem(item
= new BMenuItem("US-ASCII", msg
));
855 if (encoding
== B_MAIL_US_ASCII_CONVERSION
)
856 item
->SetMarked(true);
863 TPrefsWindow::_BuildWarnUnencodableMenu(bool warnUnencodable
)
865 return _BuildBoolMenu(P_WARN_UNENCODABLE
, "warnUnencodable",
871 TPrefsWindow::_BuildSpellCheckStartOnMenu(bool spellCheckStartOn
)
873 return _BuildBoolMenu(P_SPELL_CHECK_START_ON
, "spellCheckStartOn",
879 TPrefsWindow::_BuildAutoMarkReadMenu(bool autoMarkRead
)
881 return _BuildBoolMenu(P_MARK_READ
, "autoMarkRead",
887 TPrefsWindow::_BuildButtonBarMenu(uint8 show
)
891 BPopUpMenu
* menu
= new BPopUpMenu("");
893 msg
= new BMessage(P_BUTTON_BAR
);
894 msg
->AddInt8("bar", kShowToolBar
);
895 menu
->AddItem(item
= new BMenuItem(
896 B_TRANSLATE("Show icons & labels"), msg
));
898 item
->SetMarked(true);
900 msg
= new BMessage(P_BUTTON_BAR
);
901 msg
->AddInt8("bar", kShowToolBarIconsOnly
);
902 menu
->AddItem(item
= new BMenuItem(B_TRANSLATE("Show icons only"), msg
));
904 item
->SetMarked(true);
906 msg
= new BMessage(P_BUTTON_BAR
);
907 msg
->AddInt8("bar", kHideToolBar
);
908 menu
->AddItem(item
= new BMenuItem(B_TRANSLATE("Hide"), msg
));
910 item
->SetMarked(true);