Skip to content

Commit 4b60271

Browse files
committed
Merge branch 'branch_v1_10' of github.com:rcaelers/workrave into branch_v1_10
2 parents 6f7ee6d + e4db430 commit 4b60271

File tree

1 file changed

+60
-61
lines changed

1 file changed

+60
-61
lines changed

frontend/applets/gnome-shell/src/extension.js

+60-61
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
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;
92
const GLib = imports.gi.GLib;
3+
const GObject = imports.gi.GObject;
4+
const Gettext = imports.gettext;
105
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;
1112
const Workrave = imports.gi.Workrave;
1213

1314
const _ = Gettext.gettext;
@@ -155,13 +156,11 @@ const CoreIface = '<node>\
155156

156157
let CoreProxy = Gio.DBusProxy.makeProxyWrapper(CoreIface);
157158

159+
const WorkraveButton = GObject.registerClass(
160+
class WorkraveButton extends PanelMenu.Button {
158161

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);
165164

166165
this._timerbox = new Workrave.Timerbox();
167166

@@ -178,11 +177,11 @@ const WorkraveButton = new Lang.Class({
178177
this._area.connect('repaint', Lang.bind(this, this._draw));
179178

180179
this._box = new St.Bin();
181-
this._box.add_actor(this._area, { y_expand: true });
180+
this._box.add_actor(this._area);
182181

183182
if (typeof this.add_actor === "function")
184183
{
185-
this.add_actor(this._box, { y_expand: true });
184+
this.add_actor(this._box);
186185
this.show();
187186
}
188187
else
@@ -202,9 +201,9 @@ const WorkraveButton = new Lang.Class({
202201
this._operation_mode_changed_id = this._core_proxy.connectSignal("OperationModeChanged", Lang.bind(this, this._onOperationModeChanged));
203202

204203
this._updateMenu(null);
205-
},
204+
}
206205

207-
_connectUI: function() {
206+
_connectUI() {
208207
try
209208
{
210209
this._watchid = Gio.DBus.session.watch_name('org.workrave.Workrave',
@@ -217,21 +216,21 @@ const WorkraveButton = new Lang.Class({
217216
{
218217
return true;
219218
}
220-
},
219+
}
221220

222-
_connectCore: function() {
223-
},
221+
_connectCore() {
222+
}
224223

225-
_onDestroy: function() {
224+
_onDestroy() {
226225
if (this._ui_proxy != null)
227226
{
228227
this._ui_proxy.EmbedRemote(false, this._bus_name);
229228
}
230229
this._stop();
231230
this._destroy();
232-
},
231+
}
233232

234-
_destroy: function() {
233+
_destroy() {
235234
if (this._watchid > 0)
236235
{
237236
Gio.DBus.session.unwatch_name(this._watchid);
@@ -249,9 +248,9 @@ const WorkraveButton = new Lang.Class({
249248
this._core_proxy.disconnectSignal(this._operation_mode_changed_id);
250249
this._core_proxy = null;
251250
}
252-
},
251+
}
253252

254-
_start: function() {
253+
_start() {
255254
if (! this._alive)
256255
{
257256
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({
263262
this._alive = true;
264263
this._update_count = 0;
265264
}
266-
},
265+
}
267266

268-
_stop_dbus: function() {
267+
_stop_dbus() {
269268
if (this._alive)
270269
{
271270
Mainloop.source_remove(this._timeoutId);
272271
Gio.DBus.session.unown_name(this._bus_id);
273272
this._timeoutId = 0;
274273
this._bus_id = 0;
275274
}
276-
},
275+
}
277276

278-
_stop: function() {
277+
_stop() {
279278
if (this._alive)
280279
{
281280
this._stop_dbus();
@@ -286,14 +285,14 @@ const WorkraveButton = new Lang.Class({
286285
this._area.queue_repaint();
287286
this._area.set_width(this._width=24);
288287
}
289-
},
288+
}
290289

291-
_draw: function(area) {
290+
_draw(area) {
292291
let cr = area.get_context();
293292
this._timerbox.draw(cr);
294-
},
293+
}
295294

296-
_onTimer: function() {
295+
_onTimer() {
297296
if (! this._alive)
298297
{
299298
return false;
@@ -307,17 +306,17 @@ const WorkraveButton = new Lang.Class({
307306
this._update_count = 0;
308307

309308
return this._alive;
310-
},
309+
}
311310

312-
_onWorkraveAppeared: function(owner) {
311+
_onWorkraveAppeared(owner) {
313312
this._start();
314-
},
313+
}
315314

316-
_onWorkraveVanished: function(oldOwner) {
315+
_onWorkraveVanished(oldOwner) {
317316
this._stop();
318-
},
317+
}
319318

320-
_onTimersUpdated : function(emitter, senderName, [microbreak, restbreak, daily]) {
319+
_onTimersUpdated (emitter, senderName, [microbreak, restbreak, daily]) {
321320

322321
if (! this._alive)
323322
{
@@ -362,49 +361,49 @@ const WorkraveButton = new Lang.Class({
362361

363362
this._area.set_width(this._width=timerbox_width);
364363
this._area.queue_repaint();
365-
},
364+
}
366365

367-
_onGetMenuReply : function([menuitems], excp) {
366+
_onGetMenuReply ([menuitems], excp) {
368367
this._updateMenu(menuitems);
369-
},
368+
}
370369

371-
_onGetTrayIconEnabledReply : function([enabled], excp) {
370+
_onGetTrayIconEnabledReply ([enabled], excp) {
372371
this._updateTrayIcon(enabled);
373-
},
372+
}
374373

375-
_onGetOperationModeReply : function([mode], excp) {
374+
_onGetOperationModeReply ([mode], excp) {
376375
this._timerbox.set_operation_mode(mode);
377-
},
376+
}
378377

379-
_onMenuUpdated : function(emitter, senderName, [menuitems]) {
378+
_onMenuUpdated (emitter, senderName, [menuitems]) {
380379
this._updateMenu(menuitems);
381-
},
380+
}
382381

383-
_onTrayIconUpdated : function(emitter, senderName, [enabled]) {
382+
_onTrayIconUpdated (emitter, senderName, [enabled]) {
384383
this._updateTrayIcon(enabled);
385-
},
384+
}
386385

387-
_onOperationModeChanged : function(emitter, senderName, [mode]) {
386+
_onOperationModeChanged (emitter, senderName, [mode]) {
388387
this._timerbox.set_operation_mode(mode);
389-
},
388+
}
390389

391-
_onCommandReply : function(menuitems) {
392-
},
390+
_onCommandReply (menuitems) {
391+
}
393392

394-
_onMenuCommand : function(item, event, command) {
393+
_onMenuCommand (item, event, command) {
395394
this._ui_proxy.CommandRemote(command, Lang.bind(this, this._onCommandReply));
396-
},
395+
}
397396

398-
_onMenuOpenCommand: function(item, event) {
397+
_onMenuOpenCommand(item, event) {
399398
this._ui_proxy.GetMenuRemote(); // A dummy method call to re-activate the service
400-
},
399+
}
401400

402-
_updateTrayIcon : function(enabled) {
401+
_updateTrayIcon (enabled) {
403402
this._force_icon = enabled;
404403
this._timerbox.set_force_icon(this._force_icon);
405-
},
404+
}
406405

407-
_updateMenu : function(menuitems) {
406+
_updateMenu (menuitems) {
408407
this.menu.removeAll();
409408

410409
let current_menu = this.menu;

0 commit comments

Comments
 (0)