gflow-dock.vala 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /********************************************************************
  2. # Copyright 2014-2022 Daniel 'grindhold' Brendle, 2015 Daniel Espinosa <esodan@gmail.com>
  3. #
  4. # This file is part of libgflow.
  5. #
  6. # libgflow is free software: you can redistribute it and/or
  7. # modify it under the terms of the GNU Lesser General Public License
  8. # as published by the Free Software Foundation, either
  9. # version 3 of the License, or (at your option) any later
  10. # version.
  11. #
  12. # libgtkflow is distributed in the hope that it will be
  13. # useful, but WITHOUT ANY WARRANTY; without even the implied
  14. # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. # PURPOSE. See the GNU Lesser General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Lesser General Public
  18. # License along with libgtkflow.
  19. # If not, see http://www.gnu.org/licenses/.
  20. *********************************************************************/
  21. namespace GFlow {
  22. /**
  23. * This class represents an endpoint of a node. These endpoints can be
  24. * connected in order to let them exchange data. The data contained
  25. * in this endpoint is stored as GLib.Value. Only Docks that contain
  26. * data with the same VariantType can be interconnected.
  27. */
  28. public interface Dock : Object {
  29. /**
  30. * The name that will be rendered for this dock
  31. */
  32. public abstract string? name { get; set; }
  33. /**
  34. * The string rendered as typehint for this dock.
  35. * If this string is "" and the show_type is set to true
  36. * libgflow will attempt to determine the type of this
  37. * dock and display it, but it produces nicer results to set
  38. * them manually.
  39. */
  40. public abstract string? typename { get; set; }
  41. /**
  42. * Determines whether this dock is highlighted
  43. * this is usually triggered when the mouse hovers over it
  44. */
  45. public abstract bool highlight { get; set; }
  46. /**
  47. * Determines whether this dock is active
  48. */
  49. public abstract bool active { get; set; }
  50. /**
  51. * A reference to the node this Dock resides in
  52. */
  53. public abstract weak Node? node { get; set; }
  54. /**
  55. * The type that has been set to this dock
  56. */
  57. public abstract GLib.Type value_type { get; }
  58. /**
  59. * This signal is being triggered, when there is a connection being established
  60. * from or to this Dock.
  61. */
  62. public signal void linked (Dock d);
  63. /**
  64. * This signal is being triggered, before a connection is made
  65. * between two docks. If the implementor returns false, the
  66. * connection is not being made.
  67. * IMPORTANT: Connect to this signal with connect_after
  68. * otherwise this default handler will be called after the
  69. * signal you implemented, thus always returning true,
  70. * rendering your code ineffective.
  71. */
  72. public virtual signal bool before_linking (Dock self, Dock other){
  73. return true;
  74. }
  75. /**
  76. * This signal is being triggered, when there is a connection being removed
  77. * from or to this Dock. If this the last connection of the dock, the
  78. * boolean parameter last will be set to true.
  79. */
  80. public signal void unlinked (Dock d, bool last);
  81. /**
  82. * Triggers when the value of this dock changes
  83. */
  84. public signal void changed(Value? value = null, string? flow_id = null);
  85. /**
  86. * Implementations should return true if this dock has at least one
  87. * connection to another dock
  88. */
  89. public abstract bool is_linked ();
  90. /**
  91. * Implementations should return true if this dock is connected
  92. * to the supplied dock
  93. */
  94. public abstract bool is_linked_to (Dock dock);
  95. /**
  96. * Connect this {@link Dock} to other {@link Dock}
  97. */
  98. public abstract void link (Dock dock) throws GLib.Error;
  99. /**
  100. * Disconnect this {@link Dock} from other {@link Dock}
  101. */
  102. public abstract void unlink (Dock dock) throws GLib.Error;
  103. /**
  104. * Disconnect this {@link Dock} from all {@link Dock}s it is connected to
  105. */
  106. public abstract void unlink_all () throws GLib.Error;
  107. /**
  108. * Tries to resolve this Dock's value-type to a displayable string
  109. */
  110. public virtual string determine_typestring () {
  111. return this.value_type.name();
  112. }
  113. /**
  114. * Returs true if this and the supplied dock have
  115. * same type
  116. */
  117. public virtual bool has_same_type (Dock other) {
  118. return this.value_type == other.value_type;
  119. }
  120. }
  121. }