linuxmint / linuxmint/cinnamon

Applet settings window, widgets cannot update other widgets

Open
#12,362 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

BUG
Dominant language
JavaScript
Stars
5.6k
Forks
915
Avg merge
5d 22h
Merged PRs (30d)
3

Description

Distribution

Mint 22

Package version

6.2.9

Graphics hardware in use

No response

Frequency

Always

Bug description

I will refer the settings window of an Applet as UI.

  1. In the UI, any action initiated by any non-button widget cannot update another widget's value shown.

  2. While the inner value is well changed, the UI is like a new instance of the value and any subsequent change from the UI accounts for the shown value, while any other procedure in the Applet accounts for the inner value.

  3. While a button can update another widget's shown value, if a non-button widget has set a widget's value (incl. itself), the button won't be able to control the widget's shown value anymore.

Steps to reproduce

metadata.json:

{
    "uuid": "ui-cant-modify-itself@you",
    "name": "Bug demo: UI can't modify itself",
    "description": "-",
    "version": "1.0.0",
    "max-instances": "1"
}

settings_schema.json:

{
    "switch-master": {
        "type": "switch",
        "description": "Switch master",
        "default": false
    },
    "switch-slave": {
        "type": "switch",
        "description": "Switch slave, controlled by `Switch master` and `on_applet_clicked`",
        "default": false
    },
    "button-apply-master-to-slave": {
        "callback": "apply_false_to_slave",
        "type": "button",
        "description": "Apply `false` to slave"
    },
    "button-show-slave": {
        "callback": "show_slave_state",
        "type": "button",
        "description": "Show slave state"
    },
    "dull-switch-show-slave": {
        "type": "switch",
        "description": "Dull switch, executes `show_slave_state` on change",
        "default": false
    }
}

applet.js:

const Applet = imports.ui.applet;
const AppletSettings = imports.ui.settings.AppletSettings;
const Main = imports.ui.main;

class ThisApplet extends Applet.TextApplet {
    constructor(metadata, orientation, panel_height, instance_id) {
        super(orientation, panel_height, instance_id);

        this.set_applet_label("Open settings...");

        this.metadata = metadata;
        this.settings = new AppletSettings(this, metadata.uuid, instance_id);

        this.settings.bind('switch-master', "master", () => {
            this.slave = this.master;
            this.show_slave_state();
        });
        this.settings.bind('switch-slave', "slave");
        this.settings.bind('dull-switch-show-slave',  null, this.show_slave_state);
    }

    apply_false_to_slave() {
        this.slave = false;
        this.show_slave_state();
    }

    show_slave_state() {
        Main.notify("Info", "Switch slave is " + this.slave);
    }

    on_applet_clicked() {
        this.slave = !this.slave;
        this.show_slave_state();
    }
}

function main(metadata, orientation, panel_height, instance_id) {
    return new ThisApplet(metadata, orientation, panel_height, instance_id);
}
Expected behavior

The UI should always have its widgets' shown value up to date according to the inner value.

Additional information

No response

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the applet.js reproduction, especially AppletSettings, settings.bind, and the switch and button callbacks; use metadata.json and settings_schema.json to install the example. Compare the inner values with the values shown in the settings window while following the reproduction steps. Done means every widget's displayed value stays synchronized with its inner value after changes from switches, buttons, and applet procedures.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.