Fixed all warnings and did some minor style updates (only those next to

the fixed warnings :).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6139 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2004-01-19 17:54:57 +00:00
parent e68c7d967c
commit ed8da400c3
5 changed files with 40 additions and 42 deletions
+6 -6
View File
@@ -28,13 +28,13 @@ Media::Media()
BRect rect(32,64,637,442); BRect rect(32,64,637,442);
BPath path; BPath path;
if(find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) { if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
path.Append(SETTINGS_FILE); path.Append(SETTINGS_FILE);
BFile file(path.Path(),B_READ_ONLY); BFile file(path.Path(),B_READ_ONLY);
if(file.InitCheck()==B_OK) { if (file.InitCheck()==B_OK) {
char buffer[255]; char buffer[255];
ssize_t size = 0; ssize_t size = 0;
while((size = file.Read(buffer, 255))>0) { while ((size = file.Read(buffer, 255)) > 0) {
int32 i=0; int32 i=0;
while(buffer[i]=='#') { while(buffer[i]=='#') {
while(i<size&&buffer[i]!='\n') while(i<size&&buffer[i]!='\n')
@@ -42,12 +42,12 @@ Media::Media()
i++; i++;
} }
int32 a,b,c,d; int32 a,b,c,d;
if(sscanf(&buffer[i], " rect = %i,%i,%i,%i", &a, &b, &c, &d)>0){ if (sscanf(&buffer[i], " rect = %li,%li,%li,%li", &a, &b, &c, &d) > 0) {
if(c-a>=int(rect.Width())) { if (c-a >= rect.IntegerWidth()) {
rect.left = a; rect.left = a;
rect.right = c; rect.right = c;
} }
if(d-b>=int(rect.Height())) { if (d-b >= rect.IntegerHeight()) {
rect.top = b; rect.top = b;
rect.bottom = d; rect.bottom = d;
} }
+7 -11
View File
@@ -24,8 +24,8 @@
// MediaListItem - Constructor // MediaListItem - Constructor
MediaListItem::MediaListItem(dormant_node_info *info, uint32 level, bool isVideo, BList *icons, uint32 modifiers=0) MediaListItem::MediaListItem(dormant_node_info *info, uint32 level, bool isVideo, BList *icons, uint32 modifiers=0)
: BListItem(level), : BListItem(level),
mIsVideo(isVideo),
mIsAudioMixer(false), mIsAudioMixer(false),
mIsVideo(isVideo),
mIsDefaultInput(false), mIsDefaultInput(false),
mIsDefaultOutput(false) mIsDefaultOutput(false)
{ {
@@ -36,11 +36,11 @@ MediaListItem::MediaListItem(dormant_node_info *info, uint32 level, bool isVideo
SetHeight(16 + kITEM_MARGIN); SetHeight(16 + kITEM_MARGIN);
} }
MediaListItem::MediaListItem(const char* label, uint32 level, bool isVideo, BList *icons, uint32 modifiers=0) MediaListItem::MediaListItem(const char *label, uint32 level, bool isVideo, BList *icons, uint32 modifiers=0)
: BListItem(level), : BListItem(level),
mIsVideo(isVideo),
mLabel(label), mLabel(label),
mIsAudioMixer(false), mIsAudioMixer(false),
mIsVideo(isVideo),
mIsDefaultInput(false), mIsDefaultInput(false),
mIsDefaultOutput(false) mIsDefaultOutput(false)
{ {
@@ -62,15 +62,12 @@ MediaListItem::DrawItem(BView *owner, BRect frame, bool complete)
{ {
rgb_color kHighlight = { 140,140,140,0 }; rgb_color kHighlight = { 140,140,140,0 };
rgb_color kBlack = { 0,0,0,0 }; rgb_color kBlack = { 0,0,0,0 };
rgb_color kWhite = { 255,255,255,0 };
BRect r(frame); BRect r(frame);
if (IsSelected() || complete) if (IsSelected() || complete) {
{
rgb_color color; rgb_color color;
if (IsSelected()) if (IsSelected()) {
{
color = kHighlight; color = kHighlight;
} else { } else {
color = owner->ViewColor(); color = owner->ViewColor();
@@ -79,7 +76,6 @@ MediaListItem::DrawItem(BView *owner, BRect frame, bool complete)
owner->SetLowColor(color); owner->SetLowColor(color);
owner->FillRect(r); owner->FillRect(r);
owner->SetHighColor(kBlack); owner->SetHighColor(kBlack);
} else { } else {
owner->SetLowColor(owner->ViewColor()); owner->SetLowColor(owner->ViewColor());
} }
+10 -9
View File
@@ -12,32 +12,34 @@
// Created : June 25, 2003 // Created : June 25, 2003
// //
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
#ifndef __MEDIALISTITEM_H__ #ifndef __MEDIALISTITEM_H__
#define __MEDIALISTITEM_H__ #define __MEDIALISTITEM_H__
#include <ListItem.h> #include <ListItem.h>
#include <MediaAddOn.h> #include <MediaAddOn.h>
class MediaListItem : public BListItem
{ class MediaListItem : public BListItem {
public: public:
MediaListItem(dormant_node_info *info, uint32 level, bool isVideo, BList *icons, uint32 modifiers=0); MediaListItem(dormant_node_info *info, uint32 level, bool isVideo, BList *icons, uint32 modifiers=0);
MediaListItem(const char* label, uint32 level, bool isVideo, BList *icons, uint32 modifiers=0); MediaListItem(const char* label, uint32 level, bool isVideo, BList *icons, uint32 modifiers=0);
~MediaListItem(); ~MediaListItem();
virtual void Update(BView *owner, const BFont *finfo); virtual void Update(BView *owner, const BFont *finfo);
virtual void DrawItem(BView *owner, BRect frame, bool complete = false); virtual void DrawItem(BView *owner, BRect frame, bool complete = false);
void SetDefault(bool isDefaultInput, bool isInput); void SetDefault(bool isDefaultInput, bool isInput);
void SetAudioMixer(bool isAudioMixer); void SetAudioMixer(bool isAudioMixer);
bool IsDefault(bool isInput) { return isInput ? mIsDefaultInput : mIsDefaultOutput; } bool IsDefault(bool isInput) { return isInput ? mIsDefaultInput : mIsDefaultOutput; }
bool IsAudioMixer() { return mIsAudioMixer; } bool IsAudioMixer() { return mIsAudioMixer; }
bool IsVideo() { return mIsVideo; } bool IsVideo() { return mIsVideo; }
const char* GetLabel() { return mLabel; } const char *GetLabel() { return mLabel; }
dormant_node_info *mInfo; dormant_node_info *mInfo;
static int Compare(const void *firstArg, const void *secondArg); static int Compare(const void *firstArg, const void *secondArg);
private: private:
const char *mLabel; const char *mLabel;
bool mIsAudioMixer; bool mIsAudioMixer;
@@ -48,5 +50,4 @@ class MediaListItem : public BListItem
BList *mIcons; BList *mIcons;
}; };
#endif /* __MEDIALISTITEM_H__ */
#endif
+13 -13
View File
@@ -161,14 +161,14 @@ SettingsView::AddNodes(BList &list, bool isInput)
{ {
BMenu *menu = isInput ? mMenu1 : mMenu2; BMenu *menu = isInput ? mMenu1 : mMenu2;
void *item; void *item;
while(item = menu->RemoveItem((int32)0)) while ((item = menu->RemoveItem((int32)0)) != NULL)
delete item; delete item;
BMessage message(ML_DEFAULT_CHANGE); BMessage message(ML_DEFAULT_CHANGE);
message.AddBool("isVideo", mIsVideo); message.AddBool("isVideo", mIsVideo);
message.AddBool("isInput", isInput); message.AddBool("isInput", isInput);
for(int32 i=0; i<list.CountItems(); i++) { for (int32 i = 0; i < list.CountItems(); i++) {
dormant_node_info *info = static_cast<dormant_node_info *>(list.ItemAt(i)); dormant_node_info *info = static_cast<dormant_node_info *>(list.ItemAt(i));
menu->AddItem(new SettingsItem(info, new BMessage(message))); menu->AddItem(new SettingsItem(info, new BMessage(message)));
} }
@@ -179,7 +179,7 @@ SettingsView::SetDefault(dormant_node_info &info, bool isInput, int32 outputID)
{ {
BMenu *menu = isInput ? mMenu1 : mMenu2; BMenu *menu = isInput ? mMenu1 : mMenu2;
for(int32 i=0; i<menu->CountItems(); i++) { for (int32 i = 0; i < menu->CountItems(); i++) {
SettingsItem *item = static_cast<SettingsItem *>(menu->ItemAt(i)); SettingsItem *item = static_cast<SettingsItem *>(menu->ItemAt(i));
if(item->mInfo && item->mInfo->addon == info.addon && item->mInfo->flavor_id == info.flavor_id) { if(item->mInfo && item->mInfo->addon == info.addon && item->mInfo->flavor_id == info.flavor_id) {
item->SetMarked(true); item->SetMarked(true);
@@ -187,26 +187,26 @@ SettingsView::SetDefault(dormant_node_info &info, bool isInput, int32 outputID)
} }
} }
if(!mIsVideo&&!isInput&&outputID>-1) { if (!mIsVideo&&!isInput&&outputID>-1) {
BMenuItem *item; BMenuItem *item;
while(item = mMenu3->RemoveItem((int32)0)) while ((item = mMenu3->RemoveItem((int32)0)) != NULL)
delete item; delete item;
BMediaRoster *roster = BMediaRoster::Roster(); BMediaRoster *roster = BMediaRoster::Roster();
media_node node; media_node node;
media_node_id node_id; media_node_id node_id;
status_t err; status_t err;
if(roster->GetInstancesFor(info.addon, info.flavor_id, &node_id)!=B_OK) if (roster->GetInstancesFor(info.addon, info.flavor_id, &node_id)!=B_OK)
err = roster->InstantiateDormantNode(info, &node, B_FLAVOR_IS_GLOBAL); err = roster->InstantiateDormantNode(info, &node, B_FLAVOR_IS_GLOBAL);
else else
err = roster->GetNodeFor(node_id, &node); err = roster->GetNodeFor(node_id, &node);
if(err == B_OK) { if (err == B_OK) {
media_input inputs[16]; media_input inputs[16];
int32 inputCount = 16; int32 inputCount = 16;
if(roster->GetAllInputsFor(node, inputs, 16, &inputCount)==B_OK) { if (roster->GetAllInputsFor(node, inputs, 16, &inputCount)==B_OK) {
BMessage message(ML_DEFAULTOUTPUT_CHANGE); BMessage message(ML_DEFAULTOUTPUT_CHANGE);
Settings2Item *listItem;
for(int32 i=0; i<inputCount; i++) { for (int32 i = 0; i < inputCount; i++) {
media_input *input = new media_input(); media_input *input = new media_input();
memcpy(input, &inputs[i], sizeof(*input)); memcpy(input, &inputs[i], sizeof(*input));
mMenu3->AddItem(item = new Settings2Item(&info, input, new BMessage(message))); mMenu3->AddItem(item = new Settings2Item(&info, input, new BMessage(message)));
@@ -239,4 +239,4 @@ Settings2Item::~Settings2Item()
{ {
delete mInput; delete mInput;
} }
+4 -3
View File
@@ -641,7 +641,7 @@ MediaWindow::UpdateProgress(int stage, const char * message, void * cookie)
MediaAlert *alert = static_cast<MediaAlert*>(cookie); MediaAlert *alert = static_cast<MediaAlert*>(cookie);
PRINT(("stage : %i\n", stage)); PRINT(("stage : %i\n", stage));
char *string = "Unknown stage"; char *string = "Unknown stage";
switch(stage) { switch (stage) {
case 10: case 10:
string = "Stopping Media Server..."; string = "Stopping Media Server...";
break; break;
@@ -660,7 +660,8 @@ MediaWindow::UpdateProgress(int stage, const char * message, void * cookie)
} }
BAutolock locker(alert); BAutolock locker(alert);
if(locker.IsLocked()) if (locker.IsLocked())
alert->TextView()->SetText(string); alert->TextView()->SetText(string);
return true; return true;
} }