diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-19 02:26:15 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-19 02:26:15 +0000 |
commit | 5dc53350ca741bd7f522ec35f4f1298c2bc25afa (patch) | |
tree | c64d6abdcacfeb3fd0a416b33439a22c6151063d /chrome | |
parent | aa91c8a101ea60c28dc81fc154916f2fdb67ec76 (diff) | |
download | chromium_src-5dc53350ca741bd7f522ec35f4f1298c2bc25afa.zip chromium_src-5dc53350ca741bd7f522ec35f4f1298c2bc25afa.tar.gz chromium_src-5dc53350ca741bd7f522ec35f4f1298c2bc25afa.tar.bz2 |
Select the Languages tab of the fonts and languages dialog when using spellcheck context menu commands to change spellchecking options. Patch by Mohamed Mansour, r=me,sky; see http://codereview.chromium.org/15031. Tweaked by me.
BUG=5639
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7289 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/render_view_context_menu_controller.cc | 13 | ||||
-rw-r--r-- | chrome/browser/views/options/fonts_languages_window_view.cc | 12 | ||||
-rw-r--r-- | chrome/browser/views/options/fonts_languages_window_view.h | 3 | ||||
-rw-r--r-- | chrome/views/tabbed_pane.cc | 13 | ||||
-rw-r--r-- | chrome/views/tabbed_pane.h | 8 |
5 files changed, 37 insertions, 12 deletions
diff --git a/chrome/browser/render_view_context_menu_controller.cc b/chrome/browser/render_view_context_menu_controller.cc index 76a6279..522ebe0 100644 --- a/chrome/browser/render_view_context_menu_controller.cc +++ b/chrome/browser/render_view_context_menu_controller.cc @@ -459,13 +459,14 @@ void RenderViewContextMenuController::ExecuteCommand(int id) { params_.misspelled_word); break; - case IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS: - views::Window::CreateChromeWindow( - source_web_contents_->GetContentHWND(), - gfx::Rect(), - new FontsLanguagesWindowView( - source_web_contents_->profile()))->Show(); + case IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS: { + FontsLanguagesWindowView* window_ = new FontsLanguagesWindowView( + source_web_contents_->profile()); + views::Window::CreateChromeWindow(source_web_contents_->GetContentHWND(), + gfx::Rect(), window_)->Show(); + window_->SelectLanguagesTab(); break; + } case IDS_CONTENT_CONTEXT_ADDSEARCHENGINE: // Not implemented. default: diff --git a/chrome/browser/views/options/fonts_languages_window_view.cc b/chrome/browser/views/options/fonts_languages_window_view.cc index 89115c8..950d104 100644 --- a/chrome/browser/views/options/fonts_languages_window_view.cc +++ b/chrome/browser/views/options/fonts_languages_window_view.cc @@ -73,6 +73,10 @@ gfx::Size FontsLanguagesWindowView::GetPreferredSize() { IDS_FONTSLANG_DIALOG_HEIGHT_LINES)); } +void FontsLanguagesWindowView::SelectLanguagesTab() { + tabs_->SelectTabForContents(languages_page_); +} + void FontsLanguagesWindowView::ViewHierarchyChanged( bool is_add, views::View* parent, views::View* child) { // Can't init before we're inserted into a Container, because we require @@ -89,11 +93,11 @@ void FontsLanguagesWindowView::Init() { AddChildView(tabs_); fonts_page_ = new FontsPageView(profile_); - tabs_->AddTabAtIndex(0, l10n_util::GetString( - IDS_FONT_LANGUAGE_SETTING_FONT_TAB_TITLE), fonts_page_, true); + tabs_->AddTab(l10n_util::GetString( + IDS_FONT_LANGUAGE_SETTING_FONT_TAB_TITLE), fonts_page_); languages_page_ = new LanguagesPageView(profile_); - tabs_->AddTabAtIndex(1, l10n_util::GetString( - IDS_FONT_LANGUAGE_SETTING_LANGUAGES_TAB_TITLE), languages_page_, true); + tabs_->AddTab(l10n_util::GetString( + IDS_FONT_LANGUAGE_SETTING_LANGUAGES_TAB_TITLE), languages_page_); } diff --git a/chrome/browser/views/options/fonts_languages_window_view.h b/chrome/browser/views/options/fonts_languages_window_view.h index 9c2f77e..0d9c77d 100644 --- a/chrome/browser/views/options/fonts_languages_window_view.h +++ b/chrome/browser/views/options/fonts_languages_window_view.h @@ -37,6 +37,9 @@ class FontsLanguagesWindowView : public views::View, virtual void Layout(); virtual gfx::Size GetPreferredSize(); + // Selects the Languages tab. + void SelectLanguagesTab(); + protected: // views::View overrides: virtual void ViewHierarchyChanged(bool is_add, diff --git a/chrome/views/tabbed_pane.cc b/chrome/views/tabbed_pane.cc index 4ceb2e2..838e6fa 100644 --- a/chrome/views/tabbed_pane.cc +++ b/chrome/views/tabbed_pane.cc @@ -127,11 +127,15 @@ View* TabbedPane::RemoveTabAtIndex(int index) { } void TabbedPane::SelectTabAt(int index) { - DCHECK(index < static_cast<int>(tab_views_.size())); + DCHECK((index >= 0) && (index < static_cast<int>(tab_views_.size()))); TabCtrl_SetCurSel(tab_control_, index); DoSelectTabAt(index); } +void TabbedPane::SelectTabForContents(const View* contents) { + SelectTabAt(GetIndexForContents(contents)); +} + int TabbedPane::GetTabCount() { return TabCtrl_GetItemCount(tab_control_); } @@ -216,6 +220,13 @@ void TabbedPane::DoSelectTabAt(int index) { listener_->TabSelectedAt(index); } +int TabbedPane::GetIndexForContents(const View* contents) const { + std::vector<View*>::const_iterator i = + std::find(tab_views_.begin(), tab_views_.end(), contents); + DCHECK(i != tab_views_.end()); + return static_cast<int>(i - tab_views_.begin()); +} + void TabbedPane::Layout() { NativeControl::Layout(); ResizeContents(GetNativeControlHWND()); diff --git a/chrome/views/tabbed_pane.h b/chrome/views/tabbed_pane.h index 5e0dd5e..7a47f5cb 100644 --- a/chrome/views/tabbed_pane.h +++ b/chrome/views/tabbed_pane.h @@ -48,9 +48,12 @@ class TabbedPane : public NativeControl { // view. The caller becomes the owner of the returned view. View* RemoveTabAtIndex(int index); - // Selects the tab at the specified |index|. + // Selects the tab at the specified |index|, which must be valid. void SelectTabAt(int index); + // Selects the tab containing the specified |contents|, which must be valid. + void SelectTabForContents(const View* contents); + // Returns the number of tabs. int GetTabCount(); @@ -67,6 +70,9 @@ class TabbedPane : public NativeControl { // Changes the contents view to the view associated with the tab at |index|. void DoSelectTabAt(int index); + // Returns the index of the tab containing the specified |contents|. + int GetIndexForContents(const View* contents) const; + void ResizeContents(HWND tab_control); HWND tab_control_; |