tuberry / color-picker

Simple color picker for GNOME Shell.
GNU General Public License v3.0
150 stars 11 forks source link

Api #4

Closed abakkk closed 4 years ago

abakkk commented 4 years ago

It provides an api-like so other extensions can use the color picker.

let extension = Main.extensionManager && Main.extensionManager.lookup('color-picker@tuberry');

if (!extension || extension.state != ExtensionUtils.ExtensionState.ENABLED)
    return;

extension.stateObj.pickAsync().then(color => {
    log(color); // "#ffffff", "rgb(255, 255, 255)" or "hsl(0, 100%, 100%)"
}).catch(e => {
    log(e); // "Error: Cancelled" if the user escaped without picking a color
});

The persistent mode is ignored and the color can be either the one that is picked or the one that is selected in the menu.

abakkk commented 4 years ago

https://framagit.org/abakkk/DrawOnYourScreen/-/archive/color-picker-test/DrawOnYourScreen-color-picker-test.zip

tuberry commented 4 years ago

Thanks! Patch merged.