void HEventList::SelectionChanged() { BColumnListView::SelectionChanged(); HEventRow* row = (HEventRow*)CurrentSelection(); if (row != NULL) { entry_ref ref; BMediaFiles().GetRefFor(fType, row->Name(), &ref); BPath path(&ref); if (path.InitCheck() == B_OK || ref.name == NULL || strcmp(ref.name, "") == 0) { row->SetPath(path.Path()); UpdateRow(row); } else { printf("name %s\n", ref.name); BMediaFiles().RemoveRefFor(fType, row->Name(), ref); BAlert* alert = new BAlert("alert", B_TRANSLATE("No such file or directory"), B_TRANSLATE("OK")); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); return; } BMessage msg(M_EVENT_CHANGED); msg.AddString("name", row->Name()); msg.AddString("path", row->Path()); Window()->PostMessage(&msg); } }
void PlayMediaFile(const char* media_type, const char* media_name) { entry_ref ref; if (BMediaFiles().GetRefFor(media_type, media_name, &ref) != B_OK || !BEntry(&ref).Exists()) return; MediaFilePlayer* player = list.EachElement(FindMediaFilePlayer, (void*)media_name); if (player != NULL) { if (*(player->Ref()) == ref) { player->Restart(); return; } list.RemoveItem(player); delete player; player = NULL; } if (player == NULL) { player = new MediaFilePlayer(media_type, media_name, &ref); if (player->InitCheck() == B_OK) list.AddItem(player); else delete player; } }
void HEventList::SetPath(const char* path) { HEventRow* row = (HEventRow*)CurrentSelection(); if (row != NULL) { entry_ref ref; BEntry entry(path); entry.GetRef(&ref); BMediaFiles().SetRefFor(fType, row->Name(), ref); row->SetPath(path); UpdateRow(row); } }
void HEventRow::Remove(const char* type) { BMediaFiles().RemoveItem(type, Name()); }