diff options
author | glotov@google.com <glotov@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-20 18:22:12 +0000 |
---|---|---|
committer | glotov@google.com <glotov@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-20 18:22:12 +0000 |
commit | 7ceeba70872aab6ac66a1043c9f1587b12fc6710 (patch) | |
tree | b1b31bd92c42eee3987a970246107772d3eda4b7 /views | |
parent | a6bab42a4a8f87d60fd0b5772d4fb6e14381853a (diff) | |
download | chromium_src-7ceeba70872aab6ac66a1043c9f1587b12fc6710.zip chromium_src-7ceeba70872aab6ac66a1043c9f1587b12fc6710.tar.gz chromium_src-7ceeba70872aab6ac66a1043c9f1587b12fc6710.tar.bz2 |
UI Language switch implemented by propagating LocaleChanged()
notification to all the views currently active.
Before this CL, all views were recreated instead. That was very refactoring-unsafe.
Note, this is first part of the change. It prepares overall architecture means and can be committed first.
The other part contains implementation details and is here: http://codereview.chromium.org/1551029/show
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/1596023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45057 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/view.cc | 5 | ||||
-rw-r--r-- | views/view.h | 10 | ||||
-rw-r--r-- | views/widget/root_view.cc | 5 | ||||
-rw-r--r-- | views/widget/root_view.h | 4 | ||||
-rw-r--r-- | views/widget/widget.h | 4 | ||||
-rw-r--r-- | views/widget/widget_gtk.cc | 13 | ||||
-rw-r--r-- | views/widget/widget_win.cc | 5 |
7 files changed, 40 insertions, 6 deletions
diff --git a/views/view.cc b/views/view.cc index 3bdb2a2..d04ccec 100644 --- a/views/view.cc +++ b/views/view.cc @@ -651,9 +651,10 @@ void View::ThemeChanged() { GetChildViewAt(i)->ThemeChanged(); } -void View::LocaleChanged() { +void View::NotifyLocaleChanged() { + LocaleChanged(); for (int i = GetChildViewCount() - 1; i >= 0; --i) - GetChildViewAt(i)->LocaleChanged(); + GetChildViewAt(i)->NotifyLocaleChanged(); } #ifndef NDEBUG diff --git a/views/view.h b/views/view.h index d8177aa..bdf1b23 100644 --- a/views/view.h +++ b/views/view.h @@ -982,10 +982,8 @@ class View : public AcceleratorTarget { virtual void ThemeChanged(); // Called when the locale has changed, overriding allows individual Views to - // update locale-dependent resources (strings, bitmaps) it may have cached - // internally. Subclasses that override this method must call the base class - // implementation to ensure child views are processed. - virtual void LocaleChanged(); + // update locale-dependent strings. + virtual void LocaleChanged() { } #ifndef NDEBUG // Returns true if the View is currently processing a paint. @@ -1125,6 +1123,10 @@ class View : public AcceleratorTarget { gfx::Point start_pt; }; + // Propagates locale changed notification from the root view downside. + // Invokes LocaleChanged() for every view in the hierarchy. + virtual void NotifyLocaleChanged(); + // RootView invokes these. These in turn invoke the appropriate OnMouseXXX // method. If a drag is detected, DoDrag is invoked. bool ProcessMousePressed(const MouseEvent& e, DragInfo* drop_info); diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc index 179d49d..3ea101c 100644 --- a/views/widget/root_view.cc +++ b/views/widget/root_view.cc @@ -241,6 +241,11 @@ void RootView::ThemeChanged() { View::ThemeChanged(); } +void RootView::NotifyLocaleChanged() { + // Propagate downside. Note that View::NotifyLocaleChanged() is private. + View::NotifyLocaleChanged(); +} + ///////////////////////////////////////////////////////////////////////////// // // RootView - event dispatch and propagation diff --git a/views/widget/root_view.h b/views/widget/root_view.h index 2d74b1f..aee0bf8 100644 --- a/views/widget/root_view.h +++ b/views/widget/root_view.h @@ -80,6 +80,10 @@ class RootView : public View, // hierarchy. virtual void ThemeChanged(); + // Public API for broadcasting locale change notifications to this View + // hierarchy. + virtual void NotifyLocaleChanged(); + // The following event methods are overridden to propagate event to the // control tree virtual bool OnMousePressed(const MouseEvent& e); diff --git a/views/widget/widget.h b/views/widget/widget.h index b57a701..d4ddcfc 100644 --- a/views/widget/widget.h +++ b/views/widget/widget.h @@ -84,6 +84,10 @@ class Widget { static Widget* GetWidgetFromNativeView(gfx::NativeView native_view); static Widget* GetWidgetFromNativeWindow(gfx::NativeWindow native_window); + // Enumerates all windows pertaining to us and notifies their + // view hierarchies that the locale has changed. + static void NotifyLocaleChanged(); + // Initialize the Widget with a parent and an initial desired size. // |contents_view| is the view that will be the single child of RootView // within this Widget. As contents_view is inserted into RootView's tree, diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc index d65ee99..20b0287 100644 --- a/views/widget/widget_gtk.cc +++ b/views/widget/widget_gtk.cc @@ -1388,4 +1388,17 @@ Widget* Widget::GetWidgetFromNativeWindow(gfx::NativeWindow native_window) { return NULL; } +// static +void Widget::NotifyLocaleChanged() { + GList *window_list = gtk_window_list_toplevels(); + for (GList* element = window_list; element; element = g_list_next(element)) { + GtkWindow* window = GTK_WINDOW(element->data); + DCHECK(window); + RootView *root_view = FindRootView(window); + if (root_view) + root_view->NotifyLocaleChanged(); + } + g_list_free(window_list); +} + } // namespace views diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc index 99e6395..84aece0 100644 --- a/views/widget/widget_win.cc +++ b/views/widget/widget_win.cc @@ -1331,4 +1331,9 @@ Widget* Widget::GetWidgetFromNativeWindow(gfx::NativeWindow native_window) { return Widget::GetWidgetFromNativeView(native_window); } +// static +void Widget::NotifyLocaleChanged() { + NOTIMPLEMENTED(); +} + } // namespace views |