General :  K-Meleon Web Browser Forum
General discussion about K-Meleon 
Adding a button checked/unchecked
Posted by: ra
Date: December 02, 2007 01:12AM

Hi,

what's the proper way to add a new button with the new pref/macros/skins-structure that toggles kmeleon.download.disableContentSniffingOnSave and is automatically looking pressed or not depending on the pref? I added the button (in a new bar for now), added the macro to toggle the pref in my personal macros file, but how do I add the "pressed look" (just like the privacy bar) without changing an original macros file?

pref_ToggleSniffingOnSave{
togglepref(BOOL,"kmeleon.download.disableContentSniffingOnSave");
statusbar(sub("%s",!getpref(BOOL,"kmeleon.download.disableContentSniffingOnSave")?$off:$on,_("Content sniffing for saving %s")));
}

Sniffing Button{
Sniffing{
macros(pref_ToggleSniffingOnSave)
Toggle whether K-M sniffs for content type or uses file extension
searchhot.bmp[4]
searchcold.bmp[4]
searchcold.bmp[4]
}
}

I'm aksing for K-M v1.1.x and v1.5a.

Options: ReplyQuote
Re: Adding a button checked/unchecked
Posted by: desga2
Date: December 02, 2007 01:47AM

For example you can find in main.kmm this code for Toggle popups button in privacy bar:

pref_TogglePopups{
menuchecked=(getpref(BOOL,$pref_Popups)==true);
togglepref(BOOL,$pref_Popups); &_pref_SyncButtons;
statusbar(sub("%s",getpref(BOOL,$pref_Popups)==true?$on:$off,_("Popup blocking %s")));
}

Greetings.

K-Meleon in Spanish

Options: ReplyQuote
Re: Adding a button checked/unchecked
Posted by: ra
Date: December 02, 2007 07:56PM

Yeah, I know this code. But that won't make my button look pressed.

Options: ReplyQuote
Re: Adding a button checked/unchecked
Posted by: JujuLand
Date: December 03, 2007 08:34AM

I have tried too, and never make it work.

A+



Mozilla/5.0 (x11; U; Linux x86_64; fr-FR; rv:38.0) Gecko/20100101 Ubuntu/12.04 K-Meleon/76.0


Web: http://jujuland.pagesperso-orange.fr/
Mail : alain [dot] aupeix [at] wanadoo [dot] fr



Ubuntu 12.04 - Gramps 3.4.9 - Harbour 3.2.0 - Hwgui 2.20-3 - K-Meleon 76.0 rc



Options: ReplyQuote
Re: Adding a button checked/unchecked
Posted by: guenter
Date: December 03, 2007 11:00AM

Maybe have a look at the lines after line 413
start/search with # Privacy Bar (make sure the toolbar name is correct):

if it matters that the spelling of the bar must be correct - this might belong to the showing of the button status.

Options: ReplyQuote
Re: Adding a button checked/unchecked
Posted by: desga2
Date: December 03, 2007 12:56PM

The complete code for a checked button; ToggleImages, for example;
(all code from main.kmm macro file)
$pref_Images="permissions.default.image";

pref_ToggleImages{
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")));
}

# Toolbar Integration
_pref_SyncButtons{
$__c="CheckButton"; $__m=",macros(pref_Toggle";

# Privacy Bar (make sure the toolbar name is correct):
$__toolbar="&Privacy Bar";
# Main Bar (make sure the toolbar name is correct):
#$__toolbar="&Main Bar";
pluginmsg(toolbars,$__c,$__toolbar.$__m."Images),".(getpref(INT,$pref_Images)==1?0:1));

}

$OnLoad=$OnLoad."_pref_SyncButtons;";
$OnStartup=$OnStartup."_pref_SyncButtons;";

Have i that says you all? smiling smiley

K-Meleon in Spanish

Options: ReplyQuote
Re: Adding a button checked/unchecked
Posted by: desga2
Date: December 03, 2007 01:40PM

Ok this is your solution case:
- In toolbars.cfg file in skin folder:
Sniffing Bar(24,24){
Sniffing{
macros(pref_ToggleSniffingOnSave)
Toggle whether K-M sniffs for content type or uses file extension
searchhot.bmp[4]
searchcold.bmp[4]
searchcold.bmp[4]
}
}

- In your macro profile folder you must create this file named 'Sniffing.kmm':
# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)

# ---------- ToggleSniffingOnSave -------------------------------------------
#
# Needed files  : -
# Dependencies	: toolbars.cfg
# Resources	    : -
# Preferences	  : -
# ---------------------------------------------------------------------------


$pref_SniffingOnSave="kmeleon.download.disableContentSniffingOnSave";

pref_ToggleSniffingOnSave{
menuchecked=(getpref(BOOL,$pref_SniffingOnSave)==false);
togglepref(BOOL,$pref_SniffingOnSave); &_pref_SyncSniffingButton;
statusbar(sub("%s",getpref(BOOL,$pref_SniffingOnSave)==false?$off:$on,_("Content sniffing for saving %s")));
}

# Toolbar Integration
_pref_SyncSniffingButton{
$__c="CheckButton"; $__m=",macros(pref_Toggle";

# Sniffing Bar (make sure the toolbar name is correct):
$__toolbar="Sniffing Bar";
pluginmsg(toolbars,$__c,$__toolbar.$__m."SniffingOnSave),".(getpref(BOOL,$pref_SniffingOnSave)?1:0));
}

$OnLoad=$OnLoad."_pref_SyncSniffingButton;";
$OnStartup=$OnStartup."_pref_SyncSniffingButton;";

Greetings! (I think that i'm very good person, kko not give you all this code) tongue sticking out smiley

K-Meleon in Spanish



Edited 1 time(s). Last edit at 12/03/2007 01:42PM by desga2.

Options: ReplyQuote
Re: Adding a button checked/unchecked
Posted by: ra
Date: December 06, 2007 09:21PM

Thank you very much for your detailled reply, desga2! Works great now. The last lines of the code were the missing pieces.

For anyone looking for the same thing, here are two changes based on desga2's last posting, that I'd recommend:

a) change the logic to truly reflect what's going on or enabled/disabled: ==true instead of ==false and ?0:1 instead of ?1:0
b) remove the toolbar size (24, 24). maybe it fits phoenity large, but not phoenity or similar small skins.

Good code example, here. smiling smiley

Options: ReplyQuote


K-Meleon forum is powered by Phorum.