Improvement requests :  K-Meleon Forum
Use this forum to talk about a feature you're missing. Use the bug tracker to report it if necessary. 
new IFMACRO condition?
Posted by: siria
Date: October 14, 2009 01:26AM

There's a condition "%ifplugin xyz" that works in toolbars.cfg
If it's not too much trouble it Would be nice to also have a "%ifmacro xyz" function smiling smiley
Meanwhile there are countless more macros than plugins, and if each would bring it's own toolbar for a single button, it would get horribly confusing with all the countless new toolbars in the view list. So I'd prefer a single toolbar with a couple macro buttons together, and also the ability to insert a macro button into one of the regular toolbars (like extensions-manager next to KM-preferences button). But there's this little problem that specific macro buttons can't be switched on/off automatically...

Options: ReplyQuote
Re: new IFMACRO condition?
Posted by: desga2
Date: October 14, 2009 01:54AM

I think this isn't needed, all this you can do it with a macro, but really this implementation can help to do it more easy to people that made skins/themes including Extensions/macros buttons.
Some example of a new button implemented in a toolbar with a macro:
http://kmeleon.sourceforge.net/forum/read.php?4,90245,90471#msg-90471
http://kmeleon.sourceforge.net/forum/read.php?4,90651

In the extension Proxy2 I added the option to set on/off toolbar button and option to select between toolbar button or privacy button type in menus.

K-Meleon in Spanish



Edited 2 time(s). Last edit at 10/14/2009 01:56AM by desga2.

Options: ReplyQuote
Re: new IFMACRO condition?
Posted by: jsnj
Date: October 14, 2009 04:04AM

Quote
desga2
I think this isn't needed, all this you can do it with a macro, but really this implementation can help to do it more easy to people that made skins/themes including Extensions/macros buttons.
Some example of a new button implemented in a toolbar with a macro:
http://kmeleon.sourceforge.net/forum/read.php?4,90245,90471#msg-90471
http://kmeleon.sourceforge.net/forum/read.php?4,90651

In the extension Proxy2 I added the option to set on/off toolbar button and option to select between toolbar button or privacy button type in menus.

I don't see how that addresses the request. Macro authors' buttons can't match all skins. So if a skin author wants to provide a matching button that references someone else's macro that's not included by default, the user is then stuck with a non-functioning button if he doesn't have that macro.

Maybe when the adding buttons to existing toolbars bug is fixed and available, all toolbar buttons created from a macro file can be re-written to have the on/off toggle option. Perhaps that may solve the problem.



Edited 1 time(s). Last edit at 10/14/2009 04:15AM by jsnj.

Options: ReplyQuote
Re: new IFMACRO condition?
Posted by: siria
Date: October 14, 2009 04:44AM

Quote
desga2
you can do it with a macro, but really this implementation can help to do it more easy to people that made skins/themes including Extensions/macros buttons.

Absolutely, that's the point. To put it short:
I'm a simple end-user dabbling a bit with a skin, not a programmer ;-)

To add buttons with a macro is surely the most professional thing, but a hundred times too difficult and time-consuming for end-users like me. And a skin author can't really manipulate with other people's stuff, change their macros. And if he'd write an own macro just to add a couple buttons, there'd still have to be some if-conditions (that may already exist in macros, no idea), but anyway, just all-around it'd be sooo much simpler to just include a litte ifmacro-line in the toolbar-cfg ;-)

Options: ReplyQuote
Re: new IFMACRO condition?
Posted by: JamesD
Date: October 14, 2009 09:49AM

To see the list of macros just run this line of code.
alert($macroModules, "Macros",INFO);
It is possible to have a macro "turned off". I have to do some more checking to see if I can find that info.

Options: ReplyQuote
Re: new IFMACRO condition?
Posted by: JujuLand
Date: October 14, 2009 01:58PM

When a macro is turned off, there is a pref in prefs.js:

kmeleon.plugins.macros.modules.macroName.load which is set to false

I think that it doesn't exist if turned on.

A+


Mozilla/5.0 (x11; U; Linux x86_64; fr-FR; rv:24.0) Gecko/20140105 Ubuntu/12.04 K-Meleon/74.0

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




Options: ReplyQuote
Re: new IFMACRO condition?
Posted by: JamesD
Date: October 14, 2009 05:54PM

@ JujuLand
Quote

When a macro is turned off, there is a pref in prefs.js:
Found them. Thank you.

Options: ReplyQuote
Re: new IFMACRO condition?
Posted by: JamesD
Date: October 15, 2009 08:39AM

