# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)

# ---------- Browser Configuration ---------------------------------------------------------------------------------
#
# Dependencies	: main.kmm (getExtensionHandler)
# Resources	: -
# Preferences	: -
#
# ------------------------------------------------------------------------------------------------------------------

cfg_FileNotFound{
alert(sub("%s",$cfg_File,_("The file %s could not be found.")),sub("&","",_($_cfg)),EXCLAIM);
}

cfg_ProfileDir{
macroinfo=_("Open the profile directory");
exec("explorer.exe \"".getfolder(ProfileFolder)."\"");
}
cfg_SettingsDir{
macroinfo=_("Open the settings directory");
exec("explorer.exe \"".getfolder(SettingsFolder)."\"");
}

cfg_Macros{
macroinfo=_("Open the default macros directory");
exec("explorer.exe \"".getfolder(MacroFolder)."\"");
}
cfg_UserMacros{
macroinfo=_("Open the user macros directory");
exec("explorer.exe \"".getfolder(UserMacroFolder)."\"");
}

cfg_Commands{
macroinfo=_("View a list of commands available for menus, macros and toolbars");
opentab(getfolder(RootFolder)."\\\browser\\defaults\\commands.html");
}

cfg_Default{
macroinfo=_("Edit a configuration file");
$cmdline = getExtensionHandler("cfg"); 
$cfg_File=$ARG."."."cfg"; $__temp="\\defaults\\settings\\";
$__path=getfolder(RootFolder)."\\browser\\defaults\\settings\\".$cfg_File; $__data=readfile($__path);
$__data==""?$__path=getfolder(RootFolder).$__temp.$cfg_File:0;
$__data==""?&cfg_FileNotFound:exec(sub("%1",$__path,$cmdline));
}

cfg_Skin{
macroinfo=_("Edit a skin configuration file");
$cmdline = getExtensionHandler("cfg");
$cfg_File=$ARG."."."cfg";
$__file="\\".$cfg_File; $__skin="\\".basename(getfolder(SkinFolder));
$__root=getpref(STRING,"kmeleon.general.skinsDir")?getpref(STRING,"kmeleon.general.skinsDir"):getfolder(RootFolder)."\\skins";
$__path=getfolder(SettingsFolder)."\\skins".$__skin.$__file; $__data=readfile($__path);
$__data==""?$__path=$__root.$__skin.$__file:0; $__data=readfile($__path);
index($__skin,"(")?$__skin=substr($__skin,0,index($__skin,"(")):0;
$__data==""?$__path=$__root.$__skin.$__file:0; $__data=readfile($__path);
$__data==""?&cfg_FileNotFound:exec(sub("%1",$__path,$cmdline));
}

cfg_Settings{
macroinfo=_("Edit a configuration file");
$cmdline = getExtensionHandler("cfg");
$cfg_File=$ARG."."."cfg"; $__temp="\\browser\\defaults\\settings\\";
$__path=getfolder(SettingsFolder)."\\".$cfg_File; $__data=readfile($__path);
$__data==""?$__path=getfolder(RootFolder).$__temp.$cfg_File:0;
$__data==""?&cfg_FileNotFound:exec(sub("%1",$__path,$cmdline));
}
cfg_UserPrefs{
macroinfo=_("Edit a preferences file");
$cmdline = getSecureExtensionHandler("js");
$cfg_File=$ARG."."."js";
$__path=getfolder(ProfileFolder)."\\".$cfg_File; $__data=readfile($__path);
$__data==""?&cfg_FileNotFound:exec(sub("%1",$__path,$cmdline));
}
cfg_UserStyle{
macroinfo=_("Edit a user style sheet");
$cmdline = getExtensionHandler("css");
$cfg_File=$ARG."."."css";
$__path=getfolder(ProfileFolder)."\\chrome\\".$cfg_File; $__data=readfile($__path);
$__data==""?&cfg_FileNotFound:exec(sub("%1",$__path,$cmdline));
}

cfg_Toolbar{
$ARG="toolbars";
if ( fileexists(getfolder(SkinFolder)."\\toolbars.cfg" ))
  &cfg_Skin;
else
  &cfg_Default;
}

cfg_Icons{
$ARG=fileexists(getfolder(SkinFolder)."\\menuicons.cfg" )?"menuicons":"skin";
&cfg_Skin;
}

# ----- PRIVATE

$_cfg="C&onfiguration";

_cfg_BuildMenu{
# edit menu
setmenu(Preferences,popup,$_cfg,moz_AboutConfig);
setmenu(Preferences,macro,"",moz_AboutConfig);
$__m=_Config_General;
setmenu($_cfg,inline,$__m);
setmenu($__m,macro,"Browser Con&figuration",moz_AboutConfig);
#setmenu($__m,macro,"&Profile Settings","cfg_UserPrefs(prefs)");
setmenu($__m,macro,"&User Settings","cfg_UserPrefs(user)");
$__m=_Config_Appearance;
setmenu($_cfg,inline,$__m);
setmenu($__m,macro,"User-Defined &StyleSheet","cfg_UserStyle(userContent)");
setmenu($__m,macro,"Ad-&Blocking StyleSheet","cfg_UserStyle(adblock)");
setmenu($__m,macro,"&Toolbars","cfg_Toolbar");
setmenu($__m,macro,"Me&nu Icons","cfg_Icons");
$__m=_Config_Settings;
setmenu($_cfg,inline,$__m);
setmenu($__m,macro,"A&ccelerators","cfg_Settings(accel)");
setmenu($__m,macro,"M&acros","cfg_Macros");
setmenu($__m,macro,"User-Defined Macr&os","cfg_UserMacros");
setmenu($__m,macro,"M&enus","cfg_Settings(menus)");
setmenu($__m,macro,"Co&mmands List",cfg_Commands);
$__m=_Config_Folders;
setmenu($_cfg,inline,$__m);
setmenu($__m,macro,"Profile &Directory",cfg_ProfileDir);
getfolder(ProfileFolder)==getfolder(SettingsFolder)?0:setmenu($__m,macro,"Settings D&irectory",cfg_SettingsDir);
}
$OnInit=$OnInit."_cfg_BuildMenu;";

# ------------------------------------------------------------------------------------------------------------------
$macroModules=$macroModules."cfg;";