MozillaZine

[Ext] PrefBar - The all in one button container

Announce and Discuss the Latest Theme and Extension Releases.
dickvl

User avatar
 
Posts: 52279
Joined: July 18th, 2005, 3:25 am

Post Posted April 8th, 2015, 5:59 pm

I created a new Checkbox button and exported the button code to a file (document_colors.but).

You can save the above posted code to a .btn file and import this file in PrefBar.

emf10679
 
Posts: 20
Joined: April 15th, 2009, 8:07 pm

Post Posted April 9th, 2015, 1:43 am

I didn't know about importing and exporting. There is always something new to learn. Anyway, I had already created a similar button. Now what I want is to combine this and the systemcolors in one.

emf10679
 
Posts: 20
Joined: April 15th, 2009, 8:07 pm

Post Posted April 9th, 2015, 11:30 pm

OK. I found in a backup the old button and exported it. This is it:

{
"prefbar:info": {
"formatversion": 3
},
"prefbar:menu:enabled": {
"items": [
"prefbar:button:togglecolors"
]
},
"prefbar:button:togglecolors": {
"type": "extcheck",
"label": "colors ",
"getfunction": "value = goPrefBar.GetPref(\"browser.display.use_document_colors\");",
"browserbtnupdatefor": "false",
"setfunction": "goPrefBar.SetPref(\"browser.display.use_system_colors\", !value);\ngoPrefBar.SetPref(\"browser.display.use_document_colors\", value);"
}
}

How can I modify the first "getfunction" to apply to the new key? The issue is the line:
"browserbtnupdatefor": "false",

lcwells8892
 
Posts: 5
Joined: April 11th, 2015, 12:06 pm

Post Posted April 11th, 2015, 12:36 pm

To update the Color check box to use the new browser.display.use_document_colors integer behavior, I built a new Menulist rom the Prefbar Customize window. When I exported the button, it looks like this:

{
"prefbar:info": {
"formatversion": 3
},
"prefbar:menu:enabled": {
"items": [
"prefbar:button:color3"
]
},
"prefbar:button:color3": {
"type": "menulist",
"label": "Color3",
"prefstring": "browser.display.document_color_use",
"items": [
[
"Always",
"2"
],
[
"Only with HCT",
"0"
],
[
"Never",
"1"
]
]
}
}

Always means Always override the document colors and use my color preferences. Never should be obvious. The Only with HCT is Only override the document colors for pages with high contrast themes. I have vision issues that are improved with a lower contrast theme. I hope this will help others if they want to cut and paste the above into a file. Make sure to add quotes ("filename.btn") to save it with the btn extension. Then select Customize and Import.

lcwells8892
 
Posts: 5
Joined: April 11th, 2015, 12:06 pm

Post Posted April 11th, 2015, 5:10 pm

After trying my initial solution for a bit, I've modified my PrefBar menulist for browser.display.use_document_colors a bit. I replaced "Always" with "My colors" and "Never" with "Doc. colors". I am considering deleting the HCT line since it's redundant for me. (On all of the sites I look at, the behavior of "Never" and "Only with HCT" are the same.)

emf10679
 
Posts: 20
Joined: April 15th, 2009, 8:07 pm

Post Posted April 11th, 2015, 6:11 pm

HCT for you is similar to your system colors -- and I can not imagine a case in which it wouldn't be, I cannot understand the reasoning of those who introduced this option.

Anyway, personally I prefer a checkbox since it takes less real estate and it takes only 1 click.

And I would like to combine changing document colors with changing system colors since:

1) For System Colors to have effect, the Document Colors should be off

2) When Document colors is on, if foreground color is not specified in the webpage, FF looks first to System colors if it is on, and if not to the FF colors. Since some webpages specify only background (white), and my System foreground is also white, in these cases I want it to look at the FF colors, where the foreground is specified as black, so in these cases the System Colors should be off.

So I need to change both, and preferably with 1 click instead of with 2, as I now do, by clicking the 2 checkboxes (that also take more space).

lcwells8892
 
Posts: 5
Joined: April 11th, 2015, 12:06 pm

Post Posted April 11th, 2015, 7:30 pm

emf10679 wrote:HCT for you is similar to your system colors -- and I can not imagine a case in which it wouldn't be, I cannot understand the reasoning of those who introduced this option.

Anyway, personally I prefer a checkbox since it takes less real estate and it takes only 1 click.

And I would like to combine changing document colors with changing system colors since:

1) For System Colors to have effect, the Document Colors should be off

2) When Document colors is on, if foreground color is not specified in the webpage, FF looks first to System colors if it is on, and if not to the FF colors. Since some webpages specify only background (white), and my System foreground is also white, in these cases I want it to look at the FF colors, where the foreground is specified as black, so in these cases the System Colors should be off.

So I need to change both, and preferably with 1 click instead of with 2, as I now do, by clicking the 2 checkboxes (that also take more space).
For the single checkbox option, you might try a new button or extcheck box and an "on-click" javascript function inside that. Then get the values of document.display.document_color_use, document.display.use_document_colors and document.display.use_system_color together and change them all at once. However, I have no idea how long it would take to build the appropriate script. Today was the first time I've tried making my own item for PrefBar. I may play around with it tomorrow.