I have two small macros which demo a system to quickly test if a certain macro is running on the system. The MacroIf.kmm file produces an ini file with all the names of active macros. The TestForMacro.kmm file is a demo of how query the ini file.

I had hoped the the query method could be used in toolbars.cfg but it does not seem to work as a %if query.

@ Jujuland
The $macroModules string seems only to have active macro names. Therefore I did not have to go to prefs.js to get inactive ones.

MacroIf.kmm

#  K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- MacroIf.kmm
# ---------- Runs at init to produce an ini file with all active macro names
#
# Dependencies        : main.kmm
# Resources           : -  
# Preferences         : -
# Version             : 0.2  10-14-09  
# --------------------------------------------------------------------------------

_MacroIf_RunCode{
$_MacroIf_MList = substr($macroModules,1);
$_MacroIf_Dist = index($_MacroIf_MList,";");
while($_MacroIf_Dist > 1) {
	$_MacroIf_Unit = substr($_MacroIf_MList,0,$_MacroIf_Dist);
	$_MacroIf_Section = "MacroNames";
	$_MacroIf_Value  = true ;
	iniwrite($_MacroIf_Section, $_MacroIf_Unit, $_MacroIf_Value, $_MacroIf_Path);
	$_MacroIf_MList = substr($_MacroIf_MList,$_MacroIf_Dist+1);
	$_MacroIf_Dist = index($_MacroIf_MList,";");
}
	
## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
$_MacroIf_Path=getfolder(UserMacroFolder)."\\MacroIf.ini";
$OnInit=$OnInit."_MacroIf_RunCode;";
$macroModules=$macroModules."MacroIf;";

TestForMacro.kmm

#  K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- TestForMacro.kmm
# ---------- Demo of method to test if a macro is running on the system
#
# Dependencies        : main.kmm
# Resources           : -  
# Preferences         : -
# Version             : 0.1  10-14-09  
# --------------------------------------------------------------------------------

_TestForMacro_RunCode {
	## --  Try with $_TFM_Query set to "MacroIf" and then try with it set to "NothingElse" 
	$_TFM_Query = "MacroIf" ;
	#$_TFM_Query = "NothingElse" ;
	if (iniread("MacroNames", $_TFM_Query, $_tfm_value, $_TestForMacro_Path) != true){
		alert($_TFM_Query." macro not active", "Results of query on ".$_TFM_Query." in MacroIf.ini", INFO);
	} else {
		alert($_TFM_Query." macro active", "Results of query on ".$_TFM_Query." in MacroIf.ini", INFO);
	}
}

_TestForMacro_GetPath { $_TestForMacro_Path=getfolder(UserMacroFolder)."\\MacroIf.ini"; }
_TestForMacro_BuildMenu { setmenu("&Tools",macro,"Test for macro",_TestForMacro_RunCode,Misc); }	
	
$OnStartup=$OnStartup."_TestForMacro_GetPath;";
$OnInit=$OnInit."_TestForMacro_BuildMenu;";
$macroModules=$macroModules."TestForMacro;";



Options: ReplyQuote
Re: new IFMACRO condition?
Posted by: JamesD
Date: October 18, 2009 08:49AM

Oops, sorry. I think I broke MacroIf when I tried to clean up the code. This copy should work.

MacroIf.kmm

#  K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- MacroIf.kmm
# ---------- Runs at init to produce an ini file with all active macro names
#
# Dependencies        : main.kmm
# Resources           : -  
# Preferences         : -
# Version             : 0.3  10-17-09  
# --------------------------------------------------------------------------------

_MacroIf_RunCode {
$_MacroIf_MList = substr($macroModules,1);
$_MacroIf_Dist = index($_MacroIf_MList,";");
while($_MacroIf_Dist > 1) {
	$_MacroIf_Unit = substr ($_MacroIf_MList,0,$_MacroIf_Dist);
	$_MacroIf_Section = "MacroNames";
	$_MacroIf_Value  = true ;
	iniwrite($_MacroIf_Section, $_MacroIf_Unit, $_MacroIf_Value, getfolder (UserMacroFolder)."\\MacroIf.ini");
	$_MacroIf_MList = substr($_MacroIf_MList,$_MacroIf_Dist+1);
	$_MacroIf_Dist = index($_MacroIf_MList,";");
	}
}
	
## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
$OnInit=$OnInit."_MacroIf_RunCode;";
$macroModules=$macroModules."MacroIf;";


Options: ReplyQuote


K-Meleon forum is powered by Phorum.