+ GtkToggleButton *toggle = GTK_TOGGLE_BUTTON(widget);
+
+ if (cb->Is3rdStateAllowedForUser())
+ {
+ // The 3 states cycle like this when clicked:
+ // checked -> undetermined -> unchecked -> checked -> ...
+ bool active = gtk_toggle_button_get_active(toggle);
+ bool inconsistent = gtk_toggle_button_get_inconsistent(toggle);
+
+ cb->m_blockEvent = true;
+
+ if (!active && !inconsistent)
+ {
+ // checked -> undetermined
+ gtk_toggle_button_set_active(toggle, true);
+ gtk_toggle_button_set_inconsistent(toggle, true);
+ }
+ else if (!active && inconsistent)
+ {
+ // undetermined -> unchecked
+ gtk_toggle_button_set_inconsistent(toggle, false);
+ }
+ else if (active && !inconsistent)
+ {
+ // unchecked -> checked
+ // nothing to do
+ }
+ else
+ {
+ wxFAIL_MSG(_T("3state wxCheckBox in unexpected state!"));
+ }
+
+ cb->m_blockEvent = false;
+ }
+ else
+ {
+ // user's action unsets undetermined state:
+ gtk_toggle_button_set_inconsistent(toggle, false);
+ }