input_bool.vala 845 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (c) 2012-2025 Daniele Bartolini et al.
  3. * SPDX-License-Identifier: GPL-3.0-or-later
  4. */
  5. namespace Crown
  6. {
  7. public class InputBool : InputField, Gtk.CheckButton
  8. {
  9. public new void set_inconsistent(bool inconsistent)
  10. {
  11. base.set_inconsistent(inconsistent);
  12. }
  13. public bool is_inconsistent()
  14. {
  15. return this.get_inconsistent();
  16. }
  17. public GLib.Value union_value()
  18. {
  19. return this.value;
  20. }
  21. public void set_union_value(GLib.Value v)
  22. {
  23. this.value = (bool)v;
  24. }
  25. public bool value
  26. {
  27. get
  28. {
  29. return this.active;
  30. }
  31. set
  32. {
  33. this.active = value;
  34. }
  35. }
  36. public InputBool()
  37. {
  38. // Data
  39. this.toggled.connect(on_value_changed);
  40. }
  41. public void on_value_changed()
  42. {
  43. if (base.get_inconsistent()) {
  44. base.set_inconsistent(false);
  45. this.value = true;
  46. }
  47. value_changed(this);
  48. }
  49. }
  50. } /* namespace Crown */