1 // Generated by gmmproc 2.64.2 -- DO NOT MODIFY! 2 #ifndef _GLIBMM_BINDING_H 3 #define _GLIBMM_BINDING_H 4 5 6 /* Copyright (C) 2014 The glibmm Development Team 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 20 */ 21 22 #include <glibmm/object.h> 23 #include <glibmm/refptr.h> 24 #include <glibmm/ustring.h> 25 #include <glibmm/value.h> 26 27 28 #ifndef DOXYGEN_SHOULD_SKIP_THIS 29 using GBinding = struct _GBinding; 30 using GBindingClass = struct _GBindingClass; 31 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 32 33 34 #ifndef DOXYGEN_SHOULD_SKIP_THIS 35 namespace Glib 36 { class GLIBMM_API Binding_Class; } // namespace Glib 37 #endif //DOXYGEN_SHOULD_SKIP_THIS 38 39 namespace Glib 40 { 41 /** @addtogroup glibmmEnums glibmm Enums and Flags */ 42 43 /** 44 * @var BindingFlags BINDING_DEFAULT 45 * The default binding; if the source property 46 * changes, the target property is updated with its value. 47 * 48 * @var BindingFlags BINDING_BIDIRECTIONAL 49 * Bidirectional binding; if either the 50 * property of the source or the property of the target changes, 51 * the other is updated. 52 * 53 * @var BindingFlags BINDING_SYNC_CREATE 54 * Synchronize the values of the source and 55 * target properties when creating the binding; the direction of 56 * the synchronization is always from the source to the target. 57 * 58 * @var BindingFlags BINDING_INVERT_BOOLEAN 59 * If the two properties being bound are 60 * booleans, setting one to <tt>true</tt> will result in the other being 61 * set to <tt>false</tt> and vice versa. This flag will only work for 62 * boolean properties, and cannot be used when passing custom 63 * transformation functions to g_object_bind_property_full(). 64 * 65 * @enum BindingFlags 66 * 67 * Flags to be passed to g_object_bind_property() or 68 * g_object_bind_property_full(). 69 * 70 * This enumeration can be extended at later date. 71 * 72 * @newin{2,44} 73 * 74 * @ingroup glibmmEnums 75 * @par Bitwise operators: 76 * <tt>%BindingFlags operator|(BindingFlags, BindingFlags)</tt><br> 77 * <tt>%BindingFlags operator&(BindingFlags, BindingFlags)</tt><br> 78 * <tt>%BindingFlags operator^(BindingFlags, BindingFlags)</tt><br> 79 * <tt>%BindingFlags operator~(BindingFlags)</tt><br> 80 * <tt>%BindingFlags& operator|=(BindingFlags&, BindingFlags)</tt><br> 81 * <tt>%BindingFlags& operator&=(BindingFlags&, BindingFlags)</tt><br> 82 * <tt>%BindingFlags& operator^=(BindingFlags&, BindingFlags)</tt><br> 83 */ 84 enum BindingFlags 85 { 86 BINDING_DEFAULT = 0x0, 87 BINDING_BIDIRECTIONAL = 1 << 0, 88 BINDING_SYNC_CREATE = 1 << 1, 89 BINDING_INVERT_BOOLEAN = 1 << 2 90 }; 91 92 /** @ingroup glibmmEnums */ 93 inline BindingFlags operator|(BindingFlags lhs, BindingFlags rhs) 94 { return static_cast<BindingFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); } 95 96 /** @ingroup glibmmEnums */ 97 inline BindingFlags operator&(BindingFlags lhs, BindingFlags rhs) 98 { return static_cast<BindingFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs)); } 99 100 /** @ingroup glibmmEnums */ 101 inline BindingFlags operator^(BindingFlags lhs, BindingFlags rhs) 102 { return static_cast<BindingFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs)); } 103 104 /** @ingroup glibmmEnums */ 105 inline BindingFlags operator~(BindingFlags flags) 106 { return static_cast<BindingFlags>(~static_cast<unsigned>(flags)); } 107 108 /** @ingroup glibmmEnums */ 109 inline BindingFlags& operator|=(BindingFlags& lhs, BindingFlags rhs) 110 { return (lhs = static_cast<BindingFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs))); } 111 112 /** @ingroup glibmmEnums */ 113 inline BindingFlags& operator&=(BindingFlags& lhs, BindingFlags rhs) 114 { return (lhs = static_cast<BindingFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs))); } 115 116 /** @ingroup glibmmEnums */ 117 inline BindingFlags& operator^=(BindingFlags& lhs, BindingFlags rhs) 118 { return (lhs = static_cast<BindingFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs))); } 119 120 } // namespace Glib 121 122 #ifndef DOXYGEN_SHOULD_SKIP_THIS 123 namespace Glib 124 { 125 126 template <> 127 class Value<Glib::BindingFlags> : public Glib::Value_Flags<Glib::BindingFlags> 128 { 129 public: 130 static GType value_type() G_GNUC_CONST; 131 }; 132 133 } // namespace Glib 134 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 135 136 namespace Glib 137 { 138 139 140 /** Bind two object properties. 141 * 142 * Glib::Binding is the representation of a binding between a property on a 143 * Glib::ObjectBase instance (or source) and another property on another Glib::ObjectBase 144 * instance (or target). Whenever the source property changes, the same 145 * value is applied to the target property; for instance, the following binding: 146 * 147 * @code 148 * Glib::Binding::bind_property(object1->property_a(), object2->property_b()); 149 * @endcode 150 * 151 * will cause property_b() of @a object2 to be updated 152 * every time the value of property_a() of @a object1 changes. 153 * 154 * It is possible to create a bidirectional binding between two properties 155 * of two Glib::ObjectBase instances, so that if either property changes, the 156 * other is updated as well, for instance: 157 * 158 * @code 159 * Glib::Binding::bind_property(object1->property_a(), object2->property_b(), 160 * Glib::BINDING_BIDIRECTIONAL); 161 * @endcode 162 * 163 * will keep the two properties in sync. 164 * 165 * It is also possible to set a custom transformation function (in both 166 * directions, in case of a bidirectional binding) to apply a custom 167 * transformation from the source value to the target value before 168 * applying it; for instance, the following binding: 169 * 170 * @code 171 * bool celsius_to_fahrenheit(const double& celsius, double& fahrenheit); 172 * bool fahrenheit_to_celsius(const double& fahrenheit, double& celsius); 173 * Glib::Binding::bind_property(adjustment1->property_value(), 174 * adjustment2->property_value(), Glib::BINDING_BIDIRECTIONAL, 175 * sigc::ptr_fun(celsius_to_fahrenheit), sigc::ptr_fun(fahrenheit_to_celsius)); 176 * @endcode 177 * 178 * will keep property_value() of the two adjustments in sync; the 179 * celsius_to_fahrenheit() function will be called whenever 180 * property_value() of @a adjustment1 changes and will transform the current value 181 * of the property before applying it to property_value() of @a adjustment2. 182 * 183 * Vice versa, the fahrenheit_to_celsius() function will be called whenever 184 * property_value() of @a adjustment2 changes, and will transform the 185 * current value of the property before applying it to property_value() 186 * of @a adjustment1. 187 * 188 * Note that Glib::Binding does not resolve cycles by itself; a cycle like 189 * 190 * @code 191 * object1->property_A() -> object2->property_B() 192 * object2->property_B() -> object3->property_C() 193 * object3->property_C() -> object1->property_A() 194 * @endcode 195 * 196 * might lead to an infinite loop. The loop, in this particular case, 197 * can be avoided if the objects emit the GObject::notify signal only 198 * if the value has effectively been changed. A binding is implemented 199 * using the GObject::notify signal, so it is susceptible to all the 200 * various ways of blocking a signal emission, like Glib::SignalProxyNormal::emission_stop() 201 * or g_signal_handler_block(). 202 * 203 * A binding will be severed, and the resources it allocates freed, whenever 204 * either one of the Glib::ObjectBase instances it refers to is deleted, 205 * when unbind() is called, or when the Glib::Binding instance loses 206 * its last reference. 207 * 208 * @newin{2,44} 209 */ 210 211 class GLIBMM_API Binding : public Glib::Object 212 { 213 214 #ifndef DOXYGEN_SHOULD_SKIP_THIS 215 216 public: 217 using CppObjectType = Binding; 218 using CppClassType = Binding_Class; 219 using BaseObjectType = GBinding; 220 using BaseClassType = GBindingClass; 221 222 // noncopyable 223 Binding(const Binding&) = delete; 224 Binding& operator=(const Binding&) = delete; 225 226 private: friend class Binding_Class; 227 static CppClassType binding_class_; 228 229 protected: 230 explicit Binding(const Glib::ConstructParams& construct_params); 231 explicit Binding(GBinding* castitem); 232 233 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 234 235 public: 236 237 Binding(Binding&& src) noexcept; 238 Binding& operator=(Binding&& src) noexcept; 239 240 ~Binding() noexcept override; 241 242 /** Get the GType for this class, for use with the underlying GObject type system. 243 */ 244 static GType get_type() G_GNUC_CONST; 245 246 #ifndef DOXYGEN_SHOULD_SKIP_THIS 247 248 249 static GType get_base_type() G_GNUC_CONST; 250 #endif 251 252 ///Provides access to the underlying C GObject. gobj()253 GBinding* gobj() { return reinterpret_cast<GBinding*>(gobject_); } 254 255 ///Provides access to the underlying C GObject. gobj()256 const GBinding* gobj() const { return reinterpret_cast<GBinding*>(gobject_); } 257 258 ///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. 259 GBinding* gobj_copy(); 260 261 private: 262 263 264 public: 265 /** A slot to be called to transform values in a binding created by 266 * bind_property_value(). 267 * 268 * For instance: 269 * @code 270 * bool on_transform_to(const GValue* from_value, GValue* to_value); 271 * @endcode 272 * 273 * @return <tt>true</tt> if the transformation was successful, and <tt>false</tt> otherwise. 274 */ 275 using SlotTransform = sigc::slot<bool, const GValue*, GValue*>; 276 277 /** A slot to be called to transform values in a binding created by 278 * bind_property(). 279 * 280 * For instance: 281 * @code 282 * bool on_transform_to(const Glib::ustring& from_string, int& to_int); 283 * @endcode 284 * 285 * @return <tt>true</tt> if the transformation was successful, and <tt>false</tt> otherwise. 286 */ 287 template <typename T_from, typename T_to> 288 using SlotTypedTransform = sigc::slot<bool, const T_from&, T_to&>; 289 290 // GValue* or Glib::ValueBase& in SlotTransform? 291 // Binding_transform_callback_common() is simpler and faster with GValue*. 292 // No need to copy between GValue and Glib::ValueBase. ValueBase would only 293 // be marginally better for users of bind_property_value(). Users would want 294 // Value<T_source> and Value<T_target>, meaning that bind_property_value() 295 // would have to be a template function. Most users would probably still 296 // prefer bind_property(). bind_property_value() is public partly because 297 // it's a good place to present documentation common to all the 298 // bind_property() overloads. 299 // See also https://gitlab.gnome.org/GNOME/glibmm/issues/61 300 /** Creates a binding between @a source_property and @a target_property, 301 * allowing you to set the transformation functions to be used by the binding. 302 * 303 * If @a flags contains Glib::BINDING_BIDIRECTIONAL then the binding will be mutual: 304 * if @a target_property changes then the @a source_property 305 * will be updated as well. The @a transform_from function is only used in case 306 * of bidirectional bindings, otherwise it will be ignored. 307 * 308 * The binding will automatically be removed when either the source or the 309 * target instance is deleted. To remove the binding without affecting the 310 * source and the target you can call unbind() on the returned Binding instance. 311 * 312 * A Glib::ObjectBase instance can have multiple bindings. 313 * 314 * If you supply transformation functions, it is usually easier to use one of the 315 * bind_property() overloads, to avoid the use of GValue in the transformation functions. 316 * 317 * @param source_property The source property to bind. 318 * @param target_property The target property to bind. 319 * @param flags Flags to pass to Binding. 320 * @param transform_to The transformation function from the source to the target, 321 * or an empty slot to use the default. 322 * @param transform_from The transformation function from the target to the source, 323 * or an empty slot to use the default. 324 * @return The Binding instance representing the binding between the two 325 * Glib::ObjectBase instances, or <tt>nullptr</tt> in case of error. 326 * 327 * @newin{2,44} 328 */ 329 static Glib::RefPtr<Binding> bind_property_value( 330 const PropertyProxy_Base& source_property, 331 const PropertyProxy_Base& target_property, 332 BindingFlags flags = BINDING_DEFAULT, 333 const SlotTransform& transform_to = SlotTransform(), 334 const SlotTransform& transform_from = SlotTransform()); 335 336 337 /** Creates a binding between @a source_property and @a target_property. 338 * 339 * @param source_property The source property to bind. 340 * @param target_property The target property to bind. 341 * @param flags Flags to pass to Binding. 342 * @return The Binding instance representing the binding between the two 343 * Glib::ObjectBase instances, or <tt>nullptr</tt> in case of error. 344 * 345 * @see bind_property_value() 346 * 347 * @newin{2,44} 348 */ 349 static Glib::RefPtr<Binding> bind_property( 350 const PropertyProxy_Base& source_property, 351 const PropertyProxy_Base& target_property, 352 BindingFlags flags = BINDING_DEFAULT) 353 { 354 return bind_property_value(source_property, target_property, flags); 355 } 356 357 /** Creates a binding between @a source_property and @a target_property, 358 * allowing you to set a transformation function to be used by the binding. 359 * 360 * @param source_property The source property to bind. 361 * @param target_property The target property to bind. 362 * @param flags Flags to pass to Binding. 363 * @param transform_to The transformation function from the source to the target, 364 * or an empty slot to use the default. 365 * @return The Binding instance representing the binding between the two 366 * Glib::ObjectBase instances, or <tt>nullptr</tt> in case of error. 367 * 368 * @tparam T_source Type of the source property. Must be a type that can be 369 * stored in a Glib::Value<T_source> object. 370 * @tparam T_target Type of the target property. Must be a type that can be 371 * stored in a Glib::Value<T_target> object. 372 * @tparam T_functor_to Type of functor that translates from the source to the target. 373 * Must be convertible to SlotTypedTransform<T_source, T_target>. 374 * 375 * @see bind_property_value() 376 * 377 * @newin{2,44} 378 */ 379 template <typename T_source, typename T_target, typename T_functor_to> bind_property(const PropertyProxy<T_source> & source_property,const PropertyProxy<T_target> & target_property,BindingFlags flags,const T_functor_to & transform_to)380 static Glib::RefPtr<Binding> bind_property( 381 const PropertyProxy<T_source>& source_property, 382 const PropertyProxy<T_target>& target_property, 383 BindingFlags flags, 384 const T_functor_to& transform_to) 385 { 386 SlotTypedTransform<T_source, T_target> slot_transform_to = transform_to; 387 388 return bind_property_value(source_property, target_property, flags, 389 slot_transform_to.empty() ? SlotTransform() : TransformProp<T_source, T_target>(slot_transform_to)); 390 } 391 392 /** Creates a binding between @a source_property and @a target_property, 393 * allowing you to set a transformation function to be used by the binding. 394 * 395 * @param source_property The source property to bind. 396 * @param target_property The target property to bind. 397 * @param flags Flags to pass to Binding. 398 * @param transform_to The transformation function from the source to the target, 399 * or an empty slot to use the default. 400 * @return The Binding instance representing the binding between the two 401 * Glib::ObjectBase instances, or <tt>nullptr</tt> in case of error. 402 * 403 * @tparam T_source Type of the source property. Must be a type that can be 404 * stored in a Glib::Value<T_source> object. 405 * @tparam T_target Type of the target property. Must be a type that can be 406 * stored in a Glib::Value<T_target> object. 407 * @tparam T_functor_to Type of functor that translates from the source to the target. 408 * Must be convertible to SlotTypedTransform<T_source, T_target>. 409 * 410 * @see bind_property_value() 411 * 412 * @newin{2,44} 413 */ 414 template <typename T_source, typename T_target, typename T_functor_to> bind_property(const PropertyProxy<T_source> & source_property,const PropertyProxy_WriteOnly<T_target> & target_property,BindingFlags flags,const T_functor_to & transform_to)415 static Glib::RefPtr<Binding> bind_property( 416 const PropertyProxy<T_source>& source_property, 417 const PropertyProxy_WriteOnly<T_target>& target_property, 418 BindingFlags flags, 419 const T_functor_to& transform_to) 420 { 421 SlotTypedTransform<T_source, T_target> slot_transform_to = transform_to; 422 423 return bind_property_value(source_property, target_property, flags, 424 slot_transform_to.empty() ? SlotTransform() : TransformProp<T_source, T_target>(slot_transform_to)); 425 } 426 427 /** Creates a binding between @a source_property and @a target_property, 428 * allowing you to set a transformation function to be used by the binding. 429 * 430 * @param source_property The source property to bind. 431 * @param target_property The target property to bind. 432 * @param flags Flags to pass to Binding. 433 * @param transform_to The transformation function from the source to the target, 434 * or an empty slot to use the default. 435 * @return The Binding instance representing the binding between the two 436 * Glib::ObjectBase instances, or <tt>nullptr</tt> in case of error. 437 * 438 * @tparam T_source Type of the source property. Must be a type that can be 439 * stored in a Glib::Value<T_source> object. 440 * @tparam T_target Type of the target property. Must be a type that can be 441 * stored in a Glib::Value<T_target> object. 442 * @tparam T_functor_to Type of functor that translates from the source to the target. 443 * Must be convertible to SlotTypedTransform<T_source, T_target>. 444 * 445 * @see bind_property_value() 446 * 447 * @newin{2,44} 448 */ 449 template <typename T_source, typename T_target, typename T_functor_to> bind_property(const PropertyProxy_ReadOnly<T_source> & source_property,const PropertyProxy<T_target> & target_property,BindingFlags flags,const T_functor_to & transform_to)450 static Glib::RefPtr<Binding> bind_property( 451 const PropertyProxy_ReadOnly<T_source>& source_property, 452 const PropertyProxy<T_target>& target_property, 453 BindingFlags flags, 454 const T_functor_to& transform_to) 455 { 456 SlotTypedTransform<T_source, T_target> slot_transform_to = transform_to; 457 458 return bind_property_value(source_property, target_property, flags, 459 slot_transform_to.empty() ? SlotTransform() : TransformProp<T_source, T_target>(slot_transform_to)); 460 } 461 462 /** Creates a binding between @a source_property and @a target_property, 463 * allowing you to set a transformation function to be used by the binding. 464 * 465 * @param source_property The source property to bind. 466 * @param target_property The target property to bind. 467 * @param flags Flags to pass to Binding. 468 * @param transform_to The transformation function from the source to the target, 469 * or an empty slot to use the default. 470 * @return The Binding instance representing the binding between the two 471 * Glib::ObjectBase instances, or <tt>nullptr</tt> in case of error. 472 * 473 * @tparam T_source Type of the source property. Must be a type that can be 474 * stored in a Glib::Value<T_source> object. 475 * @tparam T_target Type of the target property. Must be a type that can be 476 * stored in a Glib::Value<T_target> object. 477 * @tparam T_functor_to Type of functor that translates from the source to the target. 478 * Must be convertible to SlotTypedTransform<T_source, T_target>. 479 * 480 * @see bind_property_value() 481 * 482 * @newin{2,44} 483 */ 484 template <typename T_source, typename T_target, typename T_functor_to> bind_property(const PropertyProxy_ReadOnly<T_source> & source_property,const PropertyProxy_WriteOnly<T_target> & target_property,BindingFlags flags,const T_functor_to & transform_to)485 static Glib::RefPtr<Binding> bind_property( 486 const PropertyProxy_ReadOnly<T_source>& source_property, 487 const PropertyProxy_WriteOnly<T_target>& target_property, 488 BindingFlags flags, 489 const T_functor_to& transform_to) 490 { 491 SlotTypedTransform<T_source, T_target> slot_transform_to = transform_to; 492 493 return bind_property_value(source_property, target_property, flags, 494 slot_transform_to.empty() ? SlotTransform() : TransformProp<T_source, T_target>(slot_transform_to)); 495 } 496 497 /** Creates a binding between @a source_property and @a target_property, 498 * allowing you to set the transformation functions to be used by the binding. 499 * 500 * @param source_property The source property to bind. 501 * @param target_property The target property to bind. 502 * @param flags Flags to pass to Binding. 503 * @param transform_to The transformation function from the source to the target, 504 * or an empty slot to use the default. 505 * @param transform_from The transformation function from the target to the source, 506 * or an empty slot to use the default. 507 * @return The Binding instance representing the binding between the two 508 * Glib::ObjectBase instances, or <tt>nullptr</tt> in case of error. 509 * 510 * @tparam T_source Type of the source property. Must be a type that can be 511 * stored in a Glib::Value<T_source> object. 512 * @tparam T_target Type of the target property. Must be a type that can be 513 * stored in a Glib::Value<T_target> object. 514 * @tparam T_functor_to Type of functor that translates from the source to the target. 515 * Must be convertible to SlotTypedTransform<T_source, T_target>. 516 * @tparam T_functor_from Type of functor that translates from the target to the source. 517 * Must be convertible to SlotTypedTransform<T_target, T_source>. 518 * 519 * @see bind_property_value() 520 * 521 * @newin{2,44} 522 */ 523 template <typename T_source, typename T_target, typename T_functor_to, typename T_functor_from> bind_property(const PropertyProxy<T_source> & source_property,const PropertyProxy<T_target> & target_property,BindingFlags flags,const T_functor_to & transform_to,const T_functor_from & transform_from)524 static Glib::RefPtr<Binding> bind_property( 525 const PropertyProxy<T_source>& source_property, 526 const PropertyProxy<T_target>& target_property, 527 BindingFlags flags, 528 const T_functor_to& transform_to, 529 const T_functor_from& transform_from) 530 { 531 SlotTypedTransform<T_source, T_target> slot_transform_to = transform_to; 532 SlotTypedTransform<T_target, T_source> slot_transform_from = transform_from; 533 534 return bind_property_value(source_property, target_property, flags, 535 slot_transform_to.empty() ? SlotTransform() : TransformProp<T_source, T_target>(slot_transform_to), 536 slot_transform_from.empty() ? SlotTransform() : TransformProp<T_target, T_source>(slot_transform_from)); 537 } 538 539 540 /** Retrieves the Object instance used as the source of the binding. 541 * 542 * @newin{2,44} 543 * 544 * @return The source Object. 545 */ 546 Glib::RefPtr<Glib::ObjectBase> get_source(); 547 548 /** Retrieves the Object instance used as the source of the binding. 549 * 550 * @newin{2,44} 551 * 552 * @return The source Object. 553 */ 554 Glib::RefPtr<const Glib::ObjectBase> get_source() const; 555 556 /** Retrieves the name of the property of Binding::property_source() used as the source 557 * of the binding. 558 * 559 * @newin{2,44} 560 * 561 * @return The name of the source property. 562 */ 563 Glib::ustring get_source_property() const; 564 565 /** Retrieves the Object instance used as the target of the binding. 566 * 567 * @newin{2,44} 568 * 569 * @return The target Object. 570 */ 571 Glib::RefPtr<Glib::ObjectBase> get_target(); 572 573 /** Retrieves the Object instance used as the target of the binding. 574 * 575 * @newin{2,44} 576 * 577 * @return The target Object. 578 */ 579 Glib::RefPtr<const Glib::ObjectBase> get_target() const; 580 581 /** Retrieves the name of the property of Binding::property_target() used as the target 582 * of the binding. 583 * 584 * @newin{2,44} 585 * 586 * @return The name of the target property. 587 */ 588 Glib::ustring get_target_property() const; 589 590 /** Retrieves the flags passed when constructing the Binding. 591 * 592 * @newin{2,44} 593 * 594 * @return The BindingFlags used by the Binding. 595 */ 596 BindingFlags get_flags() const; 597 598 /** Explicitly releases the binding between the source and the target 599 * property expressed by this Binding instance. 600 * 601 * The binding is also released if either the source object or the target 602 * object is deleted, or this Binding instance loses its last reference, 603 * i.e. there is no more Glib::RefPtr that holds a pointer to it. 604 * 605 * @newin{2,44} 606 */ 607 void unbind(); 608 609 610 /** Flags to be used to control the Binding 611 * 612 * @newin{2,44} 613 * 614 * Default value: BINDING_DEFAULT 615 * 616 * @return A PropertyProxy_ReadOnly that allows you to get the value of the property, 617 * or receive notification when the value of the property changes. 618 */ 619 Glib::PropertyProxy_ReadOnly< Glib::BindingFlags > property_flags() const; 620 621 622 /** The Object that should be used as the source of the binding 623 * 624 * @newin{2,44} 625 * 626 * @return A PropertyProxy_ReadOnly that allows you to get the value of the property, 627 * or receive notification when the value of the property changes. 628 */ 629 Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Glib::ObjectBase> > property_source() const; 630 631 632 /** The name of the property of Binding::property_source() that should be used 633 * as the source of the binding. 634 * 635 * This should be in [canonical form][canonical-parameter-names] to get the 636 * best performance. 637 * 638 * @newin{2,44} 639 * 640 * Default value: "" 641 * 642 * @return A PropertyProxy_ReadOnly that allows you to get the value of the property, 643 * or receive notification when the value of the property changes. 644 */ 645 Glib::PropertyProxy_ReadOnly< Glib::ustring > property_source_property() const; 646 647 648 /** The Object that should be used as the target of the binding 649 * 650 * @newin{2,44} 651 * 652 * @return A PropertyProxy_ReadOnly that allows you to get the value of the property, 653 * or receive notification when the value of the property changes. 654 */ 655 Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Glib::ObjectBase> > property_target() const; 656 657 658 /** The name of the property of Binding::property_target() that should be used 659 * as the target of the binding. 660 * 661 * This should be in [canonical form][canonical-parameter-names] to get the 662 * best performance. 663 * 664 * @newin{2,44} 665 * 666 * Default value: "" 667 * 668 * @return A PropertyProxy_ReadOnly that allows you to get the value of the property, 669 * or receive notification when the value of the property changes. 670 */ 671 Glib::PropertyProxy_ReadOnly< Glib::ustring > property_target_property() const; 672 673 674 #ifndef DOXYGEN_SHOULD_SKIP_THIS 675 /** Decrement the reference count for this object. 676 * You should never need to do this manually - use the object via a RefPtr instead. 677 */ 678 void unreference() const override; 679 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 680 681 private: 682 // The functor TransformProp can be implicitly converted to a SlotTransform 683 // and used in a call to bind_property_value(). 684 template <typename T_from, typename T_to> 685 class TransformProp : public sigc::functor_base 686 { 687 public: 688 using result_type = bool; 689 TransformProp(const SlotTypedTransform<T_from,T_to> & slot)690 TransformProp(const SlotTypedTransform<T_from, T_to>& slot) : typed_transform(slot) {} 691 operator()692 bool operator()(const GValue* from_value, GValue* to_value) 693 { 694 Glib::Value<T_from> from_glib_value; 695 from_glib_value.init(from_value); 696 T_to to{}; 697 698 if (!typed_transform(from_glib_value.get(), to)) 699 return false; 700 701 Glib::Value<T_to> to_glib_value; 702 to_glib_value.init(to_value); 703 to_glib_value.set(to); 704 g_value_copy(to_glib_value.gobj(), to_value); 705 return true; 706 } 707 708 private: 709 SlotTypedTransform<T_from, T_to> typed_transform; 710 }; 711 712 713 public: 714 715 public: 716 //C++ methods used to invoke GTK+ virtual functions: 717 718 protected: 719 //GTK+ Virtual Functions (override these to change behaviour): 720 721 //Default Signal Handlers:: 722 723 724 }; 725 726 } // namespace Glib 727 728 729 namespace Glib 730 { 731 /** A Glib::wrap() method for this object. 732 * 733 * @param object The C instance. 734 * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref. 735 * @result A C++ instance that wraps this C instance. 736 * 737 * @relates Glib::Binding 738 */ 739 GLIBMM_API 740 Glib::RefPtr<Glib::Binding> wrap(GBinding* object, bool take_copy = false); 741 } 742 743 744 #endif /* _GLIBMM_BINDING_H */ 745 746