PrivacyBar toggling Proxy on/off
Posted by: Yogi
Date: March 16, 2009 08:24AM

Since we already have a privacy bar we can edit and customize, IMO it would be handy to include in default setup, alongside existent settings the option to toggle proxy on/off.

Re: PrivacyBar toggling Proxy on/off
Posted by: JamesD
Date: March 16, 2009 03:54PM

@ Yogi

I can try to look at privacy bar stuff for change or addition, but I have not yet used the privacy bar. How to you get the privacy bar. I have privacy under tools menu, but no bar.

Re: PrivacyBar toggling Proxy on/off
Posted by: Yogi
Date: March 16, 2009 04:42PM

Quote
JamesD
How to you get the privacy bar. I have privacy under tools menu, but no bar.

View\Toolbars\Privacy Bar -> has to be checked





As you can see I've already uncommented settings available in the PrivacyBar I don't have use for.

Re: PrivacyBar toggling Proxy on/off
Posted by: JamesD
Date: March 16, 2009 05:22PM

@ Yogi

Thanks, I found it. Now I have to do some research. It may be difficult as I have never used a proxy.

Re: PrivacyBar toggling Proxy on/off
Posted by: JamesD
Date: March 16, 2009 05:42PM

@ Yogi

There are not macro commands for the privacy plugin. What I have in my prefs.js file for proxy is as follows.
user_pref("kmeleon.plugins.macros.proxy0.http.proxy.keep-alive", true);
user_pref("kmeleon.plugins.macros.proxy0.http.proxy.pipelining", false);
user_pref("kmeleon.plugins.macros.proxy0.http.proxy.version", "1.1");

If you use a proxy, what shows in your prefs.js file?

Re: PrivacyBar toggling Proxy on/off
Posted by: Yogi
Date: March 16, 2009 07:53PM

My prefs.js file shows the same entries irrespective of using a proxy or using direct connection:
user_pref("kmeleon.plugins.macros.proxy.configs", "proxy1;");
user_pref("kmeleon.plugins.macros.proxy.current", "proxy1");
user_pref("kmeleon.plugins.macros.proxy0.http.proxy.keep-alive", true);
user_pref("kmeleon.plugins.macros.proxy0.http.proxy.pipelining", true);
user_pref("kmeleon.plugins.macros.proxy0.http.proxy.version", "1.1");
user_pref("kmeleon.plugins.macros.proxy1.http.proxy.pipelining", true);
user_pref("kmeleon.plugins.macros.proxy1.http.proxy.version", "1.1");
user_pref("kmeleon.plugins.macros.proxy1.name", "Proxo");
user_pref("kmeleon.plugins.macros.proxy1.proxy.ftp", "127.0.0.1");
user_pref("kmeleon.plugins.macros.proxy1.proxy.ftp_port", 80);
user_pref("kmeleon.plugins.macros.proxy1.proxy.gopher", "127.0.0.1");
user_pref("kmeleon.plugins.macros.proxy1.proxy.gopher_port", 8080);
user_pref("kmeleon.plugins.macros.proxy1.proxy.http", "127.0.0.1");
user_pref("kmeleon.plugins.macros.proxy1.proxy.http_port", 80);
user_pref("kmeleon.plugins.macros.proxy1.proxy.no_proxies_on", "localhost, 127.0.0.1");
user_pref("kmeleon.plugins.macros.proxy1.proxy.socks", "127.0.0.1");
user_pref("kmeleon.plugins.macros.proxy1.proxy.socks_port", 9050);
user_pref("kmeleon.plugins.macros.proxy1.proxy.socks_remote_dns", true);
user_pref("kmeleon.plugins.macros.proxy1.proxy.socks_version", 5);
user_pref("kmeleon.plugins.macros.proxy1.proxy.ssl", "127.0.0.1");
user_pref("kmeleon.plugins.macros.proxy1.proxy.ssl_port", 80);
user_pref("kmeleon.plugins.macros.proxy1.proxy.type", 1);
What you can see is the config of the proxy and as a matter of course it doesn't change no matter if the proxy gets used or not.
So far the only difference between your and my prefs.js I can see is the proxy setup I've made.

BTW, I'm using Proxomitron as a local filtering proxy.



Edited 1 time(s). Last edit at 03/16/2009 07:56PM by Yogi.

Re: PrivacyBar toggling Proxy on/off
Posted by: desga2
Date: March 16, 2009 08:03PM

Is possible add a Proxy toggle ON/OFF button in Privacy bar.

1) Add a button in Privacy bar, follow instructions for add buttons in your skin "toolbars.cfg" file.

