[glibmm/glibmm-2-64] Glib::Binding, TimeZone: Ignore deprecation of some glib functions



commit c619a63b6c242388ac5dff50bde7287d7318eddc
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Sat Dec 12 12:22:53 2020 +0100

    Glib::Binding, TimeZone: Ignore deprecation of some glib functions
    
    g_binding_get_source(), g_binding_get_target() and g_time_zone_new()
    are deprecated in glib 2.68. We can't use the replacement functions,
    which are new in glib 2.68. We want to be able to build and run
    with both glib 2.68 and older versions of glib.

 glib/src/binding.ccg  | 32 +++++++++++++++++++++++
 glib/src/binding.hg   | 72 ++++++++++++++++++++++++++++++++++++++++++++++++---
 glib/src/timezone.ccg | 11 ++++++++
 glib/src/timezone.hg  |  9 ++++++-
 4 files changed, 119 insertions(+), 5 deletions(-)
---
diff --git a/glib/src/binding.ccg b/glib/src/binding.ccg
index 576b64f6..732e103d 100644
--- a/glib/src/binding.ccg
+++ b/glib/src/binding.ccg
@@ -115,6 +115,37 @@ Binding::bind_property_value(const PropertyProxy_Base& source_property,
   return Glib::RefPtr<Binding>(new Binding(binding));
 }
 
+// We must hand-code get_source() and get_target().
+// g_binding_get_source() and g_binding_get_target() are deprecated in glib 2.68.
+// We can't use the replacements g_binding_dup_source() and g_binding_dup_target(),
+// which are new in glib 2.68. This version of glibmm does not require glib 2.68.
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+Glib::RefPtr<Glib::ObjectBase> Binding::get_source()
+{
+  Glib::RefPtr<Glib::ObjectBase> retvalue = Glib::wrap(g_binding_get_source(gobj()));
+  if(retvalue)
+    retvalue->reference(); //The function does not do a ref for us.
+  return retvalue;
+}
+
+Glib::RefPtr<const Glib::ObjectBase> Binding::get_source() const
+{
+  return const_cast<Binding*>(this)->get_source();
+}
+
+Glib::RefPtr<Glib::ObjectBase> Binding::get_target()
+{
+  Glib::RefPtr<Glib::ObjectBase> retvalue = Glib::wrap(g_binding_get_target(gobj()));
+  if(retvalue)
+    retvalue->reference(); //The function does not do a ref for us.
+  return retvalue;
+}
+
+Glib::RefPtr<const Glib::ObjectBase> Binding::get_target() const
+{
+  return const_cast<Binding*>(this)->get_target();
+}
+
 void
 Binding::unbind()
 {
@@ -142,5 +173,6 @@ Binding::unreference() const
 
   Object::unreference();
 }
+G_GNUC_END_IGNORE_DEPRECATIONS
 
 } // namespace Glib
diff --git a/glib/src/binding.hg b/glib/src/binding.hg
index 57b7c43c..80f8f3f1 100644
--- a/glib/src/binding.hg
+++ b/glib/src/binding.hg
@@ -376,11 +376,75 @@ public:
       slot_transform_from.empty() ? SlotTransform() : TransformProp<T_target, 
T_source>(slot_transform_from));
   }
 
-  _WRAP_METHOD(Glib::RefPtr<Glib::ObjectBase> get_source(), g_binding_get_source, refreturn, newin "2,44")
-  _WRAP_METHOD(Glib::RefPtr<const Glib::ObjectBase> get_source() const, g_binding_get_source, refreturn, 
constversion, newin "2,44")
+  // We must hand-code get_source() and get_target().
+  // g_binding_get_source() and g_binding_get_target() are deprecated in glib 2.68.
+  // We can't use the replacements g_binding_dup_source() and g_binding_dup_target(),
+  // which are new in glib 2.68. This version of glibmm does not require glib 2.68.
+  //
+  //_WRAP_METHOD(Glib::RefPtr<Glib::ObjectBase> get_source(), g_binding_get_source, refreturn, newin "2,44")
+  //_WRAP_METHOD(Glib::RefPtr<const Glib::ObjectBase> get_source() const, g_binding_get_source, refreturn, 
constversion, newin "2,44")
+  // or
+  //_WRAP_METHOD(Glib::RefPtr<Glib::ObjectBase> get_source(), g_binding_dup_source, newin "2,44")
+  //_WRAP_METHOD(Glib::RefPtr<const Glib::ObjectBase> get_source() const, g_binding_dup_source, 
constversion, newin "2,44")
+  _IGNORE(g_binding_get_source)
+
+  /** Retrieves the Glib::ObjectBase instance used as the source of the binding.
+   *
+   * A %Glib::Binding can outlive the source Glib::ObjectBase as the binding does not hold a
+   * strong reference to the source. If the source is destroyed before the
+   * binding then this function will return an empty Glib::RefPtr.
+   *
+   * @newin{2,44}
+   *
+   * @return The source Glib::ObjectBase.
+   */
+  Glib::RefPtr<Glib::ObjectBase> get_source();
+  
+  /** Retrieves the Glib::ObjectBase instance used as the source of the binding.
+   *
+   * A %Glib::Binding can outlive the source Glib::ObjectBase as the binding does not hold a
+   * strong reference to the source. If the source is destroyed before the
+   * binding then this function will return an empty Glib::RefPtr.
+   *
+   * @newin{2,44}
+   *
+   * @return The source Glib::ObjectBase.
+   */
+  Glib::RefPtr<const Glib::ObjectBase> get_source() const;
+
   _WRAP_METHOD(Glib::ustring get_source_property() const, g_binding_get_source_property, newin "2,44")
