You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

137 regels
5.8 KiB

  1. /* gbinding.h: Binding for object properties
  2. *
  3. * Copyright (C) 2010 Intel Corp.
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General
  16. * Public License along with this library; if not, write to the
  17. * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  18. * Boston, MA 02111-1307, USA.
  19. *
  20. * Author: Emmanuele Bassi <ebassi@linux.intel.com>
  21. */
  22. #if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
  23. #error "Only <glib-object.h> can be included directly."
  24. #endif
  25. #ifndef __G_BINDING_H__
  26. #define __G_BINDING_H__
  27. #include <glib.h>
  28. #include <gobject/gobject.h>
  29. G_BEGIN_DECLS
  30. #define G_TYPE_BINDING_FLAGS (g_binding_flags_get_type ())
  31. #define G_TYPE_BINDING (g_binding_get_type ())
  32. #define G_BINDING(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_BINDING, GBinding))
  33. #define G_IS_BINDING(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_BINDING))
  34. /**
  35. * GBinding:
  36. *
  37. * <structname>GBinding</structname> is an opaque structure whose members
  38. * cannot be accessed directly.
  39. *
  40. * Since: 2.26
  41. */
  42. typedef struct _GBinding GBinding;
  43. /**
  44. * GBindingTransformFunc:
  45. * @binding: a #GBinding
  46. * @source_value: the value of the source property
  47. * @target_value: the value of the target property
  48. * @user_data: data passed to the transform function
  49. *
  50. * A function to be called to transform the source property of @source
  51. * from @source_value into the target property of @target
  52. * using @target_value.
  53. *
  54. * Return value: %TRUE if the transformation was successful, and %FALSE
  55. * otherwise
  56. *
  57. * Since: 2.26
  58. */
  59. typedef gboolean (* GBindingTransformFunc) (GBinding *binding,
  60. const GValue *source_value,
  61. GValue *target_value,
  62. gpointer user_data);
  63. /**
  64. * GBindingFlags:
  65. * @G_BINDING_DEFAULT: The default binding; if the source property
  66. * changes, the target property is updated with its value.
  67. * @G_BINDING_BIDIRECTIONAL: Bidirectional binding; if either the
  68. * property of the source or the property of the target changes,
  69. * the other is updated.
  70. * @G_BINDING_SYNC_CREATE: Synchronize the values of the source and
  71. * target properties when creating the binding; the direction of
  72. * the synchronization is always from the source to the target.
  73. * @G_BINDING_INVERT_BOOLEAN: If the two properties being bound are
  74. * booleans, setting one to %TRUE will result in the other being
  75. * set to %FALSE and vice versa. This flag will only work for
  76. * boolean properties, and cannot be used when passing custom
  77. * transformation functions to g_object_bind_property_full().
  78. *
  79. * Flags to be passed to g_object_bind_property() or
  80. * g_object_bind_property_full().
  81. *
  82. * This enumeration can be extended at later date.
  83. *
  84. * Since: 2.26
  85. */
  86. typedef enum { /*< prefix=G_BINDING >*/
  87. G_BINDING_DEFAULT = 0,
  88. G_BINDING_BIDIRECTIONAL = 1 << 0,
  89. G_BINDING_SYNC_CREATE = 1 << 1,
  90. G_BINDING_INVERT_BOOLEAN = 1 << 2
  91. } GBindingFlags;
  92. GType g_binding_flags_get_type (void) G_GNUC_CONST;
  93. GType g_binding_get_type (void) G_GNUC_CONST;
  94. GBindingFlags g_binding_get_flags (GBinding *binding);
  95. GObject * g_binding_get_source (GBinding *binding);
  96. GObject * g_binding_get_target (GBinding *binding);
  97. G_CONST_RETURN gchar *g_binding_get_source_property (GBinding *binding);
  98. G_CONST_RETURN gchar *g_binding_get_target_property (GBinding *binding);
  99. GBinding *g_object_bind_property (gpointer source,
  100. const gchar *source_property,
  101. gpointer target,
  102. const gchar *target_property,
  103. GBindingFlags flags);
  104. GBinding *g_object_bind_property_full (gpointer source,
  105. const gchar *source_property,
  106. gpointer target,
  107. const gchar *target_property,
  108. GBindingFlags flags,
  109. GBindingTransformFunc transform_to,
  110. GBindingTransformFunc transform_from,
  111. gpointer user_data,
  112. GDestroyNotify notify);
  113. GBinding *g_object_bind_property_with_closures (gpointer source,
  114. const gchar *source_property,
  115. gpointer target,
  116. const gchar *target_property,
  117. GBindingFlags flags,
  118. GClosure *transform_to,
  119. GClosure *transform_from);
  120. G_END_DECLS
  121. #endif /* __G_BINDING_H__ */