[glibmm] Glib::Binding, TimeZone: Ignore deprecation of some glib functions



commit 24b17dc618b9a0f1211c8a1c0e2c250ad8056b2c
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Mon Dec 14 16:31:32 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 build with -Dwarnings=fatal
    and run with both glib 2.68 and older versions of glib.

 glib/src/binding.ccg  | 26 ++++++++++++++++++++
 glib/src/binding.hg   | 67 +++++++++++++++++++++++++++++++++++++++++++++++----
 glib/src/timezone.ccg | 11 +++++++++
 glib/src/timezone.hg  |  9 ++++++-
 4 files changed, 107 insertions(+), 6 deletions(-)
---
diff --git a/glib/src/binding.ccg b/glib/src/binding.ccg
index 0c07a07c..a1b40e91 100644
--- a/glib/src/binding.ccg
+++ b/glib/src/binding.ccg
@@ -117,6 +117,31 @@ Binding::bind_property_value(const PropertyProxy_Base& source_property,
   return Glib::make_refptr_for_instance<Binding>(new Binding(binding));
 }
 
+// We 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::ObjectBase* Binding::get_source()
+{
+  return Glib::wrap_auto(g_binding_get_source(gobj()));
+}
+
+const Glib::ObjectBase* Binding::get_source() const
+{
+  return const_cast<Binding*>(this)->get_source();
+}
+
+Glib::ObjectBase* Binding::get_target()
+{
+  return Glib::wrap_auto(g_binding_get_target(gobj()));
+}
+
+const Glib::ObjectBase* Binding::get_target() const
+{
+  return const_cast<Binding*>(this)->get_target();
+}
+
 void
 Binding::unbind()
 {
@@ -124,5 +149,6 @@ Binding::unbind()
   if (g_binding_get_source(gobj()))
     g_binding_unbind(gobj());
 }
+G_GNUC_END_IGNORE_DEPRECATIONS
 
 } // namespace Glib
diff --git a/glib/src/binding.hg b/glib/src/binding.hg
index 73451ba4..dbd64480 100644
--- a/glib/src/binding.hg
+++ b/glib/src/binding.hg
@@ -381,12 +381,69 @@ public:
       slot_transform_from.empty() ? SlotTransform() : TransformProp<T_target, 
T_source>(slot_transform_from));
   }
 
-#m4 _CONVERSION(`GObject*',`Glib::ObjectBase*',`Glib::wrap_auto($3)')
-  _WRAP_METHOD(Glib::ObjectBase* get_source(), g_binding_get_source, newin "2,44")
-  _WRAP_METHOD(const Glib::ObjectBase* get_source() const, g_binding_get_source, constversion, newin "2,44")
+  // We 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.
+  //#m4 _CONVERSION(`GObject*',`Glib::ObjectBase*',`Glib::wrap_auto($3)')
+  //_WRAP_METHOD(Glib::ObjectBase* get_source(), g_binding_get_source, newin "2,44")
+  //_WRAP_METHOD(const Glib::ObjectBase* get_source() const, g_binding_get_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 a <tt>nullptr</tt>.
+   *
+   * @newin{2,44}
+   *
+   * @return The source Glib::ObjectBase.
+   */
+  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 a <tt>nullptr</tt>.
+   *
+   * @newin{2,44}
+   *
+   * @return The source Glib::ObjectBase.
+   */
+  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::ObjectBase* get_target(), g_binding_get_target, newin "2,44")
-  _WRAP_METHOD(const Glib::ObjectBase* get_target() const, g_binding_get_target, constversion, newin "2,44")
+
+  //_WRAP_METHOD(Glib::ObjectBase* get_target(), g_binding_get_target, newin "2,44")
+  //_WRAP_METHOD(const Glib::ObjectBase* get_target() const, g_binding_get_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 a <tt>nullptr</tt>.
+   *
+   * @newin{2,44}
+   *
+   * @return The target Glib::ObjectBase.
+   */
+  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 a <tt>nullptr</tt>.
+   *
+   * @newin{2,44}
+   *
+   * @return The target Glib::ObjectBase.
+   */
+  const Glib::ObjectBase* get_target() const;
+
   _WRAP_METHOD(Glib::ustring get_target_property() const, g_binding_get_target_property, newin "2,44")
   _WRAP_METHOD(Flags get_flags() const, g_binding_get_flags, newin "2,44")
 
diff --git a/glib/src/timezone.ccg b/glib/src/timezone.ccg
index 7faf86e2..b2af6cb5 100644
--- a/glib/src/timezone.ccg
+++ b/glib/src/timezone.ccg
@@ -19,4 +19,15 @@
 namespace Glib
 {
 
+// We 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
+
 } // namespace Glib
diff --git a/glib/src/timezone.hg b/glib/src/timezone.hg
index 6ba871ec..8d28c4e4 100644
--- a/glib/src/timezone.hg
+++ b/glib/src/timezone.hg
@@ -61,7 +61,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 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]