-  _WRAP_METHOD(Glib::RefPtr<Glib::ObjectBase> get_target(), g_binding_get_target, refreturn, newin "2,44")
-  _WRAP_METHOD(Glib::RefPtr<const Glib::ObjectBase> get_target() const, g_binding_get_target, refreturn, 
constversion, newin "2,44")
+
+  //_WRAP_METHOD(Glib::RefPtr<Glib::ObjectBase> get_target(), g_binding_get_target, refreturn, newin "2,44")
+  //_WRAP_METHOD(Glib::RefPtr<const Glib::ObjectBase> get_target() const, g_binding_get_target, refreturn, 
constversion, newin "2,44")
+  // or
+  //_WRAP_METHOD(Glib::RefPtr<Glib::ObjectBase> get_target(), g_binding_dup_target, newin "2,44")
+  //_WRAP_METHOD(Glib::RefPtr<const Glib::ObjectBase> get_target() const, g_binding_dup_target, 
constversion, newin "2,44")
+  _IGNORE(g_binding_get_target)
+
+  /** Retrieves the Glib::ObjectBase instance used as the target of the binding.
+   *
+   * A %Glib::Binding can outlive the target Glib::ObjectBase as the binding does not hold a
+   * strong reference to the target. If the target is destroyed before the
+   * binding then this function will return an empty Glib::RefPtr.
+   *
+   * @newin{2,44}
+   *
+   * @return The target Glib::ObjectBase.
+   */
+  Glib::RefPtr<Glib::ObjectBase> get_target();
+  
+  /** Retrieves the Glib::ObjectBase instance used as the target of the binding.
+   *
+   * A %Glib::Binding can outlive the target Glib::ObjectBase as the binding does not hold a
+   * strong reference to the target. If the target is destroyed before the
+   * binding then this function will return an empty Glib::RefPtr.
+   *
+   * @newin{2,44}
+   *
+   * @return The target Glib::ObjectBase.
+   */
+  Glib::RefPtr<const Glib::ObjectBase> get_target() const;
+
   _WRAP_METHOD(Glib::ustring get_target_property() const, g_binding_get_target_property, newin "2,44")
   _WRAP_METHOD(BindingFlags get_flags() const, g_binding_get_flags, newin "2,44")
 
diff --git a/glib/src/timezone.ccg b/glib/src/timezone.ccg
index 42a5ae1c..bfe236a7 100644
--- a/glib/src/timezone.ccg
+++ b/glib/src/timezone.ccg
@@ -19,6 +19,17 @@
 namespace Glib
 {
 
+// We must hand-code create(const Glib::ustring& identifier).
+// g_time_zone_new() is deprecated in glib 2.68.
+// We can't use the replacement g_time_zone_new_identifier(),
+// which is new in glib 2.68. This version of glibmm does not require glib 2.68.
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+TimeZone TimeZone::create(const Glib::ustring& identifier)
+{
+  return Glib::wrap(g_time_zone_new(identifier.c_str()));
+}
+G_GNUC_END_IGNORE_DEPRECATIONS
+
 // Glib::Value<Glib::TimeZone>
 GType Value<TimeZone>::value_type()
 {
diff --git a/glib/src/timezone.hg b/glib/src/timezone.hg
index d98a5682..345c51d3 100644
--- a/glib/src/timezone.hg
+++ b/glib/src/timezone.hg
@@ -60,7 +60,14 @@ class GLIBMM_API TimeZone
   _IGNORE(g_time_zone_ref, g_time_zone_unref)
 
 public:
-  _WRAP_METHOD(static TimeZone create(const Glib::ustring& identifier), g_time_zone_new)
+  // We must hand-code create(const Glib::ustring& identifier).
+  // g_time_zone_new() is deprecated in glib 2.68.
+  // We can't use the replacement g_time_zone_new_identifier(),
+  // which is new in glib 2.68. This version of glibmm does not require glib 2.68.
+  //_WRAP_METHOD(static TimeZone create(const Glib::ustring& identifier), g_time_zone_new_identifier)
+  _WRAP_METHOD_DOCS_ONLY(g_time_zone_new)
+  static TimeZone create(const Glib::ustring& identifier);
+
   _WRAP_METHOD(static TimeZone create_local(), g_time_zone_new_local)
   _WRAP_METHOD(static TimeZone create_utc(), g_time_zone_new_utc)
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]