@@ -7,51 +7,51 @@ function BarIndicatorStyle(applet, cols, rows, height) {
77}
88
99BarIndicatorStyle . prototype = {
10-
10+
1111 _init : function ( applet , cols , rows , height ) {
1212 this . applet = applet ;
1313 this . button = [ ] ;
1414 this . update_grid ( cols , rows , height ) ;
1515 this . switch_id = global . window_manager . connect ( 'switch-workspace' , Lang . bind ( this , this . update ) ) ;
1616 this . scroll_id = this . applet . actor . connect ( 'scroll-event' , Lang . bind ( this , this . onMouseScroll ) ) ;
1717 } ,
18-
18+
1919 update_grid : function ( cols , rows , height ) {
2020 this . cols = cols ;
2121 this . rows = rows ;
2222 this . height = height ;
2323 this . rebuild ( ) ;
2424 } ,
25-
25+
2626 cleanup : function ( ) {
2727 global . window_manager . disconnect ( this . switch_id ) ;
2828 this . applet . actor . disconnect ( this . scroll_id ) ;
2929 } ,
30-
30+
3131 onMouseScroll : function ( actor , event ) {
3232 if ( this . scrollby == 'row' )
3333 this . scrollByRow ( event ) ;
3434 else
3535 this . scrollByCol ( event ) ;
3636 } ,
37-
37+
3838 scrollByCol : function ( event ) {
3939 var idx = global . screen . get_active_workspace_index ( ) ;
40-
41- if ( event . get_scroll_direction ( ) == 0 ) idx -- ;
40+
41+ if ( event . get_scroll_direction ( ) == 0 ) idx -- ;
4242 else if ( event . get_scroll_direction ( ) == 1 ) idx ++ ;
43-
43+
4444 if ( global . screen . get_workspace_by_index ( idx ) != null )
4545 global . screen . get_workspace_by_index ( idx ) . activate ( global . get_current_time ( ) ) ;
4646 } ,
47-
47+
4848 scrollByRow : function ( event ) {
4949 var idx = global . screen . get_active_workspace_index ( ) ;
5050 var numworkspaces = this . rows * this . cols ;
51-
51+
5252 var row = Math . floor ( idx / this . cols ) ;
5353 var col = idx % this . cols ;
54-
54+
5555 if ( event . get_scroll_direction ( ) == 0 ) {
5656 row -- ;
5757 if ( row < 0 ) {
@@ -66,19 +66,19 @@ BarIndicatorStyle.prototype = {
6666 col ++ ;
6767 }
6868 }
69-
69+
7070 if ( col < 0 || col >= this . cols )
7171 return ;
72-
72+
7373 idx = row * this . cols + col ;
74-
74+
7575 if ( global . screen . get_workspace_by_index ( idx ) != null )
7676 global . screen . get_workspace_by_index ( idx ) . activate ( global . get_current_time ( ) ) ;
7777 } ,
7878
7979 onRowIndicatorClicked : function ( actor , event ) {
8080 if ( event . get_button ( ) != 1 ) return false ;
81-
81+
8282 let curws_idx = global . screen . get_active_workspace_index ( ) ;
8383 let curws_row = Math . floor ( curws_idx / this . cols ) ;
8484 let [ x , y ] = event . get_coords ( ) ;
@@ -89,20 +89,20 @@ BarIndicatorStyle.prototype = {
8989 let clicked_row = Math . floor ( this . rows * y / h ) ;
9090 clicked_idx = ( clicked_row * this . cols ) + ( curws_idx % this . cols ) ;
9191
92- global . screen . get_workspace_by_index ( clicked_idx ) . activate ( global . get_current_time ( ) ) ;
92+ global . screen . get_workspace_by_index ( clicked_idx ) . activate ( global . get_current_time ( ) ) ;
9393 return true ;
9494 } ,
9595
9696 onWorkspaceButtonClicked : function ( actor , event ) {
9797 if ( event . get_button ( ) != 1 ) return false ;
9898 global . screen . get_workspace_by_index ( actor . index ) . activate ( global . get_current_time ( ) ) ;
9999 } ,
100-
100+
101101 setReactivity : function ( reactive ) {
102102 for ( let i = 0 ; i < this . button . length ; ++ i )
103103 this . button [ i ] . set_reactive ( reactive ) ;
104- } ,
105-
104+ } ,
105+
106106 rebuild : function ( ) {
107107 this . applet . actor . destroy_all_children ( ) ;
108108
@@ -117,7 +117,7 @@ BarIndicatorStyle.prototype = {
117117 this . button = [ ] ;
118118 for ( let i = 0 ; i < global . screen . n_workspaces ; ++ i ) {
119119 this . button [ i ] = new St . Button ( { name : 'workspaceButton' , style_class : 'workspace-button' , reactive : true } ) ;
120-
120+
121121 let text = ( i + 1 ) . toString ( ) ;
122122 let label = new St . Label ( { text : text } ) ;
123123 label . set_style ( "font-weight: bold" ) ;
@@ -137,19 +137,19 @@ BarIndicatorStyle.prototype = {
137137 let active_row = Math . floor ( active_ws / this . cols ) ;
138138 let low = ( active_row ) * this . cols ;
139139 let high = low + this . cols ;
140-
140+
141141 // If the user added or removed workspaces external to this applet then
142142 // we could end up with a selected workspaces that is out of bounds. Just
143143 // revert to displaying the last row in that case.
144144 if ( active_ws >= nworks ) {
145145 high = nworks - 1 ;
146146 low = high - this . cols ;
147147 }
148-
148+
149149 for ( let i = 0 ; i < nworks ; ++ i ) {
150150 if ( i >= low && i < high ) this . button [ i ] . show ( ) ;
151151 else this . button [ i ] . hide ( ) ;
152-
152+
153153 if ( i == active_ws ) {
154154 this . button [ i ] . get_child ( ) . set_text ( ( i + 1 ) . toString ( ) ) ;
155155 this . button [ i ] . add_style_pseudo_class ( 'outlined' ) ;
@@ -159,21 +159,21 @@ BarIndicatorStyle.prototype = {
159159 this . button [ i ] . remove_style_pseudo_class ( 'outlined' ) ;
160160 }
161161 }
162-
162+
163163 if ( this . row_indicator ) {
164164 this . row_indicator . queue_repaint ( ) ;
165165 }
166166 } ,
167-
167+
168168 draw_row_indicator : function ( area ) {
169169 let [ width , height ] = area . get_surface_size ( ) ;
170170 let themeNode = this . row_indicator . get_theme_node ( ) ;
171171 let cr = area . get_context ( ) ;
172-
172+
173173 let base_color = this . get_base_color ( ) ;
174174 let active_color = null ;
175175 let inactive_color = null ;
176-
176+
177177 if ( this . is_theme_light_on_dark ( ) ) {
178178 active_color = base_color . lighten ( ) ;
179179 inactive_color = base_color . darken ( ) ;
@@ -182,10 +182,10 @@ BarIndicatorStyle.prototype = {
182182 active_color = base_color . darken ( ) . darken ( ) ;
183183 inactive_color = base_color . lighten ( ) . lighten ( ) ;
184184 }
185-
185+
186186 let active = global . screen . get_active_workspace_index ( ) ;
187187 let active_row = Math . floor ( active / this . cols ) ;
188-
188+
189189 // Catch overflow due to externally added/removed workspaces
190190 if ( active >= this . button . length ) active_row = ( this . button . length - 1 ) / this . cols ;
191191
@@ -200,20 +200,20 @@ BarIndicatorStyle.prototype = {
200200 cr . stroke ( ) ;
201201 }
202202 } ,
203-
203+
204204 is_theme_light_on_dark : function ( ) {
205205 let selected_idx = global . screen . get_active_workspace_index ( ) ;
206206 let unselected_idx = 0 ;
207207 if ( unselected_idx == selected_idx ) unselected_idx = 1 ;
208-
208+
209209 let selected_txt_color = this . button [ selected_idx ] . get_theme_node ( ) . get_color ( 'color' ) ;
210210 let unselected_txt_color = this . button [ unselected_idx ] . get_theme_node ( ) . get_color ( 'color' ) ;
211211
212212 let sel_avg = ( selected_txt_color . red + selected_txt_color . green + selected_txt_color . blue ) / 3 ;
213213 let unsel_avg = ( unselected_txt_color . red + unselected_txt_color . green + unselected_txt_color . blue ) / 3 ;
214214 return ( sel_avg < unsel_avg ) ;
215215 } ,
216-
216+
217217 // All colors we use in this applet are based on this theme defined color.
218218 // We simply grab the color of a normal, non-outlined workspae button.
219219 get_base_color : function ( ) {
0 commit comments