* style cleanup, no functional change

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35596 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Alexandre Deckner
2010-02-24 13:34:36 +00:00
parent 8480d72320
commit bf7db4bb7e
6 changed files with 152 additions and 127 deletions
+8 -5
View File
@@ -16,13 +16,14 @@
HApp::HApp() HApp::HApp()
: BApplication("application/x-vnd.Haiku-Sounds") :
BApplication("application/x-vnd.Haiku-Sounds")
{ {
BRect rect; BRect rect;
rect.Set(200, 150, 590, 570); rect.Set(200, 150, 590, 570);
HWindow *win = new HWindow(rect, "Sounds"); HWindow* window = new HWindow(rect, "Sounds");
win->Show(); window->Show();
} }
@@ -34,12 +35,14 @@ HApp::~HApp()
void void
HApp::AboutRequested() HApp::AboutRequested()
{ {
(new BAlert("About Sounds", "Sounds\n" BAlert* alert = new BAlert("About Sounds",
"Sounds\n"
" Brought to you by :\n" " Brought to you by :\n"
" Oliver Ruiz Dorantes\n" " Oliver Ruiz Dorantes\n"
" Jérôme DUVAL.\n" " Jérôme DUVAL.\n"
" Original work from Atsushi Takamatsu.\n" " Original work from Atsushi Takamatsu.\n"
"Copyright " B_UTF8_COPYRIGHT "2003-2006 Haiku", "OK"))->Go(); "Copyright " B_UTF8_COPYRIGHT "2003-2006 Haiku", "OK");
alert->Go();
} }
+1 -2
View File
@@ -18,9 +18,8 @@ class HApp :public BApplication {
public: public:
HApp(); HApp();
virtual ~HApp(); virtual ~HApp();
protected:
virtual void AboutRequested(); virtual void AboutRequested();
}; };
#endif // HAPP_H #endif // HAPP_H
+15 -7
View File
@@ -18,7 +18,8 @@
HEventRow::HEventRow(const char* name, const char* path) HEventRow::HEventRow(const char* name, const char* path)
: BRow(), :
BRow(),
fName(name) fName(name)
{ {
SetField(new BStringField(name), kEventColumn); SetField(new BStringField(name), kEventColumn);
@@ -48,11 +49,14 @@ HEventRow::Remove(const char *type)
HEventList::HEventList(BRect rect, const char* name) HEventList::HEventList(BRect rect, const char* name)
: BColumnListView(rect, name, B_FOLLOW_ALL, 0, B_PLAIN_BORDER, true), :
BColumnListView(rect, name, B_FOLLOW_ALL, 0, B_PLAIN_BORDER, true),
fType(NULL) fType(NULL)
{ {
AddColumn(new BStringColumn("Event", 150, 50, 500, B_TRUNCATE_MIDDLE), kEventColumn); AddColumn(new BStringColumn("Event", 150, 50, 500, B_TRUNCATE_MIDDLE),
AddColumn(new BStringColumn("Sound", 150, 50, 500, B_TRUNCATE_END), kSoundColumn); kEventColumn);
AddColumn(new BStringColumn("Sound", 150, 50, 500, B_TRUNCATE_END),
kSoundColumn);
} }
@@ -76,7 +80,8 @@ HEventList::SetType(const char* type)
entry_ref ref; entry_ref ref;
while (mfiles.GetNextRef(&name,&ref) == B_OK) { while (mfiles.GetNextRef(&name,&ref) == B_OK) {
BPath path(&ref); BPath path(&ref);
if ((path.InitCheck() != B_OK) || (ref.name == NULL) || (strcmp(ref.name, "") == 0)) if (path.InitCheck() != B_OK || ref.name == NULL
|| strcmp(ref.name, "") == 0)
AddRow(new HEventRow(name.String(), NULL)); AddRow(new HEventRow(name.String(), NULL));
else else
AddRow(new HEventRow(name.String(), path.Path())); AddRow(new HEventRow(name.String(), path.Path()));
@@ -106,13 +111,16 @@ HEventList::SelectionChanged()
BMediaFiles().GetRefFor(fType, row->Name(), &ref); BMediaFiles().GetRefFor(fType, row->Name(), &ref);
BPath path(&ref); BPath path(&ref);
if ((path.InitCheck()==B_OK) || (ref.name == NULL) || (strcmp(ref.name, "") == 0)) { if (path.InitCheck() == B_OK || ref.name == NULL
|| strcmp(ref.name, "") == 0) {
row->SetPath(path.Path()); row->SetPath(path.Path());
UpdateRow(row); UpdateRow(row);
} else { } else {
printf("name %s\n", ref.name); printf("name %s\n", ref.name);
BMediaFiles().RemoveRefFor(fType, row->Name(), ref); BMediaFiles().RemoveRefFor(fType, row->Name(), ref);
(new BAlert("alert", "No such file or directory", "OK"))->Go(); BAlert* alert = new BAlert("alert",
"No such file or directory", "OK");
alert->Go();
return; return;
} }
BMessage msg(M_EVENT_CHANGED); BMessage msg(M_EVENT_CHANGED);
+7 -2
View File
@@ -10,9 +10,11 @@
#ifndef __HEVENTLIST_H__ #ifndef __HEVENTLIST_H__
#define __HEVENTLIST_H__ #define __HEVENTLIST_H__
#include <ColumnListView.h> #include <ColumnListView.h>
#include <String.h> #include <String.h>
enum { enum {
kEventColumn, kEventColumn,
kSoundColumn, kSoundColumn,
@@ -29,7 +31,6 @@ public:
const char* Path() const { return fPath.String(); } const char* Path() const { return fPath.String(); }
void Remove(const char* type); void Remove(const char* type);
void SetPath(const char* path); void SetPath(const char* path);
protected:
private: private:
BString fName; BString fName;
@@ -50,9 +51,13 @@ public:
void RemoveAll(); void RemoveAll();
void SetType(const char* type); void SetType(const char* type);
void SetPath(const char* path); void SetPath(const char* path);
protected: protected:
virtual void SelectionChanged(); virtual void SelectionChanged();
private: private:
char* fType; char* fType;
}; };
#endif
#endif // __HEVENTLIST_H__
+39 -30
View File
@@ -39,7 +39,8 @@ static const char kSettingsFile[] = "Sounds_Settings";
HWindow::HWindow(BRect rect, const char* name) HWindow::HWindow(BRect rect, const char* name)
: _inherited(rect, name, B_TITLED_WINDOW, 0), :
BWindow(rect, name, B_TITLED_WINDOW, 0),
fFilePanel(NULL), fFilePanel(NULL),
fPlayer(NULL) fPlayer(NULL)
{ {
@@ -93,7 +94,8 @@ HWindow::InitGUI()
{ {
BRect rect = Bounds(); BRect rect = Bounds();
rect.bottom -= 106; rect.bottom -= 106;
BView *listView = new BView(rect, "", B_FOLLOW_NONE, B_WILL_DRAW | B_PULSE_NEEDED); BView* listView = new BView(rect, "", B_FOLLOW_NONE,
B_WILL_DRAW | B_PULSE_NEEDED);
listView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); listView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(listView); AddChild(listView);
@@ -108,7 +110,8 @@ HWindow::InitGUI()
rect = Bounds(); rect = Bounds();
rect.top = rect.bottom - 105; rect.top = rect.bottom - 105;
BView *view = new BView(rect, "", B_FOLLOW_NONE, B_WILL_DRAW | B_PULSE_NEEDED); BView* view = new BView(rect, "", B_FOLLOW_NONE,
B_WILL_DRAW | B_PULSE_NEEDED);
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(view); AddChild(view);
rect = view->Bounds().InsetBySelf(12, 12); rect = view->Bounds().InsetBySelf(12, 12);
@@ -125,17 +128,19 @@ HWindow::InitGUI()
menu->AddSeparatorItem(); menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("<none>", new BMessage(M_NONE_MESSAGE))); menu->AddItem(new BMenuItem("<none>", new BMessage(M_NONE_MESSAGE)));
menu->AddItem(new BMenuItem("Other" B_UTF8_ELLIPSIS, new BMessage(M_OTHER_MESSAGE))); menu->AddItem(new BMenuItem("Other" B_UTF8_ELLIPSIS,
BMenuField *menuField = new BMenuField(rect, "filemenu", "Sound file:", menu, new BMessage(M_OTHER_MESSAGE)));
B_FOLLOW_TOP | B_FOLLOW_LEFT); BMenuField* menuField = new BMenuField(rect, "filemenu", "Sound file:",
menu, B_FOLLOW_TOP | B_FOLLOW_LEFT);
menuField->SetDivider(menuField->StringWidth("Sound file:") + 10); menuField->SetDivider(menuField->StringWidth("Sound file:") + 10);
box->AddChild(menuField); box->AddChild(menuField);
rect.OffsetBy(-2, menuField->Bounds().Height() + 15); rect.OffsetBy(-2, menuField->Bounds().Height() + 15);
BButton *button = new BButton(rect, "stop", "Stop", new BMessage(M_STOP_MESSAGE), BButton* button = new BButton(rect, "stop", "Stop",
B_FOLLOW_RIGHT | B_FOLLOW_TOP); new BMessage(M_STOP_MESSAGE), B_FOLLOW_RIGHT | B_FOLLOW_TOP);
button->ResizeToPreferred(); button->ResizeToPreferred();
button->SetEnabled(false); button->SetEnabled(false);
button->MoveTo(box->Bounds().right - button->Bounds().Width() - 15, rect.top); button->MoveTo(box->Bounds().right - button->Bounds().Width() - 15,
rect.top);
box->AddChild(button); box->AddChild(button);
rect = button->Frame(); rect = button->Frame();
@@ -151,7 +156,8 @@ HWindow::InitGUI()
box->AddChild(button); box->AddChild(button);
view->MoveTo(0, listView->Frame().bottom); view->MoveTo(0, listView->Frame().bottom);
ResizeTo(Bounds().Width(), listView->Frame().bottom + view->Bounds().Height()); ResizeTo(Bounds().Width(),
listView->Frame().bottom + view->Bounds().Height());
listView->SetResizingMode(B_FOLLOW_ALL); listView->SetResizingMode(B_FOLLOW_ALL);
view->SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM); view->SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM);
@@ -175,11 +181,11 @@ HWindow::MessageReceived(BMessage *message)
BPath path(row->Path()); BPath path(row->Path());
if (path.InitCheck() != B_OK) { if (path.InitCheck() != B_OK) {
BMenuItem* item = menu->FindItem("<none>"); BMenuItem* item = menu->FindItem("<none>");
if (item) if (item != NULL)
item->SetMarked(true); item->SetMarked(true);
} else { } else {
BMenuItem* item = menu->FindItem(path.Leaf()); BMenuItem* item = menu->FindItem(path.Leaf());
if (item) if (item != NULL)
item->SetMarked(true); item->SetMarked(true);
} }
} }
@@ -193,7 +199,8 @@ HWindow::MessageReceived(BMessage *message)
entry_ref ref; entry_ref ref;
HEventRow* row = (HEventRow*)fEventList->CurrentSelection(); HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
if (message->FindRef("refs", &ref) == B_OK && row != NULL) { if (message->FindRef("refs", &ref) == B_OK && row != NULL) {
BMenuField *menufield = cast_as(FindView("filemenu"), BMenuField); BMenuField* menufield = cast_as(FindView("filemenu"),
BMenuField);
BMenu* menu = menufield->Menu(); BMenu* menu = menufield->Menu();
// check audio file // check audio file
@@ -204,10 +211,12 @@ HWindow::MessageReceived(BMessage *message)
BMimeType mtype(type); BMimeType mtype(type);
BMimeType superType; BMimeType superType;
mtype.GetSupertype(&superType); mtype.GetSupertype(&superType);
if (superType.Type() == NULL || strcmp(superType.Type(), "audio") != 0) { if (superType.Type() == NULL
|| strcmp(superType.Type(), "audio") != 0) {
beep(); beep();
(new BAlert("", "This is not a audio file.", "OK", NULL, NULL, BAlert* alert = new BAlert("", "This is not a audio file.",
B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go(); "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
alert->Go();
break; break;
} }
@@ -216,12 +225,12 @@ HWindow::MessageReceived(BMessage *message)
BPath path(&ref); BPath path(&ref);
msg->AddRef("refs", &ref); msg->AddRef("refs", &ref);
BMenuItem* menuitem = menu->FindItem(path.Leaf()); BMenuItem* menuitem = menu->FindItem(path.Leaf());
if (!menuitem) if (menuitem == NULL)
menu->AddItem(menuitem = new BMenuItem(path.Leaf(), msg), 0); menu->AddItem(menuitem = new BMenuItem(path.Leaf(), msg), 0);
// refresh item // refresh item
fEventList->SetPath(BPath(&ref).Path()); fEventList->SetPath(BPath(&ref).Path());
// check file menu // check file menu
if (menuitem) if (menuitem != NULL)
menuitem->SetMarked(true); menuitem->SetMarked(true);
} }
break; break;
@@ -232,7 +241,7 @@ HWindow::MessageReceived(BMessage *message)
HEventRow* row = (HEventRow*)fEventList->CurrentSelection(); HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
if (row != NULL) { if (row != NULL) {
const char* path = row->Path(); const char* path = row->Path();
if (path) { if (path != NULL) {
entry_ref ref; entry_ref ref;
::get_ref_for_path(path, &ref); ::get_ref_for_path(path, &ref);
delete fPlayer; delete fPlayer;
@@ -245,7 +254,7 @@ HWindow::MessageReceived(BMessage *message)
case M_STOP_MESSAGE: case M_STOP_MESSAGE:
{ {
if (!fPlayer) if (fPlayer == NULL)
break; break;
if (fPlayer->IsPlaying()) { if (fPlayer->IsPlaying()) {
fPlayer->StopPlaying(); fPlayer->StopPlaying();
@@ -265,11 +274,11 @@ HWindow::MessageReceived(BMessage *message)
BPath path(path); BPath path(path);
if (path.InitCheck() != B_OK) { if (path.InitCheck() != B_OK) {
BMenuItem* item = menu->FindItem("<none>"); BMenuItem* item = menu->FindItem("<none>");
if (item) if (item != NULL)
item->SetMarked(true); item->SetMarked(true);
} else { } else {
BMenuItem* item = menu->FindItem(path.Leaf()); BMenuItem* item = menu->FindItem(path.Leaf());
if (item) if (item != NULL)
item->SetMarked(true); item->SetMarked(true);
} }
} }
@@ -291,7 +300,7 @@ HWindow::MessageReceived(BMessage *message)
} }
default: default:
_inherited::MessageReceived(message); BWindow::MessageReceived(message);
} }
} }
@@ -304,7 +313,7 @@ HWindow::SetupMenuField()
int32 count = fEventList->CountRows(); int32 count = fEventList->CountRows();
for (int32 i = 0; i < count; i++) { for (int32 i = 0; i < count; i++) {
HEventRow* row = (HEventRow*)fEventList->RowAt(i); HEventRow* row = (HEventRow*)fEventList->RowAt(i);
if (!row) if (row == NULL)
continue; continue;
BPath path(row->Path()); BPath path(row->Path());
@@ -329,7 +338,7 @@ HWindow::SetupMenuField()
if (err == B_OK) if (err == B_OK)
err = dir.SetTo(path.Path()); err = dir.SetTo(path.Path());
while (err == B_OK) { while (err == B_OK) {
err = dir.GetNextEntry((BEntry*)&entry, true); err = dir.GetNextEntry(&entry, true);
if (entry.InitCheck() != B_NO_ERROR) if (entry.InitCheck() != B_NO_ERROR)
break; break;
@@ -349,7 +358,7 @@ HWindow::SetupMenuField()
if (err == B_OK) if (err == B_OK)
err = dir.SetTo(path.Path()); err = dir.SetTo(path.Path());
while (err == B_OK) { while (err == B_OK) {
err = dir.GetNextEntry((BEntry*)&entry, true); err = dir.GetNextEntry(&entry, true);
if (entry.InitCheck() != B_NO_ERROR) if (entry.InitCheck() != B_NO_ERROR)
break; break;
@@ -370,7 +379,7 @@ HWindow::SetupMenuField()
if (err == B_OK) if (err == B_OK)
err = dir.SetTo(path.Path()); err = dir.SetTo(path.Path());
while (err == B_OK) { while (err == B_OK) {
err = dir.GetNextEntry((BEntry*)&entry, true); err = dir.GetNextEntry(&entry, true);
if (entry.InitCheck() != B_NO_ERROR) if (entry.InitCheck() != B_NO_ERROR)
break; break;
@@ -398,14 +407,14 @@ HWindow::Pulse()
BButton* button = cast_as(FindView("play"), BButton); BButton* button = cast_as(FindView("play"), BButton);
BButton* stop = cast_as(FindView("stop"), BButton); BButton* stop = cast_as(FindView("stop"), BButton);
if (!menufield) if (menufield == NULL)
return; return;
if (row != NULL) { if (row != NULL) {
menufield->SetEnabled(true); menufield->SetEnabled(true);
const char* path = row->Path(); const char* path = row->Path();
if (path && strcmp(path, "")) if (path != NULL && strcmp(path, ""))
button->SetEnabled(true); button->SetEnabled(true);
else else
button->SetEnabled(false); button->SetEnabled(false);
@@ -414,7 +423,7 @@ HWindow::Pulse()
button->SetEnabled(false); button->SetEnabled(false);
} }
if (fPlayer) { if (fPlayer != NULL) {
if (fPlayer->IsPlaying()) if (fPlayer->IsPlaying())
stop->SetEnabled(true); stop->SetEnabled(true);
else else
+3 -2
View File
@@ -36,8 +36,8 @@ enum{
class HWindow : public BWindow { class HWindow : public BWindow {
public: public:
HWindow(BRect rect, const char* name); HWindow(BRect rect, const char* name);
protected:
virtual ~HWindow(); virtual ~HWindow();
virtual void MessageReceived(BMessage* message); virtual void MessageReceived(BMessage* message);
virtual bool QuitRequested(); virtual bool QuitRequested();
virtual void DispatchMessage(BMessage* message, virtual void DispatchMessage(BMessage* message,
@@ -45,12 +45,13 @@ protected:
void InitGUI(); void InitGUI();
void SetupMenuField(); void SetupMenuField();
void Pulse(); void Pulse();
private: private:
typedef BWindow _inherited;
HEventList* fEventList; HEventList* fEventList;
BFilePanel* fFilePanel; BFilePanel* fFilePanel;
BFileGameSound* fPlayer; BFileGameSound* fPlayer;
BRect fFrame; BRect fFrame;
}; };
#endif // __HWINDOW_H__ #endif // __HWINDOW_H__