summaryrefslogtreecommitdiffstats
path: root/views/widget
diff options
context:
space:
mode:
authorglotov@google.com <glotov@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-20 18:22:12 +0000
committerglotov@google.com <glotov@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-20 18:22:12 +0000
commit7ceeba70872aab6ac66a1043c9f1587b12fc6710 (patch)
treeb1b31bd92c42eee3987a970246107772d3eda4b7 /views/widget
parenta6bab42a4a8f87d60fd0b5772d4fb6e14381853a (diff)
downloadchromium_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/widget')
-rw-r--r--views/widget/root_view.cc5
-rw-r--r--views/widget/root_view.h4
-rw-r--r--views/widget/widget.h4
-rw-r--r--views/widget/widget_gtk.cc13
-rw-r--r--views/widget/widget_win.cc5
5 files changed, 31 insertions, 0 deletions
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