diff --git a/src/apps/aboutsystem/AboutSystem.cpp b/src/apps/aboutsystem/AboutSystem.cpp index 53450073f3..cedf81ef8b 100644 --- a/src/apps/aboutsystem/AboutSystem.cpp +++ b/src/apps/aboutsystem/AboutSystem.cpp @@ -643,10 +643,8 @@ void AboutView::MouseDown(BPoint point) { BRect r(92, 26, 105, 31); - if (r.Contains(point)) { - printf("Easter egg\n"); - PickRandomHaiku(); - } + if (r.Contains(point)) + BMessenger(this).SendMessage('eegg'); if (Bounds().Contains(point)) { fLastActionTime = system_time(); @@ -691,6 +689,12 @@ AboutView::MessageReceived(BMessage* msg) break; } + case 'eegg': + { + printf("Easter egg\n"); + PickRandomHaiku(); + } + default: BView::MessageReceived(msg); break; @@ -789,18 +793,19 @@ AboutView::AddCopyrightEntry(const char* name, const char* text, void AboutView::PickRandomHaiku() { - BFile fortunes( -#ifdef __HAIKU__ - "/etc/fortunes/Haiku", -#else - "data/etc/fortunes/Haiku", -#endif - B_READ_ONLY); + BPath path; + if (find_directory(B_SYSTEM_DATA_DIRECTORY, &path) != B_OK) + path = "/system/data"; + path.Append("fortunes"); + path.Append("Haiku"); + + BFile fortunes(path.Path(), B_READ_ONLY); struct stat st; if (fortunes.InitCheck() < B_OK) return; if (fortunes.GetStat(&st) < B_OK) return; + char* buff = (char*)malloc((size_t)st.st_size + 1); if (!buff) return; @@ -822,6 +827,7 @@ AboutView::PickRandomHaiku() free(buff); if (haikuList.CountItems() < 1) return; + BString* s = (BString*)haikuList.ItemAt(rand() % haikuList.CountItems()); BFont font(be_bold_font); font.SetSize(be_bold_font->Size());