Add code documentation

This commit is contained in:
Romain Vigier
2020-02-23 20:05:21 +01:00
parent ff9d04cdb2
commit 1818e50382
4 changed files with 52 additions and 3 deletions
+7 -2
View File
@@ -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.
}
}
+15 -1
View File
@@ -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;
+5
View File
@@ -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() {
+25
View File
@@ -17,6 +17,31 @@ 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/>.
*/
/*
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) {