[haiku-commits] r40495 - haiku/trunk/src/apps/mail

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 14 Feb 2011 21:58:15 +0100 (CET)

Author: axeld
Date: 2011-02-14 21:58:14 +0100 (Mon, 14 Feb 2011)
New Revision: 40495
Changeset: http://dev.haiku-os.org/changeset/40495

Modified:
   haiku/trunk/src/apps/mail/Content.cpp
   haiku/trunk/src/apps/mail/Enclosures.cpp
   haiku/trunk/src/apps/mail/Enclosures.h
   haiku/trunk/src/apps/mail/Header.cpp
Log:
* Applied patch by Diver that lets Mail properly render vector icons for the
  attachments, and adds a few missing translated strings. Thanks!
* Some cleanups by myself.


Modified: haiku/trunk/src/apps/mail/Content.cpp
===================================================================
--- haiku/trunk/src/apps/mail/Content.cpp       2011-02-14 20:25:10 UTC (rev 
40494)
+++ haiku/trunk/src/apps/mail/Content.cpp       2011-02-14 20:58:14 UTC (rev 
40495)
@@ -870,29 +870,22 @@
        fCursor(false),
        fFirstSpellMark(NULL)
 {
-       BFont menuFont = *be_plain_font;
-       menuFont.SetSize(10);
-
        fStopSem = create_sem(1, "reader_sem");
        SetStylable(true);
 
        fEnclosures = new BList();
 
-       //
-       //      Enclosure pop up menu
-       //
+       // Enclosure pop up menu
        fEnclosureMenu = new BPopUpMenu("Enclosure", false, false);
-       fEnclosureMenu->SetFont(&menuFont);
+       fEnclosureMenu->SetFont(be_plain_font);
        fEnclosureMenu->AddItem(new BMenuItem(
                B_TRANSLATE("Save attachment" B_UTF8_ELLIPSIS), new 
BMessage(M_SAVE)));
        fEnclosureMenu->AddItem(new BMenuItem(B_TRANSLATE("Open attachment"),
                new BMessage(M_OPEN)));
 
-       //
-       //      Hyperlink pop up menu
-       //
+       // Hyperlink pop up menu
        fLinkMenu = new BPopUpMenu("Link", false, false);
-       fLinkMenu->SetFont(&menuFont);
+       fLinkMenu->SetFont(be_plain_font);
        fLinkMenu->AddItem(new BMenuItem(B_TRANSLATE("Open this link"),
                new BMessage(M_OPEN)));
        fLinkMenu->AddItem(new BMenuItem(B_TRANSLATE("Copy link location"),
@@ -1543,7 +1536,8 @@
                                                delete string;
                                        }
                                } else {
-                                       (menuItem = new BMenuItem("No matches", 
NULL))->SetEnabled(false);
+                                       menuItem = new 
BMenuItem(B_TRANSLATE("No matches"), NULL);
+                                       menuItem->SetEnabled(false);
                                        menu.AddItem(menuItem);
                                }
 

Modified: haiku/trunk/src/apps/mail/Enclosures.cpp
===================================================================
--- haiku/trunk/src/apps/mail/Enclosures.cpp    2011-02-14 20:25:10 UTC (rev 
40494)
+++ haiku/trunk/src/apps/mail/Enclosures.cpp    2011-02-14 20:58:14 UTC (rev 
40495)
@@ -123,11 +123,35 @@
 }
 
 
+static void
+recursive_attachment_search(TEnclosuresView* us, BMailContainer* mail,
+       BMailComponent *body)
+{
+       if (mail == NULL)
+               return;
+
+       for (int32 i = 0; i < mail->CountComponents(); i++) {
+               BMailComponent *component = mail->GetComponent(i);
+               if (component == body)
+                       continue;
+
+               if (component->ComponentType() == B_MAIL_MULTIPART_CONTAINER) {
+                       recursive_attachment_search(us,
+                               dynamic_cast<BMIMEMultipartMailContainer 
*>(component), body);
+               }
+
+               us->fList->AddItem(new TListItem(component));
+       }
+}
+
+
 //     #pragma mark -
 
 