For the white on white, I just hit <Ctrl>+A and get readable text. For space, I've stacked some of my prefBar buttons by adding a Submenu and dropping several into that folder. That still has the two click problem for you.

dickvl

User avatar
 
Posts: 52279
Joined: July 18th, 2005, 3:25 am

Post Posted April 11th, 2015, 7:59 pm

Something like this should work:

Set-function:
value = (goPrefBar.GetPref("browser.display.use_document_colors") != 1) ? 1 : 2; // Override: 1:never; 2:always
goPrefBar.SetPref("browser.display.use_document_colors", value);
goPrefBar.SetPref("browser.display.use_system_colors", (value == 2));

Get-function:
value = (goPrefBar.GetPref("browser.display.use_document_colors") == 1);
Last edited by dickvl on May 2nd, 2015, 6:44 pm, edited 1 time in total.

emf10679
 
Posts: 20
Joined: April 15th, 2009, 8:07 pm

Post Posted April 11th, 2015, 9:54 pm

> goPrefBar.SetPref("browser.display.use_system_colors", (value == 2));

Is this correct? Isn't it boolean?

dickvl

User avatar
 
Posts: 52279
Joined: July 18th, 2005, 3:25 am

Post Posted April 12th, 2015, 10:57 am

The (value == 2) expression is evaluated as a Boolean: true if value is 2 (always) and false otherwise.
You can keep the about:config page open in a tab to see the prefs change when you click the button.

lcwells8892
 
Posts: 5
Joined: April 11th, 2015, 12:06 pm

Post Posted April 12th, 2015, 11:50 am

I found that I needed these two lines in the Set function for the extcheck button. Otherwise it didn't work properly due to the new Firefox 37 settings. I found that rest of dickvl's code works nicely.

value1 = (goPrefBar.GetPref("browser.display.document_color_use") != 1) ? 1 : 2; // 1:never use my colors; 2:always use my colors
goPrefBar.SetPref("browser.display.document_color_use", value1);


Thank you. It's much better than my menulist solution.

emf10679
 
Posts: 20
Joined: April 15th, 2009, 8:07 pm

Post Posted April 12th, 2015, 8:26 pm

I've added in the Set-function a line to change the system colors simultaneously:

value1 = (goPrefBar.GetPref("browser.display.document_color_use") != 1) ? 1 : 2;
goPrefBar.SetPref("browser.display.document_color_use", value1);
goPrefBar.SetPref("browser.display.use_system_colors", value);

while in the Get-function I have:

value = goPrefBar.GetPref("browser.display.document_color_use");

Now when it's checked it uses the document colors and secondarily the FF colors (so I won't encounter the issue of white text on white background). When it's unchecked, it uses the system colors. I've also added a hot key. Though I am not sure I understand how the Get-function value is used, it seems to be working OK.

emf10679
 
Posts: 20
Joined: April 15th, 2009, 8:07 pm

Post Posted April 12th, 2015, 9:49 pm

Oops! Something happened and at one point I started getting FF colors instead of system colors. I make some changes and it works again, but I am not so confident, and if someone understands what is going on, please post the correct functions.

lcwells8892
 
Posts: 5
Joined: April 11th, 2015, 12:06 pm

Post Posted April 13th, 2015, 10:19 am

emf10679 wrote:Oops! Something happened and at one point I started getting FF colors instead of system colors. I make some changes and it works again, but I am not so confident, and if someone understands what is going on, please post the correct functions.
For the system colors, you don't get the current value in the Set Function. The value in the Get Function isn't global. I matched the function of the original color checkbox; when the box is checked, I see the document colors. My solution:
Get Function:
value = (goPrefBar.GetPref("browser.display.document_color_use") != 2);
Set function:
value1 = (goPrefBar.GetPref("browser.display.document_color_use") != 2) ? 2 : 1;
// 1:never use my colors; 2:always use my colors
goPrefBar.SetPref("browser.display.document_color_use", value1);
value2 = (goPrefBar.GetPref("browser.display.use_system_colors") != true) ? true : false;
// true: system colors; false: document colors (I chose to keep the Boolean. I saw about:config change to an integer and the browser seemed to get confused.)
goPrefBar.SetPref("browser.display.use_system_colors", value2);

Since I only change the background colors in Firefox and not globally, I've actually commented out the system color lines and instead have:

value = (goPrefBar.GetPref("browser.display.use_document_colors") != false) ? false : true; // true: document colors; false: my colors
goPrefBar.SetPref("browser.display.use_document_colors", value);

and get my desired behavior.

emf10679
 
Posts: 20
Joined: April 15th, 2009, 8:07 pm

Post Posted April 14th, 2015, 4:32 am

Thanks. Sometimes I panic when something in a code does not work and make things worse. Waiting a while to think it over with a clear mind helps.

Return to Extension/Theme Releases


Who is online

Users browsing this forum: No registered users and 2 guests