| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // LICENSE file. |
| 4 | 4 |
| 5 #include "views/controls/native_control_gtk.h" | 5 #include "views/controls/native_control_gtk.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "views/focus/focus_manager.h" | 10 #include "views/focus/focus_manager.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 void NativeControlGtk::Focus() { | 66 void NativeControlGtk::Focus() { |
| 67 DCHECK(native_view()); | 67 DCHECK(native_view()); |
| 68 gtk_widget_grab_focus(native_view()); | 68 gtk_widget_grab_focus(native_view()); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void NativeControlGtk::NativeControlCreated(GtkWidget* native_control) { | 71 void NativeControlGtk::NativeControlCreated(GtkWidget* native_control) { |
| 72 Attach(native_control); | 72 Attach(native_control); |
| 73 | 73 |
| 74 // Update the newly created GtkWdigetwith any resident enabled state. | 74 // Update the newly created GtkWdigetwith any resident enabled state. |
| 75 gtk_widget_set_sensitive(native_view(), IsEnabled()); | 75 gtk_widget_set_sensitive(native_view(), IsEnabled()); |
| 76 |
| 77 // Listen for focus change event to update the FocusManager focused view. |
| 78 g_signal_connect(G_OBJECT(native_control), "focus-in-event", |
| 79 G_CALLBACK(CallFocusIn), this); |
| 80 } |
| 81 |
| 82 // static |
| 83 void NativeControlGtk::CallFocusIn(GtkWidget* widget, |
| 84 GdkEventFocus* event, |
| 85 NativeControlGtk* control) { |
| 86 FocusManager* focus_manager = |
| 87 FocusManager::GetFocusManagerForNativeView(widget); |
| 88 if (!focus_manager) { |
| 89 // TODO(jcampan): http://crbug.com/21378 Reenable this NOTREACHED() when the |
| 90 // options page is only based on views. |
| 91 // NOTREACHED(); |
| 92 NOTIMPLEMENTED(); |
| 93 return; |
| 94 } |
| 95 focus_manager->SetFocusedView(control->focus_view()); |
| 76 } | 96 } |
| 77 | 97 |
| 78 } // namespace views | 98 } // namespace views |
| OLD | NEW |