2) Create a new macro file to toggle the next prefs values:
- Example for toggle proxy1:
OFF) Button OFF (NO proxy, direct conection) set to default values (delete pref)
network.http.proxy.keep-alive
network.http.proxy.pipelining
network.http.proxy.version
network.proxy.autoconfig_url
network.proxy.ftp
network.proxy.ftp_port
network.proxy.gopher
network.proxy.gopher_port
network.proxy.http
network.proxy.http_port
network.proxy.no_proxies_on
network.proxy.socks
network.proxy.socks_port
network.proxy.socks_remote_dns
network.proxy.socks_version
network.proxy.ssl
network.proxy.ssl_port
network.proxy.type

ON) Button ON (proxy1 configuration) change before default prefs to next proxy1 prefs values. For example; copy "kmeleon.plugins.macros.proxy1.proxy.type" pref value to "network.proxy.type" pref.

kmeleon.plugins.macros.proxy1.http.proxy.keep-alive
kmeleon.plugins.macros.proxy1.http.proxy.pipelining
kmeleon.plugins.macros.proxy1.http.proxy.version
kmeleon.plugins.macros.proxy1.proxy.autoconfig_url
kmeleon.plugins.macros.proxy1.proxy.ftp
kmeleon.plugins.macros.proxy1.proxy.ftp_port
kmeleon.plugins.macros.proxy1.proxy.gopher
kmeleon.plugins.macros.proxy1.proxy.gopher_port
kmeleon.plugins.macros.proxy1.proxy.http
kmeleon.plugins.macros.proxy1.proxy.http_port
kmeleon.plugins.macros.proxy1.proxy.no_proxies_on
kmeleon.plugins.macros.proxy1.proxy.socks
kmeleon.plugins.macros.proxy1.proxy.socks_port
kmeleon.plugins.macros.proxy1.proxy.socks_remote_dns
kmeleon.plugins.macros.proxy1.proxy.socks_version
kmeleon.plugins.macros.proxy1.proxy.ssl
kmeleon.plugins.macros.proxy1.proxy.ssl_port
kmeleon.plugins.macros.proxy1.proxy.type

K-Meleon in Spanish

Re: PrivacyBar toggling Proxy on/off
Posted by: JamesD
Date: March 17, 2009 02:38AM

I am working on it but is slow. I need to learn about checking to see if a button is checked or not and also how to check and un-check a button. I have the bitmap nearly done. I am slow to catch on how to put the text in the image, but I think I have found answer to that.

I suspect I will have put in a proxy on my system in order to test. Is that hard to do?

Re: PrivacyBar toggling Proxy on/off
Posted by: Yogi
Date: March 17, 2009 08:48AM

First of all, thanks for all the input.
Judging on other items of the privacy bar I thought there might be a much easier way to get a proxy toggled off/on. I was apparently wrong.
It's not that I'm so keen to have that option on the privacy bar by all means but just thought that it would make sense if it's place would be there by default.

You don't have to put a proxy on your system in order to check.
All you have to do is set K-M to use a proxy:
	
    "Name": Name of your choice e.g. ProxyTest
		

    "Use the following manual proxy settings:"
	 
    (HTTP)  127.0.0.1          Port:8080	
    (HTTPS) 127.0.0.1          Port:8080

