diff --git a/src/preferences/datatranslations/DataTranslations.cpp b/src/preferences/datatranslations/DataTranslations.cpp index cba80e6b7a..2852612420 100644 --- a/src/preferences/datatranslations/DataTranslations.cpp +++ b/src/preferences/datatranslations/DataTranslations.cpp @@ -44,27 +44,6 @@ DataTranslationsApplication::~DataTranslationsApplication() } -void -DataTranslationsApplication::AboutRequested() -{ - BAlert* alert = new BAlert(B_TRANSLATE("About"), - B_TRANSLATE("DataTranslations\n\twritten by Oliver Siebenmarck and" - " others\n\tCopyright 2002-2010, Haiku Inc. All rights reserved.\n"), - B_TRANSLATE("OK")); - - BTextView* view = alert->TextView(); - view->SetStylable(true); - - BFont font; - view->GetFont(&font); - font.SetSize(18); - font.SetFace(B_BOLD_FACE); - view->SetFontAndColor(0, 16, &font); - - alert->Go(); -} - - void DataTranslationsApplication::_InstallError(const char* name, status_t status) { diff --git a/src/preferences/datatranslations/DataTranslations.h b/src/preferences/datatranslations/DataTranslations.h index bd577fda64..41678b4392 100644 --- a/src/preferences/datatranslations/DataTranslations.h +++ b/src/preferences/datatranslations/DataTranslations.h @@ -22,7 +22,6 @@ public: virtual ~DataTranslationsApplication(); virtual void RefsReceived(BMessage* message); - virtual void AboutRequested(); private: void _InstallError(const char* name, status_t status); diff --git a/src/preferences/datatranslations/DataTranslationsWindow.cpp b/src/preferences/datatranslations/DataTranslationsWindow.cpp index 504ee2ab60..c2bb3405b0 100644 --- a/src/preferences/datatranslations/DataTranslationsWindow.cpp +++ b/src/preferences/datatranslations/DataTranslationsWindow.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -138,10 +139,11 @@ DataTranslationsWindow::_ShowConfigView(int32 id) BTranslatorRoster* roster = BTranslatorRoster::Default(); - // fConfigView is NULL the first time this function - // is called, prevent a segment fault - if (fConfigView) + if (fConfigView) { fRightBox->RemoveChild(fConfigView); + delete fConfigView; + fConfigView = NULL; + } BMessage emptyMsg; BRect rect(0, 0, 200, 233); @@ -159,6 +161,33 @@ DataTranslationsWindow::_ShowConfigView(int32 id) } +void +DataTranslationsWindow::_ShowInfoView() +{ + if (fConfigView) { + fRightBox->RemoveChild(fConfigView); + delete fConfigView; + fConfigView = NULL; + } + + BTextView* view = new BTextView("info text"); + view->MakeEditable(false); + view->MakeSelectable(false); + view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + view->SetText(B_TRANSLATE( + "Use this control panel to set default values for translators, " + "to be used when no other settings are specified by an application.")); + + BGroupView* group = new BGroupView(B_VERTICAL); + group->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + group->AddChild(view); + float spacing = be_control_look->DefaultItemSpacing(); + group->GroupLayout()->SetInsets(spacing, spacing, spacing, spacing); + fRightBox->AddChild(group); + fConfigView = group; +} + + void DataTranslationsWindow::_SetupViews() { @@ -186,6 +215,7 @@ DataTranslationsWindow::_SetupViews() // Add the translator info button fButton = new BButton("info", B_TRANSLATE("Info" B_UTF8_ELLIPSIS), new BMessage(kMsgTranslatorInfo), B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE); + fButton->SetEnabled(false); // Populate the translators list view _PopulateListView(); @@ -202,7 +232,7 @@ DataTranslationsWindow::_SetupViews() .Add(fButton, 2, 1); fTranslatorListView->MakeFocus(); - fTranslatorListView->Select(0); + _ShowInfoView(); } @@ -228,10 +258,11 @@ DataTranslationsWindow::_ShowInfoAlert(int32 id) BString message; // Convert the version number into a readable format snprintf(message.LockBuffer(2048), 2048, - B_TRANSLATE("Name:\t%s \nVersion:\t%ld.%ld.%ld\nInfo:\t%s\n\nPath:\n%s\n"), - name, B_TRANSLATION_MAJOR_VERSION(version), - B_TRANSLATION_MINOR_VERSION(version), - B_TRANSLATION_REVISION_VERSION(version), info, path.Path()); + B_TRANSLATE("Name: %s \nVersion: %ld.%ld.%ld\n\n" + "Info:\n%s\n\nPath:\n%s\n"), + name, B_TRANSLATION_MAJOR_VERSION(version), + B_TRANSLATION_MINOR_VERSION(version), + B_TRANSLATION_REVISION_VERSION(version), info, path.Path()); message.UnlockBuffer(); BAlert* alert = new BAlert(B_TRANSLATE("Info"), message.String(), @@ -262,17 +293,8 @@ DataTranslationsWindow::MessageReceived(BMessage* message) case kMsgTranslatorInfo: { int32 selected = fTranslatorListView->CurrentSelection(0); - if (selected < 0) { - // If no translator is selected, show a message explaining - // what the config panel is for - (new BAlert(B_TRANSLATE("Panel Info"), - B_TRANSLATE("Translation Settings\n\n" - "Use this control panel to set values that various\n" - "translators use when no other settings are specified\n" - "in the application."), - B_TRANSLATE("OK")))->Go(); + if (selected < 0) break; - } TranslatorItem* item = fTranslatorListView->TranslatorAt(selected); if (item != NULL) @@ -291,6 +313,7 @@ DataTranslationsWindow::MessageReceived(BMessage* message) fIconView->DrawIcon(false); fButton->SetEnabled(false); fRightBox->RemoveChild(fConfigView); + _ShowInfoView(); break; } @@ -351,4 +374,3 @@ DataTranslationsWindow::MessageReceived(BMessage* message) break; } } - diff --git a/src/preferences/datatranslations/DataTranslationsWindow.h b/src/preferences/datatranslations/DataTranslationsWindow.h index f823269530..68e420750b 100644 --- a/src/preferences/datatranslations/DataTranslationsWindow.h +++ b/src/preferences/datatranslations/DataTranslationsWindow.h @@ -30,6 +30,7 @@ public: virtual void MessageReceived(BMessage* message); private: + void _ShowInfoView(); status_t _GetTranslatorInfo(int32 id, const char*& name, const char*& info, int32& version, BPath& path); void _ShowInfoAlert(int32 id);