Skip to content
Browse files

refactor code, fix unwanted behaviour on several restarts, don't rese…

…t timeSpent on change of presets
  • Loading branch information...
1 parent 59d5f8f commit ad7a7a806438fd185e9776c9bba273fc9cef61a2 @olebowle committed Aug 23, 2011
Showing with 12 additions and 11 deletions.
  1. +12 −11 timer@olebowle.gmx.com/extension.js
View
23 timer@olebowle.gmx.com/extension.js
@@ -100,11 +100,8 @@ Indicator.prototype = {
//Restart Timer Menu
item = new PopupMenu.PopupMenuItem(_("Restart Timer"));
item.connect('activate', Lang.bind(this, function() {
- this._widget.setToggleState(true);
- this.actor.set_child(this._box);
this._timeSpent = 0;
- this._stopTimer = false;
- this._refreshTimer();
+ this._restartTimer();
}));
this.menu.addMenuItem(item);
@@ -151,13 +148,7 @@ Indicator.prototype = {
item.addActor(label);
item.connect('activate', Lang.bind(this, function() {
this._time = this._presets[key];
- this._timeSpent = 0;
- if(this._stopTimer) {
- this._widget.setToggleState(true);
- this.actor.set_child(this._box);
- this._stopTimer = false;
- this._refreshTimer();
- }
+ this._restartTimer();
}));
this._presetsMenu.menu.addMenuItem(item);
}
@@ -275,6 +266,16 @@ Indicator.prototype = {
},
//Reset all counters and timers
+ _restartTimer: function() {
+ if(this._stopTimer) {
+ this._widget.setToggleState(true);
+ this.actor.set_child(this._box);
+ this._stopTimer = false;
+ this._refreshTimer();
+ }
+ },
+
+ //Reset all counters and timers
_resetTimer: function() {
this._widget.setToggleState(false);
this.actor.set_child(this._logo);

1 comment on commit ad7a7a8

@kennym
kennym commented on ad7a7a8 Aug 23, 2011

Very quick! Thanks, sir

Please sign in to comment.
Something went wrong with that request. Please try again.