From c18df4b6011904daabe57ae239351ad11aa00355 Mon Sep 17 00:00:00 2001 From: Ryan Leavengood Date: Sun, 19 Aug 2007 05:23:31 +0000 Subject: [PATCH] Two fixes: - One from Justin O'Dell which properly enables and disables the play and stop buttons. - One from me which doesn't crash Sounds if you try to open a file which has no MIME type set. It previously assumed the super type would always exist. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22010 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/preferences/sounds/HWindow.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/preferences/sounds/HWindow.cpp b/src/preferences/sounds/HWindow.cpp index e32163b2a4..cdb6a63266 100644 --- a/src/preferences/sounds/HWindow.cpp +++ b/src/preferences/sounds/HWindow.cpp @@ -139,6 +139,7 @@ HWindow::InitGUI() ,new BMessage(M_STOP_MESSAGE) ,B_FOLLOW_RIGHT | B_FOLLOW_TOP); button->ResizeToPreferred(); + button->SetEnabled(false); button->MoveTo(box->Bounds().right - button->Bounds().Width() - 15, rect.top); box->AddChild(button); @@ -153,6 +154,7 @@ HWindow::InitGUI() ,new BMessage(M_PLAY_MESSAGE) ,B_FOLLOW_RIGHT | B_FOLLOW_TOP); button->ResizeToPreferred(); + button->SetEnabled(false); button->MoveTo(rect.left - button->Bounds().Width() - 15, rect.top); box->AddChild(button); @@ -212,7 +214,7 @@ HWindow::MessageReceived(BMessage *message) BMimeType mtype(type); BMimeType superType; mtype.GetSupertype(&superType); - if(strcmp(superType.Type(),"audio") != 0) { + if (superType.Type() == NULL || strcmp(superType.Type(), "audio") != 0) { beep(); (new BAlert("","This is not a audio file.","OK",NULL,NULL, B_WIDTH_AS_USUAL,B_STOP_ALERT))->Go(); @@ -408,9 +410,16 @@ HWindow::Pulse() if(!menufield) return; + if(sel >=0) { menufield->SetEnabled(true); - button->SetEnabled(true); + + HEventItem *item = cast_as(fEventList->ItemAt(sel),HEventItem); + const char* path = item->Path(); + if (path && strcmp(path, "")) + button->SetEnabled(true); + else + button->SetEnabled(false); } else { menufield->SetEnabled(false); button->SetEnabled(false);