General
: K-Meleon Forum
General discussion about K-Meleon.
Goto:
Forum List
•
Message List
•
Search
•
Log In
Your Name:
Subject:
Help information
BBcode help
Smileys help
[quote=kko] [size=large]2) Use macros only[/size] This code is a quick demonstration of how you could use macros to choose the location for new favorites before creation. The favorites plugin does already offer a preference to set the folder for new favorites (kmeleon.plugins.favorites.newitemFolder). The value of this pref is the path to a subfolder of the Favorites folder relative to the Favorites folder. With the help of the readreg() and promptforfolder() macro statements we're able to determine the Favorites folder's location and let the user choose a subfolder. [b]Problems:[/b] 1) The favorites plugin doesn't always notice when the pref kmeleon.plugins.favorites.newitemFolder is changed at runtime and thus does not reliably (mostly not) create the new shortcut in the desired location. (See my comment in the code.) 2) The favorites plugin is creating the filename from the document's title or the link's text. To influence the filename we had to manipulate the document. Through the macro language (and JavaScript) we could read as well as alter the document's title, but not the focused link's text (at least not under all circumstances). [b][u]AddFavorite2.kmm[/u]:[/b] [code]# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage) # ---------- Favorites --------------------------------------------------------------------------------------------- # # Dependencies : - # Resources : - # Preferences : - # # ------------------------------------------------------------------------------------------------------------------ AddFavorite2_Page{ $_FavAction=Add; &_AddFavorite2; } AddFavorite2_Link{ $_FavAction=AddLink; &_AddFavorite2; } # ----- PRIVATE _AddFavorite2{ $_FavFolder=getpref(STRING,"kmeleon.plugins.favorites.directory"); $_FavFolder==""?$_FavFolder=readreg("HKCU","Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\Favorites"):0; $_FavFolder==""?$_FavFolder=readreg("HKLM","Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\Favorites"):0; $_SubFolder="?"; while($_SubFolder=="?") &_AddFavorite2_Loop; $_SubFolder==":"?0:length($_SubFolder)==0?delpref("kmeleon.plugins.favorites.newitemFolder"): setpref(STRING,"kmeleon.plugins.favorites.newitemFolder",$_SubFolder); # HERE IS THE TRAP # When the plugin is called below, it's not sure that the pref is already updated from above $_SubFolder==":"?0: plugin(favorites,$_FavAction); } _AddFavorite2_Loop{ $_SubFolder=promptforfolder(_("Specify where to add the new shortcut. Select your Favorites folder or one of its subfolders:"),$_FavFolder."\\".getpref(STRING,"kmeleon.plugins.favorites.newitemFolder")); $_SubFolder=$_SubFolder==""?":":index($_SubFolder,$_FavFolder)==0?substr($_SubFolder,length($_FavFolder)+1):"?"; } _AddFavorite2_BuildMenu{ setmenu("F&avorites",macro,"&Add Page",AddFavorite2_Page,"favorites(Add)"); setmenu("F&avorites",command,"","favorites(Add)"); setmenu("DocumentSave",macro,"Add Page To F&avorites",AddFavorite2_Page,"favorites(Add)"); setmenu("DocumentSave",command,"","favorites(Add)"); setmenu("LinkSave",macro,"Add Link To F&avorites",AddFavorite2_Link,"favorites(AddLink)"); setmenu("LinkSave",command,"","favorites(AddLink)"); } $kFavorites==true?($OnInit=$OnInit."_AddFavorite2_BuildMenu;"):0; # ------------------------------------------------------------------------------------------------------------------ $kFavorites==true?($macroModules=$macroModules."AddFavorite2;"):0;[/code][/quote]
[Please Enable JavaScript]
K-Meleon forum is powered by
Phorum
.
Home/News
Screenshots
Download
Documentation
Resources
Get Involved
Forum
Bugs
Development