### Method

# Gio DBusConnection register_object_with_closures2

since: 2.84

#### Declaration [src]

    guint
    g_dbus_connection_register_object_with_closures2 (
      GDBusConnection* connection,
      const gchar* object_path,
      GDBusInterfaceInfo* interface_info,
      GClosure* method_call_closure,
      GClosure* get_property_closure,
      GClosure* set_property_closure,
      GError** error
    )

#### Description [src]

Version of `g_dbus_connection_register_object()` using closures instead of a `GDBusInterfaceVTable` for easier binding in other languages.

In contrast to `g_dbus_connection_register_object()` and `g_dbus_connection_register_object_with_closures()`, the reference counting semantics of the function wrapped by `method_call_closure` are not the same as those of `GDBusInterfaceMethodCallFunc`. Ownership of a reference to the `GDBusMethodInvocation` is not transferred to the function. Bindings must ensure that they add a reference to the `GDBusMethodInvocation` before calling any `g_dbus_method_invocation_return_*()` methods on it. This should be automatic as a result of the introspection annotations on those methods.

Available since: 2.84

#### Parameters

`object_path`

  Type: `const gchar*`

  The object path to register at.

  The data is owned by the caller of the method.
  The value is a NUL terminated UTF-8 string.

`interface_info`

  Type: `GDBusInterfaceInfo`

  Introspection data for the interface.

  The data is owned by the caller of the method.

`method_call_closure`

  Type: `GClosure`

  `GClosure` for handling incoming method calls.

  The argument can be `NULL`.
  The data is owned by the caller of the method.

`get_property_closure`

  Type: `GClosure`

  `GClosure` for getting a property.

  The argument can be `NULL`.
  The data is owned by the caller of the method.

`set_property_closure`

  Type: `GClosure`

  `GClosure` for setting a property.

  The argument can be `NULL`.
  The data is owned by the caller of the method.

`error`

  Type: `GError **`

  The return location for a recoverable error.

  The argument can be `NULL`.
  If the return location is not `NULL`, then you must initialize it to a `NULL` `GError*`.
  The argument will be left initialized to `NULL` by the method if there are no errors.
  In case of error, the argument will be set to a newly allocated `GError`; the caller will take ownership of the data, and be responsible for freeing it.

#### Return value

Type: `guint`

`0` if `error` is set, otherwise a registration ID (never `0`) that can be used with `g_dbus_connection_unregister_object()`.