-TEnclosuresView::TEnclosuresView(BRect rect, BRect wind_rect)
-       : BView(rect, "m_enclosures", B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT, 
B_WILL_DRAW),
+TEnclosuresView::TEnclosuresView(BRect rect, BRect windowRect)
+       :
+       BView(rect, "m_enclosures", B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT,
+               B_WILL_DRAW),
        fFocus(false)
 {
        SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
@@ -142,7 +166,7 @@
        r.left = ENCLOSE_TEXT_H + font.StringWidth(
                B_TRANSLATE("Attachments: ")) + 5;
        r.top = ENCLOSE_FIELD_V;
-       r.right = wind_rect.right - wind_rect.left - B_V_SCROLL_BAR_WIDTH - 9;
+       r.right = windowRect.right - windowRect.left - B_V_SCROLL_BAR_WIDTH - 9;
        r.bottom = Frame().Height() - 8;
        fList = new TListView(r, this);
        fList->SetInvocationMessage(new BMessage(LIST_INVOKED));
@@ -348,22 +372,6 @@
 }
 
 
-static void recursive_attachment_search(TEnclosuresView *us,BMailContainer 
*mail,BMailComponent *body) {
-       if (mail == NULL)
-               return;
-       for (int32 i = 0; i < mail->CountComponents(); i++)
-       {
-               BMailComponent *component = mail->GetComponent(i);
-               if (component == body)
-                       continue;
-
-               if (component->ComponentType() == B_MAIL_MULTIPART_CONTAINER)
-                       
recursive_attachment_search(us,dynamic_cast<BMIMEMultipartMailContainer 
*>(component),body);
-
-               us->fList->AddItem(new TListItem(component));
-       }
-}
-
 void
 TEnclosuresView::AddEnclosuresFromMail(BEmailMessage *mail)
 {
@@ -381,12 +389,13 @@
 }
 
 
-//====================================================================
 //     #pragma mark -
 
 
 TListView::TListView(BRect rect, TEnclosuresView *view)
-       :       BListView(rect, "", B_MULTIPLE_SELECTION_LIST, B_FOLLOW_TOP | 
B_FOLLOW_LEFT_RIGHT),
+       :
+       BListView(rect, "", B_MULTIPLE_SELECTION_LIST,
+               B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT),
        fParent(view)
 {
 }
