Fix Terminal localization issues in Custom color scheme

* Localized Label of the colors menu entry was used as the key
  during loading corresponding color value from the preferences file.
  It was obviously observed only on non-English locales;
* Fixes #7209 #8256.
This commit is contained in:
Siarzhuk Zharski
2013-02-10 17:45:44 +01:00
parent 1baa221173
commit 344de4ccd1
+23 -19
View File
@@ -73,12 +73,12 @@ AppearancePrefView::AppearancePrefView(const char* name,
fTerminalMessenger(messenger) fTerminalMessenger(messenger)
{ {
const char* kColorTable[] = { const char* kColorTable[] = {
B_TRANSLATE("Text"), B_TRANSLATE_MARK("Text"),
B_TRANSLATE("Background"), B_TRANSLATE_MARK("Background"),
B_TRANSLATE("Cursor"), B_TRANSLATE_MARK("Cursor"),
B_TRANSLATE("Text under cursor"), B_TRANSLATE_MARK("Text under cursor"),
B_TRANSLATE("Selected text"), B_TRANSLATE_MARK("Selected text"),
B_TRANSLATE("Selected background"), B_TRANSLATE_MARK("Selected background"),
NULL NULL
}; };
@@ -272,11 +272,14 @@ AppearancePrefView::MessageReceived(BMessage* msg)
case MSG_COLOR_CHANGED: case MSG_COLOR_CHANGED:
{ {
rgb_color oldColor = PrefHandler::Default()->getRGB( const BMessage* itemMessage
fColorField->Menu()->FindMarked()->Label()); = fColorField->Menu()->FindMarked()->Message();
const char* label = NULL;
if (itemMessage->FindString("label", &label) != B_OK)
break;
rgb_color oldColor = PrefHandler::Default()->getRGB(label);
if (oldColor != fColorControl->ValueAsColor()) { if (oldColor != fColorControl->ValueAsColor()) {
PrefHandler::Default()->setRGB( PrefHandler::Default()->setRGB(label,
fColorField->Menu()->FindMarked()->Label(),
fColorControl->ValueAsColor()); fColorControl->ValueAsColor());
modified = true; modified = true;
} }
@@ -300,9 +303,12 @@ AppearancePrefView::MessageReceived(BMessage* msg)
} }
case MSG_COLOR_FIELD_CHANGED: case MSG_COLOR_FIELD_CHANGED:
fColorControl->SetValue(PrefHandler::Default()->getRGB( {
fColorField->Menu()->FindMarked()->Label())); const char* label = NULL;
if (msg->FindString("label", &label) == B_OK)
fColorControl->SetValue(PrefHandler::Default()->getRGB(label));
break; break;
}
case MSG_BLINK_CURSOR_CHANGED: case MSG_BLINK_CURSOR_CHANGED:
if (PrefHandler::Default()->getBool(PREF_BLINK_CURSOR) if (PrefHandler::Default()->getBool(PREF_BLINK_CURSOR)
@@ -514,23 +520,21 @@ AppearancePrefView::_MakeMenu(uint32 msg, const char** items,
{ {
BPopUpMenu* menu = new BPopUpMenu(""); BPopUpMenu* menu = new BPopUpMenu("");
int32 i = 0;
while (*items) { while (*items) {
if (strcmp((*items), "") == 0) if (strcmp((*items), "") == 0)
menu->AddSeparatorItem(); menu->AddSeparatorItem();
else { else {
BMessage* message = new BMessage(msg); BMessage* message = new BMessage(msg);
menu->AddItem(new BMenuItem((*items), message)); message->AddString("label", *items);
BMenuItem* item = new BMenuItem(B_TRANSLATE(*items), message);
menu->AddItem(item);
if (strcmp(*items, defaultItemName) == 0)
item->SetMarked(true);
} }
items++; items++;
i++;
} }
BMenuItem* defaultItem = menu->FindItem(defaultItemName);
if (defaultItem)
defaultItem->SetMarked(true);
return menu; return menu;
} }