@@ -13,135 +13,139 @@ const COLORIZE_EFFECT_NAME = "bedtime-mode-colorize-effect";
13
13
const DESATURATE_EFFECT_NAME = "bedtime-mode-desaturate-effect" ;
14
14
15
15
export class Colorizer extends ModuleBase {
16
+ #transitions;
17
+ #transitionDelay;
18
+
19
+ #transitionStep;
20
+ #transitionLoopSource;
21
+
22
+ #colorTone;
23
+ #colorizeEffect;
24
+ #desaturateEffect;
25
+
16
26
constructor ( extension ) {
17
27
super ( extension ) ;
18
28
19
- this . _transitions = this . extension . settings . colorToneFactor ;
20
- this . _transitionDelayMillis = 25 ;
29
+ this . #transitions = this . extension . settings . colorToneFactor ;
30
+ this . #transitionDelay = 25 ;
21
31
22
- this . _transitionStep = 0 ;
23
- this . _transitionLoopSource = null ;
32
+ this . #transitionStep = 0 ;
24
33
25
- this . _colorTone = new ColorTone ( this . extension . settings . colorTonePreset , 0 ) ;
26
- this . _colorizeEffect = new Clutter . BrightnessContrastEffect ( ) ;
34
+ this . #colorTone = new ColorTone ( this . extension . settings . colorTonePreset , 0 ) ;
35
+ this . #colorizeEffect = new Clutter . BrightnessContrastEffect ( ) ;
27
36
28
- this . _desaturateEffect = new Clutter . DesaturateEffect ( ) ;
29
- this . _desaturateEffect . factor = 0 ;
37
+ this . #desaturateEffect = new Clutter . DesaturateEffect ( ) ;
38
+ this . #desaturateEffect . factor = 0 ;
30
39
}
31
40
32
41
enable ( ) {
33
- this . _createConnections ( ) ;
42
+ this . #createConnections ( ) ;
34
43
35
- this . extension . settings . bedtimeModeActive && this . _turnOn ( ) ;
44
+ this . extension . settings . bedtimeModeActive && this . #turnOn ( ) ;
36
45
}
37
46
38
47
disable ( ) {
39
- this . extension . settings . bedtimeModeActive ? this . _turnOff ( ) : this . _cleanUp ( ) ;
48
+ this . extension . settings . bedtimeModeActive ? this . #turnOff ( ) : this . #cleanUp ( ) ;
40
49
}
41
50
42
- _createConnections ( ) {
51
+ #createConnections ( ) {
43
52
logDebug ( "Creating connections for Colorizer..." ) ;
44
53
45
- this . extension . signalManager . connect (
46
- this ,
47
- this . extension . settings ,
48
- "bedtime-mode-active-changed" ,
49
- this . _onBedtimeModeActiveChanged . name
50
- ) ;
51
- this . extension . signalManager . connect ( this , this . extension . settings , "color-tone-preset-changed" , this . _onColorTonePresetChanged . name ) ;
52
- this . extension . signalManager . connect ( this , this . extension . settings , "color-tone-factor-changed" , this . _onColorToneFactorChanged . name ) ;
54
+ this . createConnection ( this . extension . settings , "bedtime-mode-active-changed" , this . onBedtimeModeActiveChanged . name ) ;
55
+ this . createConnection ( this . extension . settings , "color-tone-preset-changed" , this . onColorTonePresetChanged . name ) ;
56
+ this . createConnection ( this . extension . settings , "color-tone-factor-changed" , this . onColorToneFactorChanged . name ) ;
53
57
}
54
58
55
- _onBedtimeModeActiveChanged ( _settings , _bedtimeModeActive ) {
56
- _bedtimeModeActive ? this . _turnOn ( ) : this . _turnOff ( ) ;
59
+ onBedtimeModeActiveChanged ( _settings , _bedtimeModeActive ) {
60
+ _bedtimeModeActive ? this . #turnOn ( ) : this . #turnOff ( ) ;
57
61
}
58
62
59
- _onColorTonePresetChanged ( ) {
60
- this . _colorTone = new ColorTone ( this . extension . settings . colorTonePreset , this . extension . settings . colorToneFactor ) ;
61
- this . _updateEffectsFactor ( ) ;
63
+ onColorTonePresetChanged ( ) {
64
+ this . #colorTone = new ColorTone ( this . extension . settings . colorTonePreset , this . extension . settings . colorToneFactor ) ;
65
+ this . #updateEffectsFactor ( ) ;
62
66
}
63
67
64
- _onColorToneFactorChanged ( ) {
65
- this . _transitions = this . extension . settings . colorToneFactor ;
68
+ onColorToneFactorChanged ( ) {
69
+ this . #transitions = this . extension . settings . colorToneFactor ;
66
70
67
- if ( this . _transitionInProgress ( ) ) return ;
71
+ if ( this . #transitionInProgress ( ) ) return ;
68
72
69
- if ( this . extension . settings . bedtimeModeActive ) this . _transitionStep = this . _transitions ;
73
+ if ( this . extension . settings . bedtimeModeActive ) this . #transitionStep = this . #transitions ;
70
74
71
- this . _updateEffectsFactor ( ) ;
75
+ this . #updateEffectsFactor ( ) ;
72
76
}
73
77
74
- _turnOn ( ) {
78
+ #turnOn ( ) {
75
79
logDebug ( "Turning on Colorizer..." ) ;
76
80
77
- this . _destroyTransitionLoopSource ( ) ;
78
- this . _addColorEffects ( ) ;
81
+ this . #destroyTransitionLoopSource ( ) ;
82
+ this . #addColorEffects ( ) ;
79
83
80
- this . _transitionLoopSource = loopRun ( this . _smoothOn . bind ( this ) , this . _transitionDelayMillis ) ;
84
+ this . #transitionLoopSource = loopRun ( this . #smoothOn . bind ( this ) , this . #transitionDelay ) ;
81
85
}
82
86
83
- _turnOff ( ) {
87
+ #turnOff ( ) {
84
88
logDebug ( "Turning off Colorizer..." ) ;
85
89
86
- this . _destroyTransitionLoopSource ( ) ;
90
+ this . #destroyTransitionLoopSource ( ) ;
87
91
88
- this . _transitionLoopSource = loopRun ( this . _smoothOff . bind ( this ) , this . _transitionDelayMillis ) ;
92
+ this . #transitionLoopSource = loopRun ( this . #smoothOff . bind ( this ) , this . #transitionDelay ) ;
89
93
}
90
94
91
- _smoothOn ( ) {
92
- this . _transitionStep < this . _transitions && this . _transitionStep ++ ;
93
- this . _updateEffectsFactor ( ) ;
95
+ #smoothOn ( ) {
96
+ this . #transitionStep < this . #transitions && this . #transitionStep ++ ;
97
+ this . #updateEffectsFactor ( ) ;
94
98
95
- return this . _transitionStep < this . _transitions || this . _destroyTransitionLoopSource ( ) ;
99
+ return this . #transitionStep < this . #transitions || this . #destroyTransitionLoopSource ( ) ;
96
100
}
97
101
98
- _smoothOff ( ) {
99
- this . _transitionStep > 0 && this . _transitionStep -- ;
100
- this . _updateEffectsFactor ( ) ;
102
+ #smoothOff ( ) {
103
+ this . #transitionStep > 0 && this . #transitionStep -- ;
104
+ this . #updateEffectsFactor ( ) ;
101
105
102
- return this . _transitionStep > 0 || this . _cleanUp ( ) ;
106
+ return this . #transitionStep > 0 || this . #cleanUp ( ) ;
103
107
}
104
108
105
- _updateEffectsFactor ( ) {
106
- this . _colorTone . toneFactor = this . _transitionStep ;
107
- this . _desaturateEffect . factor = this . _transitionStep / 100 ;
109
+ #updateEffectsFactor ( ) {
110
+ this . #colorTone . toneFactor = this . #transitionStep ;
111
+ this . #desaturateEffect . factor = this . #transitionStep / 100 ;
108
112
109
- this . _updateColorizeEffect ( ) ;
113
+ this . #updateColorizeEffect ( ) ;
110
114
}
111
115
112
- _addColorEffects ( ) {
113
- UiGroup . get_effect ( COLORIZE_EFFECT_NAME ) || UiGroup . add_effect_with_name ( COLORIZE_EFFECT_NAME , this . _colorizeEffect ) ;
114
- UiGroup . get_effect ( DESATURATE_EFFECT_NAME ) || UiGroup . add_effect_with_name ( DESATURATE_EFFECT_NAME , this . _desaturateEffect ) ;
116
+ #addColorEffects ( ) {
117
+ UiGroup . get_effect ( COLORIZE_EFFECT_NAME ) || UiGroup . add_effect_with_name ( COLORIZE_EFFECT_NAME , this . #colorizeEffect ) ;
118
+ UiGroup . get_effect ( DESATURATE_EFFECT_NAME ) || UiGroup . add_effect_with_name ( DESATURATE_EFFECT_NAME , this . #desaturateEffect ) ;
115
119
116
- this . _updateColorizeEffect ( ) ;
120
+ this . #updateColorizeEffect ( ) ;
117
121
}
118
122
119
- _updateColorizeEffect ( ) {
120
- this . _colorizeEffect . brightness = this . _colorTone . brightnessColor ;
121
- this . _colorizeEffect . contrast = this . _colorTone . contrastColor ;
123
+ #updateColorizeEffect ( ) {
124
+ this . #colorizeEffect . brightness = this . #colorTone . brightnessColor ;
125
+ this . #colorizeEffect . contrast = this . #colorTone . contrastColor ;
122
126
}
123
127
124
- _removeColorEffects ( ) {
128
+ #removeColorEffects ( ) {
125
129
UiGroup . get_effect ( COLORIZE_EFFECT_NAME ) && UiGroup . remove_effect_by_name ( COLORIZE_EFFECT_NAME ) ;
126
130
UiGroup . get_effect ( DESATURATE_EFFECT_NAME ) && UiGroup . remove_effect_by_name ( DESATURATE_EFFECT_NAME ) ;
127
131
}
128
132
129
- _transitionInProgress ( ) {
130
- return this . _transitionLoopSource != null ;
133
+ #transitionInProgress ( ) {
134
+ return this . #transitionLoopSource != null ;
131
135
}
132
136
133
- _destroyTransitionLoopSource ( ) {
134
- if ( this . _transitionLoopSource ) {
135
- logDebug ( `Destroying Transition Loop Source ${ this . _transitionLoopSource . get_id ( ) } ` ) ;
137
+ #destroyTransitionLoopSource ( ) {
138
+ if ( this . #transitionLoopSource ) {
139
+ logDebug ( `Destroying Transition Loop Source ${ this . #transitionLoopSource . get_id ( ) } ` ) ;
136
140
137
- this . _transitionLoopSource . destroy ( ) ;
138
- this . _transitionLoopSource = null ;
141
+ this . #transitionLoopSource . destroy ( ) ;
142
+ this . #transitionLoopSource = null ;
139
143
}
140
144
}
141
145
142
- _cleanUp ( ) {
146
+ #cleanUp ( ) {
143
147
logDebug ( "Cleaning up Colorizer related changes..." ) ;
144
- this . _removeColorEffects ( ) ;
145
- this . _destroyTransitionLoopSource ( ) ;
148
+ this . #removeColorEffects ( ) ;
149
+ this . #destroyTransitionLoopSource ( ) ;
146
150
}
147
151
}
0 commit comments