Add code documentation
This commit is contained in:
@@ -26,6 +26,11 @@ const Gettext = imports.gettext.domain(config.EXT_UUID);
|
|||||||
const _ = Gettext.gettext;
|
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 {
|
var Nightlighter = class {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -33,7 +38,7 @@ var Nightlighter = class {
|
|||||||
this._connect_to_dbus();
|
this._connect_to_dbus();
|
||||||
}
|
}
|
||||||
catch(e) {
|
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();
|
return this.proxy.get_cached_property('NightLightActive').get_boolean();
|
||||||
}
|
}
|
||||||
catch(e) {
|
catch(e) {
|
||||||
return false;
|
return false; // If Night Light is disabled, we consider it is inactive.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+15
-1
@@ -27,6 +27,20 @@ const { Themer } = Me.imports.modules.Themer;
|
|||||||
const { Variants } = Me.imports.modules.Variants;
|
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 {
|
var Switcher = class {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -55,7 +69,7 @@ var Switcher = class {
|
|||||||
this.theme.stop_listening();
|
this.theme.stop_listening();
|
||||||
this.nightlight.stop_listening();
|
this.nightlight.stop_listening();
|
||||||
}
|
}
|
||||||
catch(e) {}
|
catch(e) {} // Since we're disabling, we'll just ignore errors.
|
||||||
finally {
|
finally {
|
||||||
this.theme = null;
|
this.theme = null;
|
||||||
this.variants = null;
|
this.variants = null;
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ const Me = extensionUtils.getCurrentExtension();
|
|||||||
const config = Me.imports.config;
|
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 {
|
var Themer = class {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|||||||
@@ -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/>.
|
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 {
|
var Variants = class {
|
||||||
|
|
||||||
static guess_from(name) {
|
static guess_from(name) {
|
||||||
|
|||||||
Reference in New Issue
Block a user