Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • gnome-shell gnome-shell
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 2,081
    • Issues 2,081
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 161
    • Merge requests 161
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOMEGNOME
  • gnome-shellgnome-shell
  • Merge requests
  • !1953

Add connectObject()/disconnectObject() convenience methods

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Florian Müllner requested to merge fmuellner/gnome-shell:signal-tracker into main Aug 16, 2021
  • Overview 26
  • Commits 2
  • Pipelines 26
  • Changes 59

This is a small experiment to make dealing with signals a bit more automatic and convenient.

Quoting the main commit:

signalTracker: Provide monkey-patching for (dis)connectObject()

The module exports a `addObjectSignalMethods()` method that extends
the provided prototype with `connectObject()` and `disconnectObject()`
methods.

In its simplest form, `connectObject()` looks like the regular
`connect()` method, except for an additional parameter:

```js
    this._button.connectObject('clicked',
        () => this._onButtonClicked(), this);
```

The additional object can be used to disconnect all handlers on the
instance that were connected with that object, similar to
`g_signal_handlers_disconnect_by_data()` (which cannot be used
from introspection).

For objects that are subclasses of Clutter.Actor, that will happen
automatically when the actor is destroyed, similar to
`g_signal_connect_object()`.

Finally, `connectObject()` allows to conveniently connect multiple
signals at once, similar to `g_object_connect()`:

```js
    this._toggleButton.connect(
        'clicked', () => this._onClicked(),
        'notify::checked', () => this._onChecked(), this);
```

The second commit adapts popupMenu.js to use the new methods, to see how it works out in practice.

Last but not least: Whereever this goes, it's not 41 material.

Edited Mar 03, 2022 by Florian Müllner
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: signal-tracker