Author: kirilla Date: 2011-04-14 13:08:13 +0200 (Thu, 14 Apr 2011) New Revision: 41249 Changeset: https://dev.haiku-os.org/changeset/41249 Modified: haiku/trunk/src/preferences/datatranslations/DataTranslations.cpp haiku/trunk/src/preferences/datatranslations/DataTranslations.h haiku/trunk/src/preferences/datatranslations/DataTranslationsWindow.cpp haiku/trunk/src/preferences/datatranslations/DataTranslationsWindow.h Log: Move the info button's general informative text to the main view, and set as intro screen. Remove About window. Fix memory leak of config views. Replace the info BAlert's tab characters with a single space for more consistent spacing. Modified: haiku/trunk/src/preferences/datatranslations/DataTranslations.cpp =================================================================== --- haiku/trunk/src/preferences/datatranslations/DataTranslations.cpp 2011-04-13 22:56:10 UTC (rev 41248) +++ haiku/trunk/src/preferences/datatranslations/DataTranslations.cpp 2011-04-14 11:08:13 UTC (rev 41249) @@ -45,27 +45,6 @@ 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) { BString text; Modified: haiku/trunk/src/preferences/datatranslations/DataTranslations.h =================================================================== --- haiku/trunk/src/preferences/datatranslations/DataTranslations.h 2011-04-13 22:56:10 UTC (rev 41248) +++ haiku/trunk/src/preferences/datatranslations/DataTranslations.h 2011-04-14 11:08:13 UTC (rev 41249) @@ -22,7 +22,6 @@ virtual ~DataTranslationsApplication(); virtual void RefsReceived(BMessage* message); - virtual void AboutRequested(); private: void _InstallError(const char* name, status_t status); Modified: haiku/trunk/src/preferences/datatranslations/DataTranslationsWindow.cpp =================================================================== --- haiku/trunk/src/preferences/datatranslations/DataTranslationsWindow.cpp 2011-04-13 22:56:10 UTC (rev 41248) +++ haiku/trunk/src/preferences/datatranslations/DataTranslationsWindow.cpp 2011-04-14 11:08:13 UTC (rev 41249) @@ -22,6 +22,7 @@ #include <Catalog.h> #include <ControlLook.h> #include <Entry.h> +#include <GroupView.h> #include <IconView.h> #include <LayoutBuilder.h> #include <ListView.h> @@ -138,10 +139,11 @@ 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); @@ -160,6 +162,33 @@ 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() { fConfigView = NULL; @@ -186,6 +215,7 @@ // 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 @@ .Add(fButton, 2, 1); fTranslatorListView->MakeFocus(); - fTranslatorListView->Select(0); + _ShowInfoView(); } @@ -228,10 +258,11 @@ 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 @@ 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 @@ fIconView->DrawIcon(false); fButton->SetEnabled(false); fRightBox->RemoveChild(fConfigView); + _ShowInfoView(); break; } @@ -351,4 +374,3 @@ break; } } - Modified: haiku/trunk/src/preferences/datatranslations/DataTranslationsWindow.h =================================================================== --- haiku/trunk/src/preferences/datatranslations/DataTranslationsWindow.h 2011-04-13 22:56:10 UTC (rev 41248) +++ haiku/trunk/src/preferences/datatranslations/DataTranslationsWindow.h 2011-04-14 11:08:13 UTC (rev 41249) @@ -30,6 +30,7 @@ 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);