Skip to content

Commit 91231b2

Browse files
committed
Icon goes gray if HTTPS Everywhere is disabled
1 parent b47d5eb commit 91231b2

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

src/chrome/content/toolbar_button.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ httpsEverywhere.toolbarButton = {
3434
init: function() {
3535
var tb = httpsEverywhere.toolbarButton;
3636

37+
// make sure icon is proper color during init
38+
tb.changeIcon();
39+
3740
// decide whether to show toolbar hint
3841
let hintPref = "extensions.https_everywhere.toolbar_hint_shown";
3942
if(!Services.prefs.getPrefType(hintPref)
@@ -73,6 +76,22 @@ httpsEverywhere.toolbarButton = {
7376

7477
// remove listener
7578
gBrowser.removeEventListener('load', tb.showToolbarHint, true);
79+
},
80+
81+
/**
82+
* Changes HTTPS Everywhere toolbar icon based on whether HTTPS Everywhere
83+
* is enabled or disabled.
84+
*/
85+
changeIcon: function() {
86+
var prefs = HTTPSEverywhere.get_prefs();
87+
var enabled = prefs.getBoolPref("globalEnabled");
88+
89+
var toolbarbutton = document.getElementById('https-everywhere-button');
90+
if (enabled) {
91+
toolbarbutton.setAttribute('status', 'enabled');
92+
} else {
93+
toolbarbutton.setAttribute('status', 'disabled');
94+
}
7695
}
7796

7897
};
@@ -171,6 +190,9 @@ function reload_window() {
171190
function toggleEnabledState(){
172191
HTTPSEverywhere.toggleEnabledState();
173192
reload_window();
193+
194+
// Change icon depending on enable state
195+
httpsEverywhere.toolbarButton.changeIcon();
174196
}
175197

176198
function open_in_tab(url) {
477 Bytes
Loading
784 Bytes
Loading

src/chrome/skin/https-everywhere.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ toolbar[iconsize="small"] #https-everywhere-button {
88
-moz-box-orient: horizontal;
99
}
1010

11+
/* Use CSS attribute selector for changing icon */
12+
#https-everywhere-button[status="disabled"] {
13+
list-style-image: url("chrome://https-everywhere/skin/https-everywhere-24-gray.png");
14+
}
15+
16+
toolbar[iconsize="small"] #https-everywhere-button[status="disabled"] {
17+
list-style-image: url("chrome://https-everywhere/skin/https-everywhere-16-gray.png");
18+
}
19+
1120
#https-everywhere-button menuitem.active-item label {
1221
color: #9AD100;
1322
font-weight: bold;

0 commit comments

Comments
 (0)