diff options
author | kuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-02 23:01:37 +0000 |
---|---|---|
committer | kuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-02 23:01:37 +0000 |
commit | c3f1b130271c605fa638e4c275f32cdf76211e41 (patch) | |
tree | 3689bd1e8762e7d96b480cf57fd4e589e385f884 /chrome | |
parent | 3cf66b94ebef3b9e0d50e74d44204cc08873d1e6 (diff) | |
download | chromium_src-c3f1b130271c605fa638e4c275f32cdf76211e41.zip chromium_src-c3f1b130271c605fa638e4c275f32cdf76211e41.tar.gz chromium_src-c3f1b130271c605fa638e4c275f32cdf76211e41.tar.bz2 |
mac translate infobar: fix incorrect language selected
- mac was using index of menu item to manipulate languages; this was broken when i sorted the languages by application locale
- this cl fixes the problem by manipulating languages with command ids which directly map into the languages arrays in translate delegate.
BUG=40271
TEST=verify per bug report
Review URL: http://codereview.chromium.org/1585016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43548 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/cocoa/translate_infobar.mm | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/chrome/browser/cocoa/translate_infobar.mm b/chrome/browser/cocoa/translate_infobar.mm index 930ad5b..fcf762dd 100644 --- a/chrome/browser/cocoa/translate_infobar.mm +++ b/chrome/browser/cocoa/translate_infobar.mm @@ -229,7 +229,10 @@ class TranslateNotificationObserverBridge : return; [self delegate]->ModifyOriginalLanguage(newLanguageIdx); - [fromLanguagePopUp_ selectItemAtIndex:newLanguageIdx]; + + int commandId = IDC_TRANSLATE_ORIGINAL_LANGUAGE_BASE + newLanguageIdx; + int newMenuIdx = [fromLanguagePopUp_ indexOfItemWithTag:commandId]; + [fromLanguagePopUp_ selectItemAtIndex:newMenuIdx]; [self languageModified]; } @@ -240,7 +243,11 @@ class TranslateNotificationObserverBridge : return; [self delegate]->ModifyTargetLanguage(newLanguageIdx); - [toLanguagePopUp_ selectItemAtIndex:newLanguageIdx]; + + int commandId = IDC_TRANSLATE_TARGET_LANGUAGE_BASE + newLanguageIdx; + int newMenuIdx = [toLanguagePopUp_ indexOfItemWithTag:commandId]; + [toLanguagePopUp_ selectItemAtIndex:newMenuIdx]; + [self languageModified]; } @@ -429,28 +436,33 @@ class TranslateNotificationObserverBridge : - (void)populateLanguageMenus { NSMenu* originalLanguageMenu = [fromLanguagePopUp_ menu]; - int selectedIndex = [self delegate]->original_lang_index(); + int selectedMenuIndex = 0; + int selectedLangIndex = [self delegate]->original_lang_index(); for (int i = 0; i < original_language_menu_model_->GetItemCount(); ++i) { NSString* title = base::SysUTF16ToNSString( original_language_menu_model_->GetLabelAt(i)); int cmd = original_language_menu_model_->GetCommandIdAt(i); - bool checked = i == selectedIndex; + bool checked = + (cmd - IDC_TRANSLATE_ORIGINAL_LANGUAGE_BASE) == selectedLangIndex; + if (checked) + selectedMenuIndex = i; AddMenuItem(originalLanguageMenu, self, title, cmd, checked); } - [fromLanguagePopUp_ selectItemAtIndex:selectedIndex]; + [fromLanguagePopUp_ selectItemAtIndex:selectedMenuIndex]; NSMenu* targetLanguageMenu = [toLanguagePopUp_ menu]; - selectedIndex = [self delegate]->target_lang_index(); + selectedLangIndex = [self delegate]->target_lang_index(); for (int i = 0; i < target_language_menu_model_->GetItemCount(); ++i) { NSString* title = base::SysUTF16ToNSString( target_language_menu_model_->GetLabelAt(i)); int cmd = target_language_menu_model_->GetCommandIdAt(i); - bool checked = i == selectedIndex; + bool checked = + (cmd - IDC_TRANSLATE_TARGET_LANGUAGE_BASE) == selectedLangIndex; if (checked) - selectedIndex = i; + selectedMenuIndex = i; AddMenuItem(targetLanguageMenu, self, title, cmd, checked); } - [toLanguagePopUp_ selectItemAtIndex:selectedIndex]; + [toLanguagePopUp_ selectItemAtIndex:selectedMenuIndex]; } - (void)loadLabelText { |