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

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

Issue 9728002: Removing deprecated GTK-Views code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 months 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/views/controls/native_control_gtk.h"
6
7 #include <gtk/gtk.h>
8
9 #include "base/logging.h"
10 #include "ui/base/accessibility/accessibility_types.h"
11 #include "ui/views/focus/focus_manager.h"
12 #include "ui/views/widget/widget.h"
13
14 namespace views {
15
16 NativeControlGtk::NativeControlGtk() {
17 }
18
19 NativeControlGtk::~NativeControlGtk() {
20 if (native_view())
21 gtk_widget_destroy(native_view());
22 }
23
24 ////////////////////////////////////////////////////////////////////////////////
25 // NativeControlGtk, View overrides:
26
27 void NativeControlGtk::OnEnabledChanged() {
28 View::OnEnabledChanged();
29 if (native_view())
30 gtk_widget_set_sensitive(native_view(), enabled());
31 }
32
33 void NativeControlGtk::ViewHierarchyChanged(bool is_add, View* parent,
34 View* child) {
35 // Call the base class to hide the view if we're being removed.
36 NativeViewHost::ViewHierarchyChanged(is_add, parent, child);
37
38 if (!is_add && child == this && native_view()) {
39 Detach();
40 } else if (is_add && GetWidget() && !native_view()) {
41 // Create the widget when we're added to a valid Widget. Many
42 // controls need a parent widget to function properly.
43 CreateNativeControl();
44 }
45 }
46
47 void NativeControlGtk::VisibilityChanged(View* starting_from, bool is_visible) {
48 if (!native_view()) {
49 if (GetWidget())
50 CreateNativeControl();
51 } else {
52 // The view becomes visible after native control is created.
53 // Layout now.
54 Layout();
55 }
56 }
57
58 void NativeControlGtk::OnFocus() {
59 DCHECK(native_view());
60 gtk_widget_grab_focus(native_view());
61 GetWidget()->NotifyAccessibilityEvent(
62 parent(), ui::AccessibilityTypes::EVENT_FOCUS, true);
63 }
64
65 void NativeControlGtk::NativeControlCreated(GtkWidget* native_control) {
66 Attach(native_control);
67
68 // Update the newly created GtkWidget with any resident enabled state.
69 gtk_widget_set_sensitive(native_view(), enabled());
70
71 // Listen for focus change event to update the FocusManager focused view.
72 g_signal_connect(native_control, "focus-in-event",
73 G_CALLBACK(CallFocusIn), this);
74 }
75
76 // static
77 gboolean NativeControlGtk::CallFocusIn(GtkWidget* gtk_widget,
78 GdkEventFocus* event,
79 NativeControlGtk* control) {
80 Widget* widget = Widget::GetTopLevelWidgetForNativeView(gtk_widget);
81 FocusManager* focus_manager = widget ? widget->GetFocusManager() : NULL;
82 if (!focus_manager) {
83 // TODO(jcampan): http://crbug.com/21378 Reenable this NOTREACHED() when the
84 // options page is only based on views.
85 // NOTREACHED();
86 NOTIMPLEMENTED();
87 return false;
88 }
89 focus_manager->SetFocusedView(control->focus_view());
90 return false;
91 }
92
93 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/native_control_gtk.h ('k') | ui/views/controls/scrollbar/native_scroll_bar_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698