@@ -415,15 +424,11 @@
 TListView::MouseDown(BPoint point)
 {
        int32 buttons;
-       Looper()->CurrentMessage()->FindInt32("buttons",&buttons);
+       Looper()->CurrentMessage()->FindInt32("buttons", &buttons);
 
-       if (buttons & B_SECONDARY_MOUSE_BUTTON)
-       {
-               BFont font = *be_plain_font;
-               font.SetSize(10);
-
+       if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) {
                BPopUpMenu menu("enclosure", false, false);
-               menu.SetFont(&font);
+               menu.SetFont(be_plain_font);
                menu.AddItem(new BMenuItem(B_TRANSLATE("Open attachment"),
                        new BMessage(LIST_INVOKED)));
                menu.AddItem(new BMenuItem(B_TRANSLATE("Remove attachment"),
@@ -431,24 +436,19 @@
 
                BPoint menuStart = ConvertToScreen(point);
 
-               BMenuItem *item;
-               if ((item = menu.Go(menuStart)) != NULL)
-               {
-                       if (item->Command() == LIST_INVOKED)
-                       {
+               BMenuItem* item = menu.Go(menuStart);
+               if (item != NULL) {
+                       if (item->Command() == LIST_INVOKED) {
                                BMessage msg(LIST_INVOKED);
                                msg.AddPointer("source",this);
                                msg.AddInt32("index",IndexOf(point));
                                Window()->PostMessage(&msg,fParent);
-                       }
-                       else
-                       {
+                       } else {
                                Select(IndexOf(point));
                                Window()->PostMessage(item->Command(),fParent);
                        }
                }
-       }
-       else
+       } else
                BListView::MouseDown(point);
 }
 
@@ -463,7 +463,6 @@
 }
 
 
-//====================================================================
 //     #pragma mark -
 
 
@@ -529,10 +528,10 @@
 
                BRect iconRect(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1);
 
-               BBitmap bitmap(iconRect, B_COLOR_8_BIT);
+               BBitmap bitmap(iconRect, B_RGBA32);
                if (GetTrackerIcon(type, &bitmap, B_MINI_ICON) == B_NO_ERROR) {
                        BRect rect(r.left + 4, r.top + 1, r.left + 4 + 15, 
r.top + 1 + 15);
-                       owner->SetDrawingMode(B_OP_OVER);
+                       owner->SetDrawingMode(B_OP_ALPHA);
                        owner->DrawBitmap(&bitmap, iconRect, rect);
                        owner->SetDrawingMode(B_OP_COPY);
                } else {
@@ -552,10 +551,10 @@
                BNodeInfo info(&file);
                BRect sr(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1);
 
-               BBitmap bitmap(sr, B_COLOR_8_BIT);
+               BBitmap bitmap(sr, B_RGBA32);
                if (info.GetTrackerIcon(&bitmap, B_MINI_ICON) == B_NO_ERROR) {
                        BRect dr(r.left + 4, r.top + 1, r.left + 4 + 15, r.top 
+ 1 + 15);
-                       owner->SetDrawingMode(B_OP_OVER);
+                       owner->SetDrawingMode(B_OP_ALPHA);
                        owner->DrawBitmap(&bitmap, sr, dr);
                        owner->SetDrawingMode(B_OP_COPY);
                }

Modified: haiku/trunk/src/apps/mail/Enclosures.h
===================================================================
--- haiku/trunk/src/apps/mail/Enclosures.h      2011-02-14 20:25:10 UTC (rev 
40494)
+++ haiku/trunk/src/apps/mail/Enclosures.h      2011-02-14 20:58:14 UTC (rev 
40495)
@@ -31,16 +31,10 @@
 names are registered trademarks or trademarks of their respective holders.
 All rights reserved.
 */
-
-//--------------------------------------------------------------------
-//     
-//     Enclosures.h
-//
-//--------------------------------------------------------------------
-
 #ifndef _ENCLOSURES_H
 #define _ENCLOSURES_H
 
+
 #include <Box.h>
 #include <File.h>
 #include <ListView.h>
@@ -54,77 +48,71 @@
 
 #include <MailMessage.h>
 
-#define ENCLOSURES_HEIGHT       65
 
-#define ENCLOSE_TEXT           "Attachments:"
-#define ENCLOSE_TEXT_H          7
-#define ENCLOSE_TEXT_V          3
-#define ENCLOSE_FIELD_V                 3
+#define ENCLOSURES_HEIGHT      65
 
+#define ENCLOSE_TEXT           B_TRANSLATE_WITH_CONTEXT("Attachments:", "Mail")
+#define ENCLOSE_TEXT_H         7
+#define ENCLOSE_TEXT_V         3
+#define ENCLOSE_FIELD_V                3
+
+
 class TListView;
 class TMailWindow;
 class TScrollView;
 
 
-//====================================================================
+class TEnclosuresView : public BView {
+public:
+                                                               
TEnclosuresView(BRect rect, BRect windowRect);
+       virtual                                         ~TEnclosuresView();
 
-class TEnclosuresView : public BView
-{
-       public:
-               TEnclosuresView(BRect, BRect);
-               ~TEnclosuresView();
+       virtual void                            Draw(BRect updateRect);
+       virtual void                            MessageReceived(BMessage* 
message);
+                       void                            Focus(bool focus);
+                       void                            
AddEnclosuresFromMail(BEmailMessage* mail);
 
-               virtual void Draw(BRect);
-               virtual void MessageReceived(BMessage*);
-               void Focus(bool);
-               void AddEnclosuresFromMail(BEmailMessage *mail);
+                       TListView*                      fList;
 
-               TListView *fList;
-
-       private:
-               bool fFocus;
-               float fOffset;
-               TMailWindow *fWindow;
+private:
+                       bool                            fFocus;
+                       float                           fOffset;
+                       TMailWindow*            fWindow;
 };
 
 
-//====================================================================
+class TListView : public BListView {
+public:
+                                                               TListView(BRect 
rect, TEnclosuresView* view);
 
-class TListView : public BListView
-{
-       public:
-               TListView(BRect, TEnclosuresView *);
+       virtual void                            AttachedToWindow();
+       virtual void                            MakeFocus(bool focus);
+       virtual void                            MouseDown(BPoint point);
+       virtual void                            KeyDown(const char* bytes,int32 
numBytes);
 
-               virtual void AttachedToWindow();
-               virtual void MakeFocus(bool);
-               virtual void MouseDown(BPoint point);
-               virtual void KeyDown(const char *bytes,int32 numBytes);
-
-       private:
-               TEnclosuresView *fParent;
+private:
+                       TEnclosuresView*        fParent;
 };
 
 
-//====================================================================
+class TListItem : public BListItem {
+public:
+                                                               
TListItem(entry_ref* ref);
+                                                               
TListItem(BMailComponent* component);
 
-class TListItem : public BListItem
-{
-       public:
-               TListItem(entry_ref *);
-               TListItem(BMailComponent *);
+       virtual void                            DrawItem(BView* owner, BRect 
rect,
+                                                                       bool 
complete);
+       virtual void                            Update(BView* owner, const 
BFont* font);
 
-               virtual void DrawItem(BView *, BRect, bool);
-               virtual void Update(BView *, const BFont *);
+                       BMailComponent*         Component() { return 
fComponent; };
+                       entry_ref*                      Ref() { return &fRef; }
+                       node_ref*                       NodeRef() { return 
&fNodeRef; }
 
-               BMailComponent *Component() { return fComponent; };
-               entry_ref       *Ref() { return &fRef; }
-               node_ref        *NodeRef() { return &fNodeRef; }
-
-       private:
-               BMailComponent  *fComponent;
-               entry_ref       fRef;
-               node_ref        fNodeRef;
+private:
+                       BMailComponent*         fComponent;
+                       entry_ref                       fRef;
+                       node_ref                        fNodeRef;
 };
 
-#endif // #ifndef _ENCLOSURES_H
 
+#endif // _ENCLOSURES_H

Modified: haiku/trunk/src/apps/mail/Header.cpp
===================================================================
--- haiku/trunk/src/apps/mail/Header.cpp        2011-02-14 20:25:10 UTC (rev 
40494)
+++ haiku/trunk/src/apps/mail/Header.cpp        2011-02-14 20:58:14 UTC (rev 
40495)
@@ -77,7 +77,7 @@
 using std::map;
 
 
-const char* kDateLabel = "Date:";
+const char* kDateLabel = B_TRANSLATE("Date:");
 const uint32 kMsgFrom = 'hFrm';
 const uint32 kMsgEncoding = 'encd';
 const uint32 kMsgAddressChosen = 'acsn';
@@ -234,7 +234,7 @@
                fEncodingMenu->AddSeparatorItem();
                msg = new BMessage(kMsgEncoding);
                msg->AddInt32("charset", B_MAIL_NULL_CONVERSION);
-               fEncodingMenu->AddItem(item = new BMenuItem("Automatic", msg));
+               fEncodingMenu->AddItem(item = new 
BMenuItem(B_TRANSLATE("Automatic"), msg));
                if (!markedCharSet)
                        item->SetMarked(true);
        }


Other related posts:

  • » [haiku-commits] r40495 - haiku/trunk/src/apps/mail - axeld