| OLD | NEW | 
|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 60     // The view becomes visible after native control is created. | 60     // The view becomes visible after native control is created. | 
| 61     // Layout now. | 61     // Layout now. | 
| 62     Layout(); | 62     Layout(); | 
| 63   } | 63   } | 
| 64 } | 64 } | 
| 65 | 65 | 
| 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   GetParent()->NotifyAccessibilityEvent(AccessibilityTypes::EVENT_FOCUS); | 70   parent()->NotifyAccessibilityEvent(AccessibilityTypes::EVENT_FOCUS); | 
| 71 } | 71 } | 
| 72 | 72 | 
| 73 void NativeControlGtk::NativeControlCreated(GtkWidget* native_control) { | 73 void NativeControlGtk::NativeControlCreated(GtkWidget* native_control) { | 
| 74   Attach(native_control); | 74   Attach(native_control); | 
| 75 | 75 | 
| 76   // Update the newly created GtkWdigetwith any resident enabled state. | 76   // Update the newly created GtkWidget with any resident enabled state. | 
| 77   gtk_widget_set_sensitive(native_view(), IsEnabled()); | 77   gtk_widget_set_sensitive(native_view(), IsEnabled()); | 
| 78 | 78 | 
| 79   // Listen for focus change event to update the FocusManager focused view. | 79   // Listen for focus change event to update the FocusManager focused view. | 
| 80   g_signal_connect(native_control, "focus-in-event", | 80   g_signal_connect(native_control, "focus-in-event", | 
| 81                    G_CALLBACK(CallFocusIn), this); | 81                    G_CALLBACK(CallFocusIn), this); | 
| 82 } | 82 } | 
| 83 | 83 | 
| 84 // static | 84 // static | 
| 85 gboolean NativeControlGtk::CallFocusIn(GtkWidget* widget, | 85 gboolean NativeControlGtk::CallFocusIn(GtkWidget* widget, | 
| 86                                        GdkEventFocus* event, | 86                                        GdkEventFocus* event, | 
| 87                                        NativeControlGtk* control) { | 87                                        NativeControlGtk* control) { | 
| 88   FocusManager* focus_manager = | 88   FocusManager* focus_manager = | 
| 89       FocusManager::GetFocusManagerForNativeView(widget); | 89       FocusManager::GetFocusManagerForNativeView(widget); | 
| 90   if (!focus_manager) { | 90   if (!focus_manager) { | 
| 91     // TODO(jcampan): http://crbug.com/21378 Reenable this NOTREACHED() when the | 91     // TODO(jcampan): http://crbug.com/21378 Reenable this NOTREACHED() when the | 
| 92     // options page is only based on views. | 92     // options page is only based on views. | 
| 93     // NOTREACHED(); | 93     // NOTREACHED(); | 
| 94     NOTIMPLEMENTED(); | 94     NOTIMPLEMENTED(); | 
| 95     return false; | 95     return false; | 
| 96   } | 96   } | 
| 97   focus_manager->SetFocusedView(control->focus_view()); | 97   focus_manager->SetFocusedView(control->focus_view()); | 
| 98   return false; | 98   return false; | 
| 99 } | 99 } | 
| 100 | 100 | 
| 101 }  // namespace views | 101 }  // namespace views | 
| OLD | NEW | 
|---|