* Rewrote icon drawing for the deskbar replicant, now use our shiny vector
icons. Haven't looked into R5 backward compat. * Minor style fixes, more in the next commit. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32269 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
bb1fc73715
commit
636f089026
13
src/servers/mail/DeskbarViewIcons.h
Normal file
13
src/servers/mail/DeskbarViewIcons.h
Normal file
@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Copyright 2009, Haiku. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef DESKBAR_VIEW_ICONS_H
|
||||
#define DESKBAR_VIEW_ICONS_H
|
||||
|
||||
enum {
|
||||
kIconNoMail = 1000,
|
||||
kIconNewMail = 1001
|
||||
};
|
||||
|
||||
#endif // DESKBAR_VIEW_ICONS_H
|
80
src/servers/mail/DeskbarViewIcons.rdef
Normal file
80
src/servers/mail/DeskbarViewIcons.rdef
Normal file
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright 2009, Haiku. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Alexandre Deckner <alex@zappotek.com>
|
||||
*/
|
||||
|
||||
#include "DeskbarViewIcons.h"
|
||||
|
||||
resource(kIconNoMail) #'VICN' array {
|
||||
$"6E63696610050004006A020006063C55F93D5C9ABF48EE3E484E4B6A43C35976"
|
||||
$"495F849385EAF7FFA2A5B7C2C2A0BCCCDC748994FF829AB2020006033B9EE13B"
|
||||
$"9EE1BB9EE13B9EE14A10E147F9EB00ACD3DB9FFFFFFFFF6492A8020006023A2A"
|
||||
$"16B8F45D3AE2F43C1D5446BCF5477C2100F7FBFDFF31596B02000603BA68BD3A"
|
||||
$"CB11BCBEBBBC5E184A35D549E60100343D412F364145FF566F7A020006023B4E"
|
||||
$"07BA96743B15213BEFCE499B3D4A176700435563FF2D404802000602352DDDBA"
|
||||
$"68303C7773374206477FF64AE5FA00BED1DBFF8DADBA020006023A11DA3A5196"
|
||||
$"BACC2E3A7F4848C35C4A23C100FFEEC0FFE7D6A80200060238DDE0B865633B86"
|
||||
$"F63C1C2A48AFCD493E7A00B4A06BFFA28B4E03826A31037795A303F206060200"
|
||||
$"0602BAD0C03A15D1BAF9D2BC024D4BB1114A539100FFC7BAFFC31A1A02000602"
|
||||
$"BAD0C03A15D1BAF9D2BC024D4BB1114A539101E3E3E3FF59697A0200060237FB"
|
||||
$"FC391283BC18FD3AB8644BB9C148DD1D00D6D9DCFF78899912060BE28B3F3960"
|
||||
$"3C46564C564A564E5653535155C788C71BC9764E5B5F48CB8147CB8147CC4D44"
|
||||
$"60406043603D5C3B5E3C5C3B02044647453BC291BE263C2DC189B9DE382B2F2D"
|
||||
$"342B342D392F362DBFCBBADC060CFEAFAA5A405A345A345A2B4E23572649213F"
|
||||
$"2545223F252E2D2E2DB7AFB8FEB6FDBC282ABA75B6FDBC282A492C4A2251395E"
|
||||
$"4354C1BCC81F0607FE1A5A405A345A345A2B4E23572649213F2545223F252E2D"
|
||||
$"4445560404FE44564446444F443D382FC066BAE5BAE0B8222D2F302D2D2F0606"
|
||||
$"EF03382F382FB89AB6FEB6FDBD5A2A30B6FDBD5A2A492B3A2B3A2B30382F2E2A"
|
||||
$"382FBC910605EF03382F382FB89AB6FEB763BD5A2B30B763BD5A2B49C0BBBDBD"
|
||||
$"C0BBBDBDC000BB9BBC912FBE9DBA00BC912F0605FE022C4A444D3B49444D4445"
|
||||
$"4445C156C041C0BBBDBDC122BEEAC0BBBDBD2A490606A70A444D3B49444DC7EB"
|
||||
$"4354395E22512C4A0A042F4C28513358424C0605AA03B7BABEF223433254BFB1"
|
||||
$"C3BA38443D4733410606EA0A44423A36B7BABEF2384433413D47BFB1C3BA4447"
|
||||
$"060AEEEF0E234331C24EB746C1EB31C24E3253BA6EC264BA6EC264BB8FC285BC"
|
||||
$"CAC21CBC7AC27CBCFAC1E3BD30C05DBD1AC134BD30C05D4444BD3DBFCABD3DBF"
|
||||
$"CABD60BDF73A363744394235460A05563C5E365E41584756460A04543B5C355E"
|
||||
$"36563C0A044C44563C563E4C460A064A454A43543B563C4C444C460A095C354A"
|
||||
$"434A454C46563E564658475E415E360E0A010100000A0001021001178402040A"
|
||||
$"020103000A030101000A0001041001178400040A040105000A050106000A0601"
|
||||
$"07000A070108000A0001111001178400040A0C010D000A0D010E000A0E010F00"
|
||||
$"0A0F011000"
|
||||
};
|
||||
|
||||
resource(kIconNewMail) #'VICN' array {
|
||||
$"6E63696611050004006A020006063C55F93D5C9ABF48EE3E484E4B6A43C35976"
|
||||
$"495F849385EAF7FFA2A5B7C2C2A0BCCCDC748994FF829AB2020006033B9EE13B"
|
||||
$"9EE1BB9EE13B9EE14A10E147F9EB00ACD3DB9FFFFFFFFF6492A8020006023A2A"
|
||||
$"16B8F45D3AE2F43C1D5446BCF5477C2100F7FBFDFF31596B02000603BA68BD3A"
|
||||
$"CB11BCBEBBBC5E184A35D549E60100343D412F364145FF566F7A020006023B4E"
|
||||
$"07BA96743B15213BEFCE499B3D4A176700435563FF2D404802000602352DDDBA"
|
||||
$"68303C7773374206477FF64AE5FA00BED1DBFF8DADBA020006023A11DA3A5196"
|
||||
$"BACC2E3A7F4848C35C4A23C100FFEEC0FFE7D6A80200060238DDE0B865633B86"
|
||||
$"F63C1C2A48AFCD493E7A00B4A06BFFA28B4E03826A31037795A303F206060200"
|
||||
$"06022F146D3B80D3BC7FF03032974B85E5482BA200FFC7BAFFC31A1A02000602"
|
||||
$"2F146D3B80D3BC7FF03032974B85E5482BA201E3E3E3FF59697A020006022F14"
|
||||
$"6D3B80D3BC7FF03032974B75E5484BA200D6D9DCFF78899903FAA28E13060BE2"
|
||||
$"8B3F39603C46564C564A564E5653535155C788C71BC9764E5B5F48CB8147CB81"
|
||||
$"47CC4D4460406043603D5C3B5E3C5C3B02044647453BC291BE263C2DC189B9DE"
|
||||
$"382B2F2D342B342D392F362DBFCBBADC060CFEAFAA5A405A345A345A2B4E2357"
|
||||
$"2649213F2545223F252E2D2E2DB7AFB8FEB6FDBC282ABA75B6FDBC282A492C4A"
|
||||
$"2251395E4354C1BCC81F0607FE1A5A405A345A345A2B4E23572649213F254522"
|
||||
$"3F252E2D4445560404FE44564446444F443D382FC066BAE5BAE0B8222D2F302D"
|
||||
$"2D2F0606EF03382F382FB89AB6FEB6FDBD5A2A30B6FDBD5A2A492B3A2B3A2B30"
|
||||
$"382F2E2A382FBC910605EF03382F382FB89AB6FEB763BD5A2B30B763BD5A2B49"
|
||||
$"C0BBBDBDC0BBBDBDC000BB9BBC912FBE9DBA00BC912F0605FE022C4A444D3B49"
|
||||
$"444D44454445C156C041C0BBBDBDC122BEEAC0BBBDBD2A490606A70A444D3B49"
|
||||
$"444DC7EB4354395E22512C4A0A042F4C28513358424C0605AA03B7BABEF22343"
|
||||
$"3254BFB1C3BA38443D4733410606EA0A44423A36B7BABEF2384433413D47BFB1"
|
||||
$"C3BA4447060AEEEF0E234331C24EB746C1EB31C24E3253BA6EC264BA6EC264BB"
|
||||
$"8FC285BCCAC21CBC7AC27CBCFAC1E3BD30C05DBD1AC134BD30C05D4444BD3DBF"
|
||||
$"CABD3DBFCABD60BDF73A363744394235460A054EBA2B4E285623562C50310A04"
|
||||
$"4CB9BA4C274E284EBA200A044C274E28562354220A044E404EBA2B4F324F3F0A"
|
||||
$"044E404C3F4CB9C54EBA390A084C274C3F4E404F3F4F32562C56235422140A01"
|
||||
$"0100000A0001021001178402040A020103000A030101000A0001041001178400"
|
||||
$"040A040105000A050106000A060107000A070108000A0B0109000A00020A0B10"
|
||||
$"01178400040A08010A000A09010B000A0A010C000A0001121001178400040A0C"
|
||||
$"010D000A0D010E000A10010F000A0E0110000A0F011100"
|
||||
};
|
@ -8,10 +8,11 @@ if $(TARGET_PLATFORM) != haiku {
|
||||
|
||||
UsePublicHeaders [ FDirName add-ons mail_daemon ] ;
|
||||
UsePrivateHeaders mail ;
|
||||
UseLibraryHeaders icon ;
|
||||
|
||||
SubDirHdrs [ FDirName $(HAIKU_TOP) headers os add-ons mail_daemon ] ;
|
||||
|
||||
AddResources mail_daemon : mail_daemon.rdef ;
|
||||
AddResources mail_daemon : mail_daemon.rdef DeskbarViewIcons.rdef ;
|
||||
|
||||
Server mail_daemon :
|
||||
deskbarview.cpp
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <VolumeRoster.h>
|
||||
#include <Directory.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <IconUtils.h>
|
||||
#include <Query.h>
|
||||
#include <SymLink.h>
|
||||
#include <NodeInfo.h>
|
||||
@ -36,6 +37,7 @@
|
||||
#include <MDRLanguage.h>
|
||||
|
||||
#include "deskbarview.h"
|
||||
#include "DeskbarViewIcons.h"
|
||||
|
||||
const char *kTrackerSignature = "application/x-vnd.Be-TRAK";
|
||||
|
||||
@ -62,7 +64,7 @@ status_t our_image(image_info* image)
|
||||
(char*)our_image <= (char*)image->text_part + image->text_part_size)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -76,36 +78,44 @@ BView* instantiate_deskbar_item(void)
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
DeskbarView::DeskbarView(BRect frame)
|
||||
: BView(frame, "mail_daemon", B_FOLLOW_NONE, B_WILL_DRAW | B_PULSE_NEEDED)
|
||||
, fIcon(NULL)
|
||||
, fCurrentIconState(NEW_MAIL)
|
||||
DeskbarView::DeskbarView(BRect frame)
|
||||
:
|
||||
BView(frame, "mail_daemon", B_FOLLOW_NONE, B_WILL_DRAW | B_PULSE_NEEDED),
|
||||
fStatus(kStatusNoMail)
|
||||
{
|
||||
_InitBitmaps();
|
||||
}
|
||||
|
||||
DeskbarView::DeskbarView(BMessage *message)
|
||||
: BView(message)
|
||||
, fIcon(NULL)
|
||||
, fCurrentIconState(NEW_MAIL)
|
||||
:
|
||||
BView(message),
|
||||
fStatus(kStatusNoMail)
|
||||
{
|
||||
ChangeIcon(NO_MAIL);
|
||||
_InitBitmaps();
|
||||
}
|
||||
|
||||
DeskbarView::~DeskbarView()
|
||||
{
|
||||
delete fIcon;
|
||||
for (int i = 0; i < kStatusCount; i++)
|
||||
delete fBitmaps[i];
|
||||
|
||||
for (int32 i = 0; i < fNewMailQueries.CountItems(); i++)
|
||||
delete ((BQuery *)(fNewMailQueries.ItemAt(i)));
|
||||
}
|
||||
|
||||
void DeskbarView::AttachedToWindow()
|
||||
{
|
||||
if (be_roster->IsRunning("application/x-vnd.Be-POST"))
|
||||
{
|
||||
RefreshMailQuery();
|
||||
}
|
||||
BView::AttachedToWindow();
|
||||
if (Parent())
|
||||
SetViewColor(Parent()->ViewColor());
|
||||
else
|
||||
{
|
||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
|
||||
SetLowColor(ViewColor());
|
||||
|
||||
if (be_roster->IsRunning("application/x-vnd.Be-POST")) {
|
||||
RefreshMailQuery();
|
||||
} else {
|
||||
BDeskbar deskbar;
|
||||
deskbar.RemoveItem("mail_daemon");
|
||||
}
|
||||
@ -120,10 +130,10 @@ void DeskbarView::RefreshMailQuery()
|
||||
BVolumeRoster volumes;
|
||||
BVolume volume;
|
||||
fNewMessages = 0;
|
||||
|
||||
|
||||
while (volumes.GetNextVolume(&volume) == B_OK) {
|
||||
BQuery *newMailQuery = new BQuery;
|
||||
|
||||
|
||||
newMailQuery->SetTarget(this);
|
||||
newMailQuery->SetVolume(&volume);
|
||||
newMailQuery->PushAttr(B_MAIL_ATTR_STATUS);
|
||||
@ -138,16 +148,17 @@ void DeskbarView::RefreshMailQuery()
|
||||
newMailQuery->PushOp(B_OR);
|
||||
newMailQuery->PushOp(B_AND);
|
||||
newMailQuery->Fetch();
|
||||
|
||||
|
||||
BEntry entry;
|
||||
while (newMailQuery->GetNextEntry(&entry) == B_OK)
|
||||
if (entry.InitCheck() == B_OK)
|
||||
fNewMessages++;
|
||||
|
||||
|
||||
fNewMailQueries.AddItem(newMailQuery);
|
||||
}
|
||||
|
||||
ChangeIcon((fNewMessages > 0) ? NEW_MAIL : NO_MAIL);
|
||||
fStatus = (fNewMessages > 0) ? kStatusNewMail : kStatusNoMail;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
DeskbarView* DeskbarView::Instantiate(BMessage *data)
|
||||
@ -168,18 +179,12 @@ status_t DeskbarView::Archive(BMessage *data,bool deep) const
|
||||
|
||||
void DeskbarView::Draw(BRect /*updateRect*/)
|
||||
{
|
||||
PushState();
|
||||
if (fBitmaps[fStatus] == NULL)
|
||||
return;
|
||||
|
||||
SetHighColor(Parent()->ViewColor());
|
||||
FillRect(BRect(0.0,0.0,15.0,15.0));
|
||||
if(fIcon)
|
||||
{
|
||||
SetDrawingMode(B_OP_OVER);
|
||||
DrawBitmap(fIcon,BRect(0.0,0.0,15.0,15.0));
|
||||
}
|
||||
|
||||
PopState();
|
||||
Sync();
|
||||
SetDrawingMode(B_OP_ALPHA);
|
||||
DrawBitmap(fBitmaps[fStatus]);
|
||||
SetDrawingMode(B_OP_COPY);
|
||||
}
|
||||
|
||||
status_t OpenFolder(const char* end)
|
||||
@ -187,15 +192,15 @@ status_t OpenFolder(const char* end)
|
||||
BPath path;
|
||||
find_directory(B_USER_DIRECTORY, &path);
|
||||
path.Append(end);
|
||||
|
||||
|
||||
entry_ref ref;
|
||||
if (get_ref_for_path(path.Path(),&ref) != B_OK) return B_NAME_NOT_FOUND;
|
||||
if (!BEntry(&ref).Exists()) return B_NAME_NOT_FOUND;
|
||||
|
||||
|
||||
|
||||
|
||||
BMessage open_mbox(B_REFS_RECEIVED);
|
||||
open_mbox.AddRef("refs",&ref);
|
||||
|
||||
|
||||
BMessenger tracker("application/x-vnd.Be-TRAK");
|
||||
tracker.SendMessage(&open_mbox);
|
||||
return B_OK;
|
||||
@ -244,8 +249,9 @@ DeskbarView::MessageReceived(BMessage *message)
|
||||
case B_ENTRY_REMOVED:
|
||||
fNewMessages--;
|
||||
break;
|
||||
}
|
||||
ChangeIcon((fNewMessages > 0) ? NEW_MAIL : NO_MAIL);
|
||||
}
|
||||
fStatus = (fNewMessages > 0) ? kStatusNewMail : kStatusNoMail;
|
||||
Invalidate();
|
||||
break;
|
||||
}
|
||||
case B_QUIT_REQUESTED:
|
||||
@ -256,17 +262,17 @@ DeskbarView::MessageReceived(BMessage *message)
|
||||
{
|
||||
BMessage argv(B_ARGV_RECEIVED);
|
||||
argv.AddString("argv", "E-mail");
|
||||
|
||||
|
||||
entry_ref ref;
|
||||
BPath path;
|
||||
int i = 0;
|
||||
|
||||
|
||||
while (message->FindRef("refs",i++,&ref) == B_OK && path.SetTo(&ref) == B_OK)
|
||||
{
|
||||
//fprintf(stderr,"got %s\n", path.Path());
|
||||
argv.AddString("argv", path.Path());
|
||||
}
|
||||
|
||||
|
||||
if (i > 1)
|
||||
{
|
||||
argv.AddInt32("argc", i);
|
||||
@ -281,40 +287,38 @@ DeskbarView::MessageReceived(BMessage *message)
|
||||
|
||||
|
||||
void
|
||||
DeskbarView::ChangeIcon(int32 icon)
|
||||
DeskbarView::_InitBitmaps()
|
||||
{
|
||||
if (fCurrentIconState == icon)
|
||||
return;
|
||||
|
||||
BBitmap *newIcon(NULL);
|
||||
for (int i = 0; i < kStatusCount; i++)
|
||||
fBitmaps[i] = NULL;
|
||||
|
||||
image_info info;
|
||||
if (our_image(&info) == B_OK) {
|
||||
BFile file(info.name, B_READ_ONLY);
|
||||
if (file.InitCheck() < B_OK)
|
||||
goto err;
|
||||
if (our_image(&info) != B_OK)
|
||||
return;
|
||||
|
||||
BResources rsrc(&file);
|
||||
size_t len;
|
||||
const void *data = rsrc.LoadResource('BBMP', icon == NEW_MAIL
|
||||
? "New" : "Read",&len);
|
||||
if (len == 0)
|
||||
goto err;
|
||||
BFile file(info.name, B_READ_ONLY);
|
||||
if (file.InitCheck() != B_OK)
|
||||
return;
|
||||
|
||||
BMemoryIO stream(data, len);
|
||||
stream.Seek(0, SEEK_SET);
|
||||
BMessage archive;
|
||||
if (archive.Unflatten(&stream) != B_OK)
|
||||
goto err;
|
||||
newIcon = new BBitmap(&archive);
|
||||
} else
|
||||
fputs("no image!", stderr);
|
||||
BResources resources(&file);
|
||||
if (resources.InitCheck() != B_OK)
|
||||
return;
|
||||
|
||||
err:
|
||||
fCurrentIconState = icon;
|
||||
delete fIcon;
|
||||
fIcon = newIcon;
|
||||
Invalidate();
|
||||
for (int i = 0; i < kStatusCount; i++) {
|
||||
const void* data = NULL;
|
||||
size_t size;
|
||||
data = resources.LoadResource(B_VECTOR_ICON_TYPE,
|
||||
kIconNoMail + i, &size);
|
||||
if (data != NULL) {
|
||||
BBitmap* icon = new BBitmap(Bounds(), B_RGBA32);
|
||||
if (icon->InitCheck() == B_OK
|
||||
&& BIconUtils::GetVectorIcon((const uint8 *)data,
|
||||
size, icon) == B_OK) {
|
||||
fBitmaps[i] = icon;
|
||||
} else
|
||||
delete icon;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -465,7 +469,7 @@ DeskbarView::BuildMenu()
|
||||
&& strcmp(mimeString, "application/x-vnd.Be-query") == 0)
|
||||
useNavMenu = true;
|
||||
}
|
||||
// clobber the existing ref only if the symlink derefernces completely,
|
||||
// clobber the existing ref only if the symlink derefernces completely,
|
||||
// otherwise we'll stick with what we have
|
||||
entry.GetRef(&ref);
|
||||
}
|
||||
|
@ -10,9 +10,10 @@
|
||||
#include "NavMenu.h"
|
||||
|
||||
|
||||
enum MDDeskbarIcon {
|
||||
NO_MAIL = 0,
|
||||
NEW_MAIL,
|
||||
enum {
|
||||
kStatusNoMail = 0,
|
||||
kStatusNewMail,
|
||||
kStatusCount
|
||||
};
|
||||
|
||||
enum MDDeskbarMessages {
|
||||
@ -33,7 +34,7 @@ class BPath;
|
||||
class _EXPORT DeskbarView : public BView {
|
||||
public:
|
||||
DeskbarView (BRect frame);
|
||||
DeskbarView (BMessage *data);
|
||||
DeskbarView (BMessage *data);
|
||||
|
||||
virtual ~DeskbarView();
|
||||
|
||||
@ -46,17 +47,16 @@ class _EXPORT DeskbarView : public BView {
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
virtual void Pulse();
|
||||
|
||||
void ChangeIcon(int32 icon);
|
||||
|
||||
private:
|
||||
void RefreshMailQuery();
|
||||
bool CreateMenuLinks(BDirectory &,BPath &);
|
||||
void CreateNewMailQuery(BEntry &);
|
||||
BPopUpMenu *BuildMenu();
|
||||
|
||||
BBitmap *fIcon;
|
||||
int32 fCurrentIconState;
|
||||
|
||||
void _InitBitmaps();
|
||||
|
||||
BBitmap* fBitmaps[kStatusCount];
|
||||
int32 fStatus;
|
||||
|
||||
BList fNewMailQueries;
|
||||
int32 fNewMessages;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user