| 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 <gtk/gtk.h> | 5 #include <gtk/gtk.h> |
| 6 | 6 |
| 7 #include "views/controls/button/native_button_gtk.h" | 7 #include "views/controls/button/native_button_gtk.h" |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 if (!native_view()) | 76 if (!native_view()) |
| 77 return gfx::Size(); | 77 return gfx::Size(); |
| 78 GtkRequisition size_request = { 0, 0 }; | 78 GtkRequisition size_request = { 0, 0 }; |
| 79 gtk_widget_size_request(native_view(), &size_request); | 79 gtk_widget_size_request(native_view(), &size_request); |
| 80 return gfx::Size(size_request.width, size_request.height); | 80 return gfx::Size(size_request.width, size_request.height); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void NativeButtonGtk::CreateNativeControl() { | 83 void NativeButtonGtk::CreateNativeControl() { |
| 84 GtkWidget* widget = gtk_button_new(); | 84 GtkWidget* widget = gtk_button_new(); |
| 85 g_signal_connect(G_OBJECT(widget), "clicked", | 85 g_signal_connect(G_OBJECT(widget), "clicked", |
| 86 G_CALLBACK(CallClicked), NULL); | 86 G_CALLBACK(CallClicked), this); |
| 87 NativeControlCreated(widget); | 87 NativeControlCreated(widget); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void NativeButtonGtk::NativeControlCreated(GtkWidget* widget) { | 90 void NativeButtonGtk::NativeControlCreated(GtkWidget* widget) { |
| 91 NativeControlGtk::NativeControlCreated(widget); | 91 NativeControlGtk::NativeControlCreated(widget); |
| 92 | 92 |
| 93 UpdateFont(); | 93 UpdateFont(); |
| 94 UpdateLabel(); | 94 UpdateLabel(); |
| 95 UpdateDefault(); | 95 UpdateDefault(); |
| 96 } | 96 } |
| 97 | 97 |
| 98 // static | 98 // static |
| 99 void NativeButtonGtk::CallClicked(GtkButton* widget) { | 99 void NativeButtonGtk::CallClicked(GtkButton* widget, NativeButtonGtk* button) { |
| 100 View* view = NativeViewHostGtk::GetViewForNative(GTK_WIDGET(widget)); | 100 button->OnClicked(); |
| 101 if (view) | |
| 102 static_cast<NativeButtonGtk*>(view)->OnClicked(); | |
| 103 } | 101 } |
| 104 | 102 |
| 105 void NativeButtonGtk::OnClicked() { | 103 void NativeButtonGtk::OnClicked() { |
| 106 native_button_->ButtonPressed(); | 104 native_button_->ButtonPressed(); |
| 107 } | 105 } |
| 108 | 106 |
| 109 NativeCheckboxGtk::NativeCheckboxGtk(Checkbox* checkbox) | 107 NativeCheckboxGtk::NativeCheckboxGtk(Checkbox* checkbox) |
| 110 : NativeButtonGtk(checkbox) { | 108 : NativeButtonGtk(checkbox) { |
| 111 } | 109 } |
| 112 | 110 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 127 return new NativeButtonGtk(native_button); | 125 return new NativeButtonGtk(native_button); |
| 128 } | 126 } |
| 129 | 127 |
| 130 // static | 128 // static |
| 131 NativeButtonWrapper* NativeButtonWrapper::CreateCheckboxWrapper( | 129 NativeButtonWrapper* NativeButtonWrapper::CreateCheckboxWrapper( |
| 132 Checkbox* checkbox) { | 130 Checkbox* checkbox) { |
| 133 return new NativeCheckboxGtk(checkbox); | 131 return new NativeCheckboxGtk(checkbox); |
| 134 } | 132 } |
| 135 | 133 |
| 136 } // namespace views | 134 } // namespace views |
| OLD | NEW |