diff --git a/src/modules/Nightlighter.js b/src/modules/Nightlighter.js index 20d0816..63f1c6a 100644 --- a/src/modules/Nightlighter.js +++ b/src/modules/Nightlighter.js @@ -26,6 +26,11 @@ const Gettext = imports.gettext.domain(config.EXT_UUID); const _ = Gettext.gettext; +/* +The Nightlighter establishes a connection with the session bus to get the +current Night Light status. It can also be asked to listen to status changes. +*/ + var Nightlighter = class { constructor() { @@ -33,7 +38,7 @@ var Nightlighter = class { this._connect_to_dbus(); } catch(e) { - throw e; + throw e; // Let's pass the error up. } } @@ -42,7 +47,7 @@ var Nightlighter = class { return this.proxy.get_cached_property('NightLightActive').get_boolean(); } catch(e) { - return false; + return false; // If Night Light is disabled, we consider it is inactive. } } diff --git a/src/modules/Switcher.js b/src/modules/Switcher.js index 6482b6b..2afd04b 100644 --- a/src/modules/Switcher.js +++ b/src/modules/Switcher.js @@ -27,6 +27,20 @@ const { Themer } = Me.imports.modules.Themer; const { Variants } = Me.imports.modules.Variants; +/* +The Switcher is the brain of the extension. + +When the extension is enabled, it listens to theme changes from the user and +changes in the Night Light status: + - On theme changes, it asks for the new day and night variants for that + theme. + - On Night Light activation or deactivation, it asks for the relevant + variant to be applied. + +When the extension is disabled, it resets the theme to the last one the user +explicitely selected, stops listening to changes and cleans itself. +*/ + var Switcher = class { constructor() { @@ -55,7 +69,7 @@ var Switcher = class { this.theme.stop_listening(); this.nightlight.stop_listening(); } - catch(e) {} + catch(e) {} // Since we're disabling, we'll just ignore errors. finally { this.theme = null; this.variants = null; diff --git a/src/modules/Themer.js b/src/modules/Themer.js index ac99db6..0c5c122 100644 --- a/src/modules/Themer.js +++ b/src/modules/Themer.js @@ -23,6 +23,11 @@ const Me = extensionUtils.getCurrentExtension(); const config = Me.imports.config; +/* +The Theme communicates with the system to get the current theme or set a new +one. It can also be asked to listen to theme changes. +*/ + var Themer = class { constructor() { diff --git a/src/modules/Variants.js b/src/modules/Variants.js index 830e7d7..5ac6eb9 100644 --- a/src/modules/Variants.js +++ b/src/modules/Variants.js @@ -17,6 +17,31 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ + +/* +The magic of guessing theme variants happens here. + +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 + variant + - Remove any signs of a light variant to the day variant and add '-dark' to + get the night variant + +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 +and dark variants the theme offer, except if the user explicitly chose a +specific variant. + +Light variants, from the most to the least generic: + - '' + - '-light' + - '-darker' + +Dark variants, from the most the least generic: + - '-dark' + - '-darkest' +*/ + var Variants = class { static guess_from(name) {