(Don't forget to save the settings.)

By toggling proxy on while trying to surf you will get the message that K-M couldn't reach the server.(logic, since there is no proxy listening at port:8080 on your localhost)
By toggling proxy off you will be able to surf as usual.



Edited 1 time(s). Last edit at 03/17/2009 08:50AM by Yogi.

Re: PrivacyBar toggling Proxy on/off
Posted by: JamesD
Date: March 17, 2009 11:54AM

@ Yogi

Don't worry if it takes me some effort to make it happen. I am retired and after the wife's "to do" list, this is what I get to do. This macro is a little slow getting done because I have to learn, with a lot of testing, some plugin stuff that I have not done before.

I may use your info from last post for testing. I wonder if I could use a real proxy. I found this site http://hulk.org/ but I don't know what to enter in the fields for proxy custom.

Re: PrivacyBar toggling Proxy on/off
Posted by: desga2
Date: March 17, 2009 12:29PM

@ JamesD:

I can help you with this, if you have any question ask me.

I can do the button for privacy bar, I made icons and text buttons with IcoFX, while you could worked in macro code.
You can use an existed privacy bar button, for example "Images".

In your skin "toolbars.cfg" file "Images" privacy button is:
Images{
	macros(pref_ToggleImages)
	Block Images. Press F9 to toggle.
	privhot.bmp[3]
	privcold.bmp[3]
	}

In macros "main.kmm" file you can find "pref_ToggleImages" function:
pref_ToggleImages{
macroinfo=_("Toggle image loading");
menuchecked=(getpref(INT,$pref_Images)==2);
togglepref(INT,$pref_Images,1,2); &_pref_SyncButtons;
statusbar(sub("%s",getpref(INT,$pref_Images)==2?$off:$on,_("Image loading %s")));
}

And the related "_pref_SyncButtons" macro function:
# Toolbar Integration
_pref_SyncButtons{
$__c="CheckButton"; $__m=",macros(pref_Toggle";
# Privacy Bar (make sure the toolbar name is correct):
$__toolbar="&Privacy Bar";
pluginmsg(toolbars,$__c,$__toolbar.$__m."Animation),".(getpref(STRING,$pref_Animation)=="none"?1:0));
pluginmsg(toolbars,$__c,$__toolbar.$__m."Colors),".(getpref(BOOL,$pref_Colors)?0:1));
pluginmsg(toolbars,$__c,$__toolbar.$__m."Cookies),".(getpref(INT,$pref_Cookies)==2?1:0));
pluginmsg(toolbars,$__c,$__toolbar.$__m."Images),".(getpref(INT,$pref_Images)==1?0:1));
pluginmsg(toolbars,$__c,$__toolbar.$__m."Java),".(getpref(BOOL,$pref_Java)?0:1));
pluginmsg(toolbars,$__c,$__toolbar.$__m."JavaScript),".(getpref(BOOL,$pref_JavaScript)?0:1));
pluginmsg(toolbars,$__c,$__toolbar.$__m."Popups),".(getpref(BOOL,$pref_Popups)?1:0));
pluginmsg(toolbars,$__c,$__toolbar.$__m."Referer),".(getpref(INT,$pref_Referer)==0?1:0));
# Main Bar (make sure the toolbar name is correct):
$__toolbar="&Main Bar";
pluginmsg(toolbars,$__c,$__toolbar.$__m."Popups),".(getpref(BOOL,$pref_Popups)?1:0));
}

K-Meleon in Spanish

Re: PrivacyBar toggling Proxy on/off
Posted by: Yogi
Date: March 17, 2009 06:50PM

@ JamesD

Don't worry, I have plenty of time smiling smiley
It would be nice if once finished it would be implemented in the default setup of further K-M distributions.

Of course you can use a real proxy as a learning experience as well if you whish so.
The site above, as far as I can see is a web service and not an open public proxy to be used directly with your browser.
You can find thousands of 'free' public proxies by doing a search whith Google you could theoretically try. For different reasons I wouldn't recommend any of them.
Besides, finding a working proxy is a PITA. Even if you are lucky and you catch a working one there is no warranty that it will still work after a few minutes of use.
So far about free public open proxies.
You could also try (my recommendation) to experiment with a local proxy you will have to install/unzip on your system.
Proxomitron for instance would be an interesting (learning) choice because it is a very versatile filtering (and much more) local proxy you could use alongside with as many browsers you just whish. Forget about filters like AdBlock+ which are poor improvisations compared with a mighty tool like Proxomitron.
Another option as a local proxy to play whith would be Tor (SOCKS Proxy/anonymyzer-service). However it makes little sense to use Tor on a regular basis since it will unnecessarily slow down your surfing. Just in case you will opt for Tor, I suggest not to install the whole Vidalia/Tor bundle for novices but only the Tor package for experts.

@ desga2

Using an existing button like you are suggesting, makes IMHO much more sense since it would perfectly integrate optically as well with the rest of present items on the privacy bar.

Re: PrivacyBar toggling Proxy on/off
Posted by: JamesD
Date: March 17, 2009 09:01PM

Sorry to be late getting back to you. Needed to do stuff with my wife. I have an image at http://www.perigee.net/~jmd8421r/ProxyTog.bmp

All the images for the privacy bar had words on them and none said "proxy". I am starting with a bar for proxy. Once that works, it would be simple change to put on privacy bar.

Big question is how to tell what is the current button color, green or red, and how to know if user changes something from the "Tools" menu. Also what if the user has more than one proxy.

I will try to put in the "dummy" proxy stuff. I need to see what is in prefs.js when it is turned on.

As soon as I get the colors changing from the macro, I will post here so you can see direction I am taking.

Re: PrivacyBar toggling Proxy on/off
Posted by: JamesD
Date: March 17, 2009 09:34PM

@ Yogi

I have the "Dummy" proxy set up. It works just as you said. No surfing with Dummy selected and full surfing when direct connect is has check mark.

Nothing in prefs.js says which is checked. You meant I need somehow to check to see if the menu item is checked in order to see which one is being used. I will have a go at doing that.

This is the macro so far. It is very incomplete. You can see the button.

ProxTog.kmm

#  K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- ProxTog.kmm
# ---------- Proxy bar with icon for proxy on and proxy off
#
# Dependencies        : main.kmm
# Resources           :  
# Preferences         : -
# Version             : 0.1  3/17/09 
# --------------------------------------------------------------------------------

#From plugin documentation
#pluginmsg(toolbars, "AddToolbar", "<ToolbarName>, <ButtonWidth>, <ButtonHeight>","");
#pluginmsg(toolbars, "AddButton", "<ToolbarName>, <ButtonName>, <Command>, <MenuName>, <TooltipText>, <ButtonWidth>, <ButtonHeight>, hot.bmp[0], cold.bmp[0], dead.bmp[0]","");

_ProxTog_RunBar{
$_ProxTog_ToolbarName = "Proxy" ;
$_ProxTog_BWidth = "52" ;
$_ProxTog_BHeight = "14" ;
$_ProxTog_LastItem = "" ;
$_ProxTog_AddBarTag = $_ProxTog_ToolbarName .",".$_ProxTog_BWidth.",".$_ProxTog_BHeight.",". $_ProxTog_LastItem ; 
#alert($_ProxTog_AddBarTag, "bar tag DEBUG", INFO);
pluginmsg(toolbars, "AddToolbar", $_ProxTog_AddBarTag);

$_ProxTog_ButtonName = "PT" ;
#$_ProxTog_Command = ID_CLOSE_ALLOTHERTAB ;
$_ProxTog_Command = "macros(_ProxTog_Button)" ;
$_ProxTog_MenuName = "" ;
$_ProxTog_tipText = "Toggle proxy";
$_ProxTog_ImageHot = "ProxyTog.bmp[1]" ;
$_ProxTog_ImageCold = "ProxyTog.bmp[0]" ;
$_ProxTog_ImageDead = "ProxyTog.bmp[2]" ;
$_ProxTog_AddButtonTag = $_ProxTog_ToolbarName.",".$_ProxTog_ButtonName.",".$_ProxTog_Command.",".$_ProxTog_MenuName.",".$_ProxTog_tipText.",".$_ProxTog_BWidth.",".$_ProxTog_BHeight.",".$_ProxTog_ImageHot.",".$_ProxTog_ImageCold.",".$_ProxTog_ImageDead.",".$_ProxTog_LastItem ; 
#alert($_ProxTog_AddButtonTag, "button tag DEBUG", INFO);
pluginmsg(toolbars, "AddButton", $_ProxTog_AddButtonTag);
}
_ProxTog_Button{
alert("ProxTog pressed", "DEBUG", INFO);

#$_SearchIconTag =  $_ProxTog_ToolbarName.",".$_ProxTog_ButtonName.", COLD, ProxyTog.bmp[". $_ProxTog_Index ."]" ;
#pluginmsg(toolbars, "SetButtonImage", $_SearchIconTag);

}

$OnSetup=$OnSetup."_ProxTog_RunBar;";
$macroModules=$macroModules."ProxTog;";


Re: PrivacyBar toggling Proxy on/off
Posted by: JamesD
Date: March 17, 2009 09:50PM

@ Yogi

No way to see menu. Can only see a pref in order to create/change menu. I cannot find a pref which says which proxy is in use. All the proxy1(Dummy) stuff still in prefs.js even when I am back to using direct connection.

Not sure where to go from here.

Re: PrivacyBar toggling Proxy on/off
Posted by: JamesD
Date: March 17, 2009 10:52PM

@ Yogi

I think I found it. user_pref("network.proxy.type", 1);

This line exists when Dummy is the proxy and does not exist when direct connection is the method. The value is zero (default) for direct connection and is 4 if the automatic proxy is selected. I found this stuff in proxy.kmm.

Maybe there is a place in proxy.kmm to put a call to the value for the color of the proxy button.

Re: PrivacyBar toggling Proxy on/off
Posted by: JamesD
Date: March 18, 2009 02:32PM

@ Yogi

Several false starts later, I have a macro which works for custom proxies. It does not yet handle auto detect or changes from the tools menu.

Try this and see if it works for you.

ProxTog.kmm

#  K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- ProxTog.kmm
# ---------- Proxy bar with icon for proxy on and proxy off
# ---------- Does not yet handle auto detect or pick up on change from tools menu
#
# Dependencies        : main.kmm
# Resources           :  
# Preferences         : "network.proxy.type"
# Version             : 0.3  3/18/09 
# --------------------------------------------------------------------------------

_ProxTog_RunBar{
$_ProxTog_ToolbarName = "Proxy" ;
$_ProxTog_BWidth = "52" ;
$_ProxTog_BHeight = "14" ;
$_ProxTog_LastItem = "" ;
$_ProxTog_AddBarTag = $_ProxTog_ToolbarName .",".$_ProxTog_BWidth.",".$_ProxTog_BHeight.",". $_ProxTog_LastItem ; 
#alert($_ProxTog_AddBarTag, "bar tag DEBUG", INFO);
pluginmsg(toolbars, "AddToolbar", $_ProxTog_AddBarTag);

$_ProxTog_ButtonName = "PT" ;
$_ProxTog_Command = "macros(_ProxTog_Button)" ;
$_ProxTog_MenuName = "" ;
$_ProxTog_tipText = "Toggle proxy";
$_ProxTog_ImageHot = "ProxyTog.bmp[1]" ;
$_ProxTog_ImageCold = "ProxyTog.bmp[0]" ;
$_ProxTog_ImageDead = "ProxyTog.bmp[2]" ;
$_ProxTog_AddButtonTag = $_ProxTog_ToolbarName.",".$_ProxTog_ButtonName.",".$_ProxTog_Command.",".$_ProxTog_MenuName.",".$_ProxTog_tipText.",".$_ProxTog_BWidth.",".$_ProxTog_BHeight.",".$_ProxTog_ImageHot.",".$_ProxTog_ImageCold.",".$_ProxTog_ImageDead.",".$_ProxTog_LastItem ; 
#alert($_ProxTog_AddButtonTag, "button tag DEBUG", INFO);
pluginmsg(toolbars, "AddButton", $_ProxTog_AddButtonTag);
macros(_ProxTog_Status);
}

_ProxTog_Status{
# Button setup indicated proxy as "on"
# If actual proxy status is "off" the proxy.type will zero
if (getpref(INT,"network.proxy.type") == 0) {
	$_ProxTog_IconTag =  $_ProxTog_ToolbarName.",".$_ProxTog_Command.", COLD, ProxyTog.bmp[2]" ;
	pluginmsg(toolbars, "SetButtonImage", $_ProxTog_IconTag);
	}
}

_ProxTog_Button{
# If a defined proxy is in use the status will be in getpref(INT,"network.proxy.type")
$_ProxTog_Status = getpref(INT,"network.proxy.type");
	if ($_ProxTog_Status != 0) {
	# A proxy was in use  CHANGE TO NOT IN USE
	setpref(INT,"network.proxy.type",0);
	$_ProxTog_IconTag =  $_ProxTog_ToolbarName.",".$_ProxTog_Command.", COLD, ProxyTog.bmp[2]" ;
	pluginmsg(toolbars, "SetButtonImage", $_ProxTog_IconTag);	
	} else {
	# A proxy was not in use  CHANGE TO IN USE
	setpref(INT,"network.proxy.type",1);
	$_ProxTog_IconTag =  $_ProxTog_ToolbarName.",".$_ProxTog_Command.", COLD, ProxyTog.bmp[0]" ;
	pluginmsg(toolbars, "SetButtonImage", $_ProxTog_IconTag);	
		}
}

$OnSetup=$OnSetup."_ProxTog_RunBar;";
$macroModules=$macroModules."ProxTog;";


Re: PrivacyBar toggling Proxy on/off
Posted by: Yogi
Date: March 18, 2009 05:47PM

@ JamesD

Just tested and it works!
It works exactly the way I imagined it should.
It doesn't have to autodetect. All it has to do is to toggle proxy on/off (yes/no).
For more complex settings (autodetect, several proxies and so on) we already have the tools menu for.
Single minor glitch, the toggle button is greyed out but my guess is it's because of my Klassic skin I use. I always delete the default skin since I don't have any use for it. However this minor glitch is irrelevant and probably easy to fix.
Now since it works, it would be nice to implement the proxy toggle option into the privacy bar smiling smiley



Edited 1 time(s). Last edit at 03/18/2009 05:51PM by Yogi.

Re: PrivacyBar toggling Proxy on/off
Posted by: JamesD
Date: March 18, 2009 07:42PM

@ Yogi

Glad it works. I have now a version which will pick up changes from the tools menu except for auto-detect. It requires an edit of Proxy.kmm to add two lines of code.

Can you be more specific about "Single minor glitch, the toggle button is greyed out"? I use the Klassic skin and my button appears to work and shows just fine. You should have a green box with word proxy if proxy is in force and a red box with word proxy when direct connect is in force. When the pointer is over the button, you should have a yellow box.

Changing from proxy to direct connect changes only one pref value. Changing from auto detect adds or removes a whole long list of prefs. Should we try to include auto detect?

Re: PrivacyBar toggling Proxy on/off
Posted by: Yogi
Date: March 18, 2009 08:44PM

Toggle button:


I'm afraid I did something wrong. Actually I just placed the ProxTog.kmm in the user defined macros folder.

My initially (and actually smiling smiley ) goal was a slight enhancement to the privacy bar without any attracting attention by only adding the toggle off/on option for proxy. The absolute same visual look like the toggle Cookies, Javascript, Java, Referer..., perfectly visually harmonizing with already existing items (green checkmark 'Proxy' /toggled/ red cross 'Proxy'), with no third option.
For any other setting/option there we still have the tool menu.

I'm a minimalist by nature smiling smiley
However it's your work and merit and finally you have to decide about functionality and look smiling smiley

Re: PrivacyBar toggling Proxy on/off
Posted by: JamesD
Date: March 18, 2009 09:34PM

@ Yogi

The bitmap located here http://www.perigee.net/~jmd8421r/ProxyTog.bmp is to go in a folder named Default in the skins folder. Give it the name ProxyTog.bmp. The macro should be able to find it there.

I am not much of a graphic artist. I could do a box but not a check mark. None of the existing images said proxy.

Re: PrivacyBar toggling Proxy on/off
Posted by: Yogi
Date: March 18, 2009 10:06PM

@ JamesD

Thanks, works like a charm!!!
I'll try to make the image look the same like the other items. That's the most easiest and irrelevant part however. Will make a screenshot when ready.
Thanks again smiling smiley

Re: PrivacyBar toggling Proxy on/off
Posted by: JamesD
Date: March 18, 2009 11:57PM

@ Yogi

Supposed to be easy to move to privacy bar. NOT! I have got some silly mistake that I can't find. Control, proxy or not, is working but every time a change is made the button disappears.

I think the images on the privacy bar used a smaller type than I used for the word "proxy". The bottom of the letters are cut off when placed on the privacy bar. Also my images may be too wide.



Edited 1 time(s). Last edit at 03/19/2009 12:00AM by JamesD.

Re: PrivacyBar toggling Proxy on/off
Posted by: JamesD
Date: March 19, 2009 12:43AM

@ Yogi

The images you make need to be 54 x 10 in size. The images that I made were 52 x 14. I made the Proxy bar that 52,14 size. The Privacy bar is 54,10 if I understand the numbers by its name in Toolbar.cfg.

Re: PrivacyBar toggling Proxy on/off
Posted by: Yogi
Date: March 19, 2009 12:59AM

@ JamesD

The way it looks now:



with the slightly modified ProxyTog image:



You could try my ProxyTog.bmp shrinked to 10 pixel high like that of privbar_red/green.bmp



With the toolbars locked as you can see on my image it already looks as if it would be part of the privacy bar.
That's ok for me at least!!! smiling smiley

Re: PrivacyBar toggling Proxy on/off
Posted by: Yogi
Date: March 19, 2009 01:20AM

@ JamesD

Sorry, I didn't read carefully enough your post. It's late here in Germany smiling smiley
However I don't have to go to work tomorrow grinning smiley
I'll make the image with the dimensions you suggested.

Re: PrivacyBar toggling Proxy on/off
Posted by: Yogi
Date: March 19, 2009 01:40AM

@ JamesD

ProxyTog.bmp 3x 54x10 -> 162x10





Edited 1 time(s). Last edit at 03/19/2009 01:41AM by Yogi.

Re: PrivacyBar toggling Proxy on/off
Posted by: JamesD
Date: March 19, 2009 12:07PM

@ Yogi

Thanks for the new bitmap image. Saved me a lot of work.

Still have had no luck with the version for Privacy bar. The _PBProxTog_Status macro may be running at a wrong time. I always get green when sometimes I should get red. Also when I click on the button and the _PBProxTog_Button macro runs the image is gone. I am going to post the code in hope that someone can spot my mistake. I cannot see anything wrong with the pluginmsg(toolbars, "SetButtonImage", statement. The rest of the statement looks like this:
From PBProxyTog.kmm for Privacy bar using setclipboard
&Privacy Bar,macros(_PBProxTog_Button), COLD, PBProxyTog.bmp[2]

From ProxyTog.kmm for Proxy bar using setclipboard
Proxy,macros(_ProxTog_Button), COLD, ProxyTog.bmp[2]
Except for name change they are the same.

For the PBProxyTog.kmm there has to be a button created in toolbars.cfg file. I put my code after User Agent.
	User Agent{
	ID_APP_ABOUT|&User Agent
	Check Browser Identity. Right-click to choose different User Agent.
	privbar_red.bmp[14]
	privbar_green.bmp[14]
	}

	-
	Proxy{
	macros(_PBProxTog_Button)
	Toggle proxy
	PBProxyTog.bmp[1]
	PBProxyTog.bmp[0]
	PBProxyTog.bmp[2]
	}

	%endif

PBProxyTog.kmm

#  K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- PBProxTog.kmm
# ---------- Icon for proxy on and proxy off as part of privacy bar
# ---------- Does not yet handle auto detect 
#
# Dependencies        : main.kmm, proxy.kmm
# Resources           :  
# Preferences         : "network.proxy.type"
# Version             : 0.4  3/18/09 
# --------------------------------------------------------------------------------

_PBProxTog_Status{
$_PBProxTog_ToolbarName = "&Privacy Bar" ;
$_PBProxTog_Command = "macros(_PBProxTog_Button)" ;
if (getpref(INT,"network.proxy.type") == 0) {
	#alert("In the zero loop", "status macro  DEBUG", INFO);
	$_PBProxTog_IconTag =  $_PBProxTog_ToolbarName.",".$_PBProxTog_Command.", COLD, PBProxyTog.bmp[2]" ;
	#alert($_PBProxTog_IconTag, "data for setbuttonimage  DEBUG", INFO);
setclipboard($_PBProxTog_IconTag);
	pluginmsg(toolbars, "SetButtonImage", $_PBProxTog_IconTag);
	}
}

_PBProxTog_Button{
# If a defined proxy is in use the status will be in getpref(INT,"network.proxy.type")
alert($_PBProxTog_ToolbarName, "toolbar name  DEBUG", INFO);
alert($_PBProxTog_Command, "button name   DEBUG", INFO);
$_PBProxTog_Status = getpref(INT,"network.proxy.type");
	if ($_PBProxTog_Status != 0) {
	# A proxy was in use  CHANGE TO NOT IN USE
	setpref(INT,"network.proxy.type",0);
	$_PBProxTog_IconTag =  $_PBProxTog_ToolbarName.",".$_PBProxTog_Command.", COLD, PBProxyTog.bmp[2]" ;
	pluginmsg(toolbars, "SetButtonImage", $_PBProxTog_IconTag);	
	} else {
	# A proxy was not in use  CHANGE TO IN USE
	setpref(INT,"network.proxy.type",1);
	$_PBProxTog_IconTag =  $_PBProxTog_ToolbarName.",".$_PBProxTog_Command.", COLD, PBProxyTog.bmp[0]" ;
	pluginmsg(toolbars, "SetButtonImage", $_PBProxTog_IconTag);	
		}
}

ProxTog_ToolsAlert{
if ( getpref(INT,"network.proxy.type") == 1 {
	$_PBProxTog_IconTag =  $_PBProxTog_ToolbarName.",".$_PBProxTog_Command.", COLD, ProxyTog.bmp[0]" ;
	pluginmsg(toolbars, "SetButtonImage", $_PBProxTog_IconTag);
	} else {
	$_PBProxTog_IconTag =  $_PBProxTog_ToolbarName.",".$_PBProxTog_Command.", COLD, ProxyTog.bmp[2]" ;
	pluginmsg(toolbars, "SetButtonImage", $_PBProxTog_IconTag);	
	}
}

$OnInit=$OnInit."_PBProxTog_Status;";
$macroModules=$macroModules."PBProxTog;";


Re: PrivacyBar toggling Proxy on/off
Posted by: JamesD
Date: March 21, 2009 01:47AM

@ Yogi

Finally got it working. Problem was where I placed the button for proxy in the privacy bar. I does not seem to work if placed after user agent. It does work if placed before cookies.

&Privacy Bar(54,10){

	%ifplugin macros

	Proxy{
	macros(_PBProxTog_Button)
	Toggle proxy
	PBProxyTog.bmp[1]
	PBProxyTog.bmp[0]
	}

	-

	Cookies{


Use the image posted by Yogi on March 19. Give it the name PBProxyTog.bmp and place in the Default folder under the skins folder.

In order to pick up on changes from TOOLS - PROXY, you will need to add a line of code in proxy.kmm file in two places.

Proxy_None{
macroinfo=_("Connect directly to the Internet");
menuchecked=(getpref(INT,$_Proxy_Type)==0);
setpref(INT,$_Proxy_Type,0); statusbar(_("Connecting directly"));
&PBProxTog_ToolsAlert;
}

and

_Proxy_Custom{
setpref(STRING,$_Proxy_Current,$_proxy); $ExecMacros="_Proxy_SetPref";
$_type=BOOL;   $List=$_Proxy_PrefBool; &ExecMacros_List;
$_type=INT;    $List=$_Proxy_PrefInt;  &ExecMacros_List;
$_type=STRING; $List=$_Proxy_PrefStr;  &ExecMacros_List;
statusbar(sub("%s",getpref(STRING,$macroPrefBranch.$_proxy.".name"),_("Connecting over proxy '%s'")));
&PBProxTog_ToolsAlert;
}

PBProxTog.kmm

#  K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- PBProxTog.kmm
# ---------- Icon for proxy on and proxy off as part of privacy bar
# ---------- Does not yet handle auto detect 
#
# Dependencies        : main.kmm, proxy.kmm
# Resources           :  
# Preferences         : "network.proxy.type"
# Version             : 0.5  3/21/09 
# Author              : JamesD
# --------------------------------------------------------------------------------

_PBProxTog_Status{
$_PBProxTog_ToolbarName = "&Privacy Bar" ;
$_PBProxTog_Command = "macros(_PBProxTog_Button)" ;
if (getpref(INT,"network.proxy.type") == 0) {
	$_PBProxTog_IconTag =  $_PBProxTog_ToolbarName.",".$_PBProxTog_Command.", COLD, PBProxyTog.bmp[2]" ;
	pluginmsg(toolbars, "SetButtonImage", $_PBProxTog_IconTag);
	}
}

_PBProxTog_Button{
$_PBProxTog_Status = getpref(INT,"network.proxy.type");
	if ($_PBProxTog_Status != 0) {
	setpref(INT,"network.proxy.type",0);
	$_PBProxTog_IconTag =  $_PBProxTog_ToolbarName.",".$_PBProxTog_Command.", COLD, PBProxyTog.bmp[2]" ;
	pluginmsg(toolbars, "SetButtonImage", $_PBProxTog_IconTag);	
	} else {
	setpref(INT,"network.proxy.type",1);
	$_PBProxTog_IconTag =  $_PBProxTog_ToolbarName.",".$_PBProxTog_Command.", COLD, PBProxyTog.bmp[0]" ;
	pluginmsg(toolbars, "SetButtonImage", $_PBProxTog_IconTag);	
		}
}

PBProxTog_ToolsAlert{
if ( getpref(INT,"network.proxy.type") == 1) {
	$_PBProxTog_IconTag =  $_PBProxTog_ToolbarName.",".$_PBProxTog_Command.", COLD, PBProxyTog.bmp[0]" ;
	pluginmsg(toolbars, "SetButtonImage", $_PBProxTog_IconTag);
	} else {
	$_PBProxTog_IconTag =  $_PBProxTog_ToolbarName.",".$_PBProxTog_Command.", COLD, PBProxyTog.bmp[2]" ;
	pluginmsg(toolbars, "SetButtonImage", $_PBProxTog_IconTag);	
	}
}

$OnStartup=$OnStartup."_PBProxTog_Status;";
$macroModules=$macroModules."PBProxTog;";



Edited 1 time(s). Last edit at 03/24/2009 06:02PM by JamesD.

Re: PrivacyBar toggling Proxy on/off
Posted by: Yogi
Date: March 21, 2009 06:42PM

@ JamesD

Fine job JamesD!
Works like a charm.
You've been right, picking up changes from TOOLS perfects the macro!

Thx again, danke smiling smiley


It's a long way to understand the macro arguments and I'm a lazy type but I'll try to get at least the very basics.
I just added two lines to PBProxTog.kmm in order to make the proxy status visible on the status bar while toggling:

_PBProxTog_Button
.................
setpref(INT,$_Proxy_Type,0); statusbar(_("Connecting directly"));
and
setpref(INT,$_Proxy_Type,1); statusbar(_("Connecting over proxy"));

I know this is just chickenfeed but I'm still happy it works at least smiling smiley



Edited 1 time(s). Last edit at 03/22/2009 08:05PM by Yogi.

K-Meleon forum is powered by Phorum.