Connection Manager#

class ignis.connection_manager.ConnectionManager#

A helper class for managing connection handler IDs.

property ids: dict[gi.repository.GObject.Object, list[int]]#

A dictionary mapping GObject instances to lists of handler IDs.

connect(gobject: gi.repository.GObject.Object, signal_name: str, handler: Callable, *args) int#

Connect to a signal and store the handler ID. Equivalent to GObject.Object.connect(), but also saves the handler ID in ids.

Parameters:
  • gobject (Object) -- The GObject instance.

  • signal_name (str) -- The signal name.

  • handler (Callable) -- The handler function.

  • *args -- Arguments to pass to handler.

Return type:

int

Returns:

The handler ID.

disconnect(gobject: gi.repository.GObject.Object, handler_id: int) None#

Disconnect from a signal by the handler_id. Equivalent to GObject.Object.disconnect(), but also removes the stored handler ID from ids.

Parameters:
  • gobject (Object) -- The GObject instance.

  • handler_id (int) -- The handler ID.

Return type:

None

disconnect_gobject(gobject: gi.repository.GObject.Object) None#

Disconnect the given GObject from ALL signals that were connected using connect().

Parameters:

gobject (Object) -- The GObject to disconnect.

Return type:

None

disconnect_all() None#

Disconnect ALL GObjects from ALL signals that were connected using connect().

Return type:

None

class ignis.connection_manager.DBusConnectionManager#

A helper class for managing DBusProxy subscription IDs.

property ids: dict[DBusProxy, list[int]]#

A dictionary mapping DBusProxy instances to lists of subscription IDs.

subscribe(proxy: DBusProxy, signal_name: str, callback: Callable) int#

Subscribe to a D-Bus signal. The same as DBusProxy.signal_subscribe, but saves the subscription ID to ids.

Parameters:
  • proxy (DBusProxy) -- The D-Bus proxy instance.

  • signal_name (str) -- The signal name.

  • callback (Callable) -- The callback function.

Return type:

int

Returns:

The subscription ID.

unsubscribe(proxy: DBusProxy, subscription_id: int) None#

Unsubscribe from a signal by the subscription_id. Equivalent to DBusProxy.unsubscribe(), but also removes the stored subscription ID from ids.

Parameters:
  • gobject -- The D-Bus proxy instance.

  • subscription_id (int) -- The subscription ID.

Return type:

None

unsubscribe_proxy(proxy: DBusProxy) None#

Unsubscribe the given proxy from ALL signals that were subscribed using subscribe().

Parameters:

proxy (DBusProxy) -- The proxy to unsubscribe.

Return type:

None

unsubscribe_all() None#

Unsubscribe ALL proxys from ALL signals that were subscribed using subscribe().

Return type:

None