Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: ui/views/controls/native_control_gtk.cc

Issue 8909002: views: Convert IsEnabled() to just enabled() since it's just a simple accessor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/native_control.cc ('k') | ui/views/controls/native_control_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ui/views/controls/native_control_gtk.h" 5 #include "ui/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 "ui/base/accessibility/accessibility_types.h" 10 #include "ui/base/accessibility/accessibility_types.h"
11 #include "ui/views/focus/focus_manager.h" 11 #include "ui/views/focus/focus_manager.h"
12 #include "ui/views/widget/widget.h" 12 #include "ui/views/widget/widget.h"
13 13
14 namespace views { 14 namespace views {
15 15
16 NativeControlGtk::NativeControlGtk() { 16 NativeControlGtk::NativeControlGtk() {
17 } 17 }
18 18
19 NativeControlGtk::~NativeControlGtk() { 19 NativeControlGtk::~NativeControlGtk() {
20 if (native_view()) 20 if (native_view())
21 gtk_widget_destroy(native_view()); 21 gtk_widget_destroy(native_view());
22 } 22 }
23 23
24 //////////////////////////////////////////////////////////////////////////////// 24 ////////////////////////////////////////////////////////////////////////////////
25 // NativeControlGtk, View overrides: 25 // NativeControlGtk, View overrides:
26 26
27 void NativeControlGtk::OnEnabledChanged() { 27 void NativeControlGtk::OnEnabledChanged() {
28 View::OnEnabledChanged(); 28 View::OnEnabledChanged();
29 if (native_view()) 29 if (native_view())
30 gtk_widget_set_sensitive(native_view(), IsEnabled()); 30 gtk_widget_set_sensitive(native_view(), enabled());
31 } 31 }
32 32
33 void NativeControlGtk::ViewHierarchyChanged(bool is_add, View* parent, 33 void NativeControlGtk::ViewHierarchyChanged(bool is_add, View* parent,
34 View* child) { 34 View* child) {
35 // Call the base class to hide the view if we're being removed. 35 // Call the base class to hide the view if we're being removed.
36 NativeViewHost::ViewHierarchyChanged(is_add, parent, child); 36 NativeViewHost::ViewHierarchyChanged(is_add, parent, child);
37 37
38 if (!is_add && child == this && native_view()) { 38 if (!is_add && child == this && native_view()) {
39 Detach(); 39 Detach();
40 } else if (is_add && GetWidget() && !native_view()) { 40 } else if (is_add && GetWidget() && !native_view()) {
(...skipping 18 matching lines...) Expand all
59 DCHECK(native_view()); 59 DCHECK(native_view());
60 gtk_widget_grab_focus(native_view()); 60 gtk_widget_grab_focus(native_view());
61 GetWidget()->NotifyAccessibilityEvent( 61 GetWidget()->NotifyAccessibilityEvent(
62 parent(), ui::AccessibilityTypes::EVENT_FOCUS, true); 62 parent(), ui::AccessibilityTypes::EVENT_FOCUS, true);
63 } 63 }
64 64
65 void NativeControlGtk::NativeControlCreated(GtkWidget* native_control) { 65 void NativeControlGtk::NativeControlCreated(GtkWidget* native_control) {
66 Attach(native_control); 66 Attach(native_control);
67 67
68 // Update the newly created GtkWidget with any resident enabled state. 68 // Update the newly created GtkWidget with any resident enabled state.
69 gtk_widget_set_sensitive(native_view(), IsEnabled()); 69 gtk_widget_set_sensitive(native_view(), enabled());
70 70
71 // Listen for focus change event to update the FocusManager focused view. 71 // Listen for focus change event to update the FocusManager focused view.
72 g_signal_connect(native_control, "focus-in-event", 72 g_signal_connect(native_control, "focus-in-event",
73 G_CALLBACK(CallFocusIn), this); 73 G_CALLBACK(CallFocusIn), this);
74 } 74 }
75 75
76 // static 76 // static
77 gboolean NativeControlGtk::CallFocusIn(GtkWidget* gtk_widget, 77 gboolean NativeControlGtk::CallFocusIn(GtkWidget* gtk_widget,
78 GdkEventFocus* event, 78 GdkEventFocus* event,
79 NativeControlGtk* control) { 79 NativeControlGtk* control) {
80 Widget* widget = Widget::GetTopLevelWidgetForNativeView(gtk_widget); 80 Widget* widget = Widget::GetTopLevelWidgetForNativeView(gtk_widget);
81 FocusManager* focus_manager = widget ? widget->GetFocusManager() : NULL; 81 FocusManager* focus_manager = widget ? widget->GetFocusManager() : NULL;
82 if (!focus_manager) { 82 if (!focus_manager) {
83 // TODO(jcampan): http://crbug.com/21378 Reenable this NOTREACHED() when the 83 // TODO(jcampan): http://crbug.com/21378 Reenable this NOTREACHED() when the
84 // options page is only based on views. 84 // options page is only based on views.
85 // NOTREACHED(); 85 // NOTREACHED();
86 NOTIMPLEMENTED(); 86 NOTIMPLEMENTED();
87 return false; 87 return false;
88 } 88 }
89 focus_manager->SetFocusedView(control->focus_view()); 89 focus_manager->SetFocusedView(control->focus_view());
90 return false; 90 return false;
91 } 91 }
92 92
93 } // namespace views 93 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/native_control.cc ('k') | ui/views/controls/native_control_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698