1
1
const Clutter = imports . gi . Clutter ;
2
- const St = imports . gi . St ;
3
- const Mainloop = imports . mainloop ;
4
- const Main = imports . ui . main ;
5
- const Lang = imports . lang ;
6
- const PopupMenu = imports . ui . popupMenu ;
7
- const PanelMenu = imports . ui . panelMenu ;
8
- const Gettext = imports . gettext ;
9
2
const GLib = imports . gi . GLib ;
3
+ const GObject = imports . gi . GObject ;
4
+ const Gettext = imports . gettext ;
10
5
const Gio = imports . gi . Gio ;
6
+ const Lang = imports . lang ;
7
+ const Main = imports . ui . main ;
8
+ const Mainloop = imports . mainloop ;
9
+ const PanelMenu = imports . ui . panelMenu ;
10
+ const PopupMenu = imports . ui . popupMenu ;
11
+ const St = imports . gi . St ;
11
12
const Workrave = imports . gi . Workrave ;
12
13
13
14
const _ = Gettext . gettext ;
@@ -155,13 +156,11 @@ const CoreIface = '<node>\
155
156
156
157
let CoreProxy = Gio . DBusProxy . makeProxyWrapper ( CoreIface ) ;
157
158
159
+ const WorkraveButton = GObject . registerClass (
160
+ class WorkraveButton extends PanelMenu . Button {
158
161
159
- const WorkraveButton = new Lang . Class ( {
160
- Name : 'WorkraveButton' ,
161
- Extends : PanelMenu . Button ,
162
-
163
- _init : function ( ) {
164
- PanelMenu . Button . prototype . _init . call ( this , 0.0 ) ;
162
+ _init ( ) {
163
+ super . _init ( 0.0 ) ;
165
164
166
165
this . _timerbox = new Workrave . Timerbox ( ) ;
167
166
@@ -178,11 +177,11 @@ const WorkraveButton = new Lang.Class({
178
177
this . _area . connect ( 'repaint' , Lang . bind ( this , this . _draw ) ) ;
179
178
180
179
this . _box = new St . Bin ( ) ;
181
- this . _box . add_actor ( this . _area , { y_expand : true } ) ;
180
+ this . _box . add_actor ( this . _area ) ;
182
181
183
182
if ( typeof this . add_actor === "function" )
184
183
{
185
- this . add_actor ( this . _box , { y_expand : true } ) ;
184
+ this . add_actor ( this . _box ) ;
186
185
this . show ( ) ;
187
186
}
188
187
else
@@ -202,9 +201,9 @@ const WorkraveButton = new Lang.Class({
202
201
this . _operation_mode_changed_id = this . _core_proxy . connectSignal ( "OperationModeChanged" , Lang . bind ( this , this . _onOperationModeChanged ) ) ;
203
202
204
203
this . _updateMenu ( null ) ;
205
- } ,
204
+ }
206
205
207
- _connectUI : function ( ) {
206
+ _connectUI ( ) {
208
207
try
209
208
{
210
209
this . _watchid = Gio . DBus . session . watch_name ( 'org.workrave.Workrave' ,
@@ -217,21 +216,21 @@ const WorkraveButton = new Lang.Class({
217
216
{
218
217
return true ;
219
218
}
220
- } ,
219
+ }
221
220
222
- _connectCore : function ( ) {
223
- } ,
221
+ _connectCore ( ) {
222
+ }
224
223
225
- _onDestroy : function ( ) {
224
+ _onDestroy ( ) {
226
225
if ( this . _ui_proxy != null )
227
226
{
228
227
this . _ui_proxy . EmbedRemote ( false , this . _bus_name ) ;
229
228
}
230
229
this . _stop ( ) ;
231
230
this . _destroy ( ) ;
232
- } ,
231
+ }
233
232
234
- _destroy : function ( ) {
233
+ _destroy ( ) {
235
234
if ( this . _watchid > 0 )
236
235
{
237
236
Gio . DBus . session . unwatch_name ( this . _watchid ) ;
@@ -249,9 +248,9 @@ const WorkraveButton = new Lang.Class({
249
248
this . _core_proxy . disconnectSignal ( this . _operation_mode_changed_id ) ;
250
249
this . _core_proxy = null ;
251
250
}
252
- } ,
251
+ }
253
252
254
- _start : function ( ) {
253
+ _start ( ) {
255
254
if ( ! this . _alive )
256
255
{
257
256
this . _bus_id = Gio . DBus . session . own_name ( this . _bus_name , Gio . BusNameOwnerFlags . NONE , null , null ) ;
@@ -263,19 +262,19 @@ const WorkraveButton = new Lang.Class({
263
262
this . _alive = true ;
264
263
this . _update_count = 0 ;
265
264
}
266
- } ,
265
+ }
267
266
268
- _stop_dbus : function ( ) {
267
+ _stop_dbus ( ) {
269
268
if ( this . _alive )
270
269
{
271
270
Mainloop . source_remove ( this . _timeoutId ) ;
272
271
Gio . DBus . session . unown_name ( this . _bus_id ) ;
273
272
this . _timeoutId = 0 ;
274
273
this . _bus_id = 0 ;
275
274
}
276
- } ,
275
+ }
277
276
278
- _stop : function ( ) {
277
+ _stop ( ) {
279
278
if ( this . _alive )
280
279
{
281
280
this . _stop_dbus ( ) ;
@@ -286,14 +285,14 @@ const WorkraveButton = new Lang.Class({
286
285
this . _area . queue_repaint ( ) ;
287
286
this . _area . set_width ( this . _width = 24 ) ;
288
287
}
289
- } ,
288
+ }
290
289
291
- _draw : function ( area ) {
290
+ _draw ( area ) {
292
291
let cr = area . get_context ( ) ;
293
292
this . _timerbox . draw ( cr ) ;
294
- } ,
293
+ }
295
294
296
- _onTimer : function ( ) {
295
+ _onTimer ( ) {
297
296
if ( ! this . _alive )
298
297
{
299
298
return false ;
@@ -307,17 +306,17 @@ const WorkraveButton = new Lang.Class({
307
306
this . _update_count = 0 ;
308
307
309
308
return this . _alive ;
310
- } ,
309
+ }
311
310
312
- _onWorkraveAppeared : function ( owner ) {
311
+ _onWorkraveAppeared ( owner ) {
313
312
this . _start ( ) ;
314
- } ,
313
+ }
315
314
316
- _onWorkraveVanished : function ( oldOwner ) {
315
+ _onWorkraveVanished ( oldOwner ) {
317
316
this . _stop ( ) ;
318
- } ,
317
+ }
319
318
320
- _onTimersUpdated : function ( emitter , senderName , [ microbreak , restbreak , daily ] ) {
319
+ _onTimersUpdated ( emitter , senderName , [ microbreak , restbreak , daily ] ) {
321
320
322
321
if ( ! this . _alive )
323
322
{
@@ -362,49 +361,49 @@ const WorkraveButton = new Lang.Class({
362
361
363
362
this . _area . set_width ( this . _width = timerbox_width ) ;
364
363
this . _area . queue_repaint ( ) ;
365
- } ,
364
+ }
366
365
367
- _onGetMenuReply : function ( [ menuitems ] , excp ) {
366
+ _onGetMenuReply ( [ menuitems ] , excp ) {
368
367
this . _updateMenu ( menuitems ) ;
369
- } ,
368
+ }
370
369
371
- _onGetTrayIconEnabledReply : function ( [ enabled ] , excp ) {
370
+ _onGetTrayIconEnabledReply ( [ enabled ] , excp ) {
372
371
this . _updateTrayIcon ( enabled ) ;
373
- } ,
372
+ }
374
373
375
- _onGetOperationModeReply : function ( [ mode ] , excp ) {
374
+ _onGetOperationModeReply ( [ mode ] , excp ) {
376
375
this . _timerbox . set_operation_mode ( mode ) ;
377
- } ,
376
+ }
378
377
379
- _onMenuUpdated : function ( emitter , senderName , [ menuitems ] ) {
378
+ _onMenuUpdated ( emitter , senderName , [ menuitems ] ) {
380
379
this . _updateMenu ( menuitems ) ;
381
- } ,
380
+ }
382
381
383
- _onTrayIconUpdated : function ( emitter , senderName , [ enabled ] ) {
382
+ _onTrayIconUpdated ( emitter , senderName , [ enabled ] ) {
384
383
this . _updateTrayIcon ( enabled ) ;
385
- } ,
384
+ }
386
385
387
- _onOperationModeChanged : function ( emitter , senderName , [ mode ] ) {
386
+ _onOperationModeChanged ( emitter , senderName , [ mode ] ) {
388
387
this . _timerbox . set_operation_mode ( mode ) ;
389
- } ,
388
+ }
390
389
391
- _onCommandReply : function ( menuitems ) {
392
- } ,
390
+ _onCommandReply ( menuitems ) {
391
+ }
393
392
394
- _onMenuCommand : function ( item , event , command ) {
393
+ _onMenuCommand ( item , event , command ) {
395
394
this . _ui_proxy . CommandRemote ( command , Lang . bind ( this , this . _onCommandReply ) ) ;
396
- } ,
395
+ }
397
396
398
- _onMenuOpenCommand : function ( item , event ) {
397
+ _onMenuOpenCommand ( item , event ) {
399
398
this . _ui_proxy . GetMenuRemote ( ) ; // A dummy method call to re-activate the service
400
- } ,
399
+ }
401
400
402
- _updateTrayIcon : function ( enabled ) {
401
+ _updateTrayIcon ( enabled ) {
403
402
this . _force_icon = enabled ;
404
403
this . _timerbox . set_force_icon ( this . _force_icon ) ;
405
- } ,
404
+ }
406
405
407
- _updateMenu : function ( menuitems ) {
406
+ _updateMenu ( menuitems ) {
408
407
this . menu . removeAll ( ) ;
409
408
410
409
let current_menu = this . menu ;
0 commit comments