Skip to content

Commit

Permalink
basic support for blinking the menu via a loop timer
Browse files Browse the repository at this point in the history
  • Loading branch information
hossman committed Oct 10, 2012
1 parent f91e7ad commit f8a9153
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/

const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Main = imports.ui.main;
const MessageTray = imports.ui.messageTray;

Expand Down Expand Up @@ -116,9 +117,30 @@ function _MessageStyleHandler() {
return false;
}

this._loopStyle = function(toggle) {
// :TODO: make loopDelay a setting
let loopDelay = 1000; // ms
let userMenu = Main.panel._statusArea.userMenu;

if (!this._hasStyleAdded) {
// notifications may have been cleared since loop timer was added
return;
}
let style = toggle ?
("color: " + settings.get_string(SETTING_COLOR)) :
this._oldStyle;

userMenu._iconBox.set_style(style);

// loop it
if (0 < loopDelay) {
let that = this;
Mainloop.timeout_add(loopDelay, function() { that._loopStyle(!toggle) });
}
}

this._addMessageStyle = function() {
let userMenu = Main.panel._statusArea.userMenu;
let color = settings.get_string(SETTING_COLOR);

if (!this._hasStyleAdded) {
// Only cache oldStyle when when adding style the first time.
Expand All @@ -127,7 +149,7 @@ function _MessageStyleHandler() {
this._oldStyle = userMenu._iconBox.get_style();
}

userMenu._iconBox.set_style("color: " + color);
this._loopStyle(true);
this._hasStyleAdded = true;
}

Expand Down

0 comments on commit f8a9153

Please sign in to comment.