Use ESLint and reformat code

This commit is contained in:
Romain
2020-08-01 07:31:53 +00:00
parent 35c6b8fa33
commit 728ae6ef40
77 changed files with 4129 additions and 3302 deletions
+1
View File
@@ -0,0 +1 @@
src/convenience.js
+4
View File
@@ -0,0 +1,4 @@
extends:
- ./lint/eslintrc-gjs.yml
- ./lint/eslintrc-shell.yml
- ./lint/eslintrc-extension.yml
+24 -10
View File
@@ -4,11 +4,31 @@ You're welcome to contribute to the [code](#contributing-to-the-code) or to the
## Contributing to the code ## Contributing to the code
Create a new branch describing what your're working on, for example `feature/{name-of-the-feature}` or `theme/{name-of-the-theme}`. When you're done, commit all your changes and create a new merge request. Choose the appropriate merge request template. You'll need `make` and [NPM](https://www.npmjs.com/) to install the development dependencies:
```bash
make deps-install
```
Create a new branch describing what your're working on, for example `feature/{name-of-the-feature}` or `theme/{name-of-the-theme}`.
To make sure your code passes basic checks, run:
```bash
make test
```
When you're done, commit all your changes and create a new merge request. Choose the appropriate merge request template.
### Coding style ### Coding style
Please follow the coding style of each file. We follow the [GNOME Shell coding style](https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/master/HACKING.md) and we use [ESLint](https://eslint.org/) to enforce it.
To make sure your code follows it:
```bash
make test-lint
```
### Copyright notice ### Copyright notice
@@ -16,18 +36,12 @@ If you make changes to a file, please add your copyright notice at the top of th
### Themes and unit tests ### Themes and unit tests
If you add support for a theme, please write a unit test for each of its variants, in the `tests` directory, with the theme name as filename. Unit tests are written for [AVA](https://github.com/avajs/ava) and run with node and npm. If you add support for a theme, please write a unit test for each of its variants, in the `tests` directory, with the theme name as filename. Unit tests are written for [AVA](https://github.com/avajs/ava).
To install the tests dependencies:
```bash
npm install
```
To run the tests: To run the tests:
```bash ```bash
make test make test-variants
``` ```
## Contributing to the translations ## Contributing to the translations
+8 -1
View File
@@ -56,7 +56,14 @@ uninstall:
clean: build-clean deps-clean clean: build-clean deps-clean
.PHONY: test .PHONY: test
test: test: test-lint test-variants
.PHONY: test-lint
test-lint:
npx eslint .
.PHONY: test-variants
test-variants:
cat ./src/modules/GtkVariants.js ./tests/gtk_themes/_variants.js.template > ./tests/gtk_themes/_variants.js cat ./src/modules/GtkVariants.js ./tests/gtk_themes/_variants.js.template > ./tests/gtk_themes/_variants.js
cat ./src/modules/ShellVariants.js ./tests/shell_themes/_variants.js.template > ./tests/shell_themes/_variants.js cat ./src/modules/ShellVariants.js ./tests/shell_themes/_variants.js.template > ./tests/shell_themes/_variants.js
npm run test npm run test
+6
View File
@@ -0,0 +1,6 @@
rules:
no-unused-vars:
- error
- vars: 'local'
varsIgnorePattern: (^unused|_$)
argsIgnorePattern: ^(unused|_)
+232
View File
@@ -0,0 +1,232 @@
---
# From https://gitlab.gnome.org/GNOME/gjs/
env:
es6: true
extends: 'eslint:recommended'
rules:
array-bracket-newline:
- error
- consistent
array-bracket-spacing:
- error
- never
array-callback-return: error
arrow-parens:
- error
- as-needed
arrow-spacing: error
block-scoped-var: error
block-spacing: error
brace-style: error
# Waiting for this to have matured a bit in eslint
# camelcase:
# - error
# - properties: never
# allow: [^vfunc_, ^on_, _instance_init]
comma-dangle:
- error
- arrays: always-multiline
objects: always-multiline
functions: never
comma-spacing:
- error
- before: false
after: true
comma-style:
- error
- last
computed-property-spacing: error
curly:
- error
- multi-or-nest
- consistent
dot-location:
- error
- property
eol-last: error
eqeqeq: error
func-call-spacing: error
func-name-matching: error
func-style:
- error
- declaration
- allowArrowFunctions: true
indent:
- error
- 4
- ignoredNodes:
# Allow not indenting the body of GObject.registerClass, since in the
# future it's intended to be a decorator
- 'CallExpression[callee.object.name=GObject][callee.property.name=registerClass] > ClassExpression:first-child'
# Allow dedenting chained member expressions
MemberExpression: 'off'
key-spacing:
- error
- beforeColon: false
afterColon: true
keyword-spacing:
- error
- before: true
after: true
linebreak-style:
- error
- unix
lines-between-class-members: error
max-nested-callbacks: error
max-statements-per-line: error
new-parens: error
no-array-constructor: error
no-await-in-loop: error
no-caller: error
no-constant-condition:
- error
- checkLoops: false
no-div-regex: error
no-empty:
- error
- allowEmptyCatch: true
no-extra-bind: error
no-extra-parens:
- error
- all
- conditionalAssign: false
nestedBinaryExpressions: false
returnAssign: false
no-implicit-coercion:
- error
- allow:
- '!!'
no-invalid-this: error
no-iterator: error
no-label-var: error
no-lonely-if: error
no-loop-func: error
no-nested-ternary: error
no-new-object: error
no-new-wrappers: error
no-octal-escape: error
no-proto: error
no-prototype-builtins: 'off'
no-restricted-properties:
- error
- object: Lang
property: bind
message: Use arrow notation or Function.prototype.bind()
- object: Lang
property: Class
message: Use ES6 classes
- object: imports
property: mainloop
message: Use GLib main loops and timeouts
no-restricted-syntax:
- error
- selector: >-
MethodDefinition[key.name="_init"] >
FunctionExpression[params.length=1] >
BlockStatement[body.length=1]
CallExpression[arguments.length=1][callee.object.type="Super"][callee.property.name="_init"] >
Identifier:first-child
message: _init() that only calls super._init() is unnecessary
- selector: >-
MethodDefinition[key.name="_init"] >
FunctionExpression[params.length=0] >
BlockStatement[body.length=1]
CallExpression[arguments.length=0][callee.object.type="Super"][callee.property.name="_init"]
message: _init() that only calls super._init() is unnecessary
no-return-assign: error
no-return-await: error
no-self-compare: error
no-shadow: error
no-shadow-restricted-names: error
no-spaced-func: error
no-tabs: error
no-template-curly-in-string: error
no-throw-literal: error
no-trailing-spaces: error
no-undef-init: error
no-unneeded-ternary: error
no-unused-expressions: error
no-unused-vars:
- error
# Vars use a suffix _ instead of a prefix because of file-scope private vars
- varsIgnorePattern: (^unused|_$)
argsIgnorePattern: ^(unused|_)
no-useless-call: error
no-useless-computed-key: error
no-useless-concat: error
no-useless-constructor: error
no-useless-rename: error
no-useless-return: error
no-whitespace-before-property: error
no-with: error
nonblock-statement-body-position:
- error
- below
object-curly-newline:
- error
- consistent: true
object-curly-spacing: error
object-shorthand: error
operator-assignment: error
operator-linebreak: error
# These may be a bit controversial, we can try them out and enable them later
# prefer-const: error
# prefer-destructuring: error
prefer-numeric-literals: error
prefer-promise-reject-errors: error
prefer-rest-params: error
prefer-spread: error
prefer-template: error
quotes:
- error
- single
- avoidEscape: true
require-await: error
rest-spread-spacing: error
semi:
- error
- always
semi-spacing:
- error
- before: false
after: true
semi-style: error
space-before-blocks: error
space-before-function-paren:
- error
- named: never
# for `function ()` and `async () =>`, preserve space around keywords
anonymous: always
asyncArrow: always
space-in-parens: error
space-infix-ops:
- error
- int32Hint: false
space-unary-ops: error
spaced-comment: error
switch-colon-spacing: error
symbol-description: error
template-curly-spacing: error
template-tag-spacing: error
unicode-bom: error
valid-jsdoc:
- error
- requireReturn: false
wrap-iife:
- error
- inside
yield-star-spacing: error
yoda: error
globals:
ARGV: readonly
Debugger: readonly
GIRepositoryGType: readonly
globalThis: readonly
imports: readonly
Intl: readonly
log: readonly
logError: readonly
print: readonly
printerr: readonly
parserOptions:
ecmaVersion: 2019
+16
View File
@@ -0,0 +1,16 @@
# From https://gitlab.gnome.org/GNOME/gnome-shell/
rules:
camelcase:
- error
- properties: never
allow: [^vfunc_, ^on_]
consistent-return: error
key-spacing:
- error
- mode: minimum
beforeColon: false
afterColon: true
object-curly-spacing:
- error
- always
prefer-arrow-callback: error
+559
View File
@@ -185,6 +185,12 @@
"integrity": "sha512-apwXVmYVpQ34m/i71vrApRrRKCWQnZZF1+npOD0WV5xZFfwWOmKGQ2RWlfdy9vWITsenisM8M0Qeq8agcFHNiQ==", "integrity": "sha512-apwXVmYVpQ34m/i71vrApRrRKCWQnZZF1+npOD0WV5xZFfwWOmKGQ2RWlfdy9vWITsenisM8M0Qeq8agcFHNiQ==",
"dev": true "dev": true
}, },
"acorn-jsx": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.2.0.tgz",
"integrity": "sha512-HiUX/+K2YpkpJ+SzBffkM/AQ2YE03S0U1kjTLVpoJdhZMOWy8qvXVN9JdLqv2QsaQ6MPYQIuNmwD8zOiYUofLQ==",
"dev": true
},
"acorn-walk": { "acorn-walk": {
"version": "7.1.1", "version": "7.1.1",
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.1.1.tgz", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.1.1.tgz",
@@ -201,6 +207,18 @@
"indent-string": "^4.0.0" "indent-string": "^4.0.0"
} }
}, },
"ajv": {
"version": "6.12.3",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.3.tgz",
"integrity": "sha512-4K0cK3L1hsqk9xIb2z9vs/XU+PGJZ9PNpJRDS9YLzmNdX6jmVPfamLvTJr0aDAusnHyCHO6MjzlkAsgtqp9teA==",
"dev": true,
"requires": {
"fast-deep-equal": "^3.1.1",
"fast-json-stable-stringify": "^2.0.0",
"json-schema-traverse": "^0.4.1",
"uri-js": "^4.2.2"
}
},
"ansi-align": { "ansi-align": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-3.0.0.tgz", "resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-3.0.0.tgz",
@@ -250,6 +268,12 @@
} }
} }
}, },
"ansi-colors": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz",
"integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==",
"dev": true
},
"ansi-regex": { "ansi-regex": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz",
@@ -707,6 +731,17 @@
"integrity": "sha1-fj5Iu+bZl7FBfdyihoIEtNPYVxU=", "integrity": "sha1-fj5Iu+bZl7FBfdyihoIEtNPYVxU=",
"dev": true "dev": true
}, },
"cross-spawn": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
"dev": true,
"requires": {
"path-key": "^3.1.0",
"shebang-command": "^2.0.0",
"which": "^2.0.1"
}
},
"crypto-random-string": { "crypto-random-string": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz", "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz",
@@ -761,6 +796,12 @@
"integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==",
"dev": true "dev": true
}, },
"deep-is": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz",
"integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=",
"dev": true
},
"defaults": { "defaults": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz", "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz",
@@ -828,6 +869,15 @@
"path-type": "^4.0.0" "path-type": "^4.0.0"
} }
}, },
"doctrine": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz",
"integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==",
"dev": true,
"requires": {
"esutils": "^2.0.2"
}
},
"dot-prop": { "dot-prop": {
"version": "5.2.0", "version": "5.2.0",
"resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.2.0.tgz", "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.2.0.tgz",
@@ -864,6 +914,15 @@
"once": "^1.4.0" "once": "^1.4.0"
} }
}, },
"enquirer": {
"version": "2.3.6",
"resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz",
"integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==",
"dev": true,
"requires": {
"ansi-colors": "^4.1.1"
}
},
"equal-length": { "equal-length": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/equal-length/-/equal-length-1.0.1.tgz", "resolved": "https://registry.npmjs.org/equal-length/-/equal-length-1.0.1.tgz",
@@ -891,18 +950,170 @@
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
"dev": true "dev": true
}, },
"eslint": {
"version": "7.5.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-7.5.0.tgz",
"integrity": "sha512-vlUP10xse9sWt9SGRtcr1LAC67BENcQMFeV+w5EvLEoFe3xJ8cF1Skd0msziRx/VMC+72B4DxreCE+OR12OA6Q==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.0.0",
"ajv": "^6.10.0",
"chalk": "^4.0.0",
"cross-spawn": "^7.0.2",
"debug": "^4.0.1",
"doctrine": "^3.0.0",
"enquirer": "^2.3.5",
"eslint-scope": "^5.1.0",
"eslint-utils": "^2.1.0",
"eslint-visitor-keys": "^1.3.0",
"espree": "^7.2.0",
"esquery": "^1.2.0",
"esutils": "^2.0.2",
"file-entry-cache": "^5.0.1",
"functional-red-black-tree": "^1.0.1",
"glob-parent": "^5.0.0",
"globals": "^12.1.0",
"ignore": "^4.0.6",
"import-fresh": "^3.0.0",
"imurmurhash": "^0.1.4",
"is-glob": "^4.0.0",
"js-yaml": "^3.13.1",
"json-stable-stringify-without-jsonify": "^1.0.1",
"levn": "^0.4.1",
"lodash": "^4.17.19",
"minimatch": "^3.0.4",
"natural-compare": "^1.4.0",
"optionator": "^0.9.1",
"progress": "^2.0.0",
"regexpp": "^3.1.0",
"semver": "^7.2.1",
"strip-ansi": "^6.0.0",
"strip-json-comments": "^3.1.0",
"table": "^5.2.3",
"text-table": "^0.2.0",
"v8-compile-cache": "^2.0.3"
},
"dependencies": {
"ignore": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz",
"integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==",
"dev": true
},
"lodash": {
"version": "4.17.19",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz",
"integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==",
"dev": true
},
"semver": {
"version": "7.3.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz",
"integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==",
"dev": true
},
"strip-json-comments": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz",
"integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==",
"dev": true
}
}
},
"eslint-scope": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.0.tgz",
"integrity": "sha512-iiGRvtxWqgtx5m8EyQUJihBloE4EnYeGE/bz1wSPwJE6tZuJUtHlhqDM4Xj2ukE8Dyy1+HCZ4hE0fzIVMzb58w==",
"dev": true,
"requires": {
"esrecurse": "^4.1.0",
"estraverse": "^4.1.1"
}
},
"eslint-utils": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz",
"integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==",
"dev": true,
"requires": {
"eslint-visitor-keys": "^1.1.0"
}
},
"eslint-visitor-keys": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz",
"integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==",
"dev": true
},
"espree": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/espree/-/espree-7.2.0.tgz",
"integrity": "sha512-H+cQ3+3JYRMEIOl87e7QdHX70ocly5iW4+dttuR8iYSPr/hXKFb+7dBsZ7+u1adC4VrnPlTkv0+OwuPnDop19g==",
"dev": true,
"requires": {
"acorn": "^7.3.1",
"acorn-jsx": "^5.2.0",
"eslint-visitor-keys": "^1.3.0"
},
"dependencies": {
"acorn": {
"version": "7.3.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.3.1.tgz",
"integrity": "sha512-tLc0wSnatxAQHVHUapaHdz72pi9KUyHjq5KyHjGg9Y8Ifdc79pTh2XvI6I1/chZbnM7QtNKzh66ooDogPZSleA==",
"dev": true
}
}
},
"esprima": { "esprima": {
"version": "4.0.1", "version": "4.0.1",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
"dev": true "dev": true
}, },
"esquery": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/esquery/-/esquery-1.3.1.tgz",
"integrity": "sha512-olpvt9QG0vniUBZspVRN6lwB7hOZoTRtT+jzR+tS4ffYx2mzbw+z0XCOk44aaLYKApNX5nMm+E+P6o25ip/DHQ==",
"dev": true,
"requires": {
"estraverse": "^5.1.0"
},
"dependencies": {
"estraverse": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.1.0.tgz",
"integrity": "sha512-FyohXK+R0vE+y1nHLoBM7ZTyqRpqAlhdZHCWIWEviFLiGB8b04H6bQs8G+XTthacvT8VuwvteiP7RJSxMs8UEw==",
"dev": true
}
}
},
"esrecurse": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz",
"integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==",
"dev": true,
"requires": {
"estraverse": "^4.1.0"
}
},
"estraverse": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz",
"integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==",
"dev": true
},
"esutils": { "esutils": {
"version": "2.0.3", "version": "2.0.3",
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
"integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
"dev": true "dev": true
}, },
"fast-deep-equal": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
"dev": true
},
"fast-diff": { "fast-diff": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz", "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz",
@@ -923,6 +1134,18 @@
"picomatch": "^2.2.1" "picomatch": "^2.2.1"
} }
}, },
"fast-json-stable-stringify": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
"integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==",
"dev": true
},
"fast-levenshtein": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz",
"integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=",
"dev": true
},
"fastq": { "fastq": {
"version": "1.8.0", "version": "1.8.0",
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.8.0.tgz", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.8.0.tgz",
@@ -941,6 +1164,15 @@
"escape-string-regexp": "^1.0.5" "escape-string-regexp": "^1.0.5"
} }
}, },
"file-entry-cache": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz",
"integrity": "sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==",
"dev": true,
"requires": {
"flat-cache": "^2.0.1"
}
},
"fill-range": { "fill-range": {
"version": "7.0.1", "version": "7.0.1",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
@@ -960,6 +1192,34 @@
"path-exists": "^4.0.0" "path-exists": "^4.0.0"
} }
}, },
"flat-cache": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz",
"integrity": "sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==",
"dev": true,
"requires": {
"flatted": "^2.0.0",
"rimraf": "2.6.3",
"write": "1.0.3"
},
"dependencies": {
"rimraf": {
"version": "2.6.3",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz",
"integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==",
"dev": true,
"requires": {
"glob": "^7.1.3"
}
}
}
},
"flatted": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.2.tgz",
"integrity": "sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==",
"dev": true
},
"fs.realpath": { "fs.realpath": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
@@ -973,6 +1233,12 @@
"dev": true, "dev": true,
"optional": true "optional": true
}, },
"functional-red-black-tree": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz",
"integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=",
"dev": true
},
"get-caller-file": { "get-caller-file": {
"version": "2.0.5", "version": "2.0.5",
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
@@ -1020,6 +1286,23 @@
"ini": "^1.3.5" "ini": "^1.3.5"
} }
}, },
"globals": {
"version": "12.4.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz",
"integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==",
"dev": true,
"requires": {
"type-fest": "^0.8.1"
},
"dependencies": {
"type-fest": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz",
"integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==",
"dev": true
}
}
},
"globby": { "globby": {
"version": "11.0.0", "version": "11.0.0",
"resolved": "https://registry.npmjs.org/globby/-/globby-11.0.0.tgz", "resolved": "https://registry.npmjs.org/globby/-/globby-11.0.0.tgz",
@@ -1095,6 +1378,24 @@
"integrity": "sha1-SMptcvbGo68Aqa1K5odr44ieKwk=", "integrity": "sha1-SMptcvbGo68Aqa1K5odr44ieKwk=",
"dev": true "dev": true
}, },
"import-fresh": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.1.tgz",
"integrity": "sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ==",
"dev": true,
"requires": {
"parent-module": "^1.0.0",
"resolve-from": "^4.0.0"
},
"dependencies": {
"resolve-from": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
"integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==",
"dev": true
}
}
},
"import-lazy": { "import-lazy": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/import-lazy/-/import-lazy-2.1.0.tgz", "resolved": "https://registry.npmjs.org/import-lazy/-/import-lazy-2.1.0.tgz",
@@ -1275,6 +1576,12 @@
"integrity": "sha512-VjSeb/lHmkoyd8ryPVIKvOCn4D1koMqY+vqyjjUfc3xyKtP4dYOxM44sZrnqQSzSds3xyOrUTLTC9LVCVgLngw==", "integrity": "sha512-VjSeb/lHmkoyd8ryPVIKvOCn4D1koMqY+vqyjjUfc3xyKtP4dYOxM44sZrnqQSzSds3xyOrUTLTC9LVCVgLngw==",
"dev": true "dev": true
}, },
"isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
"integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=",
"dev": true
},
"isobject": { "isobject": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/isobject/-/isobject-4.0.0.tgz", "resolved": "https://registry.npmjs.org/isobject/-/isobject-4.0.0.tgz",
@@ -1315,6 +1622,18 @@
"integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==", "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==",
"dev": true "dev": true
}, },
"json-schema-traverse": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==",
"dev": true
},
"json-stable-stringify-without-jsonify": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz",
"integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=",
"dev": true
},
"keyv": { "keyv": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/keyv/-/keyv-3.1.0.tgz", "resolved": "https://registry.npmjs.org/keyv/-/keyv-3.1.0.tgz",
@@ -1333,6 +1652,16 @@
"package-json": "^6.3.0" "package-json": "^6.3.0"
} }
}, },
"levn": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz",
"integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==",
"dev": true,
"requires": {
"prelude-ls": "^1.2.1",
"type-check": "~0.4.0"
}
},
"lines-and-columns": { "lines-and-columns": {
"version": "1.1.6", "version": "1.1.6",
"resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz", "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz",
@@ -1577,6 +1906,15 @@
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
"dev": true "dev": true
}, },
"mkdirp": {
"version": "0.5.5",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
"integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
"dev": true,
"requires": {
"minimist": "^1.2.5"
}
},
"ms": { "ms": {
"version": "2.1.2", "version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
@@ -1589,6 +1927,12 @@
"integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==",
"dev": true "dev": true
}, },
"natural-compare": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz",
"integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=",
"dev": true
},
"normalize-package-data": { "normalize-package-data": {
"version": "2.5.0", "version": "2.5.0",
"resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz",
@@ -1631,6 +1975,20 @@
"mimic-fn": "^2.1.0" "mimic-fn": "^2.1.0"
} }
}, },
"optionator": {
"version": "0.9.1",
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz",
"integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==",
"dev": true,
"requires": {
"deep-is": "^0.1.3",
"fast-levenshtein": "^2.0.6",
"levn": "^0.4.1",
"prelude-ls": "^1.2.1",
"type-check": "^0.4.0",
"word-wrap": "^1.2.3"
}
},
"ora": { "ora": {
"version": "4.0.4", "version": "4.0.4",
"resolved": "https://registry.npmjs.org/ora/-/ora-4.0.4.tgz", "resolved": "https://registry.npmjs.org/ora/-/ora-4.0.4.tgz",
@@ -1724,6 +2082,15 @@
} }
} }
}, },
"parent-module": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
"integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==",
"dev": true,
"requires": {
"callsites": "^3.0.0"
}
},
"parse-json": { "parse-json": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz",
@@ -1752,6 +2119,12 @@
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
"dev": true "dev": true
}, },
"path-key": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
"integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
"dev": true
},
"path-parse": { "path-parse": {
"version": "1.0.6", "version": "1.0.6",
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz",
@@ -1840,6 +2213,12 @@
"irregular-plurals": "^3.2.0" "irregular-plurals": "^3.2.0"
} }
}, },
"prelude-ls": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz",
"integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==",
"dev": true
},
"prepend-http": { "prepend-http": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz", "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz",
@@ -1855,6 +2234,12 @@
"parse-ms": "^2.1.0" "parse-ms": "^2.1.0"
} }
}, },
"progress": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz",
"integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==",
"dev": true
},
"pump": { "pump": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz",
@@ -1865,6 +2250,12 @@
"once": "^1.3.1" "once": "^1.3.1"
} }
}, },
"punycode": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==",
"dev": true
},
"pupa": { "pupa": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/pupa/-/pupa-2.0.1.tgz", "resolved": "https://registry.npmjs.org/pupa/-/pupa-2.0.1.tgz",
@@ -1927,6 +2318,12 @@
"picomatch": "^2.2.1" "picomatch": "^2.2.1"
} }
}, },
"regexpp": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.1.0.tgz",
"integrity": "sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==",
"dev": true
},
"registry-auth-token": { "registry-auth-token": {
"version": "4.1.1", "version": "4.1.1",
"resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-4.1.1.tgz", "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-4.1.1.tgz",
@@ -2062,6 +2459,21 @@
"integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=",
"dev": true "dev": true
}, },
"shebang-command": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
"integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
"dev": true,
"requires": {
"shebang-regex": "^3.0.0"
}
},
"shebang-regex": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
"integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
"dev": true
},
"signal-exit": { "signal-exit": {
"version": "3.0.3", "version": "3.0.3",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz",
@@ -2239,6 +2651,99 @@
"has-flag": "^4.0.0" "has-flag": "^4.0.0"
} }
}, },
"table": {
"version": "5.4.6",
"resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz",
"integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==",
"dev": true,
"requires": {
"ajv": "^6.10.2",
"lodash": "^4.17.14",
"slice-ansi": "^2.1.0",
"string-width": "^3.0.0"
},
"dependencies": {
"ansi-regex": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz",
"integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==",
"dev": true
},
"ansi-styles": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
"integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
"dev": true,
"requires": {
"color-convert": "^1.9.0"
}
},
"astral-regex": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz",
"integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==",
"dev": true
},
"color-convert": {
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
"integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
"dev": true,
"requires": {
"color-name": "1.1.3"
}
},
"color-name": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=",
"dev": true
},
"emoji-regex": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz",
"integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==",
"dev": true
},
"is-fullwidth-code-point": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz",
"integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=",
"dev": true
},
"slice-ansi": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz",
"integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==",
"dev": true,
"requires": {
"ansi-styles": "^3.2.0",
"astral-regex": "^1.0.0",
"is-fullwidth-code-point": "^2.0.0"
}
},
"string-width": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz",
"integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==",
"dev": true,
"requires": {
"emoji-regex": "^7.0.1",
"is-fullwidth-code-point": "^2.0.0",
"strip-ansi": "^5.1.0"
}
},
"strip-ansi": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz",
"integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==",
"dev": true,
"requires": {
"ansi-regex": "^4.1.0"
}
}
}
},
"temp-dir": { "temp-dir": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/temp-dir/-/temp-dir-2.0.0.tgz", "resolved": "https://registry.npmjs.org/temp-dir/-/temp-dir-2.0.0.tgz",
@@ -2251,6 +2756,12 @@
"integrity": "sha512-a6sumDlzyHVJWb8+YofY4TW112G6p2FCPEAFk+59gIYHv3XHRhm9ltVQ9kli4hNWeQBwSpe8cRN25x0ROunMOw==", "integrity": "sha512-a6sumDlzyHVJWb8+YofY4TW112G6p2FCPEAFk+59gIYHv3XHRhm9ltVQ9kli4hNWeQBwSpe8cRN25x0ROunMOw==",
"dev": true "dev": true
}, },
"text-table": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz",
"integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=",
"dev": true
},
"time-zone": { "time-zone": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/time-zone/-/time-zone-1.0.0.tgz", "resolved": "https://registry.npmjs.org/time-zone/-/time-zone-1.0.0.tgz",
@@ -2278,6 +2789,15 @@
"integrity": "sha1-n5up2e+odkw4dpi8v+sshI8RrbM=", "integrity": "sha1-n5up2e+odkw4dpi8v+sshI8RrbM=",
"dev": true "dev": true
}, },
"type-check": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
"integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==",
"dev": true,
"requires": {
"prelude-ls": "^1.2.1"
}
},
"type-fest": { "type-fest": {
"version": "0.3.1", "version": "0.3.1",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.3.1.tgz", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.3.1.tgz",
@@ -2335,6 +2855,15 @@
} }
} }
}, },
"uri-js": {
"version": "4.2.2",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz",
"integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==",
"dev": true,
"requires": {
"punycode": "^2.1.0"
}
},
"url-parse-lax": { "url-parse-lax": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-3.0.0.tgz", "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-3.0.0.tgz",
@@ -2344,6 +2873,12 @@
"prepend-http": "^2.0.0" "prepend-http": "^2.0.0"
} }
}, },
"v8-compile-cache": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz",
"integrity": "sha512-8OQ9CL+VWyt3JStj7HX7/ciTL2V3Rl1Wf5OL+SNTm0yK1KvtReVulksyeRnCANHHuUxHlQig+JJDlUhBt1NQDQ==",
"dev": true
},
"validate-npm-package-license": { "validate-npm-package-license": {
"version": "3.0.4", "version": "3.0.4",
"resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz",
@@ -2369,6 +2904,15 @@
"integrity": "sha512-ZMjC3ho+KXo0BfJb7JgtQ5IBuvnShdlACNkKkdsqBmYw3bPAaJfPeYUo6tLUaT5tG/Gkh7xkpBhKRQ9e7pyg9Q==", "integrity": "sha512-ZMjC3ho+KXo0BfJb7JgtQ5IBuvnShdlACNkKkdsqBmYw3bPAaJfPeYUo6tLUaT5tG/Gkh7xkpBhKRQ9e7pyg9Q==",
"dev": true "dev": true
}, },
"which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"dev": true,
"requires": {
"isexe": "^2.0.0"
}
},
"which-module": { "which-module": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz",
@@ -2384,6 +2928,12 @@
"string-width": "^4.0.0" "string-width": "^4.0.0"
} }
}, },
"word-wrap": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",
"integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==",
"dev": true
},
"wrap-ansi": { "wrap-ansi": {
"version": "6.2.0", "version": "6.2.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
@@ -2401,6 +2951,15 @@
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"dev": true "dev": true
}, },
"write": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz",
"integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==",
"dev": true,
"requires": {
"mkdirp": "^0.5.1"
}
},
"write-file-atomic": { "write-file-atomic": {
"version": "3.0.3", "version": "3.0.3",
"resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.3.tgz", "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.3.tgz",
+2 -1
View File
@@ -8,6 +8,7 @@
"test": "ava" "test": "ava"
}, },
"devDependencies": { "devDependencies": {
"ava": "^3.8.2" "ava": "^3.8.2",
"eslint": "^7.5.0"
} }
} }
+34 -22
View File
@@ -19,41 +19,53 @@ this program. If not, see <http s ://www.gnu.org/licenses/>.
const { extensionUtils } = imports.misc; const { extensionUtils } = imports.misc;
const Me = extensionUtils.getCurrentExtension(); const Me = extensionUtils.getCurrentExtension();
const shell_minor_version = parseInt(imports.misc.config.PACKAGE_VERSION.split('.')[1]); const shellMinorVersion = parseInt(imports.misc.config.PACKAGE_VERSION.split('.')[1]);
function init_translations(domain) { function initTranslations(domain) {
if ( shell_minor_version <= 30 ) return Me.imports.convenience.initTranslations(domain); if (shellMinorVersion <= 30)
else return extensionUtils.initTranslations(domain); return Me.imports.convenience.initTranslations(domain);
else
return extensionUtils.initTranslations(domain);
} }
function extension_manager_initialized() { function extensionManagerInitialized() {
if ( shell_minor_version > 32 ) return imports.ui.main.extensionManager._initialized; if (shellMinorVersion > 32)
else return imports.ui.extensionSystem.initted; return imports.ui.main.extensionManager._initialized;
else
return imports.ui.extensionSystem.initted;
} }
function extension_manager_lookup(uuid) { function extensionManagerLookup(uuid) {
if ( shell_minor_version > 32 ) return imports.ui.main.extensionManager.lookup(uuid); if (shellMinorVersion > 32)
else return extensionUtils.extensions[uuid] || null; return imports.ui.main.extensionManager.lookup(uuid);
else
return extensionUtils.extensions[uuid] || null;
} }
function get_extension_settings() { function getExtensionSettings() {
if ( shell_minor_version <= 30 ) return Me.imports.convenience.getSettings(); if (shellMinorVersion <= 30)
else return extensionUtils.getSettings(); return Me.imports.convenience.getSettings();
else
return extensionUtils.getSettings();
} }
function key_binding_auto_repeat() { function keyBindingAutoRepeat() {
// if version is less then 3.30 the keybinding flags are NONE // if version is less then 3.30 the keybinding flags are NONE
if (shell_minor_version < 30) return imports.gi.Meta.KeyBindingFlags.NONE; if (shellMinorVersion < 30)
else return imports.gi.Meta.KeyBindingFlags.IGNORE_AUTOREPEAT; return imports.gi.Meta.KeyBindingFlags.NONE;
}; else
return imports.gi.Meta.KeyBindingFlags.IGNORE_AUTOREPEAT;
}
function get_actor(subject) { function getActor(subject) {
if (shell_minor_version > 34) return subject; if (shellMinorVersion > 34)
else return subject.actor; return subject;
}; else
return subject.actor;
}
+48 -51
View File
@@ -19,12 +19,11 @@ this program. If not, see <http s ://www.gnu.org/licenses/>.
'use strict'; 'use strict';
const { extensionUtils } = imports.misc; const { extensionUtils } = imports.misc;
const { main } = imports.ui;
const Me = extensionUtils.getCurrentExtension(); const Me = extensionUtils.getCurrentExtension();
const compat = Me.imports.compat; const compat = Me.imports.compat;
const { log_debug } = Me.imports.utils; const { logDebug } = Me.imports.utils;
const { SettingsManager } = Me.imports.modules.SettingsManager; const { SettingsManager } = Me.imports.modules.SettingsManager;
const { Timer } = Me.imports.modules.Timer; const { Timer } = Me.imports.modules.Timer;
const { GtkThemer } = Me.imports.modules.GtkThemer; const { GtkThemer } = Me.imports.modules.GtkThemer;
@@ -47,65 +46,63 @@ var commander = null;
function init() { function init() {
log_debug('Initializing extension...'); logDebug('Initializing extension...');
compat.init_translations(Me.metadata.uuid); compat.initTranslations(Me.metadata.uuid);
log_debug('Extension initialized.'); logDebug('Extension initialized.');
} }
function enable() { function enable() {
this._await_extensionManager_init().then(() => { _awaitExtensionManagerInit().then(() => {
log_debug('Enabling extension...'); logDebug('Enabling extension...');
settingsManager = new SettingsManager(); settingsManager = new SettingsManager();
timer = new Timer(); timer = new Timer();
gtkThemer = new GtkThemer(); gtkThemer = new GtkThemer();
shellThemer = new ShellThemer(); shellThemer = new ShellThemer();
iconThemer = new IconThemer(); iconThemer = new IconThemer();
cursorThemer = new CursorThemer(); cursorThemer = new CursorThemer();
backgrounder = new Backgrounder(); backgrounder = new Backgrounder();
commander = new Commander(); commander = new Commander();
settingsManager.enable(); settingsManager.enable();
gtkThemer.enable(); gtkThemer.enable();
shellThemer.enable(); shellThemer.enable();
iconThemer.enable(); iconThemer.enable();
cursorThemer.enable(); cursorThemer.enable();
backgrounder.enable(); backgrounder.enable();
commander.enable(); commander.enable();
timer.enable(); timer.enable();
enabled = true; enabled = true;
log_debug('Extension enabled.'); logDebug('Extension enabled.');
}); });
} }
function disable() { function disable() {
log_debug('Disabling extension...'); logDebug('Disabling extension...');
enabled = false; enabled = false;
gtkThemer.disable(); gtkThemer.disable();
shellThemer.disable(); shellThemer.disable();
iconThemer.disable(); iconThemer.disable();
cursorThemer.disable(); cursorThemer.disable();
backgrounder.disable(); backgrounder.disable();
commander.disable(); commander.disable();
timer.disable(); timer.disable();
settingsManager.disable(); settingsManager.disable();
settingsManager = null; settingsManager = null;
timer = null; timer = null;
gtkThemer = null; gtkThemer = null;
shellThemer = null; shellThemer = null;
iconThemer = null; iconThemer = null;
cursorThemer = null; cursorThemer = null;
backgrounder = null; backgrounder = null;
commander = null; commander = null;
log_debug('Extension disabled.'); logDebug('Extension disabled.');
} }
async function _await_extensionManager_init() { async function _awaitExtensionManagerInit() {
log_debug('Waiting for the Extension Manager to be initialized...'); logDebug('Waiting for the Extension Manager to be initialized...');
while ( true ) { while (!compat.extensionManagerInitialized())
if ( compat.extension_manager_initialized() ) return; await undefined; // eslint-disable-line no-await-in-loop
await null;
}
} }
+86 -81
View File
@@ -16,13 +16,12 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see <http s ://www.gnu.org/licenses/>. this program. If not, see <http s ://www.gnu.org/licenses/>.
*/ */
const { GLib } = imports.gi;
const { extensionUtils } = imports.misc; const { extensionUtils } = imports.misc;
const Me = extensionUtils.getCurrentExtension(); const Me = extensionUtils.getCurrentExtension();
const e = Me.imports.extension; const e = Me.imports.extension;
const { log_debug } = Me.imports.utils; const { logDebug } = Me.imports.utils;
/** /**
* The Backgrounder is responsible for changing the desktop background * The Backgrounder is responsible for changing the desktop background
@@ -33,98 +32,104 @@ const { log_debug } = Me.imports.utils;
*/ */
var Backgrounder = class { var Backgrounder = class {
enable() { constructor() {
log_debug('Enabling Backgrounder...'); this._backgroundsStatusChangedConnect = null;
this._watch_status(); this._backgroundTimeChangedConnect = null;
if ( e.settingsManager.backgrounds_enabled ) { this._backgroundChangedConnect = null;
this._connect_settings(); this._timeChangedConnect = null;
this._connect_timer(); }
}
log_debug('Backgrounder enabled.');
}
disable() { enable() {
log_debug('Disabling Backgrounder...'); logDebug('Enabling Backgrounder...');
this._disconnect_timer(); this._watchStatus();
this._disconnect_settings(); if (e.settingsManager.backgroundsEnabled) {
this._unwatch_status(); this._connectSettings();
log_debug('Backgrounder disabled.'); this._connectTimer();
} }
logDebug('Backgrounder enabled.');
}
disable() {
logDebug('Disabling Backgrounder...');
this._disconnectTimer();
this._disconnectSettings();
this._unwatchStatus();
logDebug('Backgrounder disabled.');
}
_watch_status() { _watchStatus() {
log_debug('Watching backgrounds status...'); logDebug('Watching backgrounds status...');
this._backgrounds_status_changed_connect = e.settingsManager.connect('backgrounds-status-changed', this._on_backgrounds_status_changed.bind(this)); this._backgroundsStatusChangedConnect = e.settingsManager.connect('backgrounds-status-changed', this._onBackgroundsStatusChanged.bind(this));
} }
_unwatch_status() { _unwatchStatus() {
if ( this._backgrounds_status_changed_connect ) { if (this._backgroundsStatusChangedConnect) {
e.settingsManager.disconnect(this._backgrounds_status_changed_connect); e.settingsManager.disconnect(this._backgroundsStatusChangedConnect);
this._backgrounds_status_changed_connect = null; this._backgroundsStatusChangedConnect = null;
} }
log_debug('Stopped watching backgrounds status.'); logDebug('Stopped watching backgrounds status.');
} }
_connect_settings() { _connectSettings() {
log_debug('Connecting Backgrounder to settings...'); logDebug('Connecting Backgrounder to settings...');
this._background_time_changed_connect = e.settingsManager.connect('background-time-changed', this._on_background_time_changed.bind(this)); this._backgroundTimeChangedConnect = e.settingsManager.connect('background-time-changed', this._onBackgroundTimeChanged.bind(this));
this._background_changed_connect = e.settingsManager.connect('background-changed', this._on_background_changed.bind(this)); this._backgroundChangedConnect = e.settingsManager.connect('background-changed', this._onBackgroundChanged.bind(this));
} }
_disconnect_settings() { _disconnectSettings() {
if ( this._background_time_changed_connect ) { if (this._backgroundTimeChangedConnect) {
e.settingsManager.disconnect(this._background_time_changed_connect); e.settingsManager.disconnect(this._backgroundTimeChangedConnect);
this._background_time_changed_connect = null; this._backgroundTimeChangedConnect = null;
} }
if ( this._background_changed_connect ) { if (this._backgroundChangedConnect) {
e.settingsManager.disconnect(this._background_changed_connect); e.settingsManager.disconnect(this._backgroundChangedConnect);
this._background_changed_connect = null; this._backgroundChangedConnect = null;
} }
log_debug('Disconnected Backgrounder from settings.'); logDebug('Disconnected Backgrounder from settings.');
} }
_connect_timer() { _connectTimer() {
log_debug('Connecting Backgrounder to Timer...'); logDebug('Connecting Backgrounder to Timer...');
this._time_changed_connect = e.timer.connect('time-changed', this._on_time_changed.bind(this)); this._timeChangedConnect = e.timer.connect('time-changed', this._onTimeChanged.bind(this));
} }
_disconnect_timer() { _disconnectTimer() {
if ( this._time_changed_connect ) { if (this._timeChangedConnect) {
e.timer.disconnect(this._time_changed_connect); e.timer.disconnect(this._timeChangedConnect);
this._time_changed_connect = null; this._timeChangedConnect = null;
} }
log_debug('Disconnected Backgrounder from Timer.'); logDebug('Disconnected Backgrounder from Timer.');
} }
_on_backgrounds_status_changed(settings, enabled) { _onBackgroundsStatusChanged(_settings, _enabled) {
this.disable(); this.disable();
this.enable(); this.enable();
} }
_on_background_time_changed(settings, changed_background_time) { _onBackgroundTimeChanged(_settings, changedBackgroundTime) {
if ( changed_background_time === e.timer.time ) { if (changedBackgroundTime === e.timer.time)
this._change_background(changed_background_time); this._changeBackground(changedBackgroundTime);
} }
}
_on_background_changed(settings, new_background) { _onBackgroundChanged(_settings, newBackground) {
switch (e.timer.time) { switch (e.timer.time) {
case 'day': case 'day':
e.settingsManager.background_day = new_background; e.settingsManager.backgroundDay = newBackground;
break; break;
case 'night': case 'night':
e.settingsManager.background_night = new_background; e.settingsManager.backgroundNight = newBackground;
} }
} }
_on_time_changed(timer, new_time) { _onTimeChanged(_timer, newTime) {
this._change_background(new_time); this._changeBackground(newTime);
} }
_change_background(time) { _changeBackground(time) {
e.settingsManager.background = time === 'day' ? e.settingsManager.background_day : e.settingsManager.background_night; e.settingsManager.background = time === 'day' ? e.settingsManager.backgroundDay : e.settingsManager.backgroundNight;
} }
} };
+54 -50
View File
@@ -22,7 +22,7 @@ const { extensionUtils } = imports.misc;
const Me = extensionUtils.getCurrentExtension(); const Me = extensionUtils.getCurrentExtension();
const e = Me.imports.extension; const e = Me.imports.extension;
const { log_debug } = Me.imports.utils; const { logDebug } = Me.imports.utils;
/** /**
@@ -30,64 +30,68 @@ const { log_debug } = Me.imports.utils;
*/ */
var Commander = class { var Commander = class {
enable() { constructor() {
log_debug('Enabling Commander...'); this._commandsStatusChangedConnect = null;
this._watch_status(); this._timeChangedConnect = null;
if ( e.settingsManager.commands_enabled ) { }
this._connect_timer();
}
log_debug('Commander enabled.');
}
disable() { enable() {
log_debug('Disabling Commander...'); logDebug('Enabling Commander...');
this._disconnect_timer(); this._watchStatus();
this._unwatch_status(); if (e.settingsManager.commandsEnabled)
log_debug('Commander disabled.'); this._connectTimer();
} logDebug('Commander enabled.');
}
disable() {
logDebug('Disabling Commander...');
this._disconnectTimer();
this._unwatchStatus();
logDebug('Commander disabled.');
}
_watch_status() { _watchStatus() {
log_debug('Watching commands status...'); logDebug('Watching commands status...');
this._commands_status_changed_connect = e.settingsManager.connect('commands-status-changed', this._on_commands_status_changed.bind(this)); this._commandsStatusChangedConnect = e.settingsManager.connect('commands-status-changed', this._onCommandsStatusChanged.bind(this));
} }
_unwatch_status() { _unwatchStatus() {
if ( this._commands_status_changed_connect ) { if (this._commandsStatusChangedConnect) {
e.settingsManager.disconnect(this._commands_status_changed_connect); e.settingsManager.disconnect(this._commandsStatusChangedConnect);
this._commands_status_changed_connect = null; this._commandsStatusChangedConnect = null;
} }
log_debug('Stopped watching commands status.'); logDebug('Stopped watching commands status.');
} }
_connect_timer() { _connectTimer() {
log_debug('Connecting Commander to Timer...'); logDebug('Connecting Commander to Timer...');
this._time_changed_connect = e.timer.connect('time-changed', this._on_time_changed.bind(this)); this._timeChangedConnect = e.timer.connect('time-changed', this._onTimeChanged.bind(this));
} }
_disconnect_timer() { _disconnectTimer() {
if ( this._time_changed_connect ) { if (this._timeChangedConnect) {
e.timer.disconnect(this._time_changed_connect); e.timer.disconnect(this._timeChangedConnect);
this._time_changed_connect = null; this._timeChangedConnect = null;
} }
log_debug('Disconnecting Commander from Timer.'); logDebug('Disconnecting Commander from Timer.');
} }
_on_commands_status_changed(settings, enabled) { _onCommandsStatusChanged(_settings, _enabled) {
this.disable(); this.disable();
this.enable(); this.enable();
} }
_on_time_changed(timer, new_time) { _onTimeChanged(_timer, newTime) {
this._spawn_command(new_time); this._spawnCommand(newTime);
} }
_spawn_command(time) { _spawnCommand(time) {
const command = time === 'day' ? e.settingsManager.command_sunrise : e.settingsManager.command_sunset; const command = time === 'day' ? e.settingsManager.commandSunrise : e.settingsManager.commandSunset;
GLib.spawn_async(null, ['sh', '-c', command], null, GLib.SpawnFlags.SEARCH_PATH, null); GLib.spawn_async(null, ['sh', '-c', command], null, GLib.SpawnFlags.SEARCH_PATH, null);
log_debug(`Spawned ${time} command.`); logDebug(`Spawned ${time} command.`);
} }
} };
+111 -105
View File
@@ -22,7 +22,7 @@ const { main } = imports.ui;
const Me = extensionUtils.getCurrentExtension(); const Me = extensionUtils.getCurrentExtension();
const e = Me.imports.extension; const e = Me.imports.extension;
const { log_debug } = Me.imports.utils; const { logDebug } = Me.imports.utils;
/** /**
@@ -31,125 +31,131 @@ const { log_debug } = Me.imports.utils;
*/ */
var CursorThemer = class { var CursorThemer = class {
enable() { constructor() {
log_debug('Enabling Cursor Themer...'); this._cursorVariantsStatusChangedConnect = null;
this._watch_status(); this._cursorVariantChangedConnect = null;
this._save_original_theme(); this._cursorThemeChangedConnect = null;
if ( e.settingsManager.cursor_variants_enabled ) { this._timeChangedConnect = null;
this._connect_settings(); }
this._connect_timer();
}
log_debug('Cursor Themer enabled.');
}
disable() { enable() {
log_debug('Disabling Cursor Themer...'); logDebug('Enabling Cursor Themer...');
this._disconnect_timer(); this._watchStatus();
this._disconnect_settings(); this._saveOriginalTheme();
this._reset_original_theme(); if (e.settingsManager.cursorVariantsEnabled) {
this._unwatch_status(); this._connectSettings();
log_debug('Cursor Themer disabled.'); this._connectTimer();
} }
logDebug('Cursor Themer enabled.');
}
disable() {
logDebug('Disabling Cursor Themer...');
this._disconnectTimer();
this._disconnectSettings();
this._resetOriginalTheme();
this._unwatchStatus();
logDebug('Cursor Themer disabled.');
}
_watch_status() { _watchStatus() {
log_debug('Watching cursor variants status...'); logDebug('Watching cursor variants status...');
this._cursor_variants_status_changed_connect = e.settingsManager.connect('cursor-variants-status-changed', this._on_cursor_variants_status_changed.bind(this)); this._cursorVariantsStatusChangedConnect = e.settingsManager.connect('cursor-variants-status-changed', this._onCursorVariantsStatusChanged.bind(this));
} }
_unwatch_status() { _unwatchStatus() {
if ( this._cursor_variants_status_changed_connect ) { if (this._cursorVariantsStatusChangedConnect) {
e.settingsManager.disconnect(this._cursor_variants_status_changed_connect); e.settingsManager.disconnect(this._cursorVariantsStatusChangedConnect);
this._cursor_variants_status_changed_connect = null; this._cursorVariantsStatusChangedConnect = null;
} }
log_debug('Stopped watching cursor variants status.'); logDebug('Stopped watching cursor variants status.');
} }
_connect_settings() { _connectSettings() {
log_debug('Connecting Cursor Themer to settings...'); logDebug('Connecting Cursor Themer to settings...');
this._cursor_variant_changed_connect = e.settingsManager.connect('cursor-variant-changed', this._on_cursor_variant_changed.bind(this)); this._cursorVariantChangedConnect = e.settingsManager.connect('cursor-variant-changed', this._onCursorVariantChanged.bind(this));
this._cursor_theme_changed_connect = e.settingsManager.connect('cursor-theme-changed', this._on_cursor_theme_changed.bind(this)); this._cursorThemeChangedConnect = e.settingsManager.connect('cursor-theme-changed', this._onCursorThemeChanged.bind(this));
} }
_disconnect_settings() { _disconnectSettings() {
if ( this._cursor_variant_changed_connect ) { if (this._cursorVariantChangedConnect) {
e.settingsManager.disconnect(this._cursor_variant_changed_connect); e.settingsManager.disconnect(this._cursorVariantChangedConnect);
this._cursor_variant_changed_connect = null; this._cursorVariantChangedConnect = null;
} }
if ( this._cursor_theme_changed_connect ) { if (this._cursorThemeChangedConnect) {
e.settingsManager.disconnect(this._cursor_theme_changed_connect); e.settingsManager.disconnect(this._cursorThemeChangedConnect);
this._cursor_theme_changed_connect = null; this._cursorThemeChangedConnect = null;
} }
log_debug('Disconnected Cursor Themer from settings.'); logDebug('Disconnected Cursor Themer from settings.');
} }
_connect_timer() { _connectTimer() {
log_debug('Connecting Cursor Themer to Timer...'); logDebug('Connecting Cursor Themer to Timer...');
this._time_changed_connect = e.timer.connect('time-changed', this._on_time_changed.bind(this)); this._timeChangedConnect = e.timer.connect('time-changed', this._onTimeChanged.bind(this));
} }
_disconnect_timer() { _disconnectTimer() {
if ( this._time_changed_connect ) { if (this._timeChangedConnect) {
e.timer.disconnect(this._time_changed_connect); e.timer.disconnect(this._timeChangedConnect);
this._time_changed_connect = null; this._timeChangedConnect = null;
} }
log_debug('Disconnected Cursor Themer from Timer.'); logDebug('Disconnected Cursor Themer from Timer.');
} }
_on_cursor_variants_status_changed(settings, enabled) { _onCursorVariantsStatusChanged(_settings, _enabled) {
this.disable(); this.disable();
this.enable(); this.enable();
} }
_on_cursor_variant_changed(settings, changed_variant_time) { _onCursorVariantChanged(_settings, changedVariantTime) {
if ( changed_variant_time === e.timer.time ) { if (changedVariantTime === e.timer.time)
this._set_variant(changed_variant_time); this._setVariant(changedVariantTime);
} }
}
_on_cursor_theme_changed(settings, new_theme) { _onCursorThemeChanged(_settings, newTheme) {
switch (e.timer.time) { switch (e.timer.time) {
case 'day': case 'day':
e.settingsManager.cursor_variant_day = new_theme; e.settingsManager.cursorVariantDay = newTheme;
break; break;
case 'night': case 'night':
e.settingsManager.cursor_variant_night = new_theme; e.settingsManager.cursorVariantNight = newTheme;
} }
this._set_variant(e.timer.time); this._setVariant(e.timer.time);
} }
_on_time_changed(timer, new_time) { _onTimeChanged(_timer, newTime) {
this._set_variant(new_time); this._setVariant(newTime);
} }
_set_variant(time) { _setVariant(time) {
log_debug(`Setting the cursor ${time} variant...`); logDebug(`Setting the cursor ${time} variant...`);
switch (time) { switch (time) {
case 'day': case 'day':
e.settingsManager.cursor_theme = e.settingsManager.cursor_variant_day; e.settingsManager.cursorTheme = e.settingsManager.cursorVariantDay;
break; break;
case 'night': case 'night':
e.settingsManager.cursor_theme = e.settingsManager.cursor_variant_night; e.settingsManager.cursorTheme = e.settingsManager.cursorVariantNight;
break; break;
case 'original': case 'original':
e.settingsManager.cursor_theme = e.settingsManager.cursor_variant_original; e.settingsManager.cursorTheme = e.settingsManager.cursorVariantOriginal;
break; break;
} }
} }
_save_original_theme() { _saveOriginalTheme() {
e.settingsManager.cursor_variant_original = e.settingsManager.cursor_theme; e.settingsManager.cursorVariantOriginal = e.settingsManager.cursorTheme;
} }
_reset_original_theme() { _resetOriginalTheme() {
// We don't reset the theme when locking the session to prevent // We don't reset the theme when locking the session to prevent
// flicker on unlocking // flicker on unlocking
if ( !main.screenShield.locked ) { if (!main.screenShield.locked) {
log_debug('Resetting to the user\'s original cursor theme...'); logDebug('Resetting to the user\'s original cursor theme...');
this._set_variant('original'); this._setVariant('original');
} }
} }
} };
+133 -131
View File
@@ -16,14 +16,13 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see <http s ://www.gnu.org/licenses/>. this program. If not, see <http s ://www.gnu.org/licenses/>.
*/ */
const { Gio, GLib, Gtk } = imports.gi;
const { extensionUtils } = imports.misc; const { extensionUtils } = imports.misc;
const { main } = imports.ui; const { main } = imports.ui;
const Me = extensionUtils.getCurrentExtension(); const Me = extensionUtils.getCurrentExtension();
const e = Me.imports.extension; const e = Me.imports.extension;
const { log_debug, log_error, get_installed_gtk_themes } = Me.imports.utils; const { logDebug, notifyError, getInstalledGtkThemes } = Me.imports.utils;
const { GtkVariants } = Me.imports.modules.GtkVariants; const { GtkVariants } = Me.imports.modules.GtkVariants;
const Gettext = imports.gettext.domain(Me.metadata.uuid); const Gettext = imports.gettext.domain(Me.metadata.uuid);
@@ -43,155 +42,158 @@ const _ = Gettext.gettext;
*/ */
var GtkThemer = class { var GtkThemer = class {
enable() { constructor() {
log_debug('Enabling GTK Themer...'); this._gtkVariantsStatusChangedConnect = null;
try { this._gtkVariantChangedConnect = null;
this._watch_status(); this._gtkThemeChangedConnect = null;
this._save_original_theme(); this._timeChangedConnect = null;
if ( e.settingsManager.gtk_variants_enabled ) { }
this._update_variants();
this._connect_settings();
this._connect_timer();
}
}
catch(e) {
log_error(e);
}
log_debug('GTK Themer enabled.');
}
disable() { enable() {
log_debug('Disabling GTK Themer...'); logDebug('Enabling GTK Themer...');
this._disconnect_timer(); try {
this._disconnect_settings(); this._watchStatus();
this._reset_original_theme(); this._saveOriginalTheme();
this._unwatch_status(); if (e.settingsManager.gtkVariantsEnabled) {
log_debug('GTK Themer disabled.'); this._updateVariants();
} this._connectSettings();
this._connectTimer();
}
} catch (error) {
notifyError(error);
}
logDebug('GTK Themer enabled.');
}
disable() {
logDebug('Disabling GTK Themer...');
this._disconnectTimer();
this._disconnectSettings();
this._resetOriginalTheme();
this._unwatchStatus();
logDebug('GTK Themer disabled.');
}
_watch_status() { _watchStatus() {
log_debug('Watching GTK variants status...'); logDebug('Watching GTK variants status...');
this._gtk_variants_status_changed_connect = e.settingsManager.connect('gtk-variants-status-changed', this._on_gtk_variants_status_changed.bind(this)); this._gtkVariantsStatusChangedConnect = e.settingsManager.connect('gtk-variants-status-changed', this._onGtkVariantsStatusChanged.bind(this));
} }
_unwatch_status() { _unwatchStatus() {
if ( this._gtk_variants_status_changed_connect ) { if (this._gtkVariantsStatusChangedConnect) {
e.settingsManager.disconnect(this._gtk_variants_status_changed_connect); e.settingsManager.disconnect(this._gtkVariantsStatusChangedConnect);
this._gtk_variants_status_changed_connect = null; this._gtkVariantsStatusChangedConnect = null;
} }
log_debug('Stopped watching GTK variants status.'); logDebug('Stopped watching GTK variants status.');
} }
_connect_settings() { _connectSettings() {
log_debug('Connecting GTK Themer to settings...'); logDebug('Connecting GTK Themer to settings...');
this._gtk_variant_changed_connect = e.settingsManager.connect('gtk-variant-changed', this._on_gtk_variant_changed.bind(this)); this._gtkVariantChangedConnect = e.settingsManager.connect('gtk-variant-changed', this._onGtkVariantChanged.bind(this));
this._gtk_theme_changed_connect = e.settingsManager.connect('gtk-theme-changed', this._on_gtk_theme_changed.bind(this)); this._gtkThemeChangedConnect = e.settingsManager.connect('gtk-theme-changed', this._onGtkThemeChanged.bind(this));
} }
_disconnect_settings() { _disconnectSettings() {
if ( this._gtk_variant_changed_connect ) { if (this._gtkVariantChangedConnect) {
e.settingsManager.disconnect(this._gtk_variant_changed_connect); e.settingsManager.disconnect(this._gtkVariantChangedConnect);
this._gtk_variant_changed_connect = null; this._gtkVariantChangedConnect = null;
} }
if ( this._gtk_theme_changed_connect ) { if (this._gtkThemeChangedConnect) {
e.settingsManager.disconnect(this._gtk_theme_changed_connect); e.settingsManager.disconnect(this._gtkThemeChangedConnect);
this._gtk_theme_changed_connect = null; this._gtkThemeChangedConnect = null;
} }
log_debug('Disconnected GTK Themer from settings.'); logDebug('Disconnected GTK Themer from settings.');
} }
_connect_timer() { _connectTimer() {
log_debug('Connecting GTK Themer to Timer...'); logDebug('Connecting GTK Themer to Timer...');
this._time_changed_connect = e.timer.connect('time-changed', this._on_time_changed.bind(this)); this._timeChangedConnect = e.timer.connect('time-changed', this._onTimeChanged.bind(this));
} }
_disconnect_timer() { _disconnectTimer() {
if ( this._time_changed_connect ) { if (this._timeChangedConnect) {
e.timer.disconnect(this._time_changed_connect); e.timer.disconnect(this._timeChangedConnect);
this._time_changed_connect = null; this._timeChangedConnect = null;
} }
log_debug('Disconnected GTK Themer from Timer.'); logDebug('Disconnected GTK Themer from Timer.');
} }
_on_gtk_variants_status_changed(settings, enabled) { _onGtkVariantsStatusChanged(_settings, _enabled) {
this.disable(); this.disable();
this.enable(); this.enable();
} }
_on_gtk_variant_changed(settings, changed_variant_time) { _onGtkVariantChanged(_settings, changedVariantTime) {
if ( changed_variant_time === e.timer.time ) { if (changedVariantTime === e.timer.time)
this._set_variant(changed_variant_time); this._setVariant(changedVariantTime);
} }
}
_on_gtk_theme_changed(settings, new_theme) { _onGtkThemeChanged(_settings, _newTheme) {
try { try {
this._update_variants(); this._updateVariants();
this._set_variant(e.timer.time); this._setVariant(e.timer.time);
} } catch (error) {
catch(e) { notifyError(error);
log_error(e); }
} }
}
_on_time_changed(timer, new_time) { _onTimeChanged(_timer, newTime) {
this._set_variant(new_time); this._setVariant(newTime);
} }
_are_variants_up_to_date() { _areVariantsUpToDate() {
return ( e.settingsManager.gtk_theme === e.settingsManager.gtk_variant_day || e.settingsManager.gtk_theme === e.settingsManager.gtk_variant_night ); return e.settingsManager.gtkTheme === e.settingsManager.gtkVariantDay || e.settingsManager.gtkTheme === e.settingsManager.gtkVariantNight;
} }
_set_variant(time) { _setVariant(time) {
log_debug(`Setting the GTK ${time} variant...`); logDebug(`Setting the GTK ${time} variant...`);
switch (time) { switch (time) {
case 'day': case 'day':
e.settingsManager.gtk_theme = e.settingsManager.gtk_variant_day; e.settingsManager.gtkTheme = e.settingsManager.gtkVariantDay;
break; break;
case 'night': case 'night':
e.settingsManager.gtk_theme = e.settingsManager.gtk_variant_night; e.settingsManager.gtkTheme = e.settingsManager.gtkVariantNight;
break; break;
case 'original': case 'original':
e.settingsManager.gtk_theme = e.settingsManager.gtk_variant_original; e.settingsManager.gtkTheme = e.settingsManager.gtkVariantOriginal;
break; break;
} }
} }
_update_variants() { _updateVariants() {
if ( e.settingsManager.manual_gtk_variants || this._are_variants_up_to_date() ) { if (e.settingsManager.manualGtkVariants || this._areVariantsUpToDate())
return; return;
}
log_debug('Updating GTK variants...'); logDebug('Updating GTK variants...');
const variants = GtkVariants.guess_from(e.settingsManager.gtk_theme); const variants = GtkVariants.guessFrom(e.settingsManager.gtkTheme);
const installed_themes = get_installed_gtk_themes(); const installedThemes = getInstalledGtkThemes();
if ( !installed_themes.has(variants.get('day')) || !installed_themes.has(variants.get('night')) ) { if (!installedThemes.has(variants.get('day')) || !installedThemes.has(variants.get('night'))) {
e.settingsManager.gtk_variant_original = variants.get('original'); e.settingsManager.gtkVariantOriginal = variants.get('original');
const message = _('Unable to automatically detect the day and night variants for the "%s" GTK theme. Please manually choose them in the extension\'s preferences.').format(variants.get('original')); const message = _('Unable to automatically detect the day and night variants for the "%s" GTK theme. Please manually choose them in the extension\'s preferences.').format(variants.get('original'));
throw new Error(message); throw new Error(message);
} }
e.settingsManager.gtk_variant_day = variants.get('day'); e.settingsManager.gtkVariantDay = variants.get('day');
e.settingsManager.gtk_variant_night = variants.get('night'); e.settingsManager.gtkVariantNight = variants.get('night');
e.settingsManager.gtk_variant_original = variants.get('original'); e.settingsManager.gtkVariantOriginal = variants.get('original');
log_debug(`New GTK variants. { day: '${variants.get('day')}'; night: '${variants.get('night')}' }`); logDebug(`New GTK variants. { day: '${variants.get('day')}'; night: '${variants.get('night')}' }`);
} }
_save_original_theme() { _saveOriginalTheme() {
e.settingsManager.gtk_variant_original = e.settingsManager.gtk_theme; e.settingsManager.gtkVariantOriginal = e.settingsManager.gtkTheme;
} }
_reset_original_theme() { _resetOriginalTheme() {
// We don't reset the theme when locking the session to prevent // We don't reset the theme when locking the session to prevent
// flicker on unlocking // flicker on unlocking
if ( !main.screenShield.locked ) { if (!main.screenShield.locked) {
log_debug('Resetting to the user\'s original GTK theme...'); logDebug('Resetting to the user\'s original GTK theme...');
this._set_variant('original'); this._setVariant('original');
} }
} }
} };
+63 -77
View File
@@ -21,10 +21,10 @@ this program. If not, see <http s ://www.gnu.org/licenses/>.
* The magic of guessing theme variants happens here. * The magic of guessing theme variants happens here.
* *
* If the theme doesn't fit a particular case, we'll do the following: * If the theme doesn't fit a particular case, we'll do the following:
* - Remove any signs of a dark variant to the theme name to get the day * - Remove any signs of a dark variant to the theme name to get the day
* variant * variant
* - Remove any signs of a light variant to the day variant and add '-dark' to * - Remove any signs of a light variant to the day variant and add '-dark' to
* get the night variant * get the night variant
* *
* For themes that don't work with the general rule, a particular case must be * For themes that don't work with the general rule, a particular case must be
* written. Day and night variants should be guessed with the most generic light * written. Day and night variants should be guessed with the most generic light
@@ -32,84 +32,70 @@ this program. If not, see <http s ://www.gnu.org/licenses/>.
* specific variant. * specific variant.
* *
* Light variants, from the most to the least generic: * Light variants, from the most to the least generic:
* - '' * - ''
* - '-light' * - '-light'
* - '-darker' * - '-darker'
* *
* Dark variants, from the most the least generic: * Dark variants, from the most the least generic:
* - '-dark' * - '-dark'
* - '-darkest' * - '-darkest'
*/ */
var GtkVariants = class { var GtkVariants = class {
static guess_from(name) { static guessFrom(name) {
const variants = new Map(); const variants = new Map();
variants.set('original', name); variants.set('original', name);
if ( name.includes('Adapta') ) { if (name.includes('Adapta')) {
variants.set('day', name.replace('-Nokto', '')); variants.set('day', name.replace('-Nokto', ''));
variants.set('night', variants.get('day').replace('Adapta', 'Adapta-Nokto')); variants.set('night', variants.get('day').replace('Adapta', 'Adapta-Nokto'));
} } else if (name.includes('Arc')) {
else if ( name.includes('Arc') ) { variants.set('day', name.replace(/-Dark(?!er)/, ''));
const basename = name.split('-')[0]; variants.set('night', variants.get('day').replace(/Arc(-Darker)?/, 'Arc-Dark'));
variants.set('day', name.replace(/-Dark(?!er)/, '')); } else if (name.match('Cabinet')) {
variants.set('night', variants.get('day').replace(/Arc(-Darker)?/, 'Arc-Dark')); variants.set('day', name.replace(/-Dark(?!er)/, '-Light'));
} variants.set('night', variants.get('day').replace(/(-Light|-Darker)/, '-Dark'));
else if ( name.match('Cabinet') ) { } else if (name.match(/^(Canta|ChromeOS|Materia|Orchis).*-compact/)) {
variants.set('day', name.replace(/-Dark(?!er)/, '-Light')); variants.set('day', name.replace('-dark', ''));
variants.set('night', variants.get('day').replace(/(-Light|-Darker)/, '-Dark')) variants.set('night', variants.get('day').replace(/(-light)?-compact/, '-dark-compact'));
} } else if (name.includes('Flat-Remix-GTK')) {
else if ( name.match(/^(Canta|ChromeOS|Materia|Orchis).*-compact/) ) { const isSolid = name.includes('-Solid');
variants.set('day', name.replace('-dark', '')); const withoutBorder = name.includes('-NoBorder');
variants.set('night', variants.get('day').replace(/(-light)?-compact/, '-dark-compact')); const basename = name.split('-').slice(0, 4).join('-');
} variants.set('day', basename + (name.includes('-Darker') ? '-Darker' : '') + (isSolid ? '-Solid' : ''));
else if ( name.includes('Flat-Remix-GTK') ) { variants.set('night', basename + (name.includes('-Darkest') ? '-Darkest' : '-Dark') + (isSolid ? '-Solid' : '') + (withoutBorder ? '-NoBorder' : ''));
const isSolid = name.includes('-Solid'); } else if (name.includes('HighContrast')) {
const withoutBorder = name.includes('-NoBorder'); variants.set('day', 'HighContrast');
const basename = name.split('-').slice(0, 4).join('-'); variants.set('night', 'HighContrastInverse');
variants.set('day', basename + (name.includes('-Darker') ? '-Darker' : '') + (isSolid ? '-Solid' : '')); } else if (name.match(/^(Layan|Macwaita|Matcha|Nextwaita)/)) {
variants.set('night', basename + (name.includes('-Darkest') ? '-Darkest' : '-Dark') + (isSolid ? '-Solid' : '') + (withoutBorder ? '-NoBorder' : '')); const basename = name.split('-')[0];
} variants.set('day', name.replace('-dark', ''));
else if ( name.includes('HighContrast') ) { variants.set('night', variants.get('day').replace(new RegExp(`${basename}(-light)?`), `${basename}-dark`));
variants.set('day', 'HighContrast'); } else if (name.includes('Mojave')) {
variants.set('night', 'HighContrastInverse'); variants.set('day', name.replace('-dark', '-light'));
} variants.set('night', variants.get('day').replace('-light', '-dark'));
else if ( name.match(/^(Layan|Macwaita|Matcha|Nextwaita)/) ) { } else if (name.includes('Plata')) {
const basename = name.split('-')[0]; variants.set('day', name.replace('-Noir', ''));
variants.set('day', name.replace('-dark', '')); variants.set('night', variants.get('day').replace(/Plata(-Lumine)?/, 'Plata-Noir'));
variants.set('night', variants.get('day').replace(new RegExp(`${basename}(-light)?`), `${basename}-dark`)); } else if (name.match(/^Prof-Gnome-(.+)-3(.*)/)) {
} variants.set('day', name.replace(/-Dark(?!er)/, '-Light'));
else if ( name.includes('Mojave') ) { variants.set('night', variants.get('day').replace(/(-Light(-DS)?|-Darker)/, '-Dark'));
variants.set('day', name.replace('-dark', '-light')); } else if (name.includes('Simply_Circles')) {
variants.set('night', variants.get('day').replace('-light', '-dark')); variants.set('day', name.replace('_Dark', '_Light'));
} variants.set('night', name.replace('_Light', '_Dark'));
else if ( name.includes('Plata') ) { } else if (name.includes('Teja')) {
variants.set('day', name.replace('-Noir', '')); const darkVariant = `_${name.replace('_Light').split('_')[1] || 'Dark'}`;
variants.set('night', variants.get('day').replace(/Plata(-Lumine)?/, 'Plata-Noir')); variants.set('day', name.replace(/(_Dark(est)?|_Black)/, ''));
} variants.set('night', variants.get('day').replace('_Light', '') + darkVariant);
else if ( name.match(/^Prof-Gnome-(.+)-3(.*)/) ) { } else if (name.includes('vimix')) {
variants.set('day', name.replace(/-Dark(?!er)/, '-Light')); variants.set('day', name.replace('-dark', ''));
variants.set('night', variants.get('day').replace(/(-Light(-DS)?|-Darker)/, '-Dark')) variants.set('night', variants.get('day').replace(/vimix(-light)?/, 'vimix-dark'));
} } else {
else if ( name.includes('Simply_Circles') ) { variants.set('day', name.replace(/-dark(?!er)(est)?/, ''));
variants.set('day', name.replace('_Dark', '_Light')); variants.set('night', variants.get('day').replace(/(-light|-darker)/, '') + (name.includes('-darkest') ? '-darkest' : '-dark'));
variants.set('night', name.replace('_Light', '_Dark')); }
}
else if ( name.includes('Teja') ) {
const dark_variant = '_' + (name.replace('_Light').split('_')[1] || 'Dark');
variants.set('day', name.replace(/(_Dark(est)?|_Black)/, ''));
variants.set('night', variants.get('day').replace('_Light', '') + dark_variant);
}
else if ( name.includes('vimix') ) {
variants.set('day', name.replace('-dark', ''));
variants.set('night', variants.get('day').replace(/vimix(-light)?/, 'vimix-dark'));
}
else {
variants.set('day', name.replace(/-dark(?!er)(est)?/, ''));
variants.set('night', variants.get('day').replace(/(-light|-darker)/, '') + (name.includes('-darkest') ? '-darkest' : '-dark'));
}
return variants; return variants;
} }
} };
+111 -105
View File
@@ -22,7 +22,7 @@ const { main } = imports.ui;
const Me = extensionUtils.getCurrentExtension(); const Me = extensionUtils.getCurrentExtension();
const e = Me.imports.extension; const e = Me.imports.extension;
const { log_debug } = Me.imports.utils; const { logDebug } = Me.imports.utils;
/** /**
@@ -31,125 +31,131 @@ const { log_debug } = Me.imports.utils;
*/ */
var IconThemer = class { var IconThemer = class {
enable() { constructor() {
log_debug('Enabling Icon Themer...'); this._iconVariantsStatusChangedConnect = null;
this._watch_status(); this._iconVariantChangedConnect = null;
this._save_original_theme(); this._iconThemeChangedConnect = null;
if ( e.settingsManager.icon_variants_enabled ) { this._timeChangedConnect = null;
this._connect_settings(); }
this._connect_timer();
}
log_debug('Icon Themer enabled.');
}
disable() { enable() {
log_debug('Disabling Icon Themer...'); logDebug('Enabling Icon Themer...');
this._disconnect_timer(); this._watchStatus();
this._disconnect_settings(); this._saveOriginalTheme();
this._reset_original_theme(); if (e.settingsManager.iconVariantsEnabled) {
this._unwatch_status(); this._connectSettings();
log_debug('Icon Themer disabled.'); this._connectTimer();
} }
logDebug('Icon Themer enabled.');
}
disable() {
logDebug('Disabling Icon Themer...');
this._disconnectTimer();
this._disconnectSettings();
this._resetOriginalTheme();
this._unwatchStatus();
logDebug('Icon Themer disabled.');
}
_watch_status() { _watchStatus() {
log_debug('Watching icon variants status...'); logDebug('Watching icon variants status...');
this._icon_variants_status_changed_connect = e.settingsManager.connect('icon-variants-status-changed', this._on_icon_variants_status_changed.bind(this)); this._iconVariantsStatusChangedConnect = e.settingsManager.connect('icon-variants-status-changed', this._onIconVariantsStatusChanged.bind(this));
} }
_unwatch_status() { _unwatchStatus() {
if ( this._icon_variants_status_changed_connect ) { if (this._iconVariantsStatusChangedConnect) {
e.settingsManager.disconnect(this._icon_variants_status_changed_connect); e.settingsManager.disconnect(this._iconVariantsStatusChangedConnect);
this._icon_variants_status_changed_connect = null; this._iconVariantsStatusChangedConnect = null;
} }
log_debug('Stopped watching icon variants status.'); logDebug('Stopped watching icon variants status.');
} }
_connect_settings() { _connectSettings() {
log_debug('Connecting Icon Themer to settings...'); logDebug('Connecting Icon Themer to settings...');
this._icon_variant_changed_connect = e.settingsManager.connect('icon-variant-changed', this._on_icon_variant_changed.bind(this)); this._iconVariantChangedConnect = e.settingsManager.connect('icon-variant-changed', this._onIconVariantChanged.bind(this));
this._icon_theme_changed_connect = e.settingsManager.connect('icon-theme-changed', this._on_icon_theme_changed.bind(this)); this._iconThemeChangedConnect = e.settingsManager.connect('icon-theme-changed', this._onIconThemeChanged.bind(this));
} }
_disconnect_settings() { _disconnectSettings() {
if ( this._icon_variant_changed_connect ) { if (this._iconVariantChangedConnect) {
e.settingsManager.disconnect(this._icon_variant_changed_connect); e.settingsManager.disconnect(this._iconVariantChangedConnect);
this._icon_variant_changed_connect = null; this._iconVariantChangedConnect = null;
} }
if ( this._icon_theme_changed_connect ) { if (this._iconThemeChangedConnect) {
e.settingsManager.disconnect(this._icon_theme_changed_connect); e.settingsManager.disconnect(this._iconThemeChangedConnect);
this._icon_theme_changed_connect = null; this._iconThemeChangedConnect = null;
} }
log_debug('Disconnected Icon Themer from settings.'); logDebug('Disconnected Icon Themer from settings.');
} }
_connect_timer() { _connectTimer() {
log_debug('Connecting Icon Themer to Timer...'); logDebug('Connecting Icon Themer to Timer...');
this._time_changed_connect = e.timer.connect('time-changed', this._on_time_changed.bind(this)); this._timeChangedConnect = e.timer.connect('time-changed', this._onTimeChanged.bind(this));
} }
_disconnect_timer() { _disconnectTimer() {
if ( this._time_changed_connect ) { if (this._timeChangedConnect) {
e.timer.disconnect(this._time_changed_connect); e.timer.disconnect(this._timeChangedConnect);
this._time_changed_connect = null; this._timeChangedConnect = null;
} }
log_debug('Disconnected Icon Themer from Timer.'); logDebug('Disconnected Icon Themer from Timer.');
} }
_on_icon_variants_status_changed(settings, enabled) { _onIconVariantsStatusChanged(_settings, _enabled) {
this.disable(); this.disable();
this.enable(); this.enable();
} }
_on_icon_variant_changed(settings, changed_variant_time) { _onIconVariantChanged(_settings, changedVariantTime) {
if ( changed_variant_time === e.timer.time ) { if (changedVariantTime === e.timer.time)
this._set_variant(changed_variant_time); this._setVariant(changedVariantTime);
} }
}
_on_icon_theme_changed(settings, new_theme) { _onIconThemeChanged(_settings, newTheme) {
switch (e.timer.time) { switch (e.timer.time) {
case 'day': case 'day':
e.settingsManager.icon_variant_day = new_theme; e.settingsManager.iconVariantDay = newTheme;
break; break;
case 'night': case 'night':
e.settingsManager.icon_variant_night = new_theme; e.settingsManager.iconVariantNight = newTheme;
} }
this._set_variant(e.timer.time); this._setVariant(e.timer.time);
} }
_on_time_changed(timer, new_time) { _onTimeChanged(_timer, newTime) {
this._set_variant(new_time); this._setVariant(newTime);
} }
_set_variant(time) { _setVariant(time) {
log_debug(`Setting the icon ${time} variant...`); logDebug(`Setting the icon ${time} variant...`);
switch (time) { switch (time) {
case 'day': case 'day':
e.settingsManager.icon_theme = e.settingsManager.icon_variant_day; e.settingsManager.iconTheme = e.settingsManager.iconVariantDay;
break; break;
case 'night': case 'night':
e.settingsManager.icon_theme = e.settingsManager.icon_variant_night; e.settingsManager.iconTheme = e.settingsManager.iconVariantNight;
break; break;
case 'original': case 'original':
e.settingsManager.icon_theme = e.settingsManager.icon_variant_original; e.settingsManager.iconTheme = e.settingsManager.iconVariantOriginal;
break; break;
} }
} }
_save_original_theme() { _saveOriginalTheme() {
e.settingsManager.icon_variant_original = e.settingsManager.icon_theme; e.settingsManager.iconVariantOriginal = e.settingsManager.iconTheme;
} }
_reset_original_theme() { _resetOriginalTheme() {
// We don't reset the theme when locking the session to prevent // We don't reset the theme when locking the session to prevent
// flicker on unlocking // flicker on unlocking
if ( !main.screenShield.locked ) { if (!main.screenShield.locked) {
log_debug('Resetting to the user\'s original icon theme...'); logDebug('Resetting to the user\'s original icon theme...');
this._set_variant('original'); this._setVariant('original');
} }
} }
} };
File diff suppressed because it is too large Load Diff
+140 -138
View File
@@ -23,7 +23,7 @@ const { main } = imports.ui;
const Me = extensionUtils.getCurrentExtension(); const Me = extensionUtils.getCurrentExtension();
const e = Me.imports.extension; const e = Me.imports.extension;
const { log_debug, log_error, get_installed_shell_themes, get_shell_theme_stylesheet, apply_shell_stylesheet } = Me.imports.utils; const { logDebug, notifyError, getInstalledShellThemes, getShellThemeStylesheet, applyShellStylesheet } = Me.imports.utils;
const { ShellVariants } = Me.imports.modules.ShellVariants; const { ShellVariants } = Me.imports.modules.ShellVariants;
const Gettext = imports.gettext.domain(Me.metadata.uuid); const Gettext = imports.gettext.domain(Me.metadata.uuid);
@@ -42,164 +42,166 @@ const _ = Gettext.gettext;
*/ */
var ShellThemer = class { var ShellThemer = class {
enable() { constructor() {
log_debug('Enabling Shell Themer...'); this._shellVariantsStatusChangedConnect = null;
try { this._shellVariantChangedConnect = null;
this._watch_status(); this._shellThemeChangedConnect = null;
this._save_original_theme(); this._timeChangedConnect = null;
if ( e.settingsManager.shell_variants_enabled ) { }
this._update_variants();
this._connect_settings();
this._connect_timer();
}
}
catch(e) {
log_error(e);
}
log_debug('Shell Themer enabled.');
}
disable() { enable() {
log_debug('Disabling Shell Themer...'); logDebug('Enabling Shell Themer...');
this._disconnect_timer(); try {
this._disconnect_settings(); this._watchStatus();
this._reset_original_theme(); this._saveOriginalTheme();
this._unwatch_status(); if (e.settingsManager.shellVariantsEnabled) {
log_debug('Shell Themer disabled.'); this._updateVariants();
} this._connectSettings();
this._connectTimer();
}
} catch (error) {
notifyError(error);
}
logDebug('Shell Themer enabled.');
}
disable() {
logDebug('Disabling Shell Themer...');
this._disconnectTimer();
this._disconnectSettings();
this._resetOriginalTheme();
this._unwatchStatus();
logDebug('Shell Themer disabled.');
}
_watch_status() { _watchStatus() {
log_debug('Watching shell variants status...'); logDebug('Watching shell variants status...');
this._shell_variants_status_changed_connect = e.settingsManager.connect('shell-variants-status-changed', this._on_shell_variants_status_changed.bind(this)); this._shellVariantsStatusChangedConnect = e.settingsManager.connect('shell-variants-status-changed', this._onShellVariantsStatusChanged.bind(this));
} }
_unwatch_status() { _unwatchStatus() {
if ( this._shell_variants_status_changed_connect ) { if (this._shellVariantsStatusChangedConnect) {
e.settingsManager.disconnect(this._shell_variants_status_changed_connect); e.settingsManager.disconnect(this._shellVariantsStatusChangedConnect);
this._shell_variants_status_changed_connect = null; this._shellVariantsStatusChangedConnect = null;
} }
log_debug('Stopped watching shell variants status.'); logDebug('Stopped watching shell variants status.');
} }
_connect_settings() { _connectSettings() {
log_debug('Connecting Shell Themer to settings...'); logDebug('Connecting Shell Themer to settings...');
this._shell_variant_changed_connect = e.settingsManager.connect('shell-variant-changed', this._on_shell_variant_changed.bind(this)); this._shellVariantChangedConnect = e.settingsManager.connect('shell-variant-changed', this._onShellVariantChanged.bind(this));
this._shell_theme_changed_connect = e.settingsManager.connect('shell-theme-changed', this._on_shell_theme_changed.bind(this)); this._shellThemeChangedConnect = e.settingsManager.connect('shell-theme-changed', this._onShellThemeChanged.bind(this));
} }
_disconnect_settings() { _disconnectSettings() {
if ( this._shell_variant_changed_connect ) { if (this._shellVariantChangedConnect) {
e.settingsManager.disconnect(this._shell_variant_changed_connect); e.settingsManager.disconnect(this._shellVariantChangedConnect);
this._shell_variant_changed_connect = null; this._shellVariantChangedConnect = null;
} }
if ( this._shell_theme_changed_connect ) { if (this._shellThemeChangedConnect) {
e.settingsManager.disconnect(this._shell_theme_changed_connect); e.settingsManager.disconnect(this._shellThemeChangedConnect);
this._shell_theme_changed_connect = null; this._shellThemeChangedConnect = null;
} }
log_debug('Disconnected Shell Themer from settings.'); logDebug('Disconnected Shell Themer from settings.');
} }
_connect_timer() { _connectTimer() {
log_debug('Connecting Shell Themer to Timer...'); logDebug('Connecting Shell Themer to Timer...');
this._time_changed_connect = e.timer.connect('time-changed', this._on_time_changed.bind(this)); this._timeChangedConnect = e.timer.connect('time-changed', this._onTimeChanged.bind(this));
} }
_disconnect_timer() { _disconnectTimer() {
if ( this._time_changed_connect ) { if (this._timeChangedConnect) {
e.timer.disconnect(this._time_changed_connect); e.timer.disconnect(this._timeChangedConnect);
this._time_changed_connect = null; this._timeChangedConnect = null;
} }
log_debug('Disconnected Shell Themer from Timer.'); logDebug('Disconnected Shell Themer from Timer.');
} }
_on_shell_variants_status_changed(settings, enabled) { _onShellVariantsStatusChanged(_settings, _enabled) {
this.disable(); this.disable();
this.enable(); this.enable();
} }
_on_shell_variant_changed(settings, changed_variant_time) { _onShellVariantChanged(_settings, changedVariantTime) {
if ( changed_variant_time === e.timer.time ) { if (changedVariantTime === e.timer.time)
this._set_variant(e.timer.time); this._setVariant(e.timer.time);
} }
}
_on_shell_theme_changed(settings, new_theme) { _onShellThemeChanged(_settings, _newTheme) {
try { try {
this._update_variants(); this._updateVariants();
this._set_variant(e.timer.time); this._setVariant(e.timer.time);
} } catch (error) {
catch(e) { notifyError(error);
log_error(e); }
} }
}
_on_time_changed(timer, new_time) { _onTimeChanged(_timer, newTime) {
this._set_variant(new_time); this._setVariant(newTime);
} }
_are_variants_up_to_date() { _areVariantsUpToDate() {
return ( e.settingsManager.shell_theme === e.settingsManager.shell_variant_day || e.settingsManager.shell_theme === e.settingsManager.shell_variant_night ); return e.settingsManager.shellTheme === e.settingsManager.shellVariantDay || e.settingsManager.shellTheme === e.settingsManager.shellVariantNight;
} }
_set_variant(time) { _setVariant(time) {
log_debug(`Setting the shell ${time} variant...`); logDebug(`Setting the shell ${time} variant...`);
let shell_theme; let shellTheme;
switch (time) { switch (time) {
case 'day': case 'day':
shell_theme = e.settingsManager.shell_variant_day; shellTheme = e.settingsManager.shellVariantDay;
break; break;
case 'night': case 'night':
shell_theme = e.settingsManager.shell_variant_night; shellTheme = e.settingsManager.shellVariantNight;
break; break;
case 'original': case 'original':
shell_theme = e.settingsManager.shell_variant_original; shellTheme = e.settingsManager.shellVariantOriginal;
break; break;
} }
if ( e.settingsManager.use_userthemes ) { if (e.settingsManager.useUserthemes) {
e.settingsManager.shell_theme = shell_theme; e.settingsManager.shellTheme = shellTheme;
} } else {
else { const stylesheet = getShellThemeStylesheet(shellTheme);
const stylesheet = get_shell_theme_stylesheet(shell_theme); applyShellStylesheet(stylesheet);
apply_shell_stylesheet(stylesheet); }
} }
}
_update_variants() { _updateVariants() {
if ( !e.settingsManager.use_userthemes || e.settingsManager.manual_shell_variants || this._are_variants_up_to_date() ) { if (!e.settingsManager.useUserthemes || e.settingsManager.manualShellVariants || this._areVariantsUpToDate())
return; return;
}
log_debug('Updating Shell variants...'); logDebug('Updating Shell variants...');
const variants = ShellVariants.guess_from(e.settingsManager.shell_theme); const variants = ShellVariants.guessFrom(e.settingsManager.shellTheme);
const installed_themes = get_installed_shell_themes(); const installedThemes = getInstalledShellThemes();
if ( !installed_themes.has(variants.get('day')) || !installed_themes.has(variants.get('night')) ) { if (!installedThemes.has(variants.get('day')) || !installedThemes.has(variants.get('night'))) {
e.settingsManager.shell_variant_original = variants.get('original'); e.settingsManager.shellVariantOriginal = variants.get('original');
const message = _('Unable to automatically detect the day and night variants for the "%s" GNOME Shell theme. Please manually choose them in the extension\'s preferences.').format(variants.get('original')); const message = _('Unable to automatically detect the day and night variants for the "%s" GNOME Shell theme. Please manually choose them in the extension\'s preferences.').format(variants.get('original'));
throw new Error(message); throw new Error(message);
} }
e.settingsManager.shell_variant_day = variants.get('day'); e.settingsManager.shellVariantDay = variants.get('day');
e.settingsManager.shell_variant_night = variants.get('night'); e.settingsManager.shellVariantNight = variants.get('night');
e.settingsManager.shell_variant_original = variants.get('original'); e.settingsManager.shellVariantOriginal = variants.get('original');
log_debug(`New Shell variants. { day: '${variants.get('day')}'; night: '${variants.get('night')}' }`); logDebug(`New Shell variants. { day: '${variants.get('day')}'; night: '${variants.get('night')}' }`);
} }
_save_original_theme() { _saveOriginalTheme() {
e.settingsManager.shell_variant_original = e.settingsManager.shell_theme; e.settingsManager.shellVariantOriginal = e.settingsManager.shellTheme;
} }
_reset_original_theme() { _resetOriginalTheme() {
// We don't reset the theme when locking the session to prevent // We don't reset the theme when locking the session to prevent
// flicker on unlocking // flicker on unlocking
if ( !main.screenShield.locked ) { if (!main.screenShield.locked) {
log_debug('Resetting to the user\'s original Shell theme...'); logDebug('Resetting to the user\'s original Shell theme...');
this._set_variant('original'); this._setVariant('original');
} }
} }
} };
Signals.addSignalMethods(ShellThemer.prototype); Signals.addSignalMethods(ShellThemer.prototype);
+57 -69
View File
@@ -17,15 +17,14 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see <http s ://www.gnu.org/licenses/>. this program. If not, see <http s ://www.gnu.org/licenses/>.
*/ */
/** /**
* The magic of guessing theme variants happens here. * The magic of guessing theme variants happens here.
* *
* If the theme doesn't fit a particular case, we'll do the following: * If the theme doesn't fit a particular case, we'll do the following:
* - Remove any signs of a dark variant to the theme name to get the day * - Remove any signs of a dark variant to the theme name to get the day
* variant * variant
* - Remove any signs of a light variant to the day variant and add '-dark' to * - Remove any signs of a light variant to the day variant and add '-dark' to
* get the night variant * get the night variant
* *
* For themes that don't work with the general rule, a particular case must be * For themes that don't work with the general rule, a particular case must be
* written. Day and night variants should be guessed with the most generic light * written. Day and night variants should be guessed with the most generic light
@@ -33,75 +32,64 @@ this program. If not, see <http s ://www.gnu.org/licenses/>.
* specific variant. * specific variant.
* *
* Light variants, from the most to the least generic: * Light variants, from the most to the least generic:
* - '' * - ''
* - '-light' * - '-light'
* - '-darker' * - '-darker'
* *
* Dark variants, from the most the least generic: * Dark variants, from the most the least generic:
* - '-dark' * - '-dark'
* - '-darkest' * - '-darkest'
*/ */
var ShellVariants = class { var ShellVariants = class {
static guess_from(name) { static guessFrom(name) {
const variants = new Map(); const variants = new Map();
variants.set('original', name); variants.set('original', name);
if ( name === '' ) { if (name === '') {
variants.set('day', ''); variants.set('day', '');
variants.set('night', ''); variants.set('night', '');
} } else if (name.includes('Adapta')) {
else if ( name.includes('Adapta') ) { variants.set('day', name.replace('-Nokto', ''));
variants.set('day', name.replace('-Nokto', '')); variants.set('night', variants.get('day').replace('Adapta', 'Adapta-Nokto'));
variants.set('night', variants.get('day').replace('Adapta', 'Adapta-Nokto')); } else if (name.includes('Arc')) {
} variants.set('day', name.replace('-Dark', ''));
else if ( name.includes('Arc') ) { variants.set('night', variants.get('day').replace('Arc', 'Arc-Dark'));
variants.set('day', name.replace('-Dark', '')); } else if (name.match(/^(Canta|ChromeOS|Materia|Orchis).*-compact/)) {
variants.set('night', variants.get('day').replace('Arc', 'Arc-Dark')); variants.set('day', name.replace('-dark', ''));
} variants.set('night', variants.get('day').replace(/(-light)?-compact/, '-dark-compact'));
else if ( name.match(/^(Canta|ChromeOS|Materia|Orchis).*-compact/) ) { } else if (name.includes('Flat-Remix')) {
variants.set('day', name.replace('-dark', '')); const color = name.split('-')[2] && !['Dark', 'Darkest', 'fullPanel'].includes(name.split('-')[2]) ? `-${name.split('-')[2]}` : '';
variants.set('night', variants.get('day').replace(/(-light)?-compact/, '-dark-compact')); const darkVariant = name.includes('Darkest') ? '-Darkest' : '-Dark';
} const size = name.includes('fullPanel') ? '-fullPanel' : '';
else if ( name.includes('Flat-Remix') ) { variants.set('day', name.replace(/-Dark(est)?/, ''));
const color = ( name.split('-')[2] && !['Dark', 'Darkest', 'fullPanel'].includes(name.split('-')[2]) ) ? '-' + name.split('-')[2] : ''; variants.set('night', `Flat-Remix${color}${darkVariant}${size}`);
const dark_variant = name.includes('Darkest') ? '-Darkest' : '-Dark'; } else if (name.match(/^(Layan|Matcha)/)) {
const size = name.includes('fullPanel')? '-fullPanel' : ''; const basename = name.split('-')[0];
variants.set('day', name.replace(/-Dark(est)?/, '')); variants.set('day', name.replace('-dark', ''));
variants.set('night', `Flat-Remix${color}${dark_variant}${size}`); variants.set('night', variants.get('day').replace(new RegExp(`${basename}(-light)?`), `${basename}-dark`));
} } else if (name.includes('Mojave')) {
else if ( name.match(/^(Layan|Matcha)/) ) { variants.set('day', name.replace('-dark', '-light'));
const basename = name.split('-')[0]; variants.set('night', variants.get('day').replace('-light', '-dark'));
variants.set('day', name.replace('-dark', '')); } else if (name.includes('Plata')) {
variants.set('night', variants.get('day').replace(new RegExp(`${basename}(-light)?`), `${basename}-dark`)); variants.set('day', name.replace('-Noir', ''));
} variants.set('night', variants.get('day').replace(/Plata(-Lumine)?/, 'Plata-Noir'));
else if ( name.includes('Mojave') ) { } else if (name.includes('Simply_Circles')) {
variants.set('day', name.replace('-dark', '-light')); variants.set('day', name.replace('_Dark', '_Light'));
variants.set('night', variants.get('day').replace('-light', '-dark')); variants.set('night', name.replace('_Light', '_Dark'));
} } else if (name.includes('Teja')) {
else if ( name.includes('Plata') ) { const darkVariant = `_${name.replace('_Light').split('_')[1] || 'Dark'}`;
variants.set('day', name.replace('-Noir', '')); variants.set('day', name.replace(/(_Dark(est)?|_Black)/, ''));
variants.set('night', variants.get('day').replace(/Plata(-Lumine)?/, 'Plata-Noir')); variants.set('night', variants.get('day').replace('_Light', '') + darkVariant);
} } else if (name.includes('vimix')) {
else if ( name.includes('Simply_Circles') ) { variants.set('day', name.replace('-dark', ''));
variants.set('day', name.replace('_Dark', '_Light')); variants.set('night', variants.get('day').replace(/vimix(-light)?/, 'vimix-dark'));
variants.set('night', name.replace('_Light', '_Dark')); } else {
} variants.set('day', name.replace(/-dark(?!er)(est)?/, ''));
else if ( name.includes('Teja') ) { variants.set('night', variants.get('day').replace(/(-light|-darker)/, '') + (name.includes('-darkest') ? '-darkest' : '-dark'));
const dark_variant = '_' + (name.replace('_Light').split('_')[1] || 'Dark'); }
variants.set('day', name.replace(/(_Dark(est)?|_Black)/, ''));
variants.set('night', variants.get('day').replace('_Light', '') + dark_variant);
}
else if ( name.includes('vimix') ) {
variants.set('day', name.replace('-dark', ''));
variants.set('night', variants.get('day').replace(/vimix(-light)?/, 'vimix-dark'));
}
else {
variants.set('day', name.replace(/-dark(?!er)(est)?/, ''));
variants.set('night', variants.get('day').replace(/(-light|-darker)/, '') + (name.includes('-darkest') ? '-darkest' : '-dark'));
}
return variants; return variants;
} }
} };
+126 -125
View File
@@ -22,7 +22,7 @@ const Signals = imports.signals;
const Me = extensionUtils.getCurrentExtension(); const Me = extensionUtils.getCurrentExtension();
const e = Me.imports.extension; const e = Me.imports.extension;
const { log_debug } = Me.imports.utils; const { logDebug } = Me.imports.utils;
const { TimerNightlight } = Me.imports.modules.TimerNightlight; const { TimerNightlight } = Me.imports.modules.TimerNightlight;
const { TimerLocation } = Me.imports.modules.TimerLocation; const { TimerLocation } = Me.imports.modules.TimerLocation;
const { TimerSchedule } = Me.imports.modules.TimerSchedule; const { TimerSchedule } = Me.imports.modules.TimerSchedule;
@@ -37,156 +37,157 @@ const { TimerOndemand } = Me.imports.modules.TimerOndemand;
* *
* It will try to use one of this three different time sources, in this order of * It will try to use one of this three different time sources, in this order of
* preference: * preference:
* - Night Light * - Night Light
* - Location Services * - Location Services
* - Manual schedule * - Manual schedule
* *
* The user can manually force a specific time source and set the manual * The user can manually force a specific time source and set the manual
* schedule in the extensions's preferences. * schedule in the extensions's preferences.
*/ */
var Timer = class { var Timer = class {
constructor() { constructor() {
this._source = null; this._source = null;
this._previous_time = null; this._previousTime = null;
} this._nightlightStatusChangedConnect = null;
this._locationStatusChangedConnect = null;
this._manualTimeSourceChangedConnect = null;
this._timeSourceChangedConnect = null;
this._timeChangedConnect = null;
}
enable() { enable() {
log_debug('Enabling Timer...'); logDebug('Enabling Timer...');
this._connect_settings(); this._connectSettings();
this._create_source(); this._createSource();
this._connect_source(); this._connectSource();
this._enable_source(); this._enableSource();
log_debug('Timer enabled.'); logDebug('Timer enabled.');
} }
disable() { disable() {
log_debug('Disabling Timer...'); logDebug('Disabling Timer...');
this._disconnect_source(); this._disconnectSource();
this._disable_source(); this._disableSource();
this._disconnect_settings(); this._disconnectSettings();
log_debug('Timer disabled.'); logDebug('Timer disabled.');
} }
get time() { get time() {
return this._source.time; return this._source.time;
} }
_connect_settings() { _connectSettings() {
log_debug('Connecting Timer to settings...'); logDebug('Connecting Timer to settings...');
this._nightlight_status_changed_connect = e.settingsManager.connect('nightlight-status-changed', this._on_source_changed.bind(this)); this._nightlightStatusChangedConnect = e.settingsManager.connect('nightlight-status-changed', this._onSourceChanged.bind(this));
this._location_status_changed_connect = e.settingsManager.connect('location-status-changed', this._on_source_changed.bind(this)); this._locationStatusChangedConnect = e.settingsManager.connect('location-status-changed', this._onSourceChanged.bind(this));
this._manual_time_source_changed_connect = e.settingsManager.connect('manual-time-source-changed', this._on_source_changed.bind(this)); this._manualTimeSourceChangedConnect = e.settingsManager.connect('manual-time-source-changed', this._onSourceChanged.bind(this));
this._time_source_changed_connect = e.settingsManager.connect('time-source-changed', this._on_time_source_changed.bind(this)); this._timeSourceChangedConnect = e.settingsManager.connect('time-source-changed', this._onTimeSourceChanged.bind(this));
} }
_disconnect_settings() { _disconnectSettings() {
if ( this._nightlight_status_changed_connect ) { if (this._nightlightStatusChangedConnect) {
e.settingsManager.disconnect(this._nightlight_status_changed_connect); e.settingsManager.disconnect(this._nightlightStatusChangedConnect);
this._nightlight_status_changed_connect = null; this._nightlightStatusChangedConnect = null;
} }
if ( this._location_status_changed_connect ) { if (this._locationStatusChangedConnect) {
e.settingsManager.disconnect(this._location_status_changed_connect); e.settingsManager.disconnect(this._locationStatusChangedConnect);
this._location_status_changed_connect = null; this._locationStatusChangedConnect = null;
} }
if ( this._manual_time_source_changed_connect ) { if (this._manualTimeSourceChangedConnect) {
e.settingsManager.disconnect(this._manual_time_source_changed_connect); e.settingsManager.disconnect(this._manualTimeSourceChangedConnect);
this._manual_time_source_changed_connect = null; this._manualTimeSourceChangedConnect = null;
} }
if ( this._time_source_changed_connect ) { if (this._timeSourceChangedConnect) {
e.settingsManager.disconnect(this._time_source_changed_connect); e.settingsManager.disconnect(this._timeSourceChangedConnect);
this._time_source_changed_connect = null; this._timeSourceChangedConnect = null;
} }
log_debug('Disconnected Timer from settings.'); logDebug('Disconnected Timer from settings.');
} }
_create_source() { _createSource() {
switch ( this._get_source() ) { switch (this._getSource()) {
case 'nightlight': case 'nightlight':
this._source = new TimerNightlight(); this._source = new TimerNightlight();
break; break;
case 'location': case 'location':
this._source = new TimerLocation(); this._source = new TimerLocation();
break; break;
case 'schedule': case 'schedule':
this._source = new TimerSchedule(); this._source = new TimerSchedule();
break; break;
case 'ondemand': case 'ondemand':
this._source = new TimerOndemand(); this._source = new TimerOndemand();
break; break;
} }
} }
_enable_source() { _enableSource() {
this._source.enable(); this._source.enable();
} }
_disable_source() { _disableSource() {
if ( this._source ) { if (this._source) {
this._source.disable(); this._source.disable();
this._source = null; this._source = null;
} }
} }
_connect_source() { _connectSource() {
log_debug('Connecting to time source...'); logDebug('Connecting to time source...');
this._time_changed_connect = this._source.connect('time-changed', this._on_time_changed.bind(this)); this._timeChangedConnect = this._source.connect('time-changed', this._onTimeChanged.bind(this));
} }
_disconnect_source() { _disconnectSource() {
if ( this._time_changed_connect ) { if (this._timeChangedConnect) {
this._source.disconnect(this._time_changed_connect); this._source.disconnect(this._timeChangedConnect);
this._time_changed_connect = null; this._timeChangedConnect = null;
} }
log_debug('Disconnected from time source.'); logDebug('Disconnected from time source.');
} }
_on_source_changed() { _onSourceChanged() {
this.disable(); this.disable();
this.enable(); this.enable();
} }
_on_time_source_changed(settings, new_source) { _onTimeSourceChanged(_settings, _newSource) {
if ( e.settingsManager.manual_time_source ) { if (e.settingsManager.manualTimeSource)
this._on_source_changed(); this._onSourceChanged();
} }
}
_on_time_changed(source, new_time) { _onTimeChanged(_source, newTime) {
if ( new_time !== this._previous_time) { if (newTime !== this._previousTime) {
log_debug(`Time has changed to ${new_time}.`); logDebug(`Time has changed to ${newTime}.`);
this.emit('time-changed', new_time); this.emit('time-changed', newTime);
this._previous_time = new_time; this._previousTime = newTime;
} }
} }
_get_source() { _getSource() {
log_debug('Getting time source...'); logDebug('Getting time source...');
if ( e.settingsManager.manual_time_source ) { if (e.settingsManager.manualTimeSource) {
log_debug(`Time source is forced to ${e.settingsManager.time_source}.`); logDebug(`Time source is forced to ${e.settingsManager.timeSource}.`);
return e.settingsManager.time_source; return e.settingsManager.timeSource;
} }
let source; let source;
if ( e.settingsManager.nightlight_enabled ) { if (e.settingsManager.nightlightEnabled)
source = 'nightlight'; source = 'nightlight';
} else if (e.settingsManager.locationEnabled)
else if ( e.settingsManager.location_enabled ) { source = 'location';
source = 'location'; else
} source = 'schedule';
else {
source = 'schedule';
}
log_debug(`Time source is ${source}.`); logDebug(`Time source is ${source}.`);
e.settingsManager.time_source = source; e.settingsManager.timeSource = source;
return source; return source;
} }
} };
Signals.addSignalMethods(Timer.prototype); Signals.addSignalMethods(Timer.prototype);
+238 -233
View File
@@ -23,64 +23,64 @@ const Signals = imports.signals;
const Me = extensionUtils.getCurrentExtension(); const Me = extensionUtils.getCurrentExtension();
const e = Me.imports.extension; const e = Me.imports.extension;
const { log_debug } = Me.imports.utils; const { logDebug } = Me.imports.utils;
// GeoClue2 interfaces from https://gitlab.freedesktop.org/geoclue/geoclue/ // GeoClue2 interfaces from https://gitlab.freedesktop.org/geoclue/geoclue/
const GEOCLUE_MANAGER_INTERFACE = ` const GEOCLUE_MANAGER_INTERFACE = `
<node> <node>
<interface name="org.freedesktop.GeoClue2.Manager"> <interface name="org.freedesktop.GeoClue2.Manager">
<property name="InUse" type="b" access="read"/> <property name="InUse" type="b" access="read"/>
<property name="AvailableAccuracyLevel" type="u" access="read"/> <property name="AvailableAccuracyLevel" type="u" access="read"/>
<method name="GetClient"> <method name="GetClient">
<arg name="client" type="o" direction="out"/> <arg name="client" type="o" direction="out"/>
</method> </method>
<method name="CreateClient"> <method name="CreateClient">
<arg name="client" type="o" direction="out"/> <arg name="client" type="o" direction="out"/>
</method> </method>
<method name="DeleteClient"> <method name="DeleteClient">
<arg name="client" type="o" direction="in"/> <arg name="client" type="o" direction="in"/>
</method> </method>
<method name="AddAgent"> <method name="AddAgent">
<arg name="id" type="s" direction="in"/> <arg name="id" type="s" direction="in"/>
</method> </method>
</interface> </interface>
</node>`; </node>`;
const GEOCLUE_CLIENT_INTERFACE = ` const GEOCLUE_CLIENT_INTERFACE = `
<node> <node>
<interface name="org.freedesktop.GeoClue2.Client"> <interface name="org.freedesktop.GeoClue2.Client">
<property name="Location" type="o" access="read"/> <property name="Location" type="o" access="read"/>
<property name="DistanceThreshold" type="u" access="readwrite"> <property name="DistanceThreshold" type="u" access="readwrite">
<annotation name="org.freedesktop.Accounts.DefaultValue" value="0"/> <annotation name="org.freedesktop.Accounts.DefaultValue" value="0"/>
</property> </property>
<property name="TimeThreshold" type="u" access="readwrite"> <property name="TimeThreshold" type="u" access="readwrite">
<annotation name="org.freedesktop.Accounts.DefaultValue" value="0"/> <annotation name="org.freedesktop.Accounts.DefaultValue" value="0"/>
</property> </property>
<property name="DesktopId" type="s" access="readwrite"/> <property name="DesktopId" type="s" access="readwrite"/>
<property name="RequestedAccuracyLevel" type="u" access="readwrite"/> <property name="RequestedAccuracyLevel" type="u" access="readwrite"/>
<property name="Active" type="b" access="read"/> <property name="Active" type="b" access="read"/>
<method name="Start"/> <method name="Start"/>
<method name="Stop"/> <method name="Stop"/>
<signal name="LocationUpdated"> <signal name="LocationUpdated">
<arg name="old" type="o"/> <arg name="old" type="o"/>
<arg name="new" type="o"/> <arg name="new" type="o"/>
</signal> </signal>
</interface> </interface>
</node>`; </node>`;
const GEOCLUE_LOCATION_INTERFACE = ` const GEOCLUE_LOCATION_INTERFACE = `
<node> <node>
<interface name="org.freedesktop.GeoClue2.Location"> <interface name="org.freedesktop.GeoClue2.Location">
<property name="Latitude" type="d" access="read"/> <property name="Latitude" type="d" access="read"/>
<property name="Longitude" type="d" access="read"/> <property name="Longitude" type="d" access="read"/>
<property name="Accuracy" type="d" access="read"/> <property name="Accuracy" type="d" access="read"/>
<property name="Altitude" type="d" access="read"/> <property name="Altitude" type="d" access="read"/>
<property name="Speed" type="d" access="read"/> <property name="Speed" type="d" access="read"/>
<property name="Heading" type="d" access="read"/> <property name="Heading" type="d" access="read"/>
<property name="Description" type="s" access="read"/> <property name="Description" type="s" access="read"/>
<property name="Timestamp" type="(tt)" access="read"/> <property name="Timestamp" type="(tt)" access="read"/>
</interface> </interface>
</node>`; </node>`;
@@ -99,224 +99,229 @@ const GEOCLUE_LOCATION_INTERFACE = `
*/ */
var TimerLocation = class { var TimerLocation = class {
constructor() { constructor() {
this._previously_daytime = null; this._previouslyDaytime = null;
// Before we have the location suntimes, we'll use the manual schedule // Before we have the location suntimes, we'll use the manual schedule
// times // times
this._suntimes = new Map([ this._suntimes = new Map([
['sunrise', e.settingsManager.schedule_sunrise], ['sunrise', e.settingsManager.scheduleSunrise],
['sunset', e.settingsManager.schedule_sunrise] ['sunset', e.settingsManager.scheduleSunrise],
]); ]);
} this._geoclueClient = null;
this._geoclueClientDbusProxy = null;
this._geoclueManagerDbusProxy = null;
this._geoclueLocationDbusProxy = null;
this._locationUpdatesConnect = null;
this._timeChangeTimer = null;
this._regularlyUpdateSuntimesTimer = null;
}
enable() { enable() {
log_debug('Enabling Location Timer...'); logDebug('Enabling Location Timer...');
this._connect_to_geoclue_dbus_proxy(); this._connectToGeoclueDbusProxy();
this._listen_to_location_updates(); this._listenToLocationUpdates();
this._connect_to_geoclue_location_dbus_proxy(); this._connectToGeoclueLocationDbusProxy();
this._update_location(); this._updateLocation();
this._update_suntimes(); this._updateSuntimes();
this._watch_for_time_change(); this._watchForTimeChange();
this._regularly_update_suntimes(); this._regularlyUpdateSuntimes();
log_debug('Location Timer enabled.'); logDebug('Location Timer enabled.');
} }
disable() { disable() {
log_debug('Disabling Location Timer...'); logDebug('Disabling Location Timer...');
this._stop_regularly_updating_suntimes(); this._stopRegularlyUpdatingSuntimes();
this._stop_watching_for_time_change(); this._stopWatchingForTimeChange();
this._stop_listening_to_location_updates(); this._stopListeningToLocationUpdates();
this._disconnect_from_geoclue_location_dbus_proxy(); this._disconnectFromGeoclueLocationDbusProxy();
this._disconnect_from_geoclue_dbus_proxy(); this._disconnectFromGeoclueDbusProxy();
log_debug('Location Timer disabled.'); logDebug('Location Timer disabled.');
} }
get time() { get time() {
return this._is_daytime() ? 'day' : 'night'; return this._isDaytime() ? 'day' : 'night';
} }
_connect_to_geoclue_dbus_proxy() { _connectToGeoclueDbusProxy() {
log_debug('Connecting to GeoClue manager DBus proxy...'); logDebug('Connecting to GeoClue manager DBus proxy...');
const GeoClueManagerProxy = Gio.DBusProxy.makeProxyWrapper(GEOCLUE_MANAGER_INTERFACE); const GeoClueManagerProxy = Gio.DBusProxy.makeProxyWrapper(GEOCLUE_MANAGER_INTERFACE);
this._geoclue_manager_dbus_proxy = new GeoClueManagerProxy( this._geoclueManagerDbusProxy = new GeoClueManagerProxy(
Gio.DBus.system, Gio.DBus.system,
'org.freedesktop.GeoClue2', 'org.freedesktop.GeoClue2',
'/org/freedesktop/GeoClue2/Manager' '/org/freedesktop/GeoClue2/Manager'
); );
log_debug('Connected to GeoClue manager DBus proxy.'); logDebug('Connected to GeoClue manager DBus proxy.');
log_debug('Getting a GeoClue client...'); logDebug('Getting a GeoClue client...');
this._geoclue_client = this._geoclue_manager_dbus_proxy.GetClientSync()[0]; this._geoclueClient = this._geoclueManagerDbusProxy.GetClientSync()[0];
log_debug(`Got a GeoClue client at ${this._geoclue_client}`); logDebug(`Got a GeoClue client at ${this._geoclueClient}`);
log_debug('Connecting to GeoClue client DBus proxy...'); logDebug('Connecting to GeoClue client DBus proxy...');
const GeoClueClientProxy = Gio.DBusProxy.makeProxyWrapper(GEOCLUE_CLIENT_INTERFACE); const GeoClueClientProxy = Gio.DBusProxy.makeProxyWrapper(GEOCLUE_CLIENT_INTERFACE);
this._geoclue_client_dbus_proxy = new GeoClueClientProxy( this._geoclueClientDbusProxy = new GeoClueClientProxy(
Gio.DBus.system, Gio.DBus.system,
'org.freedesktop.GeoClue2', 'org.freedesktop.GeoClue2',
this._geoclue_client this._geoclueClient
); );
this._geoclue_client_dbus_proxy.DesktopId = Me.metadata.uuid; this._geoclueClientDbusProxy.DesktopId = Me.metadata.uuid;
this._geoclue_client_dbus_proxy.DistanceThreshold = 10000; this._geoclueClientDbusProxy.DistanceThreshold = 10000;
this._geoclue_client_dbus_proxy.RequestedAccuracyLevel = 4; this._geoclueClientDbusProxy.RequestedAccuracyLevel = 4;
log_debug('Connected to GeoClue client DBus proxy.'); logDebug('Connected to GeoClue client DBus proxy.');
} }
_disconnect_from_geoclue_dbus_proxy() { _disconnectFromGeoclueDbusProxy() {
log_debug('Disconnecting from GeoClue DBus proxy...') logDebug('Disconnecting from GeoClue DBus proxy...');
this._geoclue_manager_dbus_proxy.DeleteClientSync(this._geoclue_client); this._geoclueManagerDbusProxy.DeleteClientSync(this._geoclueClient);
this._geoclue_client = null; this._geoclueClient = null;
this._geoclue_client_dbus_proxy = null; this._geoclueClientDbusProxy = null;
this._geoclue_manager_dbus_proxy = null; this._geoclueManagerDbusProxy = null;
log_debug('Disconnected from GeoClue DBus proxy.') logDebug('Disconnected from GeoClue DBus proxy.');
} }
_listen_to_location_updates() { _listenToLocationUpdates() {
log_debug('Listening to location updates...'); logDebug('Listening to location updates...');
this._location_updates_connect = this._geoclue_client_dbus_proxy.connectSignal('LocationUpdated', this._on_location_updated.bind(this)); this._locationUpdatesConnect = this._geoclueClientDbusProxy.connectSignal('LocationUpdated', this._onLocationUpdated.bind(this));
this._geoclue_client_dbus_proxy.StartSync(); this._geoclueClientDbusProxy.StartSync();
} }
_stop_listening_to_location_updates() { _stopListeningToLocationUpdates() {
this._geoclue_client_dbus_proxy.disconnectSignal(this._location_updates_connect); this._geoclueClientDbusProxy.disconnectSignal(this._locationUpdatesConnect);
this._location_updates_connect = null; this._locationUpdatesConnect = null;
this._geoclue_client_dbus_proxy.StopSync(); this._geoclueClientDbusProxy.StopSync();
log_debug('Stopped listening to location updates.'); logDebug('Stopped listening to location updates.');
} }
_on_location_updated(proxy, sender, [old_location_path, new_location_path]) { _onLocationUpdated(_proxy, _sender, [_oldLocationPath, newLocationPath]) {
log_debug('Location has changed.'); logDebug('Location has changed.');
this._connect_to_geoclue_location_dbus_proxy(new_location_path); this._connectToGeoclueLocationDbusProxy(newLocationPath);
this._update_location(); this._updateLocation();
this._update_suntimes(); this._updateSuntimes();
} }
_connect_to_geoclue_location_dbus_proxy(path) { _connectToGeoclueLocationDbusProxy(path) {
if ( !path ) { if (!path)
path = this._geoclue_client_dbus_proxy.Location; path = this._geoclueClientDbusProxy.Location;
} if (path !== '/') {
if ( path !== '/' ) { logDebug('Connecting to GeoClue location DBus proxy...');
log_debug('Connecting to GeoClue location DBus proxy...'); const GeoClueLocationProxy = Gio.DBusProxy.makeProxyWrapper(GEOCLUE_LOCATION_INTERFACE);
const GeoClueLocationProxy = Gio.DBusProxy.makeProxyWrapper(GEOCLUE_LOCATION_INTERFACE); this._geoclueLocationDbusProxy = new GeoClueLocationProxy(
this._geoclue_location_dbus_proxy = new GeoClueLocationProxy( Gio.DBus.system,
Gio.DBus.system, 'org.freedesktop.GeoClue2',
'org.freedesktop.GeoClue2', path
path );
); logDebug('Connected to GeoClue location DBus proxy.');
log_debug('Connected to GeoClue location DBus proxy.'); }
} }
}
_disconnect_from_geoclue_location_dbus_proxy() { _disconnectFromGeoclueLocationDbusProxy() {
log_debug('Disconnecting from GeoClue location DBus proxy...'); logDebug('Disconnecting from GeoClue location DBus proxy...');
this._geoclue_location_dbus_proxy = null; this._geoclueLocationDbusProxy = null;
log_debug('Disconnected from GeoClue location DBus proxy.'); logDebug('Disconnected from GeoClue location DBus proxy.');
} }
_update_location() { _updateLocation() {
if ( this._geoclue_location_dbus_proxy ) { if (this._geoclueLocationDbusProxy) {
log_debug('Updating location...'); logDebug('Updating location...');
const latitude = this._geoclue_location_dbus_proxy.Latitude; const latitude = this._geoclueLocationDbusProxy.Latitude;
const longitude = this._geoclue_location_dbus_proxy.Longitude; const longitude = this._geoclueLocationDbusProxy.Longitude;
this.location = new Map([ this.location = new Map([
['latitude', latitude], ['latitude', latitude],
['longitude', longitude] ['longitude', longitude],
]); ]);
log_debug(`Current location: (${latitude};${longitude})`); logDebug(`Current location: (${latitude};${longitude})`);
} }
} }
_update_suntimes() { _updateSuntimes() {
if ( !this.location ) { if (!this.location)
return; return;
}
log_debug('Updating sun times...'); logDebug('Updating sun times...');
Math.rad = degrees => degrees * Math.PI / 180; Math.rad = degrees => degrees * Math.PI / 180;
Math.deg = radians => radians * 180 / Math.PI; Math.deg = radians => radians * 180 / Math.PI;
// Calculations from https://www.esrl.noaa.gov/gmd/grad/solcalc/calcdetails.html // Calculations from https://www.esrl.noaa.gov/gmd/grad/solcalc/calcdetails.html
const latitude = this.location.get('latitude'); const latitude = this.location.get('latitude');
const longitude = this.location.get('longitude'); const longitude = this.location.get('longitude');
const dt_now = GLib.DateTime.new_now_local(); const dtNow = GLib.DateTime.new_now_local();
const dt_zero = GLib.DateTime.new_utc(1900, 1, 1, 0, 0, 0); const dtZero = GLib.DateTime.new_utc(1900, 1, 1, 0, 0, 0);
const time_span = dt_now.difference(dt_zero); const timeSpan = dtNow.difference(dtZero);
const date = time_span / 1000 / 1000 / 60 / 60 / 24 + 2; const date = timeSpan / 1000 / 1000 / 60 / 60 / 24 + 2;
const tz_offset = dt_now.get_utc_offset() / 1000 / 1000 / 60 / 60; const tzOffset = dtNow.get_utc_offset() / 1000 / 1000 / 60 / 60;
const time_past_local_midnight = 0; const timePastLocalMidnight = 0;
const julian_day = date + 2415018.5 + time_past_local_midnight - tz_offset / 24; const julianDay = date + 2415018.5 + timePastLocalMidnight - tzOffset / 24;
const julian_century = (julian_day - 2451545) / 36525; const julianCentury = (julianDay - 2451545) / 36525;
const geom_mean_long_sun = (280.46646 + julian_century * (36000.76983 + julian_century * 0.0003032)) % 360; const geomMeanLongSun = (280.46646 + julianCentury * (36000.76983 + julianCentury * 0.0003032)) % 360;
const geom_mean_anom_sun = 357.52911 + julian_century * (35999.05029 - 0.0001537 * julian_century); const geomMeanAnomSun = 357.52911 + julianCentury * (35999.05029 - 0.0001537 * julianCentury);
const eccent_earth_orbit = 0.016708634 - julian_century * (0.000042037 + 0.0000001267 * julian_century); const eccentEarthOrbit = 0.016708634 - julianCentury * (0.000042037 + 0.0000001267 * julianCentury);
const sun_eq_of_ctr = Math.sin(Math.rad(geom_mean_anom_sun)) * (1.914602 - julian_century * (0.004817 + 0.000014 * julian_century)) + Math.sin(Math.rad(2 * geom_mean_anom_sun)) * (0.019993 - 0.000101 * julian_century) + Math.sin(Math.rad(3 * geom_mean_anom_sun)) * 0.000289; const sunEqOfCtr = Math.sin(Math.rad(geomMeanAnomSun)) * (1.914602 - julianCentury * (0.004817 + 0.000014 * julianCentury)) + Math.sin(Math.rad(2 * geomMeanAnomSun)) * (0.019993 - 0.000101 * julianCentury) + Math.sin(Math.rad(3 * geomMeanAnomSun)) * 0.000289;
const sun_true_long = geom_mean_long_sun + sun_eq_of_ctr; const sunTrueLong = geomMeanLongSun + sunEqOfCtr;
const sun_app_long = sun_true_long - 0.00569 - 0.00478 * Math.sin(Math.rad(125.04 - 1934.136 * julian_century)); const sunAppLong = sunTrueLong - 0.00569 - 0.00478 * Math.sin(Math.rad(125.04 - 1934.136 * julianCentury));
const mean_obliq_ecliptic = 23 + (26 + ((21.448 - julian_century * (46.815 + julian_century * (0.00059 - julian_century * 0.001813)))) / 60) / 60; const meanObliqEcliptic = 23 + (26 + ((21.448 - julianCentury * (46.815 + julianCentury * (0.00059 - julianCentury * 0.001813)))) / 60) / 60;
const obliq_corr = mean_obliq_ecliptic + 0.00256 * Math.cos(Math.rad(125.04 - 1934.136 * julian_century)); const obliqCorr = meanObliqEcliptic + 0.00256 * Math.cos(Math.rad(125.04 - 1934.136 * julianCentury));
const sun_declin = Math.deg(Math.asin(Math.sin(Math.rad(obliq_corr)) * Math.sin(Math.rad(sun_app_long)))); const sunDeclin = Math.deg(Math.asin(Math.sin(Math.rad(obliqCorr)) * Math.sin(Math.rad(sunAppLong))));
const var_y = Math.tan(Math.rad(obliq_corr / 2)) * Math.tan(Math.rad(obliq_corr / 2)); const varY = Math.tan(Math.rad(obliqCorr / 2)) * Math.tan(Math.rad(obliqCorr / 2));
const eq_of_time = 4 * Math.deg(var_y * Math.sin(2 * Math.rad(geom_mean_long_sun)) - 2 * eccent_earth_orbit * Math.sin(Math.rad(geom_mean_anom_sun)) + 4 * eccent_earth_orbit * var_y * Math.sin(Math.rad(geom_mean_anom_sun)) * Math.cos(2 * Math.rad(geom_mean_long_sun)) - 0.5 * var_y * var_y * Math.sin(4 * Math.rad(geom_mean_long_sun)) - 1.25 * eccent_earth_orbit * eccent_earth_orbit * Math.sin(2 * Math.rad(geom_mean_anom_sun))); const eqOfTime = 4 * Math.deg(varY * Math.sin(2 * Math.rad(geomMeanLongSun)) - 2 * eccentEarthOrbit * Math.sin(Math.rad(geomMeanAnomSun)) + 4 * eccentEarthOrbit * varY * Math.sin(Math.rad(geomMeanAnomSun)) * Math.cos(2 * Math.rad(geomMeanLongSun)) - 0.5 * varY * varY * Math.sin(4 * Math.rad(geomMeanLongSun)) - 1.25 * eccentEarthOrbit * eccentEarthOrbit * Math.sin(2 * Math.rad(geomMeanAnomSun)));
const ha_sunrise = Math.deg(Math.acos(Math.cos(Math.rad(90.833)) / (Math.cos(Math.rad(latitude)) * Math.cos(Math.rad(sun_declin))) - Math.tan(Math.rad(latitude)) * Math.tan(Math.rad(sun_declin)))); const haSunrise = Math.deg(Math.acos(Math.cos(Math.rad(90.833)) / (Math.cos(Math.rad(latitude)) * Math.cos(Math.rad(sunDeclin))) - Math.tan(Math.rad(latitude)) * Math.tan(Math.rad(sunDeclin))));
const solar_noon = (720 - 4 * longitude - eq_of_time + tz_offset * 60) / 1440; const solarNoon = (720 - 4 * longitude - eqOfTime + tzOffset * 60) / 1440;
const sunrise_time = solar_noon - ha_sunrise * 4 / 1440; const timeSunrise = solarNoon - haSunrise * 4 / 1440;
const sunset_time = solar_noon + ha_sunrise * 4 / 1440; const timeSunset = solarNoon + haSunrise * 4 / 1440;
const sunrise = sunrise_time * 24; const sunrise = timeSunrise * 24;
const sunset = sunset_time * 24; const sunset = timeSunset * 24;
this._suntimes.set('sunrise', sunrise); this._suntimes.set('sunrise', sunrise);
this._suntimes.set('sunset', sunset); this._suntimes.set('sunset', sunset);
log_debug(`New sun times: (sunrise: ${sunrise}; sunset: ${sunset})`); logDebug(`New sun times: (sunrise: ${sunrise}; sunset: ${sunset})`);
} }
_regularly_update_suntimes() { _regularlyUpdateSuntimes() {
log_debug('Regularly updating sun times...'); logDebug('Regularly updating sun times...');
this._regularly_update_suntimes_timer = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 3600, () => { this._regularlyUpdateSuntimesTimer = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 3600, () => {
this._update_suntimes(); this._updateSuntimes();
return true; // Repeat the loop return true; // Repeat the loop
}); });
} }
_stop_regularly_updating_suntimes() { _stopRegularlyUpdatingSuntimes() {
GLib.Source.remove(this._regularly_update_suntimes_timer); GLib.Source.remove(this._regularlyUpdateSuntimesTimer);
this._regularly_update_suntimes_timer = null; this._regularlyUpdateSuntimesTimer = null;
log_debug('Stopped regularly updating sun times.'); logDebug('Stopped regularly updating sun times.');
} }
_is_daytime() { _isDaytime() {
const time = GLib.DateTime.new_now_local(); const time = GLib.DateTime.new_now_local();
const hour = time.get_hour() + time.get_minute() / 60 + time.get_second() / 3600; const hour = time.get_hour() + time.get_minute() / 60 + time.get_second() / 3600;
return ( hour >= this._suntimes.get('sunrise') && hour <= this._suntimes.get('sunset') ); return hour >= this._suntimes.get('sunrise') && hour <= this._suntimes.get('sunset');
} }
_watch_for_time_change() { _watchForTimeChange() {
log_debug('Watching for time change...'); logDebug('Watching for time change...');
this._time_change_timer = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 1, () => { this._timeChangeTimer = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 1, () => {
if ( !Me.imports.extension.enabled ) { if (!Me.imports.extension.enabled) {
// The extension doesn't exist anymore, quit the loop // The extension doesn't exist anymore, quit the loop
return false; return false;
} }
if ( this._previously_daytime !== this._is_daytime() ) { if (this._previouslyDaytime !== this._isDaytime()) {
this._previously_daytime = this._is_daytime(); this._previouslyDaytime = this._isDaytime();
this.emit('time-changed', this.time); this.emit('time-changed', this.time);
} }
return true; // Repeat the loop return true; // Repeat the loop
}); });
} }
_stop_watching_for_time_change() { _stopWatchingForTimeChange() {
GLib.Source.remove(this._time_change_timer); GLib.Source.remove(this._timeChangeTimer);
log_debug('Stopped watching for time change.'); logDebug('Stopped watching for time change.');
} }
} };
Signals.addSignalMethods(TimerLocation.prototype); Signals.addSignalMethods(TimerLocation.prototype);
+63 -58
View File
@@ -16,20 +16,20 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see <http s ://www.gnu.org/licenses/>. this program. If not, see <http s ://www.gnu.org/licenses/>.
*/ */
const { Gio, GLib } = imports.gi; const { Gio } = imports.gi;
const { extensionUtils } = imports.misc; const { extensionUtils } = imports.misc;
const Signals = imports.signals; const Signals = imports.signals;
const Me = extensionUtils.getCurrentExtension(); const Me = extensionUtils.getCurrentExtension();
const { log_debug } = Me.imports.utils; const { logDebug } = Me.imports.utils;
const COLOR_INTERFACE = ` const COLOR_INTERFACE = `
<node> <node>
<interface name="org.gnome.SettingsDaemon.Color"> <interface name="org.gnome.SettingsDaemon.Color">
<property name="NightLightActive" type="b" access="read"/> <property name="NightLightActive" type="b" access="read"/>
</interface> </interface>
</node>`; </node>`;
@@ -41,68 +41,73 @@ const COLOR_INTERFACE = `
*/ */
var TimerNightlight = class { var TimerNightlight = class {
enable() { constructor() {
log_debug('Enabling Night Light Timer...'); this._colorDbusProxy = null;
this._connect_to_color_dbus_proxy(); this._nightlightStateConnect = null;
this._listen_to_nightlight_state(); }
this.emit('time-changed', this.time);
log_debug('Night Light Timer enabled.');
}
disable() { enable() {
log_debug('Disabling Night Light Timer...'); logDebug('Enabling Night Light Timer...');
this._stop_listening_to_nightlight_state(); this._connectToColorDbusProxy();
this._disconnect_from_color_dbus_proxy(); this._listenToNightlightState();
log_debug('Night Light Timer disabled.'); this.emit('time-changed', this.time);
} logDebug('Night Light Timer enabled.');
}
disable() {
logDebug('Disabling Night Light Timer...');
this._stopListeningToNightlightState();
this._disconnectFromColorDbusProxy();
logDebug('Night Light Timer disabled.');
}
get time() { get time() {
return this._is_nightlight_active() ? 'night' : 'day'; return this._isNightlightActive() ? 'night' : 'day';
} }
_connect_to_color_dbus_proxy() { _connectToColorDbusProxy() {
log_debug('Connecting to Color DBus proxy...'); logDebug('Connecting to Color DBus proxy...');
const ColorProxy = Gio.DBusProxy.makeProxyWrapper(COLOR_INTERFACE); const ColorProxy = Gio.DBusProxy.makeProxyWrapper(COLOR_INTERFACE);
this._color_dbus_proxy = new ColorProxy( this._colorDbusProxy = new ColorProxy(
Gio.DBus.session, Gio.DBus.session,
'org.gnome.SettingsDaemon.Color', 'org.gnome.SettingsDaemon.Color',
'/org/gnome/SettingsDaemon/Color' '/org/gnome/SettingsDaemon/Color'
); );
log_debug('Connected to Color DBus proxy.'); logDebug('Connected to Color DBus proxy.');
} }
_disconnect_from_color_dbus_proxy() { _disconnectFromColorDbusProxy() {
log_debug('Disconnecting from Color DBus proxy...'); logDebug('Disconnecting from Color DBus proxy...');
this._color_dbus_proxy = null; this._colorDbusProxy = null;
log_debug('Disconnected from Color DBus proxy.'); logDebug('Disconnected from Color DBus proxy.');
} }
_listen_to_nightlight_state() { _listenToNightlightState() {
log_debug('Listening to Night Light state...'); logDebug('Listening to Night Light state...');
this._nightlight_state_connect = this._color_dbus_proxy.connect( this._nightlightStateConnect = this._colorDbusProxy.connect(
'g-properties-changed', 'g-properties-changed',
this._on_nightlight_state_changed.bind(this) this._onNightlightStateChanged.bind(this)
); );
} }
_stop_listening_to_nightlight_state() { _stopListeningToNightlightState() {
this._color_dbus_proxy.disconnect(this._nightlight_state_connect); this._colorDbusProxy.disconnect(this._nightlightStateConnect);
log_debug('Stopped listening to Night Light state.'); logDebug('Stopped listening to Night Light state.');
} }
_on_nightlight_state_changed(sender, dbus_properties) { _onNightlightStateChanged(_sender, dbusProperties) {
const properties = dbus_properties.deep_unpack(); const properties = dbusProperties.deep_unpack();
if ( properties.NightLightActive ) { if (properties.NightLightActive) {
log_debug('Night Light has become ' + (properties.NightLightActive.unpack() ? '' : 'in') + 'active.'); logDebug(`Night Light has become ${properties.NightLightActive.unpack() ? '' : 'in'}active.`);
this.emit('time-changed', this.time); this.emit('time-changed', this.time);
} }
} }
_is_nightlight_active() { _isNightlightActive() {
return this._color_dbus_proxy.NightLightActive; return this._colorDbusProxy.NightLightActive;
} }
} };
Signals.addSignalMethods(TimerNightlight.prototype); Signals.addSignalMethods(TimerNightlight.prototype);
+69 -69
View File
@@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see <http s ://www.gnu.org/licenses/>. this program. If not, see <http s ://www.gnu.org/licenses/>.
*/ */
const { GLib, Shell, St } = imports.gi; const { Shell, St } = imports.gi;
const { extensionUtils } = imports.misc; const { extensionUtils } = imports.misc;
const Signals = imports.signals; const Signals = imports.signals;
@@ -25,8 +25,8 @@ const { main, panelMenu } = imports.ui;
const Me = extensionUtils.getCurrentExtension(); const Me = extensionUtils.getCurrentExtension();
const e = Me.imports.extension; const e = Me.imports.extension;
const { log_debug } = Me.imports.utils; const { logDebug } = Me.imports.utils;
const { key_binding_auto_repeat, get_actor } = Me.imports.compat; const { keyBindingAutoRepeat, getActor } = Me.imports.compat;
/** /**
* The On-demand Timer allows the user to manually switch between the day and * The On-demand Timer allows the user to manually switch between the day and
@@ -36,85 +36,85 @@ const { key_binding_auto_repeat, get_actor } = Me.imports.compat;
*/ */
var TimerOndemand = class { var TimerOndemand = class {
constructor() { constructor() {
this._button = null; this._button = null;
this._icon = null; this._icon = null;
} }
enable() { enable() {
log_debug('Enabling On-demand Timer ...'); logDebug('Enabling On-demand Timer ...');
this._add_keybinding(); this._addKeybinding();
this._add_button(); this._addButton();
log_debug('On-demand Timer enabled.'); logDebug('On-demand Timer enabled.');
} }
disable() { disable() {
log_debug('Disabling On-demand Timer ...'); logDebug('Disabling On-demand Timer ...');
this._remove_keybinding(); this._removeKeybinding();
this._remove_button(); this._removeButton();
log_debug('On-demand Timer disabled.'); logDebug('On-demand Timer disabled.');
} }
get time() { get time() {
return e.settingsManager.ondemand_time; return e.settingsManager.ondemandTime;
} }
_add_keybinding() { _addKeybinding() {
log_debug('Adding On-demand Timer keybinding...'); logDebug('Adding On-demand Timer keybinding...');
// add our own keydinging handler // add our own keydinging handler
main.wm.addKeybinding( main.wm.addKeybinding(
'nightthemeswitcher-ondemand-keybinding', 'nightthemeswitcher-ondemand-keybinding',
e.settingsManager._extensionsSettings, e.settingsManager._extensionsSettings,
key_binding_auto_repeat(), keyBindingAutoRepeat(),
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW, Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
this._toggle_time.bind(this) this._toggleTime.bind(this)
); );
log_debug('Added On-demand Timer keybinding.'); logDebug('Added On-demand Timer keybinding.');
} }
_remove_keybinding() { _removeKeybinding() {
log_debug('Removing On-demand Timer keybinding...'); logDebug('Removing On-demand Timer keybinding...');
main.wm.removeKeybinding('nightthemeswitcher-ondemand-keybinding'); main.wm.removeKeybinding('nightthemeswitcher-ondemand-keybinding');
log_debug('Removed On-demand Timer keybinding.'); logDebug('Removed On-demand Timer keybinding.');
} }
_add_button() { _addButton() {
log_debug('Adding On-demand Timer button...'); logDebug('Adding On-demand Timer button...');
this._icon = new St.Icon({ this._icon = new St.Icon({
icon_name: this._get_icon_name_for_current_time(), icon_name: this._getIconNameForCurrentTime(),
style_class: 'system-status-icon' style_class: 'system-status-icon',
}); });
this._button = new panelMenu.Button(0.0); this._button = new panelMenu.Button(0.0);
const button_actor = get_actor(this._button); const buttonActor = getActor(this._button);
button_actor.add_actor(this._icon); buttonActor.add_actor(this._icon);
button_actor.connect( buttonActor.connect(
'button-press-event', 'button-press-event',
this._toggle_time.bind(this) this._toggleTime.bind(this)
); );
main.panel.addToStatusArea('NightThemeSwitcherButton', this._button); main.panel.addToStatusArea('NightThemeSwitcherButton', this._button);
log_debug('Added On-demand Timer button.'); logDebug('Added On-demand Timer button.');
} }
_remove_button() { _removeButton() {
log_debug('Removing On-demand Timer button...'); logDebug('Removing On-demand Timer button...');
this._button.destroy(); this._button.destroy();
log_debug('Removed On-demand Timer button.'); logDebug('Removed On-demand Timer button.');
} }
_toggle_time() { _toggleTime() {
e.settingsManager.ondemand_time = e.timer.time === 'day' ? 'night' : 'day'; e.settingsManager.ondemandTime = e.timer.time === 'day' ? 'night' : 'day';
this.emit('time-changed', this.time); this.emit('time-changed', this.time);
this._icon.icon_name = this._get_icon_name_for_current_time(); this._icon.icon_name = this._getIconNameForCurrentTime();
} }
_get_icon_name_for_current_time() { _getIconNameForCurrentTime() {
return e.timer.time === 'day' ? 'weather-clear-symbolic' : 'weather-clear-night-symbolic'; return e.timer.time === 'day' ? 'weather-clear-symbolic' : 'weather-clear-night-symbolic';
} }
} };
Signals.addSignalMethods(TimerOndemand.prototype); Signals.addSignalMethods(TimerOndemand.prototype);
+42 -41
View File
@@ -23,7 +23,7 @@ const Signals = imports.signals;
const Me = extensionUtils.getCurrentExtension(); const Me = extensionUtils.getCurrentExtension();
const e = Me.imports.extension; const e = Me.imports.extension;
const { log_debug } = Me.imports.utils; const { logDebug } = Me.imports.utils;
/** /**
@@ -36,53 +36,54 @@ const { log_debug } = Me.imports.utils;
*/ */
var TimerSchedule = class { var TimerSchedule = class {
constructor() { constructor() {
this._previously_daytime = null; this._previouslyDaytime = null;
} this._timeChangeTimer = null;
}
enable() { enable() {
log_debug('Enabling Schedule Timer...'); logDebug('Enabling Schedule Timer...');
this._watch_for_time_change(); this._watchForTimeChange();
log_debug('Schedule Timer enabled.'); logDebug('Schedule Timer enabled.');
} }
disable() { disable() {
log_debug('Disabling Schedule Timer...'); logDebug('Disabling Schedule Timer...');
this._stop_watching_for_time_change(); this._stopWatchingForTimeChange();
log_debug('Schedule Timer disabled.'); logDebug('Schedule Timer disabled.');
} }
get time() { get time() {
return this._is_daytime() ? 'day' : 'night'; return this._isDaytime() ? 'day' : 'night';
} }
_is_daytime() { _isDaytime() {
const time = GLib.DateTime.new_now_local(); const time = GLib.DateTime.new_now_local();
const hour = time.get_hour() + time.get_minute() / 60 + time.get_second() / 3600; const hour = time.get_hour() + time.get_minute() / 60 + time.get_second() / 3600;
return ( hour >= e.settingsManager.schedule_sunrise && hour <= e.settingsManager.schedule_sunset ); return hour >= e.settingsManager.scheduleSunrise && hour <= e.settingsManager.scheduleSunset;
} }
_watch_for_time_change() { _watchForTimeChange() {
log_debug('Watching for time change...'); logDebug('Watching for time change...');
this._time_change_timer = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 1, () => { this._timeChangeTimer = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 1, () => {
if ( !Me.imports.extension.enabled ) { if (!Me.imports.extension.enabled) {
// The extension doesn't exist anymore, quit the loop // The extension doesn't exist anymore, quit the loop
return false; return false;
} }
if ( this._previously_daytime !== this._is_daytime() ) { if (this._previouslyDaytime !== this._isDaytime()) {
this._previously_daytime = this._is_daytime(); this._previouslyDaytime = this._isDaytime();
this.emit('time-changed', this.time); this.emit('time-changed', this.time);
} }
return true; // Repeat the loop return true; // Repeat the loop
}); });
} }
_stop_watching_for_time_change() { _stopWatchingForTimeChange() {
GLib.Source.remove(this._time_change_timer); GLib.Source.remove(this._timeChangeTimer);
log_debug('Stopped watching for time change.'); logDebug('Stopped watching for time change.');
} }
} };
Signals.addSignalMethods(TimerSchedule.prototype); Signals.addSignalMethods(TimerSchedule.prototype);
+64 -64
View File
@@ -30,89 +30,89 @@ const _ = Gettext.gettext;
var BackgroundsPreferences = class { var BackgroundsPreferences = class {
constructor() { constructor() {
const settings = compat.get_extension_settings(); const settings = compat.getExtensionSettings();
const label = _('Backgrounds'); const label = _('Backgrounds');
const description = _('You can set different backgrounds for day and night.'); const description = _('You can set different backgrounds for day and night.');
const content = new SettingsList(); const content = new SettingsList();
content.add_row(new SettingsListRow(_('Switch backgrounds'), new BackgroundsEnabledControl())); content.add_row(new SettingsListRow(_('Switch backgrounds'), new BackgroundsEnabledControl()));
const day_background_row = new SettingsListRow(_('Day background'), new TimeBackgroundControl('day')); const dayBackgroundRow = new SettingsListRow(_('Day background'), new TimeBackgroundControl('day'));
settings.bind( settings.bind(
'backgrounds-enabled', 'backgrounds-enabled',
day_background_row, dayBackgroundRow,
'sensitive', 'sensitive',
Gio.SettingsBindFlags.DEFAULT Gio.SettingsBindFlags.DEFAULT
); );
content.add_row(day_background_row); content.add_row(dayBackgroundRow);
const night_background_row = new SettingsListRow(_('Night background'), new TimeBackgroundControl('night')); const nightBackgroundRow = new SettingsListRow(_('Night background'), new TimeBackgroundControl('night'));
settings.bind( settings.bind(
'backgrounds-enabled', 'backgrounds-enabled',
night_background_row, nightBackgroundRow,
'sensitive', 'sensitive',
Gio.SettingsBindFlags.DEFAULT Gio.SettingsBindFlags.DEFAULT
); );
content.add_row(night_background_row); content.add_row(nightBackgroundRow);
return new SettingsPage(label, description, content); return new SettingsPage(label, description, content);
} }
} };
class BackgroundsEnabledControl { class BackgroundsEnabledControl {
constructor() { constructor() {
const settings = compat.get_extension_settings(); const settings = compat.getExtensionSettings();
const toggle = new Gtk.Switch({ const toggle = new Gtk.Switch({
active: settings.get_boolean('backgrounds-enabled') active: settings.get_boolean('backgrounds-enabled'),
}); });
settings.bind( settings.bind(
'backgrounds-enabled', 'backgrounds-enabled',
toggle, toggle,
'active', 'active',
Gio.SettingsBindFlags.DEFAULT Gio.SettingsBindFlags.DEFAULT
); );
return toggle; return toggle;
} }
} }
class TimeBackgroundControl { class TimeBackgroundControl {
constructor(time) { constructor(time) {
const settings = compat.get_extension_settings(); const settings = compat.getExtensionSettings();
const filter = new Gtk.FileFilter(); const filter = new Gtk.FileFilter();
filter.add_mime_type('image/jpeg'); filter.add_mime_type('image/jpeg');
filter.add_mime_type('image/png'); filter.add_mime_type('image/png');
filter.add_mime_type('image/tiff'); filter.add_mime_type('image/tiff');
const preview = new Gtk.Image({ const preview = new Gtk.Image({
pixel_size: 256 pixel_size: 256,
}); });
const button = new Gtk.FileChooserButton({ const button = new Gtk.FileChooserButton({
title: _('Select your background image'), title: _('Select your background image'),
action: Gtk.FileChooserAction.OPEN, action: Gtk.FileChooserAction.OPEN,
filter: filter, filter,
preview_widget: preview, preview_widget: preview,
use_preview_label: false use_preview_label: false,
}); });
button.set_uri(settings.get_string(`background-${time}`)); button.set_uri(settings.get_string(`background-${time}`));
button.connect('update-preview', () => { button.connect('update-preview', () => {
const file = button.get_preview_filename(); const file = button.get_preview_filename();
const pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(file, 256, 256); const pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(file, 256, 256);
preview.set_from_pixbuf(pixbuf); preview.set_from_pixbuf(pixbuf);
}); });
button.connect('file-set', () => settings.set_string(`background-${time}`, button.get_uri())); button.connect('file-set', () => settings.set_string(`background-${time}`, button.get_uri()));
settings.connect(`changed::background-${time}`, () => button.set_uri(settings.get_string(`background-${time}`))); settings.connect(`changed::background-${time}`, () => button.set_uri(settings.get_string(`background-${time}`)));
return button; return button;
} }
} }
+56 -56
View File
@@ -30,77 +30,77 @@ const _ = Gettext.gettext;
var CommandsPreferences = class { var CommandsPreferences = class {
constructor() { constructor() {
const settings = compat.get_extension_settings(); const settings = compat.getExtensionSettings();
const label = _('Commands'); const label = _('Commands');
const description = _('You can set custom commands that will be run when the time of the day changes.'); const description = _('You can set custom commands that will be run when the time of the day changes.');
const content = new SettingsList(); const content = new SettingsList();
content.add_row(new SettingsListRow(_('Use custom commands'), new CommandsEnabledControl())); content.add_row(new SettingsListRow(_('Use custom commands'), new CommandsEnabledControl()));
const day_command_row = new SettingsListRow(_('Sunrise'), new SuntimeCommandControl('sunrise')); const dayCommandRow = new SettingsListRow(_('Sunrise'), new SuntimeCommandControl('sunrise'));
settings.bind( settings.bind(
'commands-enabled', 'commands-enabled',
day_command_row, dayCommandRow,
'sensitive', 'sensitive',
Gio.SettingsBindFlags.DEFAULT Gio.SettingsBindFlags.DEFAULT
); );
content.add_row(day_command_row); content.add_row(dayCommandRow);
const night_command_row = new SettingsListRow(_('Sunset'), new SuntimeCommandControl('sunset')); const nightCommandRow = new SettingsListRow(_('Sunset'), new SuntimeCommandControl('sunset'));
settings.bind( settings.bind(
'commands-enabled', 'commands-enabled',
night_command_row, nightCommandRow,
'sensitive', 'sensitive',
Gio.SettingsBindFlags.DEFAULT Gio.SettingsBindFlags.DEFAULT
); );
content.add_row(night_command_row); content.add_row(nightCommandRow);
return new SettingsPage(label, description, content); return new SettingsPage(label, description, content);
} }
} };
class CommandsEnabledControl { class CommandsEnabledControl {
constructor() { constructor() {
const settings = compat.get_extension_settings(); const settings = compat.getExtensionSettings();
const toggle = new Gtk.Switch({ const toggle = new Gtk.Switch({
active: settings.get_boolean('commands-enabled') active: settings.get_boolean('commands-enabled'),
}); });
settings.bind( settings.bind(
'commands-enabled', 'commands-enabled',
toggle, toggle,
'active', 'active',
Gio.SettingsBindFlags.DEFAULT Gio.SettingsBindFlags.DEFAULT
); );
return toggle; return toggle;
} }
} }
class SuntimeCommandControl { class SuntimeCommandControl {
constructor(suntime) { constructor(suntime) {
const message = new Map([ const message = new Map([
['sunrise', _('Hello sunshine!')], ['sunrise', _('Hello sunshine!')],
['sunset', _('Hello moonshine!')] ['sunset', _('Hello moonshine!')],
]); ]);
const settings = compat.get_extension_settings(); const settings = compat.getExtensionSettings();
const entry = new Gtk.Entry({ const entry = new Gtk.Entry({
width_request: 300, width_request: 300,
placeholder_text: _(`notify-send "${message.get(suntime)}"`) placeholder_text: _(`notify-send "${message.get(suntime)}"`),
}); });
settings.bind( settings.bind(
`command-${suntime}`, `command-${suntime}`,
entry, entry,
'text', 'text',
Gio.SettingsBindFlags.DEFAULT Gio.SettingsBindFlags.DEFAULT
); );
return entry; return entry;
} }
} }
+52 -52
View File
@@ -23,7 +23,7 @@ const Me = extensionUtils.getCurrentExtension();
const compat = Me.imports.compat; const compat = Me.imports.compat;
const { SettingsPage, SettingsList, SettingsListRow } = Me.imports.preferences.bases; const { SettingsPage, SettingsList, SettingsListRow } = Me.imports.preferences.bases;
const { get_installed_cursor_themes } = Me.imports.utils; const { getInstalledCursorThemes } = Me.imports.utils;
const Gettext = imports.gettext.domain(Me.metadata.uuid); const Gettext = imports.gettext.domain(Me.metadata.uuid);
const _ = Gettext.gettext; const _ = Gettext.gettext;
@@ -31,72 +31,72 @@ const _ = Gettext.gettext;
var CursorThemePreferences = class { var CursorThemePreferences = class {
constructor() { constructor() {
const settings = compat.get_extension_settings(); const settings = compat.getExtensionSettings();
const label = _('Cursor theme'); const label = _('Cursor theme');
const description = _('You can set different cursor themes for day and night.'); const description = _('You can set different cursor themes for day and night.');
const content = new SettingsList(); const content = new SettingsList();
content.add_row(new SettingsListRow(_('Switch cursor variants'), new CursorVariantsEnabledControl())); content.add_row(new SettingsListRow(_('Switch cursor variants'), new CursorVariantsEnabledControl()));
const day_variant_row = new SettingsListRow(_('Day variant'), new TimeCursorVariantControl('day')); const dayVariantRow = new SettingsListRow(_('Day variant'), new TimeCursorVariantControl('day'));
settings.bind( settings.bind(
'cursor-variants-enabled', 'cursor-variants-enabled',
day_variant_row, dayVariantRow,
'sensitive', 'sensitive',
Gio.SettingsBindFlags.DEFAULT Gio.SettingsBindFlags.DEFAULT
); );
content.add_row(day_variant_row); content.add_row(dayVariantRow);
const night_variant_row = new SettingsListRow(_('Night variant'), new TimeCursorVariantControl('night')); const nightVariantRow = new SettingsListRow(_('Night variant'), new TimeCursorVariantControl('night'));
settings.bind( settings.bind(
'cursor-variants-enabled', 'cursor-variants-enabled',
night_variant_row, nightVariantRow,
'sensitive', 'sensitive',
Gio.SettingsBindFlags.DEFAULT Gio.SettingsBindFlags.DEFAULT
); );
content.add_row(night_variant_row); content.add_row(nightVariantRow);
return new SettingsPage(label, description, content); return new SettingsPage(label, description, content);
} }
} };
class CursorVariantsEnabledControl { class CursorVariantsEnabledControl {
constructor() { constructor() {
const settings = compat.get_extension_settings(); const settings = compat.getExtensionSettings();
const toggle = new Gtk.Switch({ const toggle = new Gtk.Switch({
active: settings.get_boolean('cursor-variants-enabled') active: settings.get_boolean('cursor-variants-enabled'),
}); });
settings.bind( settings.bind(
'cursor-variants-enabled', 'cursor-variants-enabled',
toggle, toggle,
'active', 'active',
Gio.SettingsBindFlags.DEFAULT Gio.SettingsBindFlags.DEFAULT
); );
return toggle; return toggle;
} }
} }
class TimeCursorVariantControl { class TimeCursorVariantControl {
constructor(time) { constructor(time) {
const settings = compat.get_extension_settings(); const settings = compat.getExtensionSettings();
const combo = new Gtk.ComboBoxText(); const combo = new Gtk.ComboBoxText();
const themes = Array.from(get_installed_cursor_themes()).sort(); const themes = Array.from(getInstalledCursorThemes()).sort();
themes.forEach(theme => combo.append(theme, theme)); themes.forEach(theme => combo.append(theme, theme));
settings.bind( settings.bind(
`cursor-variant-${time}`, `cursor-variant-${time}`,
combo, combo,
'active-id', 'active-id',
Gio.SettingsBindFlags.DEFAULT Gio.SettingsBindFlags.DEFAULT
); );
return combo; return combo;
} }
} }
+69 -69
View File
@@ -23,7 +23,7 @@ const Me = extensionUtils.getCurrentExtension();
const compat = Me.imports.compat; const compat = Me.imports.compat;
const { SettingsPage, SettingsList, SettingsListRow } = Me.imports.preferences.bases; const { SettingsPage, SettingsList, SettingsListRow } = Me.imports.preferences.bases;
const { get_installed_gtk_themes } = Me.imports.utils; const { getInstalledGtkThemes } = Me.imports.utils;
const Gettext = imports.gettext.domain(Me.metadata.uuid); const Gettext = imports.gettext.domain(Me.metadata.uuid);
const _ = Gettext.gettext; const _ = Gettext.gettext;
@@ -31,96 +31,96 @@ const _ = Gettext.gettext;
var GtkThemePreferences = class { var GtkThemePreferences = class {
constructor() { constructor() {
const settings = compat.get_extension_settings(); const settings = compat.getExtensionSettings();
const label = _('GTK theme'); const label = _('GTK theme');
const description = _('The extension will try to automatically detect the day and night variants of your GTK theme.\n\nIf the theme you use isn\'t supported, please <a href="https://gitlab.com/rmnvgr/nightthemeswitcher-gnome-shell-extension/-/issues">submit a request</a>. You can also manually set variants.'); const description = _('The extension will try to automatically detect the day and night variants of your GTK theme.\n\nIf the theme you use isn\'t supported, please <a href="https://gitlab.com/rmnvgr/nightthemeswitcher-gnome-shell-extension/-/issues">submit a request</a>. You can also manually set variants.');
const content = new SettingsList(); const content = new SettingsList();
content.add_row(new SettingsListRow(_('Switch GTK variants'), new GtkVariantsEnabledControl())); content.add_row(new SettingsListRow(_('Switch GTK variants'), new GtkVariantsEnabledControl()));
const manual_variants_row = new SettingsListRow(_('Manual variants'), new ManualGtkVariantsControl()); const manualVariantsRow = new SettingsListRow(_('Manual variants'), new ManualGtkVariantsControl());
settings.bind( settings.bind(
'gtk-variants-enabled', 'gtk-variants-enabled',
manual_variants_row, manualVariantsRow,
'sensitive', 'sensitive',
Gio.SettingsBindFlags.DEFAULT Gio.SettingsBindFlags.DEFAULT
); );
content.add_row(manual_variants_row); content.add_row(manualVariantsRow);
const day_variant_row = new SettingsListRow(_('Day variant'), new TimeGtkVariantControl('day')); const dayVariantRow = new SettingsListRow(_('Day variant'), new TimeGtkVariantControl('day'));
const update_day_variant_row_sensitivity = () => day_variant_row.set_sensitive(!!(settings.get_boolean('gtk-variants-enabled') && settings.get_boolean('manual-gtk-variants'))); const updateDayVariantRowSensitivity = () => dayVariantRow.set_sensitive(!!(settings.get_boolean('gtk-variants-enabled') && settings.get_boolean('manual-gtk-variants')));
settings.connect('changed::gtk-variants-enabled', update_day_variant_row_sensitivity); settings.connect('changed::gtk-variants-enabled', updateDayVariantRowSensitivity);
settings.connect('changed::manual-gtk-variants', update_day_variant_row_sensitivity) settings.connect('changed::manual-gtk-variants', updateDayVariantRowSensitivity);
update_day_variant_row_sensitivity(); updateDayVariantRowSensitivity();
content.add_row(day_variant_row); content.add_row(dayVariantRow);
const night_variant_row = new SettingsListRow(_('Night variant'), new TimeGtkVariantControl('night')); const nightVariantRow = new SettingsListRow(_('Night variant'), new TimeGtkVariantControl('night'));
const update_night_variant_row_sensitivity = () => night_variant_row.set_sensitive(!!(settings.get_boolean('gtk-variants-enabled') && settings.get_boolean('manual-gtk-variants'))); const updateNightVariantRowSensitivity = () => nightVariantRow.set_sensitive(!!(settings.get_boolean('gtk-variants-enabled') && settings.get_boolean('manual-gtk-variants')));
settings.connect('changed::gtk-variants-enabled', update_night_variant_row_sensitivity); settings.connect('changed::gtk-variants-enabled', updateNightVariantRowSensitivity);
settings.connect('changed::manual-gtk-variants', update_night_variant_row_sensitivity) settings.connect('changed::manual-gtk-variants', updateNightVariantRowSensitivity);
update_night_variant_row_sensitivity(); updateNightVariantRowSensitivity();
content.add_row(night_variant_row); content.add_row(nightVariantRow);
return new SettingsPage(label, description, content); return new SettingsPage(label, description, content);
} }
} };
class GtkVariantsEnabledControl { class GtkVariantsEnabledControl {
constructor() { constructor() {
const settings = compat.get_extension_settings(); const settings = compat.getExtensionSettings();
const toggle = new Gtk.Switch({ const toggle = new Gtk.Switch({
active: settings.get_boolean('gtk-variants-enabled') active: settings.get_boolean('gtk-variants-enabled'),
}); });
settings.bind( settings.bind(
'gtk-variants-enabled', 'gtk-variants-enabled',
toggle, toggle,
'active', 'active',
Gio.SettingsBindFlags.DEFAULT Gio.SettingsBindFlags.DEFAULT
); );
return toggle; return toggle;
} }
} }
class ManualGtkVariantsControl { class ManualGtkVariantsControl {
constructor() { constructor() {
const settings = compat.get_extension_settings(); const settings = compat.getExtensionSettings();
const toggle = new Gtk.Switch({ const toggle = new Gtk.Switch({
active: false active: false,
}); });
settings.bind( settings.bind(
'manual-gtk-variants', 'manual-gtk-variants',
toggle, toggle,
'active', 'active',
Gio.SettingsBindFlags.DEFAULT Gio.SettingsBindFlags.DEFAULT
); );
return toggle; return toggle;
} }
} }
class TimeGtkVariantControl { class TimeGtkVariantControl {
constructor(time) { constructor(time) {
const settings = compat.get_extension_settings(); const settings = compat.getExtensionSettings();
const combo = new Gtk.ComboBoxText(); const combo = new Gtk.ComboBoxText();
const themes = Array.from(get_installed_gtk_themes()).sort(); const themes = Array.from(getInstalledGtkThemes()).sort();
themes.forEach(theme => combo.append(theme, theme)); themes.forEach(theme => combo.append(theme, theme));
settings.bind( settings.bind(
`gtk-variant-${time}`, `gtk-variant-${time}`,
combo, combo,
'active-id', 'active-id',
Gio.SettingsBindFlags.DEFAULT Gio.SettingsBindFlags.DEFAULT
); );
return combo; return combo;
} }
} }
+52 -52
View File
@@ -23,7 +23,7 @@ const Me = extensionUtils.getCurrentExtension();
const compat = Me.imports.compat; const compat = Me.imports.compat;
const { SettingsPage, SettingsList, SettingsListRow } = Me.imports.preferences.bases; const { SettingsPage, SettingsList, SettingsListRow } = Me.imports.preferences.bases;
const { get_installed_icon_themes } = Me.imports.utils; const { getInstalledIconThemes } = Me.imports.utils;
const Gettext = imports.gettext.domain(Me.metadata.uuid); const Gettext = imports.gettext.domain(Me.metadata.uuid);
const _ = Gettext.gettext; const _ = Gettext.gettext;
@@ -31,72 +31,72 @@ const _ = Gettext.gettext;
var IconThemePreferences = class { var IconThemePreferences = class {
constructor() { constructor() {
const settings = compat.get_extension_settings(); const settings = compat.getExtensionSettings();
const label = _('Icon theme'); const label = _('Icon theme');
const description = _('You can set different icon themes for day and night.'); const description = _('You can set different icon themes for day and night.');
const content = new SettingsList(); const content = new SettingsList();
content.add_row(new SettingsListRow(_('Switch icon variants'), new IconVariantsEnabledControl())); content.add_row(new SettingsListRow(_('Switch icon variants'), new IconVariantsEnabledControl()));
const day_variant_row = new SettingsListRow(_('Day variant'), new TimeIconVariantControl('day')); const dayVariantRow = new SettingsListRow(_('Day variant'), new TimeIconVariantControl('day'));
settings.bind( settings.bind(
'icon-variants-enabled', 'icon-variants-enabled',
day_variant_row, dayVariantRow,
'sensitive', 'sensitive',
Gio.SettingsBindFlags.DEFAULT Gio.SettingsBindFlags.DEFAULT
); );
content.add_row(day_variant_row); content.add_row(dayVariantRow);
const night_variant_row = new SettingsListRow(_('Night variant'), new TimeIconVariantControl('night')); const nightVariantRow = new SettingsListRow(_('Night variant'), new TimeIconVariantControl('night'));
settings.bind( settings.bind(
'icon-variants-enabled', 'icon-variants-enabled',
night_variant_row, nightVariantRow,
'sensitive', 'sensitive',
Gio.SettingsBindFlags.DEFAULT Gio.SettingsBindFlags.DEFAULT
); );
content.add_row(night_variant_row); content.add_row(nightVariantRow);
return new SettingsPage(label, description, content); return new SettingsPage(label, description, content);
} }
} };
class IconVariantsEnabledControl { class IconVariantsEnabledControl {
constructor() { constructor() {
const settings = compat.get_extension_settings(); const settings = compat.getExtensionSettings();
const toggle = new Gtk.Switch({ const toggle = new Gtk.Switch({
active: settings.get_boolean('icon-variants-enabled') active: settings.get_boolean('icon-variants-enabled'),
}); });
settings.bind( settings.bind(
'icon-variants-enabled', 'icon-variants-enabled',
toggle, toggle,
'active', 'active',
Gio.SettingsBindFlags.DEFAULT Gio.SettingsBindFlags.DEFAULT
); );
return toggle; return toggle;
} }
} }
class TimeIconVariantControl { class TimeIconVariantControl {
constructor(time) { constructor(time) {
const settings = compat.get_extension_settings(); const settings = compat.getExtensionSettings();
const combo = new Gtk.ComboBoxText(); const combo = new Gtk.ComboBoxText();
const themes = Array.from(get_installed_icon_themes()).sort(); const themes = Array.from(getInstalledIconThemes()).sort();
themes.forEach(theme => combo.append(theme, theme)); themes.forEach(theme => combo.append(theme, theme));
settings.bind( settings.bind(
`icon-variant-${time}`, `icon-variant-${time}`,
combo, combo,
'active-id', 'active-id',
Gio.SettingsBindFlags.DEFAULT Gio.SettingsBindFlags.DEFAULT
); );
return combo; return combo;
} }
} }
+223 -226
View File
@@ -30,280 +30,277 @@ const _ = Gettext.gettext;
var SchedulePreferences = class { var SchedulePreferences = class {
constructor() { constructor() {
const settings = compat.get_extension_settings(); const settings = compat.getExtensionSettings();
const label = _('Schedule'); const label = _('Schedule');
const description = _('The extension will try to use Night Light or Location Services to automatically set your current sunrise and sunset times if they are enabled.\n\nIf you prefer, you can manually choose a time source.'); const description = _('The extension will try to use Night Light or Location Services to automatically set your current sunrise and sunset times if they are enabled.\n\nIf you prefer, you can manually choose a time source.');
const content = new SettingsList(); const content = new SettingsList();
content.add_row(new SettingsListRow(_('Automatic time source'), new ManualTimeSourceControl())); content.add_row(new SettingsListRow(_('Automatic time source'), new ManualTimeSourceControl()));
const time_source_row = new SettingsListRow(_('Time source'), new TimeSourceControl()); const timeSourceRow = new SettingsListRow(_('Time source'), new TimeSourceControl());
settings.bind( settings.bind(
'manual-time-source', 'manual-time-source',
time_source_row, timeSourceRow,
'sensitive', 'sensitive',
Gio.SettingsBindFlags.DEFAULT Gio.SettingsBindFlags.DEFAULT
); );
content.add_row(time_source_row); content.add_row(timeSourceRow);
const ondemand_shortcut_row = new SettingsListRow(_('On-demand shortcut'), new KeyBindingControl()); const ondemandShortcutRow = new SettingsListRow(_('On-demand shortcut'), new KeyBindingControl());
const update_ondemand_shortcut_row_sensitivity = () => ondemand_shortcut_row.set_sensitive(!!(settings.get_boolean('manual-time-source') && settings.get_string('time-source') === 'ondemand')); const updateOndemandShortcutRowSensitivity = () => ondemandShortcutRow.set_sensitive(!!(settings.get_boolean('manual-time-source') && settings.get_string('time-source') === 'ondemand'));
settings.connect('changed::manual-time-source', () => update_ondemand_shortcut_row_sensitivity()); settings.connect('changed::manual-time-source', () => updateOndemandShortcutRowSensitivity());
settings.connect('changed::time-source', () => update_ondemand_shortcut_row_sensitivity()); settings.connect('changed::time-source', () => updateOndemandShortcutRowSensitivity());
update_ondemand_shortcut_row_sensitivity(); updateOndemandShortcutRowSensitivity();
content.add_row(ondemand_shortcut_row); content.add_row(ondemandShortcutRow);
const sunrise_row = new SettingsListRow(_('Sunrise'), new SuntimeControl('sunrise')); const sunriseRow = new SettingsListRow(_('Sunrise'), new SuntimeControl('sunrise'));
const update_sunrise_row_sensitivity = () => sunrise_row.set_sensitive(!!(settings.get_boolean('manual-time-source') && settings.get_string('time-source') === 'schedule')); const updateSunriseRowSensitivity = () => sunriseRow.set_sensitive(!!(settings.get_boolean('manual-time-source') && settings.get_string('time-source') === 'schedule'));
settings.connect('changed::manual-time-source', () => update_sunrise_row_sensitivity()); settings.connect('changed::manual-time-source', () => updateSunriseRowSensitivity());
settings.connect('changed::time-source', () => update_sunrise_row_sensitivity()); settings.connect('changed::time-source', () => updateSunriseRowSensitivity());
update_sunrise_row_sensitivity(); updateSunriseRowSensitivity();
content.add_row(sunrise_row); content.add_row(sunriseRow);
const sunset_row = new SettingsListRow(_('Sunset'), new SuntimeControl('sunset')); const sunsetRow = new SettingsListRow(_('Sunset'), new SuntimeControl('sunset'));
const update_sunset_row_sensitivity = () => sunset_row.set_sensitive(!!(settings.get_boolean('manual-time-source') && settings.get_string('time-source') === 'schedule')); const updateSunsetRowSensitivity = () => sunsetRow.set_sensitive(!!(settings.get_boolean('manual-time-source') && settings.get_string('time-source') === 'schedule'));
settings.connect('changed::manual-time-source', () => update_sunset_row_sensitivity()); settings.connect('changed::manual-time-source', () => updateSunsetRowSensitivity());
settings.connect('changed::time-source', () => update_sunset_row_sensitivity()); settings.connect('changed::time-source', () => updateSunsetRowSensitivity());
update_sunset_row_sensitivity(); updateSunsetRowSensitivity();
content.add_row(sunset_row); content.add_row(sunsetRow);
return new SettingsPage(label, description, content); return new SettingsPage(label, description, content);
} }
} };
class ManualTimeSourceControl { class ManualTimeSourceControl {
constructor() { constructor() {
const settings = compat.get_extension_settings(); const settings = compat.getExtensionSettings();
const toggle = new Gtk.Switch({ const toggle = new Gtk.Switch({
active: false active: false,
}); });
settings.bind( settings.bind(
'manual-time-source', 'manual-time-source',
toggle, toggle,
'active', 'active',
Gio.SettingsBindFlags.INVERT_BOOLEAN Gio.SettingsBindFlags.INVERT_BOOLEAN
); );
return toggle; return toggle;
} }
} }
class TimeSourceControl { class TimeSourceControl {
constructor() { constructor() {
const settings = compat.get_extension_settings(); const settings = compat.getExtensionSettings();
const colorSettings = new Gio.Settings({ schema: 'org.gnome.settings-daemon.plugins.color' }); const colorSettings = new Gio.Settings({ schema: 'org.gnome.settings-daemon.plugins.color' });
const locationSettings = new Gio.Settings({ schema: 'org.gnome.system.location' }); const locationSettings = new Gio.Settings({ schema: 'org.gnome.system.location' });
const box = new Gtk.Box({ const box = new Gtk.Box({
spacing: 8, spacing: 8,
orientation: Gtk.Orientation.HORIZONTAL, orientation: Gtk.Orientation.HORIZONTAL,
can_focus: false can_focus: false,
}); });
const nightlight_radio = new Gtk.RadioButton({ const nightlightRadio = new Gtk.RadioButton({
label: _('Night Light'), label: _('Night Light'),
active: (settings.get_string('time-source') === 'nightlight') active: settings.get_string('time-source') === 'nightlight',
}); });
nightlight_radio.connect('toggled', () => { nightlightRadio.connect('toggled', () => {
if ( nightlight_radio.get_active() ) { if (nightlightRadio.get_active())
settings.set_string('time-source', 'nightlight') settings.set_string('time-source', 'nightlight');
} });
}); colorSettings.bind(
colorSettings.bind( 'night-light-enabled',
'night-light-enabled', nightlightRadio,
nightlight_radio, 'sensitive',
'sensitive', Gio.SettingsBindFlags.DEFAULT
Gio.SettingsBindFlags.DEFAULT );
); box.pack_start(nightlightRadio, false, false, 0);
box.pack_start(nightlight_radio, false, false, 0);
const location_radio = new Gtk.RadioButton({ const locationRadio = new Gtk.RadioButton({
label: _('Location Services'), label: _('Location Services'),
group: nightlight_radio, group: nightlightRadio,
active: (settings.get_string('time-source') === 'location') active: settings.get_string('time-source') === 'location',
}); });
location_radio.connect('toggled', () => { locationRadio.connect('toggled', () => {
if ( location_radio.get_active() ) { if (locationRadio.get_active())
settings.set_string('time-source', 'location') settings.set_string('time-source', 'location');
} });
}); locationSettings.bind(
locationSettings.bind( 'enabled',
'enabled', locationRadio,
location_radio, 'sensitive',
'sensitive', Gio.SettingsBindFlags.DEFAULT
Gio.SettingsBindFlags.DEFAULT );
); box.pack_start(locationRadio, false, false, 0);
box.pack_start(location_radio, false, false, 0);
const schedule_radio = new Gtk.RadioButton({ const scheduleRadio = new Gtk.RadioButton({
label: _('Manual schedule'), label: _('Manual schedule'),
group: nightlight_radio, group: nightlightRadio,
active: (settings.get_string('time-source') === 'schedule') active: settings.get_string('time-source') === 'schedule',
}); });
schedule_radio.connect('toggled', () => { scheduleRadio.connect('toggled', () => {
if ( schedule_radio.get_active() ) { if (scheduleRadio.get_active())
settings.set_string('time-source', 'schedule') settings.set_string('time-source', 'schedule');
} });
}); settings.bind(
settings.bind( 'manual-time-source',
'manual-time-source', scheduleRadio,
schedule_radio, 'sensitive',
'sensitive', Gio.SettingsBindFlags.DEFAULT
Gio.SettingsBindFlags.DEFAULT );
); box.pack_start(scheduleRadio, false, false, 0);
box.pack_start(schedule_radio, false, false, 0);
const ondemand_radio = new Gtk.RadioButton({ const ondemandRadio = new Gtk.RadioButton({
label: _('On-demand'), label: _('On-demand'),
group: nightlight_radio, group: nightlightRadio,
active: (settings.get_string('time-source') === 'ondemand') active: settings.get_string('time-source') === 'ondemand',
}); });
ondemand_radio.connect('toggled', () => { ondemandRadio.connect('toggled', () => {
settings.set_string('time-source', 'ondemand') settings.set_string('time-source', 'ondemand');
}); });
settings.bind( settings.bind(
'manual-time-source', 'manual-time-source',
ondemand_radio, ondemandRadio,
'sensitive', 'sensitive',
Gio.SettingsBindFlags.DEFAULT Gio.SettingsBindFlags.DEFAULT
); );
box.pack_start(ondemand_radio, false, false, 0); box.pack_start(ondemandRadio, false, false, 0);
return box; return box;
} }
} }
class KeyBindingControl { class KeyBindingControl {
constructor() { constructor() {
const settings = compat.get_extension_settings(); const settings = compat.getExtensionSettings();
const KEYBINDING_KEY = 'nightthemeswitcher-ondemand-keybinding'; const KEYBINDING_KEY = 'nightthemeswitcher-ondemand-keybinding';
const COLUMN_KEY = 0; const COLUMN_KEY = 0;
const COLUMN_MODS = 1; const COLUMN_MODS = 1;
const list_store = new Gtk.ListStore(); const listStore = new Gtk.ListStore();
list_store.set_column_types([GObject.TYPE_INT, GObject.TYPE_INT]); listStore.set_column_types([GObject.TYPE_INT, GObject.TYPE_INT]);
const tree_view = new Gtk.TreeView({model: list_store}); const treeView = new Gtk.TreeView({ model: listStore });
tree_view.set_headers_visible(false); treeView.set_headers_visible(false);
const renderer = new Gtk.CellRendererAccel({ editable: true}); const renderer = new Gtk.CellRendererAccel({ editable: true });
const column = new Gtk.TreeViewColumn(); const column = new Gtk.TreeViewColumn();
const iter = list_store.append(); const iter = listStore.append();
const update_shortcut_row = (accel) => { const updateShortcutRow = accel => {
const [key, mods] = accel ? Gtk.accelerator_parse(accel) : [0, 0]; const [key, mods] = accel ? Gtk.accelerator_parse(accel) : [0, 0];
list_store.set(iter, [COLUMN_KEY, COLUMN_MODS], [key, mods]); listStore.set(iter, [COLUMN_KEY, COLUMN_MODS], [key, mods]);
}; };
renderer.connect('accel-edited', (renderer, path, key, mods) => { renderer.connect('accel-edited', (_renderer, _path, key, mods) => {
const accel = Gtk.accelerator_name(key, mods); const accel = Gtk.accelerator_name(key, mods);
update_shortcut_row(accel); updateShortcutRow(accel);
settings.set_strv(KEYBINDING_KEY, [accel]); settings.set_strv(KEYBINDING_KEY, [accel]);
}); });
renderer.connect('accel-cleared', () => { renderer.connect('accel-cleared', () => {
update_shortcut_row(null); updateShortcutRow(null);
settings.set_strv(KEYBINDING_KEY, []); settings.set_strv(KEYBINDING_KEY, []);
}); });
settings.connect(`changed::${KEYBINDING_KEY}`, () => { settings.connect(`changed::${KEYBINDING_KEY}`, () => {
update_shortcut_row(settings.get_strv(KEYBINDING_KEY)[0]); updateShortcutRow(settings.get_strv(KEYBINDING_KEY)[0]);
}); });
column.pack_start(renderer, true); column.pack_start(renderer, true);
column.add_attribute(renderer, 'accel-key', COLUMN_KEY); column.add_attribute(renderer, 'accel-key', COLUMN_KEY);
column.add_attribute(renderer, 'accel-mods', COLUMN_MODS); column.add_attribute(renderer, 'accel-mods', COLUMN_MODS);
tree_view.append_column(column); treeView.append_column(column);
update_shortcut_row(settings.get_strv(KEYBINDING_KEY)[0]); updateShortcutRow(settings.get_strv(KEYBINDING_KEY)[0]);
return tree_view; return treeView;
} }
} }
class SuntimeControl { class SuntimeControl {
constructor(suntime) { constructor(suntime) {
const settings = compat.get_extension_settings(); const settings = compat.getExtensionSettings();
const box = new Gtk.Box({ const box = new Gtk.Box({
spacing: 8, spacing: 8,
orientation: Gtk.Orientation.HORIZONTAL, orientation: Gtk.Orientation.HORIZONTAL,
can_focus: false can_focus: false,
}); });
const time = settings.get_double(`schedule-${suntime}`); const time = settings.get_double(`schedule-${suntime}`);
const hours = Math.trunc(time); const hours = Math.trunc(time);
const minutes = Math.round((time - hours) * 60); const minutes = Math.round((time - hours) * 60);
const hours_spin = new Gtk.SpinButton({ const hoursSpin = new Gtk.SpinButton({
adjustment: new Gtk.Adjustment({ adjustment: new Gtk.Adjustment({
value: hours, value: hours,
lower: 0, lower: 0,
upper: 23, upper: 23,
step_increment: 1, step_increment: 1,
page_increment: 0, page_increment: 0,
page_size: 0 page_size: 0,
}), }),
value: hours, value: hours,
numeric: true, numeric: true,
wrap: true, wrap: true,
orientation: Gtk.Orientation.VERTICAL orientation: Gtk.Orientation.VERTICAL,
}); });
hours_spin.connect('output', () => { hoursSpin.connect('output', () => {
const text = hours_spin.adjustment.value.toString().padStart(2, '0'); const text = hoursSpin.adjustment.value.toString().padStart(2, '0');
hours_spin.set_text(text); hoursSpin.set_text(text);
return true; return true;
}); });
hours_spin.connect('value-changed', () => { hoursSpin.connect('value-changed', () => {
const old_time = settings.get_double(`schedule-${suntime}`); const oldTime = settings.get_double(`schedule-${suntime}`);
const old_hour = Math.trunc(old_time); const oldHour = Math.trunc(oldTime);
const minutes = old_time - old_hour; const newMinutes = oldTime - oldHour;
const new_time = hours_spin.value + minutes; const newTime = hoursSpin.value + newMinutes;
settings.set_double(`schedule-${suntime}`, new_time); settings.set_double(`schedule-${suntime}`, newTime);
}); });
const separator = new Gtk.Label({ label: ':' }); const separator = new Gtk.Label({ label: ':' });
const minutes_spin = new Gtk.SpinButton({ const minutesSpin = new Gtk.SpinButton({
adjustment: new Gtk.Adjustment({ adjustment: new Gtk.Adjustment({
value: minutes, value: minutes,
lower: 0, lower: 0,
upper: 59, upper: 59,
step_increment: 1, step_increment: 1,
page_increment: 0, page_increment: 0,
page_size: 0 page_size: 0,
}), }),
value: minutes, value: minutes,
numeric: true, numeric: true,
wrap: true, wrap: true,
orientation: Gtk.Orientation.VERTICAL orientation: Gtk.Orientation.VERTICAL,
}); });
minutes_spin.connect('output', () => { minutesSpin.connect('output', () => {
const text = minutes_spin.adjustment.value.toString().padStart(2, '0'); const text = minutesSpin.adjustment.value.toString().padStart(2, '0');
minutes_spin.set_text(text); minutesSpin.set_text(text);
return true; return true;
}); });
minutes_spin.connect('value-changed', () => { minutesSpin.connect('value-changed', () => {
const hour = Math.trunc(settings.get_double(`schedule-${suntime}`)); const hour = Math.trunc(settings.get_double(`schedule-${suntime}`));
const minutes = minutes_spin.value / 60; const newMinutes = minutesSpin.value / 60;
const new_time = hour + minutes; const newTime = hour + newMinutes;
settings.set_double(`schedule-${suntime}`, new_time); settings.set_double(`schedule-${suntime}`, newTime);
}); });
box.pack_start(hours_spin, false, false, 0); box.pack_start(hoursSpin, false, false, 0);
box.pack_start(separator, false, false, 0); box.pack_start(separator, false, false, 0);
box.pack_start(minutes_spin, false, false, 0); box.pack_start(minutesSpin, false, false, 0);
return box; return box;
} }
} }
+69 -69
View File
@@ -23,7 +23,7 @@ const Me = extensionUtils.getCurrentExtension();
const compat = Me.imports.compat; const compat = Me.imports.compat;
const { SettingsPage, SettingsList, SettingsListRow } = Me.imports.preferences.bases; const { SettingsPage, SettingsList, SettingsListRow } = Me.imports.preferences.bases;
const { get_installed_shell_themes } = Me.imports.utils; const { getInstalledShellThemes } = Me.imports.utils;
const Gettext = imports.gettext.domain(Me.metadata.uuid); const Gettext = imports.gettext.domain(Me.metadata.uuid);
const _ = Gettext.gettext; const _ = Gettext.gettext;
@@ -31,96 +31,96 @@ const _ = Gettext.gettext;
var ShellThemePreferences = class { var ShellThemePreferences = class {
constructor() { constructor() {
const settings = compat.get_extension_settings(); const settings = compat.getExtensionSettings();
const label = _('Shell theme'); const label = _('Shell theme');
const description = _('The extension will try to automatically detect the day and night variants of your GNOME Shell theme.\n\nIf the theme you use isn\'t supported, please <a href="https://gitlab.com/rmnvgr/nightthemeswitcher-gnome-shell-extension/-/issues">submit a request</a>. You can also manually set variants.'); const description = _('The extension will try to automatically detect the day and night variants of your GNOME Shell theme.\n\nIf the theme you use isn\'t supported, please <a href="https://gitlab.com/rmnvgr/nightthemeswitcher-gnome-shell-extension/-/issues">submit a request</a>. You can also manually set variants.');
const content = new SettingsList(); const content = new SettingsList();
content.add_row(new SettingsListRow(_('Switch Shell variants'), new ShellVariantsEnabledControl())); content.add_row(new SettingsListRow(_('Switch Shell variants'), new ShellVariantsEnabledControl()));
const manual_variants_row = new SettingsListRow(_('Manual variants'), new ManualShellVariantsControl()); const manualVariantsRow = new SettingsListRow(_('Manual variants'), new ManualShellVariantsControl());
settings.bind( settings.bind(
'shell-variants-enabled', 'shell-variants-enabled',
manual_variants_row, manualVariantsRow,
'sensitive', 'sensitive',
Gio.SettingsBindFlags.DEFAULT Gio.SettingsBindFlags.DEFAULT
); );
content.add_row(manual_variants_row); content.add_row(manualVariantsRow);
const day_variant_row = new SettingsListRow(_('Day variant'), new TimeShellVariantControl('day')); const dayVariantRow = new SettingsListRow(_('Day variant'), new TimeShellVariantControl('day'));
const update_day_variant_row_sensitivity = () => day_variant_row.set_sensitive(!!(settings.get_boolean('shell-variants-enabled') && settings.get_boolean('manual-shell-variants'))); const updateDayVariantRowSensitivity = () => dayVariantRow.set_sensitive(!!(settings.get_boolean('shell-variants-enabled') && settings.get_boolean('manual-shell-variants')));
settings.connect('changed::shell-variants-enabled', update_day_variant_row_sensitivity); settings.connect('changed::shell-variants-enabled', updateDayVariantRowSensitivity);
settings.connect('changed::manual-shell-variants', update_day_variant_row_sensitivity) settings.connect('changed::manual-shell-variants', updateDayVariantRowSensitivity);
update_day_variant_row_sensitivity(); updateDayVariantRowSensitivity();
content.add_row(day_variant_row); content.add_row(dayVariantRow);
const night_variant_row = new SettingsListRow(_('Night variant'), new TimeShellVariantControl('night')); const nightVariantRow = new SettingsListRow(_('Night variant'), new TimeShellVariantControl('night'));
const update_night_variant_row_sensitivity = () => night_variant_row.set_sensitive(!!(settings.get_boolean('shell-variants-enabled') && settings.get_boolean('manual-shell-variants'))); const updateNightVariantRowSensitivity = () => nightVariantRow.set_sensitive(!!(settings.get_boolean('shell-variants-enabled') && settings.get_boolean('manual-shell-variants')));
settings.connect('changed::shell-variants-enabled', update_night_variant_row_sensitivity); settings.connect('changed::shell-variants-enabled', updateNightVariantRowSensitivity);
settings.connect('changed::manual-shell-variants', update_night_variant_row_sensitivity) settings.connect('changed::manual-shell-variants', updateNightVariantRowSensitivity);
update_night_variant_row_sensitivity(); updateNightVariantRowSensitivity();
content.add_row(night_variant_row); content.add_row(nightVariantRow);
return new SettingsPage(label, description, content); return new SettingsPage(label, description, content);
} }
} };
class ShellVariantsEnabledControl { class ShellVariantsEnabledControl {
constructor() { constructor() {
const settings = compat.get_extension_settings(); const settings = compat.getExtensionSettings();
const toggle = new Gtk.Switch({ const toggle = new Gtk.Switch({
active: settings.get_boolean('shell-variants-enabled') active: settings.get_boolean('shell-variants-enabled'),
}); });
settings.bind( settings.bind(
'shell-variants-enabled', 'shell-variants-enabled',
toggle, toggle,
'active', 'active',
Gio.SettingsBindFlags.DEFAULT Gio.SettingsBindFlags.DEFAULT
); );
return toggle; return toggle;
} }
} }
class ManualShellVariantsControl { class ManualShellVariantsControl {
constructor() { constructor() {
const settings = compat.get_extension_settings(); const settings = compat.getExtensionSettings();
const toggle = new Gtk.Switch({ const toggle = new Gtk.Switch({
active: false active: false,
}); });
settings.bind( settings.bind(
'manual-shell-variants', 'manual-shell-variants',
toggle, toggle,
'active', 'active',
Gio.SettingsBindFlags.DEFAULT Gio.SettingsBindFlags.DEFAULT
); );
return toggle; return toggle;
} }
} }
class TimeShellVariantControl { class TimeShellVariantControl {
constructor(time) { constructor(time) {
const settings = compat.get_extension_settings(); const settings = compat.getExtensionSettings();
const combo = new Gtk.ComboBoxText(); const combo = new Gtk.ComboBoxText();
const themes = Array.from(get_installed_shell_themes()).sort(); const themes = Array.from(getInstalledShellThemes()).sort();
themes.forEach(theme => combo.append(theme, (theme === '' ? _('Default') : theme))); themes.forEach(theme => combo.append(theme, theme === '' ? _('Default') : theme));
settings.bind( settings.bind(
`shell-variant-${time}`, `shell-variant-${time}`,
combo, combo,
'active-id', 'active-id',
Gio.SettingsBindFlags.DEFAULT Gio.SettingsBindFlags.DEFAULT
); );
return combo; return combo;
} }
} }
+68 -68
View File
@@ -21,89 +21,89 @@ const { Gtk } = imports.gi;
var SettingsPage = class { var SettingsPage = class {
constructor(label, description, content_widget) { constructor(label, description, contentWidget) {
this.label = new Gtk.Label({ this.label = new Gtk.Label({
label: label label,
}); });
this.page = new Gtk.Box({ this.page = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL, orientation: Gtk.Orientation.VERTICAL,
spacing: 30, spacing: 30,
margin_top: 30, margin_top: 30,
margin_end: 36, margin_end: 36,
margin_start: 36, margin_start: 36,
margin_bottom: 36, margin_bottom: 36,
valign: Gtk.Align.START, valign: Gtk.Align.START,
halign: Gtk.Align.CENTER halign: Gtk.Align.CENTER,
}); });
const description_widget = new Gtk.Label({ const descriptionWidget = new Gtk.Label({
label: description, label: description,
use_markup: true, use_markup: true,
width_request: 600, width_request: 600,
max_width_chars: 60, max_width_chars: 60,
wrap: true, wrap: true,
justify: Gtk.Justification.LEFT, justify: Gtk.Justification.LEFT,
halign: Gtk.Align.START halign: Gtk.Align.START,
}); });
this.page.pack_start(description_widget, false, false, 0); this.page.pack_start(descriptionWidget, false, false, 0);
this.page.pack_start(content_widget, false, false, 0); this.page.pack_start(contentWidget, false, false, 0);
} }
} };
var SettingsList = class { var SettingsList = class {
constructor() { constructor() {
const frame = new Gtk.Frame({ const frame = new Gtk.Frame({
can_focus: false can_focus: false,
}); });
const list = new Gtk.ListBox({ const list = new Gtk.ListBox({
border_width: 0, border_width: 0,
margin: 0, margin: 0,
can_focus: false, can_focus: false,
selection_mode: Gtk.SelectionMode.NONE selection_mode: Gtk.SelectionMode.NONE,
}); });
frame.add(list); frame.add(list);
frame.add_row = (widget) => { frame.add_row = widget => {
if ( list.get_children().length > 0 ) { if (list.get_children().length > 0) {
const separator = new Gtk.Separator({ const separator = new Gtk.Separator({
orientation: Gtk.Orientation.VERTICAL, orientation: Gtk.Orientation.VERTICAL,
can_focus: false can_focus: false,
}); });
list.add(separator); list.add(separator);
} }
list.add(widget); list.add(widget);
} };
return frame; return frame;
} }
} };
var SettingsListRow = class { var SettingsListRow = class {
constructor(label, widget) { constructor(label, widget) {
const row = new Gtk.Box({ const row = new Gtk.Box({
margin: 16, margin: 16,
spacing: 30, spacing: 30,
orientation: Gtk.Orientation.HORIZONTAL, orientation: Gtk.Orientation.HORIZONTAL,
can_focus: false can_focus: false,
}); });
const label_widget = new Gtk.Label({ const labelWidget = new Gtk.Label({
label: label, label,
halign: Gtk.Align.START halign: Gtk.Align.START,
}); });
row.pack_start(label_widget, true, true, 0); row.pack_start(labelWidget, true, true, 0);
widget.set_halign(Gtk.Align.END); widget.set_halign(Gtk.Align.END);
row.pack_start(widget, false, false, 0); row.pack_start(widget, false, false, 0);
return row; return row;
} }
} };
+20 -20
View File
@@ -34,36 +34,36 @@ const { ShellThemePreferences } = Me.imports.preferences.ShellTheme;
function init() { function init() {
compat.init_translations(Me.metadata.uuid); compat.initTranslations(Me.metadata.uuid);
} }
function buildPrefsWidget() { function buildPrefsWidget() {
const prefs_widget = new Gtk.Notebook({ const prefsWidget = new Gtk.Notebook({
visible: true visible: true,
}); });
const schedulePreferences = new SchedulePreferences(); const schedulePreferences = new SchedulePreferences();
prefs_widget.append_page(schedulePreferences.page, schedulePreferences.label); prefsWidget.append_page(schedulePreferences.page, schedulePreferences.label);
const gtkThemePreferences = new GtkThemePreferences(); const gtkThemePreferences = new GtkThemePreferences();
prefs_widget.append_page(gtkThemePreferences.page, gtkThemePreferences.label); prefsWidget.append_page(gtkThemePreferences.page, gtkThemePreferences.label);
const shellThemePreferences = new ShellThemePreferences(); const shellThemePreferences = new ShellThemePreferences();
prefs_widget.append_page(shellThemePreferences.page, shellThemePreferences.label); prefsWidget.append_page(shellThemePreferences.page, shellThemePreferences.label);
const iconThemePreferences = new IconThemePreferences(); const iconThemePreferences = new IconThemePreferences();
prefs_widget.append_page(iconThemePreferences.page, iconThemePreferences.label); prefsWidget.append_page(iconThemePreferences.page, iconThemePreferences.label);
const cursorThemePreferences = new CursorThemePreferences(); const cursorThemePreferences = new CursorThemePreferences();
prefs_widget.append_page(cursorThemePreferences.page, cursorThemePreferences.label); prefsWidget.append_page(cursorThemePreferences.page, cursorThemePreferences.label);
const backgroundsPreferences = new BackgroundsPreferences(); const backgroundsPreferences = new BackgroundsPreferences();
prefs_widget.append_page(backgroundsPreferences.page, backgroundsPreferences.label); prefsWidget.append_page(backgroundsPreferences.page, backgroundsPreferences.label);
const commandsPreferences = new CommandsPreferences(); const commandsPreferences = new CommandsPreferences();
prefs_widget.append_page(commandsPreferences.page, commandsPreferences.label); prefsWidget.append_page(commandsPreferences.page, commandsPreferences.label);
prefs_widget.show_all(); prefsWidget.show_all();
return prefs_widget; return prefsWidget;
} }
+107 -129
View File
@@ -31,23 +31,20 @@ const _ = Gettext.gettext;
* Output a debug message to the console if the debug config is active. * Output a debug message to the console if the debug config is active.
* @param {string} message The message to log. * @param {string} message The message to log.
*/ */
function log_debug(message) { function logDebug(message) {
if (config.debug) { if (config.debug)
log(`[DEBUG] ${Me.metadata.name}: ${message}`); log(`[DEBUG] ${Me.metadata.name}: ${message}`);
}
} }
/** /**
* Log an error and show a notification if it has a message. * Log an error and show a notification if it has a message.
* @param {Error} error The error to log. * @param {Error} error The error to log.
*/ */
function log_error(error) { function notifyError(error) {
if (config.debug) { if (config.debug)
logError(error, Me.metadata.name); logError(error, Me.metadata.name);
} if (error.message && imports.ui)
if ( error.message && imports.ui ) { imports.ui.main.notifyError(Me.metadata.name, error.message);
imports.ui.main.notifyError(Me.metadata.name, error.message);
}
} }
/** /**
@@ -55,12 +52,12 @@ function log_error(error) {
* @param {string} resource The resource to get the directories. * @param {string} resource The resource to get the directories.
* @returns {string[]} An array of paths. * @returns {string[]} An array of paths.
*/ */
function get_resources_dirs_paths(resource) { function getResourcesDirsPaths(resource) {
return [ return [
GLib.build_filenamev([GLib.get_home_dir(), `.${resource}`]), GLib.build_filenamev([GLib.get_home_dir(), `.${resource}`]),
GLib.build_filenamev([GLib.get_user_data_dir(), resource]), GLib.build_filenamev([GLib.get_user_data_dir(), resource]),
...GLib.get_system_data_dirs().map(path => GLib.build_filenamev([path, resource])) ...GLib.get_system_data_dirs().map(path => GLib.build_filenamev([path, resource])),
]; ];
} }
/** /**
@@ -68,106 +65,91 @@ function get_resources_dirs_paths(resource) {
* @param {string} type The resources to get. * @param {string} type The resources to get.
* @returns {Set} A set of installed resources. * @returns {Set} A set of installed resources.
*/ */
function get_installed_resources(type) { function getInstalledResources(type) {
const installed_resources = new Set(); const installedResources = new Set();
getResourcesDirsPaths(type).forEach(resourcesDirPath => {
get_resources_dirs_paths(type).forEach(resources_dir_path => { const resourcesDir = Gio.File.new_for_path(resourcesDirPath);
const resources_dir = Gio.File.new_for_path(resources_dir_path); if (resourcesDir.query_file_type(Gio.FileQueryInfoFlags.NONE, null) !== Gio.FileType.DIRECTORY)
return;
if (resources_dir.query_file_type(Gio.FileQueryInfoFlags.NONE, null) !== Gio.FileType.DIRECTORY) { const resourcesDirsEnumerator = resourcesDir.enumerate_children('', Gio.FileQueryInfoFlags.NONE, null);
return; while (true) {
} let resourceDirInfo = resourcesDirsEnumerator.next_file(null);
if (resourceDirInfo === null)
const resources_dirs_enumerator = resources_dir.enumerate_children('', Gio.FileQueryInfoFlags.NONE, null); break;
const resourceDir = resourcesDirsEnumerator.get_child(resourceDirInfo);
while (true) { if (resourceDir === null)
let resource_dir_info = resources_dirs_enumerator.next_file(null); break;
const resource = new Map([
if (resource_dir_info === null) { ['name', resourceDir.get_basename()],
break; ['path', resourceDir.get_path()],
} ]);
installedResources.add(resource);
const resource_dir = resources_dirs_enumerator.get_child(resource_dir_info); }
if ( resource_dir === null ) { resourcesDirsEnumerator.close(null);
break; });
} return installedResources;
const resource = new Map([
['name', resource_dir.get_basename()],
['path', resource_dir.get_path()]
]);
installed_resources.add(resource);
}
resources_dirs_enumerator.close(null);
});
return installed_resources;
} }
/** /**
* Get all the installed GTK themes on the system. * Get all the installed GTK themes on the system.
* @returns {Set<string>} A set containing all the installed GTK themes names. * @returns {Set<string>} A set containing all the installed GTK themes names.
*/ */
function get_installed_gtk_themes() { function getInstalledGtkThemes() {
const themes = new Set(['Adwaita', 'HighContrast', 'HighContrastInverse']); const themes = new Set(['Adwaita', 'HighContrast', 'HighContrastInverse']);
get_installed_resources('themes').forEach(theme => { getInstalledResources('themes').forEach(theme => {
const version = [0, Gtk.MINOR_VERSION].find(gtk_version => { const version = [0, Gtk.MINOR_VERSION].find(gtkVersion => {
if (gtk_version % 2) { if (gtkVersion % 2)
gtk_version += 1; gtkVersion += 1;
} const cssFile = Gio.File.new_for_path(GLib.build_filenamev([theme.get('path'), `gtk-3.${gtkVersion}`, 'gtk.css']));
const css_file = Gio.File.new_for_path(GLib.build_filenamev([theme.get('path'), `gtk-3.${gtk_version}`, 'gtk.css'])); return cssFile.query_exists(null);
return css_file.query_exists(null); });
}); if (version !== undefined)
if ( version !== undefined ) { themes.add(theme.get('name'));
themes.add(theme.get('name')); });
} return themes;
});
return themes;
} }
/** /**
* Get all the installed shell themes on the system. * Get all the installed shell themes on the system.
* @returns {Set<string>} A set containing all the installed shell themes names. * @returns {Set<string>} A set containing all the installed shell themes names.
*/ */
function get_installed_shell_themes() { function getInstalledShellThemes() {
const themes = new Set(['']); const themes = new Set(['']);
get_installed_resources('themes').forEach(theme => { getInstalledResources('themes').forEach(theme => {
const theme_file = Gio.File.new_for_path(GLib.build_filenamev([theme.get('path'), 'gnome-shell', 'gnome-shell.css'])); const themeFile = Gio.File.new_for_path(GLib.build_filenamev([theme.get('path'), 'gnome-shell', 'gnome-shell.css']));
if ( theme_file.query_exists(null) ) { if (themeFile.query_exists(null))
themes.add(theme.get('name')); themes.add(theme.get('name'));
} });
}); return themes;
return themes;
} }
/** /**
* Get all the installed icon themes on the system. * Get all the installed icon themes on the system.
* @returns {Set<string>} A set containing all the installed icon themes names. * @returns {Set<string>} A set containing all the installed icon themes names.
*/ */
function get_installed_icon_themes() { function getInstalledIconThemes() {
const themes = new Set(); const themes = new Set();
get_installed_resources('icons').forEach(theme => { getInstalledResources('icons').forEach(theme => {
const theme_file = Gio.File.new_for_path(GLib.build_filenamev([theme.get('path'), 'index.theme'])); const themeFile = Gio.File.new_for_path(GLib.build_filenamev([theme.get('path'), 'index.theme']));
if ( theme_file.query_exists(null) ) { if (themeFile.query_exists(null))
themes.add(theme.get('name')); themes.add(theme.get('name'));
} });
}); themes.delete('default');
themes.delete('default'); return themes;
return themes;
} }
/** /**
* Get all the installed cursor themes on the system. * Get all the installed cursor themes on the system.
* @returns {Set<string>} A set containing all the installed cursor themes names. * @returns {Set<string>} A set containing all the installed cursor themes names.
*/ */
function get_installed_cursor_themes() { function getInstalledCursorThemes() {
const themes = new Set(); const themes = new Set();
get_installed_resources('icons').forEach(theme => { getInstalledResources('icons').forEach(theme => {
const theme_file = Gio.File.new_for_path(GLib.build_filenamev([theme.get('path'), 'cursors'])); const themeFile = Gio.File.new_for_path(GLib.build_filenamev([theme.get('path'), 'cursors']));
if ( theme_file.query_exists(null) ) { if (themeFile.query_exists(null))
themes.add(theme.get('name')); themes.add(theme.get('name'));
} });
}); return themes;
return themes;
} }
/** /**
@@ -175,8 +157,8 @@ function get_installed_cursor_themes() {
* @returns {Object|undefined} The User Themes extension object or undefined if * @returns {Object|undefined} The User Themes extension object or undefined if
* it isn't installed. * it isn't installed.
*/ */
function get_userthemes_extension() { function getUserthemesExtension() {
return compat.extension_manager_lookup('user-theme@gnome-shell-extensions.gcampax.github.com'); return compat.extensionManagerLookup('user-theme@gnome-shell-extensions.gcampax.github.com');
} }
/** /**
@@ -184,24 +166,19 @@ function get_userthemes_extension() {
* @returns {Gio.Settings|null} The User Themes extension settings or null if * @returns {Gio.Settings|null} The User Themes extension settings or null if
* the extension isn't installed. * the extension isn't installed.
*/ */
function get_userthemes_settings() { function getUserthemesSettings() {
let extension = get_userthemes_extension(); let extension = getUserthemesExtension();
if (!extension)
if ( !extension ) { return null;
return null; const schemaDir = extension.dir.get_child('schemas');
} const GioSSS = Gio.SettingsSchemaSource;
let schemaSource;
const schema_dir = extension.dir.get_child('schemas'); if (schemaDir.query_exists(null))
const GioSSS = Gio.SettingsSchemaSource; schemaSource = GioSSS.new_from_directory(schemaDir.get_path(), GioSSS.get_default(), false);
let schemaSource; else
if ( schema_dir.query_exists(null) ) { schemaSource = GioSSS.get_default();
schemaSource = GioSSS.new_from_directory(schema_dir.get_path(), GioSSS.get_default(), false); const schemaObj = schemaSource.lookup('org.gnome.shell.extensions.user-theme', true);
} return new Gio.Settings({ settings_schema: schemaObj });
else {
schemaSource = GioSSS.get_default();
}
const schemaObj = schemaSource.lookup('org.gnome.shell.extensions.user-theme', true);
return new Gio.Settings({ settings_schema: schemaObj });
} }
/** /**
@@ -209,26 +186,27 @@ function get_userthemes_settings() {
* @param {string} theme The shell theme name. * @param {string} theme The shell theme name.
* @returns {string|null} Path to the shell theme stylesheet. * @returns {string|null} Path to the shell theme stylesheet.
*/ */
function get_shell_theme_stylesheet(theme) { function getShellThemeStylesheet(theme) {
log_debug('Getting the ' + (theme ? `'${theme}'` : 'default') + ' theme shell stylesheet...'); const themeName = theme ? `'${theme}'` : 'default';
let stylesheet = null; logDebug(`Getting the ${themeName} theme shell stylesheet...`);
if ( theme ) { let stylesheet = null;
const stylesheet_paths = get_resources_dirs_paths('themes').map(path => GLib.build_filenamev([path, theme, 'gnome-shell', 'gnome-shell.css'])); if (theme) {
stylesheet = stylesheet_paths.find(path => { const stylesheetPaths = getResourcesDirsPaths('themes').map(path => GLib.build_filenamev([path, theme, 'gnome-shell', 'gnome-shell.css']));
const file = Gio.file_new_for_path(path); stylesheet = stylesheetPaths.find(path => {
return file.query_exists(null); const file = Gio.file_new_for_path(path);
}); return file.query_exists(null);
} });
return stylesheet; }
return stylesheet;
} }
/** /**
* Apply a stylesheet to the shell. * Apply a stylesheet to the shell.
* @param {string} stylesheet The shell stylesheet to apply. * @param {string} stylesheet The shell stylesheet to apply.
*/ */
function apply_shell_stylesheet(stylesheet) { function applyShellStylesheet(stylesheet) {
log_debug('Applying shell stylesheet...'); logDebug('Applying shell stylesheet...');
imports.ui.main.setThemeStylesheet(stylesheet); imports.ui.main.setThemeStylesheet(stylesheet);
imports.ui.main.loadTheme(); imports.ui.main.loadTheme();
log_debug('Shell stylesheet applied.'); logDebug('Shell stylesheet applied.');
} }
+3
View File
@@ -0,0 +1,3 @@
env:
commonjs: true
node: true
+12 -12
View File
@@ -21,25 +21,25 @@ const { Variants } = require('./_variants');
test('Adapta', t => { test('Adapta', t => {
const variants = Variants.guess_from('Adapta'); const variants = Variants.guessFrom('Adapta');
t.is(variants.get('day'), 'Adapta'); t.is(variants.get('day'), 'Adapta');
t.is(variants.get('night'), 'Adapta-Nokto') t.is(variants.get('night'), 'Adapta-Nokto');
}); });
test('Adapta-Nokto', t => { test('Adapta-Nokto', t => {
const variants = Variants.guess_from('Adapta-Nokto'); const variants = Variants.guessFrom('Adapta-Nokto');
t.is(variants.get('day'), 'Adapta'); t.is(variants.get('day'), 'Adapta');
t.is(variants.get('night'), 'Adapta-Nokto'); t.is(variants.get('night'), 'Adapta-Nokto');
}); });
test('Adapta-Eta', t => { test('Adapta-Eta', t => {
const variants = Variants.guess_from('Adapta-Eta'); const variants = Variants.guessFrom('Adapta-Eta');
t.is(variants.get('day'), 'Adapta-Eta'); t.is(variants.get('day'), 'Adapta-Eta');
t.is(variants.get('night'), 'Adapta-Nokto-Eta'); t.is(variants.get('night'), 'Adapta-Nokto-Eta');
}); });
test('Adapta-Nokto-Eta', t => { test('Adapta-Nokto-Eta', t => {
const variants = Variants.guess_from('Adapta-Nokto-Eta'); const variants = Variants.guessFrom('Adapta-Nokto-Eta');
t.is(variants.get('day'), 'Adapta-Eta'); t.is(variants.get('day'), 'Adapta-Eta');
t.is(variants.get('night'), 'Adapta-Nokto-Eta'); t.is(variants.get('night'), 'Adapta-Nokto-Eta');
}); });
+6 -6
View File
@@ -21,13 +21,13 @@ const { Variants } = require('./_variants');
test('Adwaita', t => { test('Adwaita', t => {
const variants = Variants.guess_from('Adwaita'); const variants = Variants.guessFrom('Adwaita');
t.is(variants.get('day'), 'Adwaita'); t.is(variants.get('day'), 'Adwaita');
t.is(variants.get('night'), 'Adwaita-dark'); t.is(variants.get('night'), 'Adwaita-dark');
}); });
test('Adwaita-dark', t => { test('Adwaita-dark', t => {
const variants = Variants.guess_from('Adwaita-dark'); const variants = Variants.guessFrom('Adwaita-dark');
t.is(variants.get('day'), 'Adwaita'); t.is(variants.get('day'), 'Adwaita');
t.is(variants.get('night'), 'Adwaita-dark'); t.is(variants.get('night'), 'Adwaita-dark');
}); });
+18 -18
View File
@@ -21,37 +21,37 @@ const { Variants } = require('./_variants');
test('Arc', t => { test('Arc', t => {
const variants = Variants.guess_from('Arc'); const variants = Variants.guessFrom('Arc');
t.is(variants.get('day'), 'Arc'); t.is(variants.get('day'), 'Arc');
t.is(variants.get('night'), 'Arc-Dark'); t.is(variants.get('night'), 'Arc-Dark');
}); });
test('Arc-Dark', t => { test('Arc-Dark', t => {
const variants = Variants.guess_from('Arc-Dark'); const variants = Variants.guessFrom('Arc-Dark');
t.is(variants.get('day'), 'Arc'); t.is(variants.get('day'), 'Arc');
t.is(variants.get('night'), 'Arc-Dark'); t.is(variants.get('night'), 'Arc-Dark');
}); });
test('Arc-Darker', t => { test('Arc-Darker', t => {
const variants = Variants.guess_from('Arc-Darker'); const variants = Variants.guessFrom('Arc-Darker');
t.is(variants.get('day'), 'Arc-Darker'); t.is(variants.get('day'), 'Arc-Darker');
t.is(variants.get('night'), 'Arc-Dark'); t.is(variants.get('night'), 'Arc-Dark');
}); });
test('Arc-Darker-solid', t => { test('Arc-Darker-solid', t => {
const variants = Variants.guess_from('Arc-Darker-solid'); const variants = Variants.guessFrom('Arc-Darker-solid');
t.is(variants.get('day'), 'Arc-Darker-solid'); t.is(variants.get('day'), 'Arc-Darker-solid');
t.is(variants.get('night'), 'Arc-Dark-solid'); t.is(variants.get('night'), 'Arc-Dark-solid');
}); });
test('Arc-Dark-solid', t => { test('Arc-Dark-solid', t => {
const variants = Variants.guess_from('Arc-Dark-solid'); const variants = Variants.guessFrom('Arc-Dark-solid');
t.is(variants.get('day'), 'Arc-solid'); t.is(variants.get('day'), 'Arc-solid');
t.is(variants.get('night'), 'Arc-Dark-solid'); t.is(variants.get('night'), 'Arc-Dark-solid');
}); });
test('Arc-solid', t => { test('Arc-solid', t => {
const variants = Variants.guess_from('Arc-solid'); const variants = Variants.guessFrom('Arc-solid');
t.is(variants.get('day'), 'Arc-solid'); t.is(variants.get('day'), 'Arc-solid');
t.is(variants.get('night'), 'Arc-Dark-solid'); t.is(variants.get('night'), 'Arc-Dark-solid');
}); });
+15 -15
View File
@@ -21,21 +21,21 @@ const { Variants } = require('./_variants');
['Blue', 'Green', 'Orange'].forEach(color => { ['Blue', 'Green', 'Orange'].forEach(color => {
test(`Cabinet-${color}`, t => { test(`Cabinet-${color}`, t => {
const variants = Variants.guess_from(`Cabinet-Light-${color}`); const variants = Variants.guessFrom(`Cabinet-Light-${color}`);
t.is(variants.get('day'), `Cabinet-Light-${color}`); t.is(variants.get('day'), `Cabinet-Light-${color}`);
t.is(variants.get('night'), `Cabinet-Dark-${color}`); t.is(variants.get('night'), `Cabinet-Dark-${color}`);
}); });
test(`Cabinet-Dark-${color}`, t => { test(`Cabinet-Dark-${color}`, t => {
const variants = Variants.guess_from(`Cabinet-Dark-${color}`); const variants = Variants.guessFrom(`Cabinet-Dark-${color}`);
t.is(variants.get('day'), `Cabinet-Light-${color}`); t.is(variants.get('day'), `Cabinet-Light-${color}`);
t.is(variants.get('night'), `Cabinet-Dark-${color}`); t.is(variants.get('night'), `Cabinet-Dark-${color}`);
}); });
test(`Cabinet-Darker-${color}`, t => { test(`Cabinet-Darker-${color}`, t => {
const variants = Variants.guess_from(`Cabinet-Darker-${color}`); const variants = Variants.guessFrom(`Cabinet-Darker-${color}`);
t.is(variants.get('day'), `Cabinet-Darker-${color}`); t.is(variants.get('day'), `Cabinet-Darker-${color}`);
t.is(variants.get('night'), `Cabinet-Dark-${color}`); t.is(variants.get('night'), `Cabinet-Dark-${color}`);
}); });
}); });
+30 -30
View File
@@ -21,39 +21,39 @@ const { Variants } = require('./_variants');
['', '-blue', '-indigo'].forEach(color => { ['', '-blue', '-indigo'].forEach(color => {
test(`Canta${color}`, t => { test(`Canta${color}`, t => {
const variants = Variants.guess_from(`Canta${color}`); const variants = Variants.guessFrom(`Canta${color}`);
t.is(variants.get('day'), `Canta${color}`); t.is(variants.get('day'), `Canta${color}`);
t.is(variants.get('night'), `Canta${color}-dark`); t.is(variants.get('night'), `Canta${color}-dark`);
}); });
test(`Canta${color}-dark`, t => { test(`Canta${color}-dark`, t => {
const variants = Variants.guess_from(`Canta${color}-dark`); const variants = Variants.guessFrom(`Canta${color}-dark`);
t.is(variants.get('day'), `Canta${color}`); t.is(variants.get('day'), `Canta${color}`);
t.is(variants.get('night'), `Canta${color}-dark`); t.is(variants.get('night'), `Canta${color}-dark`);
}); });
test(`Canta${color}-light`, t => { test(`Canta${color}-light`, t => {
const variants = Variants.guess_from(`Canta${color}-light`); const variants = Variants.guessFrom(`Canta${color}-light`);
t.is(variants.get('day'), `Canta${color}-light`); t.is(variants.get('day'), `Canta${color}-light`);
t.is(variants.get('night'), `Canta${color}-dark`); t.is(variants.get('night'), `Canta${color}-dark`);
}); });
test(`Canta${color}-compact`, t => { test(`Canta${color}-compact`, t => {
const variants = Variants.guess_from(`Canta${color}-compact`); const variants = Variants.guessFrom(`Canta${color}-compact`);
t.is(variants.get('day'), `Canta${color}-compact`); t.is(variants.get('day'), `Canta${color}-compact`);
t.is(variants.get('night'), `Canta${color}-dark-compact`); t.is(variants.get('night'), `Canta${color}-dark-compact`);
}); });
test(`Canta${color}-dark-compact`, t => { test(`Canta${color}-dark-compact`, t => {
const variants = Variants.guess_from(`Canta${color}-dark-compact`); const variants = Variants.guessFrom(`Canta${color}-dark-compact`);
t.is(variants.get('day'), `Canta${color}-compact`); t.is(variants.get('day'), `Canta${color}-compact`);
t.is(variants.get('night'), `Canta${color}-dark-compact`); t.is(variants.get('night'), `Canta${color}-dark-compact`);
}); });
test(`Canta${color}-light-compact`, t => { test(`Canta${color}-light-compact`, t => {
const variants = Variants.guess_from(`Canta${color}-light-compact`); const variants = Variants.guessFrom(`Canta${color}-light-compact`);
t.is(variants.get('day'), `Canta${color}-light-compact`); t.is(variants.get('day'), `Canta${color}-light-compact`);
t.is(variants.get('night'), `Canta${color}-dark-compact`); t.is(variants.get('night'), `Canta${color}-dark-compact`);
}); });
}); });
+16 -16
View File
@@ -20,21 +20,21 @@ const test = require('ava');
const { Variants } = require('./_variants'); const { Variants } = require('./_variants');
['', '-compact'].forEach(size => { ['', '-compact'].forEach(size => {
test(`ChromeOS${size}`, t => { test(`ChromeOS${size}`, t => {
const variants = Variants.guess_from(`ChromeOS${size}`); const variants = Variants.guessFrom(`ChromeOS${size}`);
t.is(variants.get('day'), `ChromeOS${size}`); t.is(variants.get('day'), `ChromeOS${size}`);
t.is(variants.get('night'), `ChromeOS-dark${size}`); t.is(variants.get('night'), `ChromeOS-dark${size}`);
}); });
test(`ChromeOS-dark${size}`, t => { test(`ChromeOS-dark${size}`, t => {
const variants = Variants.guess_from(`ChromeOS-dark${size}`); const variants = Variants.guessFrom(`ChromeOS-dark${size}`);
t.is(variants.get('day'), `ChromeOS${size}`); t.is(variants.get('day'), `ChromeOS${size}`);
t.is(variants.get('night'), `ChromeOS-dark${size}`); t.is(variants.get('night'), `ChromeOS-dark${size}`);
}); });
test(`ChromeOS-light${size}`, t => { test(`ChromeOS-light${size}`, t => {
const variants = Variants.guess_from(`ChromeOS-light${size}`); const variants = Variants.guessFrom(`ChromeOS-light${size}`);
t.is(variants.get('day'), `ChromeOS-light${size}`); t.is(variants.get('day'), `ChromeOS-light${size}`);
t.is(variants.get('night'), `ChromeOS-dark${size}`); t.is(variants.get('night'), `ChromeOS-dark${size}`);
}); });
}) });
+50 -50
View File
@@ -21,63 +21,63 @@ const { Variants } = require('./_variants');
['Blue', 'Green', 'Red', 'Yellow'].forEach(color => { ['Blue', 'Green', 'Red', 'Yellow'].forEach(color => {
test(`Flat-Remix-GTK-${color}`, t => { test(`Flat-Remix-GTK-${color}`, t => {
const variants = Variants.guess_from(`Flat-Remix-GTK-${color}`); const variants = Variants.guessFrom(`Flat-Remix-GTK-${color}`);
t.is(variants.get('day'), `Flat-Remix-GTK-${color}`); t.is(variants.get('day'), `Flat-Remix-GTK-${color}`);
t.is(variants.get('night'), `Flat-Remix-GTK-${color}-Dark`); t.is(variants.get('night'), `Flat-Remix-GTK-${color}-Dark`);
}); });
test(`Flat-Remix-GTK-${color}-Dark`, t => { test(`Flat-Remix-GTK-${color}-Dark`, t => {
const variants = Variants.guess_from(`Flat-Remix-GTK-${color}-Dark`); const variants = Variants.guessFrom(`Flat-Remix-GTK-${color}-Dark`);
t.is(variants.get('day'), `Flat-Remix-GTK-${color}`); t.is(variants.get('day'), `Flat-Remix-GTK-${color}`);
t.is(variants.get('night'), `Flat-Remix-GTK-${color}-Dark`); t.is(variants.get('night'), `Flat-Remix-GTK-${color}-Dark`);
}); });
test(`Flat-Remix-GTK-${color}-Darker`, t => { test(`Flat-Remix-GTK-${color}-Darker`, t => {
const variants = Variants.guess_from(`Flat-Remix-GTK-${color}-Darker`); const variants = Variants.guessFrom(`Flat-Remix-GTK-${color}-Darker`);
t.is(variants.get('day'), `Flat-Remix-GTK-${color}-Darker`); t.is(variants.get('day'), `Flat-Remix-GTK-${color}-Darker`);
t.is(variants.get('night'), `Flat-Remix-GTK-${color}-Dark`); t.is(variants.get('night'), `Flat-Remix-GTK-${color}-Dark`);
}); });
test(`Flat-Remix-GTK-${color}-Darker-Solid`, t => { test(`Flat-Remix-GTK-${color}-Darker-Solid`, t => {
const variants = Variants.guess_from(`Flat-Remix-GTK-${color}-Darker-Solid`); const variants = Variants.guessFrom(`Flat-Remix-GTK-${color}-Darker-Solid`);
t.is(variants.get('day'), `Flat-Remix-GTK-${color}-Darker-Solid`); t.is(variants.get('day'), `Flat-Remix-GTK-${color}-Darker-Solid`);
t.is(variants.get('night'), `Flat-Remix-GTK-${color}-Dark-Solid`); t.is(variants.get('night'), `Flat-Remix-GTK-${color}-Dark-Solid`);
}); });
test(`Flat-Remix-GTK-${color}-Darkest`, t => { test(`Flat-Remix-GTK-${color}-Darkest`, t => {
const variants = Variants.guess_from(`Flat-Remix-GTK-${color}-Darkest`); const variants = Variants.guessFrom(`Flat-Remix-GTK-${color}-Darkest`);
t.is(variants.get('day'), `Flat-Remix-GTK-${color}`); t.is(variants.get('day'), `Flat-Remix-GTK-${color}`);
t.is(variants.get('night'), `Flat-Remix-GTK-${color}-Darkest`); t.is(variants.get('night'), `Flat-Remix-GTK-${color}-Darkest`);
}); });
test(`Flat-Remix-GTK-${color}-Darkest-NoBorder`, t => { test(`Flat-Remix-GTK-${color}-Darkest-NoBorder`, t => {
const variants = Variants.guess_from(`Flat-Remix-GTK-${color}-Darkest-NoBorder`); const variants = Variants.guessFrom(`Flat-Remix-GTK-${color}-Darkest-NoBorder`);
t.is(variants.get('day'), `Flat-Remix-GTK-${color}`); t.is(variants.get('day'), `Flat-Remix-GTK-${color}`);
t.is(variants.get('night'), `Flat-Remix-GTK-${color}-Darkest-NoBorder`); t.is(variants.get('night'), `Flat-Remix-GTK-${color}-Darkest-NoBorder`);
}); });
test(`Flat-Remix-GTK-${color}-Darkest-Solid`, t => { test(`Flat-Remix-GTK-${color}-Darkest-Solid`, t => {
const variants = Variants.guess_from(`Flat-Remix-GTK-${color}-Darkest-Solid`); const variants = Variants.guessFrom(`Flat-Remix-GTK-${color}-Darkest-Solid`);
t.is(variants.get('day'), `Flat-Remix-GTK-${color}-Solid`); t.is(variants.get('day'), `Flat-Remix-GTK-${color}-Solid`);
t.is(variants.get('night'), `Flat-Remix-GTK-${color}-Darkest-Solid`); t.is(variants.get('night'), `Flat-Remix-GTK-${color}-Darkest-Solid`);
}); });
test(`Flat-Remix-GTK-${color}-Darkest-Solid-NoBorder`, t => { test(`Flat-Remix-GTK-${color}-Darkest-Solid-NoBorder`, t => {
const variants = Variants.guess_from(`Flat-Remix-GTK-${color}-Darkest-Solid-NoBorder`); const variants = Variants.guessFrom(`Flat-Remix-GTK-${color}-Darkest-Solid-NoBorder`);
t.is(variants.get('day'), `Flat-Remix-GTK-${color}-Solid`); t.is(variants.get('day'), `Flat-Remix-GTK-${color}-Solid`);
t.is(variants.get('night'), `Flat-Remix-GTK-${color}-Darkest-Solid-NoBorder`); t.is(variants.get('night'), `Flat-Remix-GTK-${color}-Darkest-Solid-NoBorder`);
}); });
test(`Flat-Remix-GTK-${color}-Dark-Solid`, t => { test(`Flat-Remix-GTK-${color}-Dark-Solid`, t => {
const variants = Variants.guess_from(`Flat-Remix-GTK-${color}-Dark-Solid`); const variants = Variants.guessFrom(`Flat-Remix-GTK-${color}-Dark-Solid`);
t.is(variants.get('day'), `Flat-Remix-GTK-${color}-Solid`); t.is(variants.get('day'), `Flat-Remix-GTK-${color}-Solid`);
t.is(variants.get('night'), `Flat-Remix-GTK-${color}-Dark-Solid`); t.is(variants.get('night'), `Flat-Remix-GTK-${color}-Dark-Solid`);
}); });
test(`Flat-Remix-GTK-${color}-Solid`, t => { test(`Flat-Remix-GTK-${color}-Solid`, t => {
const variants = Variants.guess_from(`Flat-Remix-GTK-${color}-Solid`); const variants = Variants.guessFrom(`Flat-Remix-GTK-${color}-Solid`);
t.is(variants.get('day'), `Flat-Remix-GTK-${color}-Solid`); t.is(variants.get('day'), `Flat-Remix-GTK-${color}-Solid`);
t.is(variants.get('night'), `Flat-Remix-GTK-${color}-Dark-Solid`); t.is(variants.get('night'), `Flat-Remix-GTK-${color}-Dark-Solid`);
}); });
}); });
+6 -6
View File
@@ -21,13 +21,13 @@ const { Variants } = require('./_variants');
test('HighContrast', t => { test('HighContrast', t => {
const variants = Variants.guess_from('HighContrast'); const variants = Variants.guessFrom('HighContrast');
t.is(variants.get('day'), 'HighContrast'); t.is(variants.get('day'), 'HighContrast');
t.is(variants.get('night'), 'HighContrastInverse'); t.is(variants.get('night'), 'HighContrastInverse');
}); });
test('HighContrastInverse', t => { test('HighContrastInverse', t => {
const variants = Variants.guess_from('HighContrastInverse'); const variants = Variants.guessFrom('HighContrastInverse');
t.is(variants.get('day'), 'HighContrast'); t.is(variants.get('day'), 'HighContrast');
t.is(variants.get('night'), 'HighContrastInverse'); t.is(variants.get('night'), 'HighContrastInverse');
}); });
+18 -18
View File
@@ -21,37 +21,37 @@ const { Variants } = require('./_variants');
test('Layan', t => { test('Layan', t => {
const variants = Variants.guess_from('Layan'); const variants = Variants.guessFrom('Layan');
t.is(variants.get('day'), 'Layan'); t.is(variants.get('day'), 'Layan');
t.is(variants.get('night'), 'Layan-dark'); t.is(variants.get('night'), 'Layan-dark');
}); });
test('Layan-dark', t => { test('Layan-dark', t => {
const variants = Variants.guess_from('Layan-dark'); const variants = Variants.guessFrom('Layan-dark');
t.is(variants.get('day'), 'Layan'); t.is(variants.get('day'), 'Layan');
t.is(variants.get('night'), 'Layan-dark'); t.is(variants.get('night'), 'Layan-dark');
}); });
test('Layan-light', t => { test('Layan-light', t => {
const variants = Variants.guess_from('Layan-light'); const variants = Variants.guessFrom('Layan-light');
t.is(variants.get('day'), 'Layan-light'); t.is(variants.get('day'), 'Layan-light');
t.is(variants.get('night'), 'Layan-dark'); t.is(variants.get('night'), 'Layan-dark');
}); });
test('Layan-solid', t => { test('Layan-solid', t => {
const variants = Variants.guess_from('Layan-solid'); const variants = Variants.guessFrom('Layan-solid');
t.is(variants.get('day'), 'Layan-solid'); t.is(variants.get('day'), 'Layan-solid');
t.is(variants.get('night'), 'Layan-dark-solid'); t.is(variants.get('night'), 'Layan-dark-solid');
}); });
test('Layan-dark-solid', t => { test('Layan-dark-solid', t => {
const variants = Variants.guess_from('Layan-dark-solid'); const variants = Variants.guessFrom('Layan-dark-solid');
t.is(variants.get('day'), 'Layan-solid'); t.is(variants.get('day'), 'Layan-solid');
t.is(variants.get('night'), 'Layan-dark-solid'); t.is(variants.get('night'), 'Layan-dark-solid');
}); });
test('Layan-light-solid', t => { test('Layan-light-solid', t => {
const variants = Variants.guess_from('Layan-light-solid'); const variants = Variants.guessFrom('Layan-light-solid');
t.is(variants.get('day'), 'Layan-light-solid'); t.is(variants.get('day'), 'Layan-light-solid');
t.is(variants.get('night'), 'Layan-dark-solid'); t.is(variants.get('night'), 'Layan-dark-solid');
}); });
+12 -12
View File
@@ -21,17 +21,17 @@ const { Variants } = require('./_variants');
['', '-Slim'].forEach(size => { ['', '-Slim'].forEach(size => {
['-blue', '-green', '-orange', '-purple', '-red', '-yellow'].forEach(color => { ['-blue', '-green', '-orange', '-purple', '-red', '-yellow'].forEach(color => {
test(`Macwaita${color}${size}`, t => { test(`Macwaita${color}${size}`, t => {
const variants = Variants.guess_from(`Macwaita${color}${size}`); const variants = Variants.guessFrom(`Macwaita${color}${size}`);
t.is(variants.get('day'), `Macwaita${color}${size}`); t.is(variants.get('day'), `Macwaita${color}${size}`);
t.is(variants.get('night'), `Macwaita-dark${color}${size}`); t.is(variants.get('night'), `Macwaita-dark${color}${size}`);
}); });
test(`Macwaita-dark${color}${size}`, t => { test(`Macwaita-dark${color}${size}`, t => {
const variants = Variants.guess_from(`Macwaita-dark${color}${size}`); const variants = Variants.guessFrom(`Macwaita-dark${color}${size}`);
t.is(variants.get('day'), `Macwaita${color}${size}`); t.is(variants.get('day'), `Macwaita${color}${size}`);
t.is(variants.get('night'), `Macwaita-dark${color}${size}`); t.is(variants.get('night'), `Macwaita-dark${color}${size}`);
}); });
}); });
}); });
+16 -16
View File
@@ -21,21 +21,21 @@ const { Variants } = require('./_variants');
['aliz', 'azul', 'sea'].forEach(color => { ['aliz', 'azul', 'sea'].forEach(color => {
test(`Matcha-${color}`, t => { test(`Matcha-${color}`, t => {
const variants = Variants.guess_from(`Matcha-${color}`); const variants = Variants.guessFrom(`Matcha-${color}`);
t.is(variants.get('day'), `Matcha-${color}`); t.is(variants.get('day'), `Matcha-${color}`);
t.is(variants.get('night'), `Matcha-dark-${color}`); t.is(variants.get('night'), `Matcha-dark-${color}`);
}); });
test(`Matcha-dark-${color}`, t => { test(`Matcha-dark-${color}`, t => {
const variants = Variants.guess_from(`Matcha-dark-${color}`); const variants = Variants.guessFrom(`Matcha-dark-${color}`);
t.is(variants.get('day'), `Matcha-${color}`); t.is(variants.get('day'), `Matcha-${color}`);
t.is(variants.get('night'), `Matcha-dark-${color}`); t.is(variants.get('night'), `Matcha-dark-${color}`);
}); });
test(`Matcha-light-${color}`, t => { test(`Matcha-light-${color}`, t => {
const variants = Variants.guess_from(`Matcha-light-${color}`); const variants = Variants.guessFrom(`Matcha-light-${color}`);
t.is(variants.get('day'), `Matcha-light-${color}`); t.is(variants.get('day'), `Matcha-light-${color}`);
t.is(variants.get('night'), `Matcha-dark-${color}`); t.is(variants.get('night'), `Matcha-dark-${color}`);
}); });
}) });
+16 -16
View File
@@ -21,21 +21,21 @@ const { Variants } = require('./_variants');
['', '-compact'].forEach(size => { ['', '-compact'].forEach(size => {
test(`Materia${size}`, t => { test(`Materia${size}`, t => {
const variants = Variants.guess_from(`Materia${size}`); const variants = Variants.guessFrom(`Materia${size}`);
t.is(variants.get('day'), `Materia${size}`); t.is(variants.get('day'), `Materia${size}`);
t.is(variants.get('night'), `Materia-dark${size}`); t.is(variants.get('night'), `Materia-dark${size}`);
}); });
test(`Materia-dark${size}`, t => { test(`Materia-dark${size}`, t => {
const variants = Variants.guess_from(`Materia-dark${size}`); const variants = Variants.guessFrom(`Materia-dark${size}`);
t.is(variants.get('day'), `Materia${size}`); t.is(variants.get('day'), `Materia${size}`);
t.is(variants.get('night'), `Materia-dark${size}`); t.is(variants.get('night'), `Materia-dark${size}`);
}); });
test(`Materia-light${size}`, t => { test(`Materia-light${size}`, t => {
const variants = Variants.guess_from(`Materia-light${size}`); const variants = Variants.guessFrom(`Materia-light${size}`);
t.is(variants.get('day'), `Materia-light${size}`); t.is(variants.get('day'), `Materia-light${size}`);
t.is(variants.get('night'), `Materia-dark${size}`); t.is(variants.get('night'), `Materia-dark${size}`);
}); });
}) });
+12 -12
View File
@@ -21,17 +21,17 @@ const { Variants } = require('./_variants');
['', '-solid'].forEach(transparency => { ['', '-solid'].forEach(transparency => {
['', '-alt'].forEach(alt => { ['', '-alt'].forEach(alt => {
test(`Mojave-light${transparency}${alt}`, t => { test(`Mojave-light${transparency}${alt}`, t => {
const variants = Variants.guess_from(`Mojave-light${transparency}${alt}`); const variants = Variants.guessFrom(`Mojave-light${transparency}${alt}`);
t.is(variants.get('day'), `Mojave-light${transparency}${alt}`); t.is(variants.get('day'), `Mojave-light${transparency}${alt}`);
t.is(variants.get('night'), `Mojave-dark${transparency}${alt}`); t.is(variants.get('night'), `Mojave-dark${transparency}${alt}`);
}); });
test(`Mojave-dark${transparency}${alt}`, t => { test(`Mojave-dark${transparency}${alt}`, t => {
const variants = Variants.guess_from(`Mojave-dark${transparency}${alt}`); const variants = Variants.guessFrom(`Mojave-dark${transparency}${alt}`);
t.is(variants.get('day'), `Mojave-light${transparency}${alt}`); t.is(variants.get('day'), `Mojave-light${transparency}${alt}`);
t.is(variants.get('night'), `Mojave-dark${transparency}${alt}`); t.is(variants.get('night'), `Mojave-dark${transparency}${alt}`);
}); });
}); });
}); });
+6 -6
View File
@@ -20,13 +20,13 @@ const test = require('ava');
const { Variants } = require('./_variants'); const { Variants } = require('./_variants');
test('Nextwaita', t => { test('Nextwaita', t => {
const variants = Variants.guess_from('Nextwaita-2.2'); const variants = Variants.guessFrom('Nextwaita-2.2');
t.is(variants.get('day'), 'Nextwaita-2.2'); t.is(variants.get('day'), 'Nextwaita-2.2');
t.is(variants.get('night'), 'Nextwaita-dark-2.2'); t.is(variants.get('night'), 'Nextwaita-dark-2.2');
}); });
test('Nextwaita-dark', t => { test('Nextwaita-dark', t => {
const variants = Variants.guess_from('Nextwaita-dark-2.2'); const variants = Variants.guessFrom('Nextwaita-dark-2.2');
t.is(variants.get('day'), 'Nextwaita-2.2'); t.is(variants.get('day'), 'Nextwaita-2.2');
t.is(variants.get('night'), 'Nextwaita-dark-2.2'); t.is(variants.get('night'), 'Nextwaita-dark-2.2');
}); });
+11 -11
View File
@@ -21,15 +21,15 @@ const { Variants } = require('./_variants');
['', '-compact'].forEach(size => { ['', '-compact'].forEach(size => {
test(`Orchis${size}`, t => { test(`Orchis${size}`, t => {
const variants = Variants.guess_from(`Orchis${size}`); const variants = Variants.guessFrom(`Orchis${size}`);
t.is(variants.get('day'), `Orchis${size}`); t.is(variants.get('day'), `Orchis${size}`);
t.is(variants.get('night'), `Orchis-dark${size}`); t.is(variants.get('night'), `Orchis-dark${size}`);
}); });
test(`Orchis-dark${size}`, t => { test(`Orchis-dark${size}`, t => {
const variants = Variants.guess_from(`Orchis-dark${size}`); const variants = Variants.guessFrom(`Orchis-dark${size}`);
t.is(variants.get('day'), `Orchis${size}`); t.is(variants.get('day'), `Orchis${size}`);
t.is(variants.get('night'), `Orchis-dark${size}`); t.is(variants.get('night'), `Orchis-dark${size}`);
}); });
}) });
+16 -16
View File
@@ -21,21 +21,21 @@ const { Variants } = require('./_variants');
['', '-Compact'].forEach(size => { ['', '-Compact'].forEach(size => {
test(`Plata${size}`, t => { test(`Plata${size}`, t => {
const variants = Variants.guess_from(`Plata${size}`); const variants = Variants.guessFrom(`Plata${size}`);
t.is(variants.get('day'), `Plata${size}`); t.is(variants.get('day'), `Plata${size}`);
t.is(variants.get('night'), `Plata-Noir${size}`); t.is(variants.get('night'), `Plata-Noir${size}`);
}); });
test(`Plata-Noir${size}`, t => { test(`Plata-Noir${size}`, t => {
const variants = Variants.guess_from(`Plata-Noir${size}`); const variants = Variants.guessFrom(`Plata-Noir${size}`);
t.is(variants.get('day'), `Plata${size}`); t.is(variants.get('day'), `Plata${size}`);
t.is(variants.get('night'), `Plata-Noir${size}`); t.is(variants.get('night'), `Plata-Noir${size}`);
}); });
test(`Plata-Lumine${size}`, t => { test(`Plata-Lumine${size}`, t => {
const variants = Variants.guess_from(`Plata-Lumine${size}`); const variants = Variants.guessFrom(`Plata-Lumine${size}`);
t.is(variants.get('day'), `Plata-Lumine${size}`); t.is(variants.get('day'), `Plata-Lumine${size}`);
t.is(variants.get('night'), `Plata-Noir${size}`); t.is(variants.get('night'), `Plata-Noir${size}`);
}); });
}) });
+12 -12
View File
@@ -21,25 +21,25 @@ const { Variants } = require('./_variants');
test('Prof-Gnome-Light-3', t => { test('Prof-Gnome-Light-3', t => {
const variants = Variants.guess_from('Prof-Gnome-Light-3'); const variants = Variants.guessFrom('Prof-Gnome-Light-3');
t.is(variants.get('day'), 'Prof-Gnome-Light-3'); t.is(variants.get('day'), 'Prof-Gnome-Light-3');
t.is(variants.get('night'), 'Prof-Gnome-Dark-3'); t.is(variants.get('night'), 'Prof-Gnome-Dark-3');
}); });
test('Prof-Gnome-Dark-3', t => { test('Prof-Gnome-Dark-3', t => {
const variants = Variants.guess_from('Prof-Gnome-Dark-3'); const variants = Variants.guessFrom('Prof-Gnome-Dark-3');
t.is(variants.get('day'), 'Prof-Gnome-Light-3'); t.is(variants.get('day'), 'Prof-Gnome-Light-3');
t.is(variants.get('night'), 'Prof-Gnome-Dark-3'); t.is(variants.get('night'), 'Prof-Gnome-Dark-3');
}); });
test('Prof-Gnome-Darker-3', t => { test('Prof-Gnome-Darker-3', t => {
const variants = Variants.guess_from('Prof-Gnome-Darker-3'); const variants = Variants.guessFrom('Prof-Gnome-Darker-3');
t.is(variants.get('day'), 'Prof-Gnome-Darker-3'); t.is(variants.get('day'), 'Prof-Gnome-Darker-3');
t.is(variants.get('night'), 'Prof-Gnome-Dark-3'); t.is(variants.get('night'), 'Prof-Gnome-Dark-3');
}); });
test('Prof-Gnome-Light-DS-3', t => { test('Prof-Gnome-Light-DS-3', t => {
const variants = Variants.guess_from('Prof-Gnome-Light-DS-3'); const variants = Variants.guessFrom('Prof-Gnome-Light-DS-3');
t.is(variants.get('day'), 'Prof-Gnome-Light-DS-3'); t.is(variants.get('day'), 'Prof-Gnome-Light-DS-3');
t.is(variants.get('night'), 'Prof-Gnome-Dark-3'); t.is(variants.get('night'), 'Prof-Gnome-Dark-3');
}); });
+17 -17
View File
@@ -21,23 +21,23 @@ const { Variants } = require('./_variants');
['', '-manjaro', '-ubuntu'].forEach(color => { ['', '-manjaro', '-ubuntu'].forEach(color => {
['', '-win'].forEach(alt => { ['', '-win'].forEach(alt => {
test(`Qogir${color}${alt}`, t => { test(`Qogir${color}${alt}`, t => {
const variants = Variants.guess_from(`Qogir${color}${alt}`); const variants = Variants.guessFrom(`Qogir${color}${alt}`);
t.is(variants.get('day'), `Qogir${color}${alt}`); t.is(variants.get('day'), `Qogir${color}${alt}`);
t.is(variants.get('night'), `Qogir${color}${alt}-dark`); t.is(variants.get('night'), `Qogir${color}${alt}-dark`);
}); });
test(`Qogir${color}${alt}-dark`, t => { test(`Qogir${color}${alt}-dark`, t => {
const variants = Variants.guess_from(`Qogir${color}${alt}-dark`); const variants = Variants.guessFrom(`Qogir${color}${alt}-dark`);
t.is(variants.get('day'), `Qogir${color}${alt}`); t.is(variants.get('day'), `Qogir${color}${alt}`);
t.is(variants.get('night'), `Qogir${color}${alt}-dark`); t.is(variants.get('night'), `Qogir${color}${alt}-dark`);
}); });
test(`Qogir${color}${alt}light`, t => { test(`Qogir${color}${alt}light`, t => {
const variants = Variants.guess_from(`Qogir${color}${alt}-light`); const variants = Variants.guessFrom(`Qogir${color}${alt}-light`);
t.is(variants.get('day'), `Qogir${color}${alt}-light`); t.is(variants.get('day'), `Qogir${color}${alt}-light`);
t.is(variants.get('night'), `Qogir${color}${alt}-dark`); t.is(variants.get('night'), `Qogir${color}${alt}-dark`);
}); });
}); });
}); });
+12 -12
View File
@@ -21,17 +21,17 @@ const { Variants } = require('./_variants');
['', '_Blue', '_Cyan', '_Green', '_Orange', '_Purple'].forEach(color => { ['', '_Blue', '_Cyan', '_Green', '_Orange', '_Purple'].forEach(color => {
['', '_Envolved'].forEach(variant => { ['', '_Envolved'].forEach(variant => {
test(`Simply_Circles${color}_Light${variant}`, t => { test(`Simply_Circles${color}_Light${variant}`, t => {
const variants = Variants.guess_from(`Simply_Circles${color}_Light${variant}`); const variants = Variants.guessFrom(`Simply_Circles${color}_Light${variant}`);
t.is(variants.get('day'), `Simply_Circles${color}_Light${variant}`); t.is(variants.get('day'), `Simply_Circles${color}_Light${variant}`);
t.is(variants.get('night'), `Simply_Circles${color}_Dark${variant}`); t.is(variants.get('night'), `Simply_Circles${color}_Dark${variant}`);
}); });
test(`Simply_Circles${color}${variant}`, t => { test(`Simply_Circles${color}${variant}`, t => {
const variants = Variants.guess_from(`Simply_Circles${color}_Dark${variant}`); const variants = Variants.guessFrom(`Simply_Circles${color}_Dark${variant}`);
t.is(variants.get('day'), `Simply_Circles${color}_Light${variant}`); t.is(variants.get('day'), `Simply_Circles${color}_Light${variant}`);
t.is(variants.get('night'), `Simply_Circles${color}_Dark${variant}`); t.is(variants.get('night'), `Simply_Circles${color}_Dark${variant}`);
}); });
}) });
}); });
+15 -15
View File
@@ -20,31 +20,31 @@ const test = require('ava');
const { Variants } = require('./_variants'); const { Variants } = require('./_variants');
test('Teja', t => { test('Teja', t => {
const variants = Variants.guess_from('Teja'); const variants = Variants.guessFrom('Teja');
t.is(variants.get('day'), 'Teja'); t.is(variants.get('day'), 'Teja');
t.is(variants.get('night'), 'Teja_Dark'); t.is(variants.get('night'), 'Teja_Dark');
}); });
test('Teja_Dark', t => { test('Teja_Dark', t => {
const variants = Variants.guess_from('Teja_Dark'); const variants = Variants.guessFrom('Teja_Dark');
t.is(variants.get('day'), 'Teja'); t.is(variants.get('day'), 'Teja');
t.is(variants.get('night'), 'Teja_Dark'); t.is(variants.get('night'), 'Teja_Dark');
}); });
test('Teja_Darkest', t => { test('Teja_Darkest', t => {
const variants = Variants.guess_from('Teja_Darkest'); const variants = Variants.guessFrom('Teja_Darkest');
t.is(variants.get('day'), 'Teja'); t.is(variants.get('day'), 'Teja');
t.is(variants.get('night'), 'Teja_Darkest'); t.is(variants.get('night'), 'Teja_Darkest');
}); });
test('Teja_Black', t => { test('Teja_Black', t => {
const variants = Variants.guess_from('Teja_Black'); const variants = Variants.guessFrom('Teja_Black');
t.is(variants.get('day'), 'Teja'); t.is(variants.get('day'), 'Teja');
t.is(variants.get('night'), 'Teja_Black'); t.is(variants.get('night'), 'Teja_Black');
}); });
test('Teja_Light', t => { test('Teja_Light', t => {
const variants = Variants.guess_from('Teja_Light'); const variants = Variants.guessFrom('Teja_Light');
t.is(variants.get('day'), 'Teja_Light'); t.is(variants.get('day'), 'Teja_Light');
t.is(variants.get('night'), 'Teja_Dark'); t.is(variants.get('night'), 'Teja_Dark');
}); });
+17 -17
View File
@@ -21,22 +21,22 @@ const { Variants } = require('./_variants');
['', '-laptop'].forEach(size => { ['', '-laptop'].forEach(size => {
['', '-beryl', '-doder', '-ruby'].forEach(color => { ['', '-beryl', '-doder', '-ruby'].forEach(color => {
test(`vimix${size}${color}`, t => { test(`vimix${size}${color}`, t => {
const variants = Variants.guess_from(`vimix${size}${color}`); const variants = Variants.guessFrom(`vimix${size}${color}`);
t.is(variants.get('day'), `vimix${size}${color}`); t.is(variants.get('day'), `vimix${size}${color}`);
t.is(variants.get('night'), `vimix-dark${size}${color}`); t.is(variants.get('night'), `vimix-dark${size}${color}`);
}); });
test(`vimix-dark${size}${color}`, t => { test(`vimix-dark${size}${color}`, t => {
const variants = Variants.guess_from(`vimix-dark${size}${color}`); const variants = Variants.guessFrom(`vimix-dark${size}${color}`);
t.is(variants.get('day'), `vimix${size}${color}`); t.is(variants.get('day'), `vimix${size}${color}`);
t.is(variants.get('night'), `vimix-dark${size}${color}`); t.is(variants.get('night'), `vimix-dark${size}${color}`);
}); });
test(`vimix-light${size}${color}`, t => { test(`vimix-light${size}${color}`, t => {
const variants = Variants.guess_from(`vimix-light${size}${color}`); const variants = Variants.guessFrom(`vimix-light${size}${color}`);
t.is(variants.get('day'), `vimix-light${size}${color}`); t.is(variants.get('day'), `vimix-light${size}${color}`);
t.is(variants.get('night'), `vimix-dark${size}${color}`); t.is(variants.get('night'), `vimix-dark${size}${color}`);
}); });
}); });
}); });
+9 -9
View File
@@ -21,19 +21,19 @@ const { Variants } = require('./_variants');
test('Yaru', t => { test('Yaru', t => {
const variants = Variants.guess_from('Yaru'); const variants = Variants.guessFrom('Yaru');
t.is(variants.get('day'), 'Yaru'); t.is(variants.get('day'), 'Yaru');
t.is(variants.get('night'), 'Yaru-dark'); t.is(variants.get('night'), 'Yaru-dark');
}); });
test('Yaru-dark', t => { test('Yaru-dark', t => {
const variants = Variants.guess_from('Yaru-dark'); const variants = Variants.guessFrom('Yaru-dark');
t.is(variants.get('day'), 'Yaru'); t.is(variants.get('day'), 'Yaru');
t.is(variants.get('night'), 'Yaru-dark'); t.is(variants.get('night'), 'Yaru-dark');
}); });
test('Yaru-light', t => { test('Yaru-light', t => {
const variants = Variants.guess_from('Yaru-light'); const variants = Variants.guessFrom('Yaru-light');
t.is(variants.get('day'), 'Yaru-light'); t.is(variants.get('day'), 'Yaru-light');
t.is(variants.get('night'), 'Yaru-dark'); t.is(variants.get('night'), 'Yaru-dark');
}); });
+15 -15
View File
@@ -20,31 +20,31 @@ const test = require('ava');
const { Variants } = require('./_variants'); const { Variants } = require('./_variants');
test('base', t => { test('base', t => {
const variants = Variants.guess_from('base'); const variants = Variants.guessFrom('base');
t.is(variants.get('day'), 'base'); t.is(variants.get('day'), 'base');
t.is(variants.get('night'), 'base-dark'); t.is(variants.get('night'), 'base-dark');
}); });
test('base-dark', t => { test('base-dark', t => {
const variants = Variants.guess_from('base-dark'); const variants = Variants.guessFrom('base-dark');
t.is(variants.get('day'), 'base'); t.is(variants.get('day'), 'base');
t.is(variants.get('night'), 'base-dark'); t.is(variants.get('night'), 'base-dark');
}); });
test('base-light', t => { test('base-light', t => {
const variants = Variants.guess_from('base-light'); const variants = Variants.guessFrom('base-light');
t.is(variants.get('day'), 'base-light'); t.is(variants.get('day'), 'base-light');
t.is(variants.get('night'), 'base-dark'); t.is(variants.get('night'), 'base-dark');
}); });
test('base-darker', t => { test('base-darker', t => {
const variants = Variants.guess_from('base-darker'); const variants = Variants.guessFrom('base-darker');
t.is(variants.get('day'), 'base-darker'); t.is(variants.get('day'), 'base-darker');
t.is(variants.get('night'), 'base-dark'); t.is(variants.get('night'), 'base-dark');
}); });
test('base-darkest', t => { test('base-darkest', t => {
const variants = Variants.guess_from('base-darkest'); const variants = Variants.guessFrom('base-darkest');
t.is(variants.get('day'), 'base'); t.is(variants.get('day'), 'base');
t.is(variants.get('night'), 'base-darkest'); t.is(variants.get('night'), 'base-darkest');
}); });
+12 -12
View File
@@ -21,25 +21,25 @@ const { Variants } = require('./_variants');
test('Adapta', t => { test('Adapta', t => {
const variants = Variants.guess_from('Adapta'); const variants = Variants.guessFrom('Adapta');
t.is(variants.get('day'), 'Adapta'); t.is(variants.get('day'), 'Adapta');
t.is(variants.get('night'), 'Adapta-Nokto'); t.is(variants.get('night'), 'Adapta-Nokto');
}); });
test('Adapta-Nokto', t => { test('Adapta-Nokto', t => {
const variants = Variants.guess_from('Adapta-Nokto'); const variants = Variants.guessFrom('Adapta-Nokto');
t.is(variants.get('day'), 'Adapta'); t.is(variants.get('day'), 'Adapta');
t.is(variants.get('night'), 'Adapta-Nokto'); t.is(variants.get('night'), 'Adapta-Nokto');
}); });
test('Adapta-Eta', t => { test('Adapta-Eta', t => {
const variants = Variants.guess_from('Adapta-Eta'); const variants = Variants.guessFrom('Adapta-Eta');
t.is(variants.get('day'), 'Adapta-Eta'); t.is(variants.get('day'), 'Adapta-Eta');
t.is(variants.get('night'), 'Adapta-Nokto-Eta'); t.is(variants.get('night'), 'Adapta-Nokto-Eta');
}); });
test('Adapta-Nokto-Eta', t => { test('Adapta-Nokto-Eta', t => {
const variants = Variants.guess_from('Adapta-Nokto-Eta'); const variants = Variants.guessFrom('Adapta-Nokto-Eta');
t.is(variants.get('day'), 'Adapta-Eta'); t.is(variants.get('day'), 'Adapta-Eta');
t.is(variants.get('night'), 'Adapta-Nokto-Eta'); t.is(variants.get('night'), 'Adapta-Nokto-Eta');
}); });
+12 -12
View File
@@ -21,25 +21,25 @@ const { Variants } = require('./_variants');
test('Arc', t => { test('Arc', t => {
const variants = Variants.guess_from('Arc'); const variants = Variants.guessFrom('Arc');
t.is(variants.get('day'), 'Arc'); t.is(variants.get('day'), 'Arc');
t.is(variants.get('night'), 'Arc-Dark'); t.is(variants.get('night'), 'Arc-Dark');
}); });
test('Arc-Dark', t => { test('Arc-Dark', t => {
const variants = Variants.guess_from('Arc-Dark'); const variants = Variants.guessFrom('Arc-Dark');
t.is(variants.get('day'), 'Arc'); t.is(variants.get('day'), 'Arc');
t.is(variants.get('night'), 'Arc-Dark'); t.is(variants.get('night'), 'Arc-Dark');
}); });
test('Arc-Dark-solid', t => { test('Arc-Dark-solid', t => {
const variants = Variants.guess_from('Arc-Dark-solid'); const variants = Variants.guessFrom('Arc-Dark-solid');
t.is(variants.get('day'), 'Arc-solid'); t.is(variants.get('day'), 'Arc-solid');
t.is(variants.get('night'), 'Arc-Dark-solid'); t.is(variants.get('night'), 'Arc-Dark-solid');
}); });
test('Arc-solid', t => { test('Arc-solid', t => {
const variants = Variants.guess_from('Arc-solid'); const variants = Variants.guessFrom('Arc-solid');
t.is(variants.get('day'), 'Arc-solid'); t.is(variants.get('day'), 'Arc-solid');
t.is(variants.get('night'), 'Arc-Dark-solid'); t.is(variants.get('night'), 'Arc-Dark-solid');
}); });
+30 -30
View File
@@ -21,39 +21,39 @@ const { Variants } = require('./_variants');
['', '-blue', '-indigo'].forEach(color => { ['', '-blue', '-indigo'].forEach(color => {
test(`Canta${color}`, t => { test(`Canta${color}`, t => {
const variants = Variants.guess_from(`Canta${color}`); const variants = Variants.guessFrom(`Canta${color}`);
t.is(variants.get('day'), `Canta${color}`); t.is(variants.get('day'), `Canta${color}`);
t.is(variants.get('night'), `Canta${color}-dark`); t.is(variants.get('night'), `Canta${color}-dark`);
}); });
test(`Canta${color}-dark`, t => { test(`Canta${color}-dark`, t => {
const variants = Variants.guess_from(`Canta${color}-dark`); const variants = Variants.guessFrom(`Canta${color}-dark`);
t.is(variants.get('day'), `Canta${color}`); t.is(variants.get('day'), `Canta${color}`);
t.is(variants.get('night'), `Canta${color}-dark`); t.is(variants.get('night'), `Canta${color}-dark`);
}); });
test(`Canta${color}-light`, t => { test(`Canta${color}-light`, t => {
const variants = Variants.guess_from(`Canta${color}-light`); const variants = Variants.guessFrom(`Canta${color}-light`);
t.is(variants.get('day'), `Canta${color}-light`); t.is(variants.get('day'), `Canta${color}-light`);
t.is(variants.get('night'), `Canta${color}-dark`); t.is(variants.get('night'), `Canta${color}-dark`);
}); });
test(`Canta${color}-compact`, t => { test(`Canta${color}-compact`, t => {
const variants = Variants.guess_from(`Canta${color}-compact`); const variants = Variants.guessFrom(`Canta${color}-compact`);
t.is(variants.get('day'), `Canta${color}-compact`); t.is(variants.get('day'), `Canta${color}-compact`);
t.is(variants.get('night'), `Canta${color}-dark-compact`); t.is(variants.get('night'), `Canta${color}-dark-compact`);
}); });
test(`Canta${color}-dark-compact`, t => { test(`Canta${color}-dark-compact`, t => {
const variants = Variants.guess_from(`Canta${color}-dark-compact`); const variants = Variants.guessFrom(`Canta${color}-dark-compact`);
t.is(variants.get('day'), `Canta${color}-compact`); t.is(variants.get('day'), `Canta${color}-compact`);
t.is(variants.get('night'), `Canta${color}-dark-compact`); t.is(variants.get('night'), `Canta${color}-dark-compact`);
}); });
test(`Canta${color}-light-compact`, t => { test(`Canta${color}-light-compact`, t => {
const variants = Variants.guess_from(`Canta${color}-light-compact`); const variants = Variants.guessFrom(`Canta${color}-light-compact`);
t.is(variants.get('day'), `Canta${color}-light-compact`); t.is(variants.get('day'), `Canta${color}-light-compact`);
t.is(variants.get('night'), `Canta${color}-dark-compact`); t.is(variants.get('night'), `Canta${color}-dark-compact`);
}); });
}); });
+16 -16
View File
@@ -20,21 +20,21 @@ const test = require('ava');
const { Variants } = require('./_variants'); const { Variants } = require('./_variants');
['', '-compact'].forEach(size => { ['', '-compact'].forEach(size => {
test(`ChromeOS${size}`, t => { test(`ChromeOS${size}`, t => {
const variants = Variants.guess_from(`ChromeOS${size}`); const variants = Variants.guessFrom(`ChromeOS${size}`);
t.is(variants.get('day'), `ChromeOS${size}`); t.is(variants.get('day'), `ChromeOS${size}`);
t.is(variants.get('night'), `ChromeOS-dark${size}`); t.is(variants.get('night'), `ChromeOS-dark${size}`);
}); });
test(`ChromeOS-dark${size}`, t => { test(`ChromeOS-dark${size}`, t => {
const variants = Variants.guess_from(`ChromeOS-dark${size}`); const variants = Variants.guessFrom(`ChromeOS-dark${size}`);
t.is(variants.get('day'), `ChromeOS${size}`); t.is(variants.get('day'), `ChromeOS${size}`);
t.is(variants.get('night'), `ChromeOS-dark${size}`); t.is(variants.get('night'), `ChromeOS-dark${size}`);
}); });
test(`ChromeOS-light${size}`, t => { test(`ChromeOS-light${size}`, t => {
const variants = Variants.guess_from(`ChromeOS-light${size}`); const variants = Variants.guessFrom(`ChromeOS-light${size}`);
t.is(variants.get('day'), `ChromeOS-light${size}`); t.is(variants.get('day'), `ChromeOS-light${size}`);
t.is(variants.get('night'), `ChromeOS-dark${size}`); t.is(variants.get('night'), `ChromeOS-dark${size}`);
}); });
}) });
+18 -18
View File
@@ -20,23 +20,23 @@ const test = require('ava');
const { Variants } = require('./_variants'); const { Variants } = require('./_variants');
['', '-Miami'].forEach(color => { ['', '-Miami'].forEach(color => {
['', '-fullPanel'].forEach(size => { ['', '-fullPanel'].forEach(size => {
test(`Flat-Remix${color}${size}`, t => { test(`Flat-Remix${color}${size}`, t => {
const variants = Variants.guess_from(`Flat-Remix${color}${size}`); const variants = Variants.guessFrom(`Flat-Remix${color}${size}`);
t.is(variants.get('day'), `Flat-Remix${color}${size}`); t.is(variants.get('day'), `Flat-Remix${color}${size}`);
t.is(variants.get('night'), `Flat-Remix${color}-Dark${size}`); t.is(variants.get('night'), `Flat-Remix${color}-Dark${size}`);
}); });
test(`Flat-Remix${color}-Dark${size}`, t => { test(`Flat-Remix${color}-Dark${size}`, t => {
const variants = Variants.guess_from(`Flat-Remix${color}-Dark${size}`); const variants = Variants.guessFrom(`Flat-Remix${color}-Dark${size}`);
t.is(variants.get('day'), `Flat-Remix${color}${size}`); t.is(variants.get('day'), `Flat-Remix${color}${size}`);
t.is(variants.get('night'), `Flat-Remix${color}-Dark${size}`); t.is(variants.get('night'), `Flat-Remix${color}-Dark${size}`);
}); });
test(`Flat-Remix${color}-Darkest${size}`, t => { test(`Flat-Remix${color}-Darkest${size}`, t => {
const variants = Variants.guess_from(`Flat-Remix${color}-Darkest${size}`); const variants = Variants.guessFrom(`Flat-Remix${color}-Darkest${size}`);
t.is(variants.get('day'), `Flat-Remix${color}${size}`); t.is(variants.get('day'), `Flat-Remix${color}${size}`);
t.is(variants.get('night'), `Flat-Remix${color}-Darkest${size}`); t.is(variants.get('night'), `Flat-Remix${color}-Darkest${size}`);
}); });
}) });
}) });
+18 -18
View File
@@ -21,37 +21,37 @@ const { Variants } = require('./_variants');
test('Layan', t => { test('Layan', t => {
const variants = Variants.guess_from('Layan'); const variants = Variants.guessFrom('Layan');
t.is(variants.get('day'), 'Layan'); t.is(variants.get('day'), 'Layan');
t.is(variants.get('night'), 'Layan-dark'); t.is(variants.get('night'), 'Layan-dark');
}); });
test('Layan-dark', t => { test('Layan-dark', t => {
const variants = Variants.guess_from('Layan-dark'); const variants = Variants.guessFrom('Layan-dark');
t.is(variants.get('day'), 'Layan'); t.is(variants.get('day'), 'Layan');
t.is(variants.get('night'), 'Layan-dark'); t.is(variants.get('night'), 'Layan-dark');
}); });
test('Layan-light', t => { test('Layan-light', t => {
const variants = Variants.guess_from('Layan-light'); const variants = Variants.guessFrom('Layan-light');
t.is(variants.get('day'), 'Layan-light'); t.is(variants.get('day'), 'Layan-light');
t.is(variants.get('night'), 'Layan-dark'); t.is(variants.get('night'), 'Layan-dark');
}); });
test('Layan-solid', t => { test('Layan-solid', t => {
const variants = Variants.guess_from('Layan-solid'); const variants = Variants.guessFrom('Layan-solid');
t.is(variants.get('day'), 'Layan-solid'); t.is(variants.get('day'), 'Layan-solid');
t.is(variants.get('night'), 'Layan-dark-solid'); t.is(variants.get('night'), 'Layan-dark-solid');
}); });
test('Layan-dark-solid', t => { test('Layan-dark-solid', t => {
const variants = Variants.guess_from('Layan-dark-solid'); const variants = Variants.guessFrom('Layan-dark-solid');
t.is(variants.get('day'), 'Layan-solid'); t.is(variants.get('day'), 'Layan-solid');
t.is(variants.get('night'), 'Layan-dark-solid'); t.is(variants.get('night'), 'Layan-dark-solid');
}); });
test('Layan-light-solid', t => { test('Layan-light-solid', t => {
const variants = Variants.guess_from('Layan-light-solid'); const variants = Variants.guessFrom('Layan-light-solid');
t.is(variants.get('day'), 'Layan-light-solid'); t.is(variants.get('day'), 'Layan-light-solid');
t.is(variants.get('night'), 'Layan-dark-solid'); t.is(variants.get('night'), 'Layan-dark-solid');
}); });
+16 -16
View File
@@ -21,21 +21,21 @@ const { Variants } = require('./_variants');
['aliz', 'azul', 'sea'].forEach(color => { ['aliz', 'azul', 'sea'].forEach(color => {
test(`Matcha-${color}`, t => { test(`Matcha-${color}`, t => {
const variants = Variants.guess_from(`Matcha-${color}`); const variants = Variants.guessFrom(`Matcha-${color}`);
t.is(variants.get('day'), `Matcha-${color}`); t.is(variants.get('day'), `Matcha-${color}`);
t.is(variants.get('night'), `Matcha-dark-${color}`); t.is(variants.get('night'), `Matcha-dark-${color}`);
}); });
test(`Matcha-dark-${color}`, t => { test(`Matcha-dark-${color}`, t => {
const variants = Variants.guess_from(`Matcha-dark-${color}`); const variants = Variants.guessFrom(`Matcha-dark-${color}`);
t.is(variants.get('day'), `Matcha-${color}`); t.is(variants.get('day'), `Matcha-${color}`);
t.is(variants.get('night'), `Matcha-dark-${color}`); t.is(variants.get('night'), `Matcha-dark-${color}`);
}); });
test(`Matcha-light-${color}`, t => { test(`Matcha-light-${color}`, t => {
const variants = Variants.guess_from(`Matcha-light-${color}`); const variants = Variants.guessFrom(`Matcha-light-${color}`);
t.is(variants.get('day'), `Matcha-light-${color}`); t.is(variants.get('day'), `Matcha-light-${color}`);
t.is(variants.get('night'), `Matcha-dark-${color}`); t.is(variants.get('night'), `Matcha-dark-${color}`);
}); });
}) });
+16 -16
View File
@@ -21,21 +21,21 @@ const { Variants } = require('./_variants');
['', '-compact'].forEach(size => { ['', '-compact'].forEach(size => {
test(`Materia${size}`, t => { test(`Materia${size}`, t => {
const variants = Variants.guess_from(`Materia${size}`); const variants = Variants.guessFrom(`Materia${size}`);
t.is(variants.get('day'), `Materia${size}`); t.is(variants.get('day'), `Materia${size}`);
t.is(variants.get('night'), `Materia-dark${size}`); t.is(variants.get('night'), `Materia-dark${size}`);
}); });
test(`Materia-dark${size}`, t => { test(`Materia-dark${size}`, t => {
const variants = Variants.guess_from(`Materia-dark${size}`); const variants = Variants.guessFrom(`Materia-dark${size}`);
t.is(variants.get('day'), `Materia${size}`); t.is(variants.get('day'), `Materia${size}`);
t.is(variants.get('night'), `Materia-dark${size}`); t.is(variants.get('night'), `Materia-dark${size}`);
}); });
test(`Materia-light${size}`, t => { test(`Materia-light${size}`, t => {
const variants = Variants.guess_from(`Materia-light${size}`); const variants = Variants.guessFrom(`Materia-light${size}`);
t.is(variants.get('day'), `Materia-light${size}`); t.is(variants.get('day'), `Materia-light${size}`);
t.is(variants.get('night'), `Materia-dark${size}`); t.is(variants.get('night'), `Materia-dark${size}`);
}); });
}) });
+12 -12
View File
@@ -21,17 +21,17 @@ const { Variants } = require('./_variants');
['', '-solid'].forEach(transparency => { ['', '-solid'].forEach(transparency => {
['', '-alt'].forEach(alt => { ['', '-alt'].forEach(alt => {
test(`Mojave-light${transparency}${alt}`, t => { test(`Mojave-light${transparency}${alt}`, t => {
const variants = Variants.guess_from(`Mojave-light${transparency}${alt}`); const variants = Variants.guessFrom(`Mojave-light${transparency}${alt}`);
t.is(variants.get('day'), `Mojave-light${transparency}${alt}`); t.is(variants.get('day'), `Mojave-light${transparency}${alt}`);
t.is(variants.get('night'), `Mojave-dark${transparency}${alt}`); t.is(variants.get('night'), `Mojave-dark${transparency}${alt}`);
}); });
test(`Mojave-dark${transparency}${alt}`, t => { test(`Mojave-dark${transparency}${alt}`, t => {
const variants = Variants.guess_from(`Mojave-dark${transparency}${alt}`); const variants = Variants.guessFrom(`Mojave-dark${transparency}${alt}`);
t.is(variants.get('day'), `Mojave-light${transparency}${alt}`); t.is(variants.get('day'), `Mojave-light${transparency}${alt}`);
t.is(variants.get('night'), `Mojave-dark${transparency}${alt}`); t.is(variants.get('night'), `Mojave-dark${transparency}${alt}`);
}); });
}); });
}); });
+11 -11
View File
@@ -21,15 +21,15 @@ const { Variants } = require('./_variants');
['', '-compact'].forEach(size => { ['', '-compact'].forEach(size => {
test(`Orchis${size}`, t => { test(`Orchis${size}`, t => {
const variants = Variants.guess_from(`Orchis${size}`); const variants = Variants.guessFrom(`Orchis${size}`);
t.is(variants.get('day'), `Orchis${size}`); t.is(variants.get('day'), `Orchis${size}`);
t.is(variants.get('night'), `Orchis-dark${size}`); t.is(variants.get('night'), `Orchis-dark${size}`);
}); });
test(`Orchis-dark${size}`, t => { test(`Orchis-dark${size}`, t => {
const variants = Variants.guess_from(`Orchis-dark${size}`); const variants = Variants.guessFrom(`Orchis-dark${size}`);
t.is(variants.get('day'), `Orchis${size}`); t.is(variants.get('day'), `Orchis${size}`);
t.is(variants.get('night'), `Orchis-dark${size}`); t.is(variants.get('night'), `Orchis-dark${size}`);
}); });
}) });
+16 -16
View File
@@ -21,21 +21,21 @@ const { Variants } = require('./_variants');
['', '-Compact'].forEach(size => { ['', '-Compact'].forEach(size => {
test(`Plata${size}`, t => { test(`Plata${size}`, t => {
const variants = Variants.guess_from(`Plata${size}`); const variants = Variants.guessFrom(`Plata${size}`);
t.is(variants.get('day'), `Plata${size}`); t.is(variants.get('day'), `Plata${size}`);
t.is(variants.get('night'), `Plata-Noir${size}`); t.is(variants.get('night'), `Plata-Noir${size}`);
}); });
test(`Plata-Noir${size}`, t => { test(`Plata-Noir${size}`, t => {
const variants = Variants.guess_from(`Plata-Noir${size}`); const variants = Variants.guessFrom(`Plata-Noir${size}`);
t.is(variants.get('day'), `Plata${size}`); t.is(variants.get('day'), `Plata${size}`);
t.is(variants.get('night'), `Plata-Noir${size}`); t.is(variants.get('night'), `Plata-Noir${size}`);
}); });
test(`Plata-Lumine${size}`, t => { test(`Plata-Lumine${size}`, t => {
const variants = Variants.guess_from(`Plata-Lumine${size}`); const variants = Variants.guessFrom(`Plata-Lumine${size}`);
t.is(variants.get('day'), `Plata-Lumine${size}`); t.is(variants.get('day'), `Plata-Lumine${size}`);
t.is(variants.get('night'), `Plata-Noir${size}`); t.is(variants.get('night'), `Plata-Noir${size}`);
}); });
}) });
+17 -17
View File
@@ -21,23 +21,23 @@ const { Variants } = require('./_variants');
['', '-manjaro', '-ubuntu'].forEach(color => { ['', '-manjaro', '-ubuntu'].forEach(color => {
['', '-win'].forEach(alt => { ['', '-win'].forEach(alt => {
test(`Qogir${color}${alt}`, t => { test(`Qogir${color}${alt}`, t => {
const variants = Variants.guess_from(`Qogir${color}${alt}`); const variants = Variants.guessFrom(`Qogir${color}${alt}`);
t.is(variants.get('day'), `Qogir${color}${alt}`); t.is(variants.get('day'), `Qogir${color}${alt}`);
t.is(variants.get('night'), `Qogir${color}${alt}-dark`); t.is(variants.get('night'), `Qogir${color}${alt}-dark`);
}); });
test(`Qogir${color}${alt}-dark`, t => { test(`Qogir${color}${alt}-dark`, t => {
const variants = Variants.guess_from(`Qogir${color}${alt}-dark`); const variants = Variants.guessFrom(`Qogir${color}${alt}-dark`);
t.is(variants.get('day'), `Qogir${color}${alt}`); t.is(variants.get('day'), `Qogir${color}${alt}`);
t.is(variants.get('night'), `Qogir${color}${alt}-dark`); t.is(variants.get('night'), `Qogir${color}${alt}-dark`);
}); });
test(`Qogir${color}${alt}light`, t => { test(`Qogir${color}${alt}light`, t => {
const variants = Variants.guess_from(`Qogir${color}${alt}-light`); const variants = Variants.guessFrom(`Qogir${color}${alt}-light`);
t.is(variants.get('day'), `Qogir${color}${alt}-light`); t.is(variants.get('day'), `Qogir${color}${alt}-light`);
t.is(variants.get('night'), `Qogir${color}${alt}-dark`); t.is(variants.get('night'), `Qogir${color}${alt}-dark`);
}); });
}); });
}); });
+12 -12
View File
@@ -21,17 +21,17 @@ const { Variants } = require('./_variants');
['', '_Blue', '_Cyan', '_Green', '_Orange', '_Purple'].forEach(color => { ['', '_Blue', '_Cyan', '_Green', '_Orange', '_Purple'].forEach(color => {
['', '_Envolved'].forEach(variant => { ['', '_Envolved'].forEach(variant => {
test(`Simply_Circles${color}_Light${variant}`, t => { test(`Simply_Circles${color}_Light${variant}`, t => {
const variants = Variants.guess_from(`Simply_Circles${color}_Light${variant}`); const variants = Variants.guessFrom(`Simply_Circles${color}_Light${variant}`);
t.is(variants.get('day'), `Simply_Circles${color}_Light${variant}`); t.is(variants.get('day'), `Simply_Circles${color}_Light${variant}`);
t.is(variants.get('night'), `Simply_Circles${color}_Dark${variant}`); t.is(variants.get('night'), `Simply_Circles${color}_Dark${variant}`);
}); });
test(`Simply_Circles${color}${variant}`, t => { test(`Simply_Circles${color}${variant}`, t => {
const variants = Variants.guess_from(`Simply_Circles${color}_Dark${variant}`); const variants = Variants.guessFrom(`Simply_Circles${color}_Dark${variant}`);
t.is(variants.get('day'), `Simply_Circles${color}_Light${variant}`); t.is(variants.get('day'), `Simply_Circles${color}_Light${variant}`);
t.is(variants.get('night'), `Simply_Circles${color}_Dark${variant}`); t.is(variants.get('night'), `Simply_Circles${color}_Dark${variant}`);
}); });
}) });
}); });
+15 -15
View File
@@ -20,31 +20,31 @@ const test = require('ava');
const { Variants } = require('./_variants'); const { Variants } = require('./_variants');
test('Teja', t => { test('Teja', t => {
const variants = Variants.guess_from('Teja'); const variants = Variants.guessFrom('Teja');
t.is(variants.get('day'), 'Teja'); t.is(variants.get('day'), 'Teja');
t.is(variants.get('night'), 'Teja_Dark'); t.is(variants.get('night'), 'Teja_Dark');
}); });
test('Teja_Dark', t => { test('Teja_Dark', t => {
const variants = Variants.guess_from('Teja_Dark'); const variants = Variants.guessFrom('Teja_Dark');
t.is(variants.get('day'), 'Teja'); t.is(variants.get('day'), 'Teja');
t.is(variants.get('night'), 'Teja_Dark'); t.is(variants.get('night'), 'Teja_Dark');
}); });
test('Teja_Darkest', t => { test('Teja_Darkest', t => {
const variants = Variants.guess_from('Teja_Darkest'); const variants = Variants.guessFrom('Teja_Darkest');
t.is(variants.get('day'), 'Teja'); t.is(variants.get('day'), 'Teja');
t.is(variants.get('night'), 'Teja_Darkest'); t.is(variants.get('night'), 'Teja_Darkest');
}); });
test('Teja_Black', t => { test('Teja_Black', t => {
const variants = Variants.guess_from('Teja_Black'); const variants = Variants.guessFrom('Teja_Black');
t.is(variants.get('day'), 'Teja'); t.is(variants.get('day'), 'Teja');
t.is(variants.get('night'), 'Teja_Black'); t.is(variants.get('night'), 'Teja_Black');
}); });
test('Teja_Light', t => { test('Teja_Light', t => {
const variants = Variants.guess_from('Teja_Light'); const variants = Variants.guessFrom('Teja_Light');
t.is(variants.get('day'), 'Teja_Light'); t.is(variants.get('day'), 'Teja_Light');
t.is(variants.get('night'), 'Teja_Dark'); t.is(variants.get('night'), 'Teja_Dark');
}); });
+17 -17
View File
@@ -21,22 +21,22 @@ const { Variants } = require('./_variants');
['', '-laptop'].forEach(size => { ['', '-laptop'].forEach(size => {
['', '-beryl', '-doder', '-ruby'].forEach(color => { ['', '-beryl', '-doder', '-ruby'].forEach(color => {
test(`vimix${size}${color}`, t => { test(`vimix${size}${color}`, t => {
const variants = Variants.guess_from(`vimix${size}${color}`); const variants = Variants.guessFrom(`vimix${size}${color}`);
t.is(variants.get('day'), `vimix${size}${color}`); t.is(variants.get('day'), `vimix${size}${color}`);
t.is(variants.get('night'), `vimix-dark${size}${color}`); t.is(variants.get('night'), `vimix-dark${size}${color}`);
}); });
test(`vimix-dark${size}${color}`, t => { test(`vimix-dark${size}${color}`, t => {
const variants = Variants.guess_from(`vimix-dark${size}${color}`); const variants = Variants.guessFrom(`vimix-dark${size}${color}`);
t.is(variants.get('day'), `vimix${size}${color}`); t.is(variants.get('day'), `vimix${size}${color}`);
t.is(variants.get('night'), `vimix-dark${size}${color}`); t.is(variants.get('night'), `vimix-dark${size}${color}`);
}); });
test(`vimix-light${size}${color}`, t => { test(`vimix-light${size}${color}`, t => {
const variants = Variants.guess_from(`vimix-light${size}${color}`); const variants = Variants.guessFrom(`vimix-light${size}${color}`);
t.is(variants.get('day'), `vimix-light${size}${color}`); t.is(variants.get('day'), `vimix-light${size}${color}`);
t.is(variants.get('night'), `vimix-dark${size}${color}`); t.is(variants.get('night'), `vimix-dark${size}${color}`);
}); });
}); });
}); });
+9 -9
View File
@@ -21,19 +21,19 @@ const { Variants } = require('./_variants');
test('Yaru', t => { test('Yaru', t => {
const variants = Variants.guess_from('Yaru'); const variants = Variants.guessFrom('Yaru');
t.is(variants.get('day'), 'Yaru'); t.is(variants.get('day'), 'Yaru');
t.is(variants.get('night'), 'Yaru-dark'); t.is(variants.get('night'), 'Yaru-dark');
}); });
test('Yaru-dark', t => { test('Yaru-dark', t => {
const variants = Variants.guess_from('Yaru-dark'); const variants = Variants.guessFrom('Yaru-dark');
t.is(variants.get('day'), 'Yaru'); t.is(variants.get('day'), 'Yaru');
t.is(variants.get('night'), 'Yaru-dark'); t.is(variants.get('night'), 'Yaru-dark');
}); });
test('Yaru-light', t => { test('Yaru-light', t => {
const variants = Variants.guess_from('Yaru-light'); const variants = Variants.guessFrom('Yaru-light');
t.is(variants.get('day'), 'Yaru-light'); t.is(variants.get('day'), 'Yaru-light');
t.is(variants.get('night'), 'Yaru-dark'); t.is(variants.get('night'), 'Yaru-dark');
}); });
+15 -15
View File
@@ -20,31 +20,31 @@ const test = require('ava');
const { Variants } = require('./_variants'); const { Variants } = require('./_variants');
test('base', t => { test('base', t => {
const variants = Variants.guess_from('base'); const variants = Variants.guessFrom('base');
t.is(variants.get('day'), 'base'); t.is(variants.get('day'), 'base');
t.is(variants.get('night'), 'base-dark'); t.is(variants.get('night'), 'base-dark');
}); });
test('base-dark', t => { test('base-dark', t => {
const variants = Variants.guess_from('base-dark'); const variants = Variants.guessFrom('base-dark');
t.is(variants.get('day'), 'base'); t.is(variants.get('day'), 'base');
t.is(variants.get('night'), 'base-dark'); t.is(variants.get('night'), 'base-dark');
}); });
test('base-light', t => { test('base-light', t => {
const variants = Variants.guess_from('base-light'); const variants = Variants.guessFrom('base-light');
t.is(variants.get('day'), 'base-light'); t.is(variants.get('day'), 'base-light');
t.is(variants.get('night'), 'base-dark'); t.is(variants.get('night'), 'base-dark');
}); });
test('base-darker', t => { test('base-darker', t => {
const variants = Variants.guess_from('base-darker'); const variants = Variants.guessFrom('base-darker');
t.is(variants.get('day'), 'base-darker'); t.is(variants.get('day'), 'base-darker');
t.is(variants.get('night'), 'base-dark'); t.is(variants.get('night'), 'base-dark');
}); });
test('base-darkest', t => { test('base-darkest', t => {
const variants = Variants.guess_from('base-darkest'); const variants = Variants.guessFrom('base-darkest');
t.is(variants.get('day'), 'base'); t.is(variants.get('day'), 'base');
t.is(variants.get('night'), 'base-darkest'); t.is(variants.get('night'), 'base-darkest');
}); });
+3 -3
View File
@@ -20,7 +20,7 @@ const test = require('ava');
const { Variants } = require('./_variants'); const { Variants } = require('./_variants');
test('default', t => { test('default', t => {
const variants = Variants.guess_from(''); const variants = Variants.guessFrom('');
t.is(variants.get('day'), ''); t.is(variants.get('day'), '');
t.is(variants.get('night'), ''); t.is(variants.get('night'), '');
}); });