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

Unified Diff: views/controls/button/native_button_gtk.cc

Issue 201079: Lands http://codereview.chromium.org/194014 for Oshima:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « views/controls/button/native_button_gtk.h ('k') | views/controls/message_box_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/controls/button/native_button_gtk.cc
===================================================================
--- views/controls/button/native_button_gtk.cc (revision 25662)
+++ views/controls/button/native_button_gtk.cc (working copy)
@@ -57,7 +57,9 @@
void NativeButtonGtk::UpdateDefault() {
if (!native_view())
return;
- if (!IsCheckbox())
+ if (IsCheckbox())
+ UpdateChecked();
+ else
NOTIMPLEMENTED();
}
@@ -115,16 +117,55 @@
native_button_->ButtonPressed();
}
+////////////////////////////////////////////////////////////////////////////////
+// NativeCheckboxGtk
NativeCheckboxGtk::NativeCheckboxGtk(Checkbox* checkbox)
- : NativeButtonGtk(checkbox) {
+ : NativeButtonGtk(checkbox),
+ checkbox_(checkbox),
+ deliver_click_event_(true) {
}
void NativeCheckboxGtk::CreateNativeControl() {
GtkWidget* widget = gtk_check_button_new();
+ g_signal_connect(G_OBJECT(widget), "clicked",
+ G_CALLBACK(CallClicked), this);
NativeControlCreated(widget);
}
+void NativeCheckboxGtk::OnClicked() {
+ // ignore event if the event is generated by
+ // gtk_toggle_button_set_active below.
+ if (deliver_click_event_) {
+ checkbox_->SetChecked(!checkbox_->checked());
+ NativeButtonGtk::OnClicked();
+ }
+}
+
+void NativeCheckboxGtk::UpdateChecked() {
+ if (!native_view())
+ return;
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(native_view()))
+ != checkbox_->checked()) {
+ // gtk_toggle_button_set_active emites "clicked" signal, which
+ // invokes OnClicked method above. deliver_click_event_ flag is used
+ // to prevent such signal to invoke OnClicked callback.
+ deliver_click_event_ = false;
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(native_view()),
+ checkbox_->checked());
+ deliver_click_event_ = true;
+ }
+}
+
// static
+void NativeCheckboxGtk::CallClicked(GtkButton* widget,
+ NativeCheckboxGtk* button) {
+ button->OnClicked();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// NativeButtonWrapper
+
+// static
int NativeButtonWrapper::GetFixedWidth() {
// TODO(brettw) implement this properly.
return 10;
« no previous file with comments | « views/controls/button/native_button_gtk.h ('k') | views/controls/message_box_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698