K-Meleon

KMeleonWiki > Resources > MacroLibrary > KmmGroups2

Submitted by: JamesD and desga2



Notes:

Groups2.kmm adds a limited groups function for KM version 1.5 and later. It does not replace Sessions, but can be used in addition to sessions. Groups2 can add a tab or group of tabs without clearing currently open tabs.

To save a group have a tab or multiple tabs open to the pages you desire and choose 'Save a Group' from the menu.

There are three ways to load a group. 1) You can click on the group's name in the menu. 2) You can enter the group's name in the URL bar and press ALT + ENTER. 3) You can use the 'Load a Group' item from the menu. This will pop up a box where you can enter the group name. Note that this method will clear any currently open tabs.


Updates:

2009-02-05
Minor bug fixes


2010-06-02
Major upgrade


Changelog

- Delete _Groups2_compat function, unused and old.
+ Add Export groups to ini file function.
+ Add Import from an ini file function, with two options: Replace and Merge.
+ Backup your groups in ini file before Import from an ini file.
+ Open a group in K-Meleon at startup.
+ Sort function to sort in alphabetical order your list of groups.
+ Report status of operations in the statusbar.
+ Option to remember Export, Import, and Backup paths.
+ Translate function added to all displayed text.
+ Other minor fixes, corrections, documentation and comments in code.


2010-08-19
Minor upgrade


Changelog

+ Add session history/restore for group deletes
+ Add HotGroups support for K-Meleon's Hotlinks
+ Add Options - About for easy checking of version number
+ Minor fix to prevent groups count from being a negative number


Open your User Macro Folder (Edit > Configuration > User-Defined Macros) or your Macro Folder (Edit > Configuration > Macros) and create the following text file:

Groups2.kmm

# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
# File name: Groups2.kmm
# ---------- Groups2 in tabs for K-Meleon 1.5.x and later -------------------------------
#
# Dependencies        : main.kmm KM version 1.5 or later and tabs
# Resources                : -
# Preferences        : k-meleon_Groups2.<group_name>.<#> = URL
#                                : k-meleon_Groups2.<group_name>.count = Number of URLs in group
#                                : k-meleon_Groups2.count = Total of groups count
#                                : k-meleon_Groups2.<#> = Group name
#                                : k-meleon_Groups2_History.<group_name>.<#> = URL
#                                : k-meleon_Groups2_History.<group_name>.count = Number of URLs in group
#                                : k-meleon_Groups2_History.count = Total of groups count
#                                : k-meleon_Groups2_History.<#> = Group name
#                                : k-meleon_Groups2.startup = Start group name
#                                : k-meleon_Groups2.exportpath, k-meleon_Groups2.importpath,
#                                : k-meleon_Groups2.backuppath, k-meleon_Groups2.paths
#                                : k-meleon_Groups2.HotGroup[0-9] = Boolean enable a Hotgroup for a Hotlink
# Version                : 0.6.7   2010-08-18
# Authors                : JamesD and desga2
# ---------------------------------------------------------------------------------------

_Groups2_About {
macroinfo = _("Groups2.kmm  version 0.6.7   2010-08-18");
alert(_("Groups2.kmm  version 0.6.7   2010-08-18"), _(Groups2) );
}

_Groups2_RunCode_Save {
macroinfo = _("Save the current tab's URLs as a group.");
$_Groups2_Name = prompt(_("Assign a name to save this group of tabs."), _("Group Name to save"));
macros(_Groups2_Symbols);
if ($_Groups2_Name != "") {
                macros("_Groups2_ObtainC");
                if ($_Groups2_Match == "true") {
                                $_Goverwrite = confirm(_("Group name: '") . $_Groups2_Name . _("' already exist.\nDo you want overwrite it?"), _("Group Name to save"), YESNO, QUESTION);
                                $_Goverwrite == "YES" ? plugin(macros, "_Goverwrite(" . $_Groups2_Name . ")") : 0;
                } else {
                                setpref(STRING, "k-meleon_Groups2." . $_Groups2_Exist_Count, $_Groups2_Name);
                                $_Groups2_Exist_Count = $_Groups2_Exist_Count + 1;
                                setpref(INT, "k-meleon_Groups2.count", $_Groups2_Exist_Count);
                                $_Groups2_Number_of_Tabs = $TabNumber;
                                $_Groups2_Tab_Count = 0;
                                while ($_Groups2_Tab_Count < $_Groups2_Number_of_Tabs) &_Groups2_Save_Loop;
                                &_Groups2_BuildGroupsMenu;
                }
}
}

_Groups2_Symbols {
$_Groups2_SymbolName = gsub( "&", "+", $_Groups2_Name );
if ($_Groups2_SymbolName != $_Groups2_Name) {
        $__gt1 = _("The & character is not allowed")."\n\n" ;
        $__gt2 = $_Groups2_Name ."  ". _("has been changed to")."\n\n" ;
        alert($__gt1 . $__gt2 . $_Groups2_SymbolName , _("Required name change"),EXCLAIM);
        $_Groups2_Name = $_Groups2_SymbolName ;
}
}

_Groups2_Save_Loop {
$_Groups2_Tab_Count == 0 ? setpref(INT, "k-meleon_Groups2." . $_Groups2_Name . ".count", $_Groups2_Number_of_Tabs) : 0;
id(ID_TAB_NEXT);
setpref(STRING, "k-meleon_Groups2." . $_Groups2_Name . "." . $_Groups2_Tab_Count, $URL);
$_Groups2_Tab_Count = $_Groups2_Tab_Count + 1;
}

_Goverwrite {
$_Groups2_Name = $ARG;
$_Groups2_Number_of_Tabs = getpref(INT, "k-meleon_Groups2." . $_Groups2_Name . ".count");
$_Groups2_Tab_Count = 0;
while ($_Groups2_Tab_Count < $_Groups2_Number_of_Tabs) &_Groups2_Delete_Loop;
$_Groups2_Number_of_Tabs = $TabNumber;
$_Groups2_Tab_Count = 0;
while ($_Groups2_Tab_Count < $_Groups2_Number_of_Tabs) &_Groups2_Save_Loop;
}

Groups2_OpenGroup {
$_Groups2_Name = $ARG;
$_Groups2_Name == "" ? $_Groups2_Name = $URLBAR : 0; $_Groups2_Name == "" ? $_Groups2_Name = $URL : 0;
$_Groups2_Name == $URL ? 0 : $_Groups2_Number_of_Tabs = getpref(INT, "k-meleon_Groups2." . $_Groups2_Name . ".count");
$_Groups2_Tab_Count = 0;
if ($_Groups2_Name != $URL) while ($_Groups2_Tab_Count < $_Groups2_Number_of_Tabs) &_Groups2_Load_Loop;
}

_Groups2_RunCode_Load {
macroinfo = _("Load a saved group of tabs.");
$_Groups2_Name = prompt(_("Enter name of group to load."), _("Group Name to load"));
if ($_Groups2_Name != "") {
                macros("_Groups2_ObtainC");
                if ($_Groups2_Match == "true") {
                                $_Groups2_Number_of_Tabs = getpref(INT, "k-meleon_Groups2." . $_Groups2_Name . ".count");
                                $_Groups2_Tab_Count = 0;
                                id(ID_CLOSE_ALLTAB);
                                $URLBAR = "about:blank";
                                while ($_Groups2_Tab_Count < $_Groups2_Number_of_Tabs) &_Groups2_Load_Loop;
                } else { alert(_("No group found with name: ") . $_Groups2_Name, _("Group Name to load"), EXCLAIM); }
}
}

_Groups2_Load_Loop {
$_Groups2_URL = getpref(STRING, "k-meleon_Groups2." . $_Groups2_Name . "." . $_Groups2_Tab_Count);
if ($URLBAR == "about:blank") {
                open($_Groups2_URL);
                $URLBAR = "";
} else {
                opentab($_Groups2_URL);
}
$_Groups2_Tab_Count = $_Groups2_Tab_Count + 1;
}

_Groups2_RunCode_Delete {
macroinfo = _("Delete a saved group of tabs.");
$_Groups_ATD = getpref(INT, "k-meleon_Groups2.count");
$_Groups_ATD < 1 ? &_Groups2_NoDelete : &_Groups2_Delete2 ;
}

_Groups2_NoDelete {
alert(_("There are no groups to delete"), _("Action halted"),EXCLAIM);
}

_Groups2_Delete2 {
$_Groups2_Name = prompt(_("Enter name of group to delete."), _("Group Name to delete"));
if ($_Groups2_Name != "") {
        macros("_Groups2_ObtainC");
        if ($_Groups2_Match == "true") {
                $_Groups2_DelName = $_Groups2_Name;
                macros("_Groups2_collapse");
                plugin(macros, "_Groups2_Get_Hg(Delete)"); 
                macros("_Groups2_Del_to_History");
                macros("_Groups2_ReLoadHistMatch");
                setpref(STRING,"k-meleon_Groups2_History." . $_Groups2_Hcount-1 , $_Groups2_NewRName);                
                $_Groups2_Number_of_Tabs = getpref(INT, "k-meleon_Groups2." . $_Groups2_Name . ".count");
                $_Groups2_Tab_Count = 0;
                while ($_Groups2_Tab_Count < $_Groups2_Number_of_Tabs) &_Groups2_Delete_Loop;
                setpref(INT, "k-meleon_Groups2.count", $_Groups2_Exist_Count - 1);
                &_Groups2_BuildGroupsMenu;
        } else {
                alert("No group found with name: " . $_Groups2_Name, "Group Name to delete", EXCLAIM);
        }
}
}

_Groups2_Del_to_History {
## add 1 to the existing history count
$_Groups2_Hcount = getpref(INT,"k-meleon_Groups2_History.count");
$_Groups2_Hcount = $_Groups2_Hcount + 1 ;
setpref(INT,"k-meleon_Groups2_History.count",$_Groups2_Hcount);
}

_Groups2_ReLoadHistMatch {
$_Groups2_NewRName = $_Groups2_Name;
## HExist_Count should be the original count before _Groups2_Del_to_History increased it
$_Groups2_HExist_Count = $_Groups2_Hcount -1;
$_Groups2_RMatch = "false" ;
macros(_Groups2_ReLoadHistMatch2);
}

_Groups2_ReLoadHistMatch2 {
if ($_Groups2_HExist_Count != 0) {
        $_GU_cntr = 0;
        ## get group names over the existing history count
        while ($_GU_cntr < $_Groups2_HExist_Count) { 
                $_Groups2_EName = getpref(STRING, "k-meleon_Groups2_History." . $_GU_cntr);
                ## compare existing name to the one currently being deleted
                $_Groups2_RMatch = $_Groups2_NewRName == $_Groups2_EName ? "true" : "false";
                if ($_Groups2_RMatch == "true") {
                        $_GU_cntr = $_Groups2_HExist_Count;
                } 
        $_GU_cntr = $_GU_cntr + 1; 
        }
}
$_Groups2_RMatch == "true" ? &_Groups2_ReLoadHistMatch3 : 0 ;        
}

_Groups2_ReLoadHistMatch3 {
$_Groups2_ExtNRN = "{" . $_Groups2_ExtCnt . "}" ;
$_Groups2_NewRName = $_Groups2_NewRName . " " . $_Groups2_ExtNRN ;
$_Groups2_ExtCnt = $_Groups2_ExtCnt + 1 ;
macros(_Groups2_ReLoadHistMatch2);
}


_Groups2_Delete_Loop {
setpref(INT,"k-meleon_Groups2_History." . $_Groups2_NewRName . ".count",$_Groups2_Tab_Count +1);
$_Groups2_Tab_Count == 0 ? delpref("k-meleon_Groups2." . $_Groups2_Name . ".count") : 0;
setpref(STRING,"k-meleon_Groups2_History.". $_Groups2_NewRName . "." . $_Groups2_Tab_Count, getpref(STRING,"k-meleon_Groups2.". $_Groups2_Name . "." . $_Groups2_Tab_Count)) ;
delpref("k-meleon_Groups2." . $_Groups2_Name . "." . $_Groups2_Tab_Count);
$_Groups2_Tab_Count = $_Groups2_Tab_Count + 1;
}
_Groups2_ObtainC {
$_Groups2_Match = "false" ;
$_Groups2_Exist_Count = getpref(INT, "k-meleon_Groups2.count");
if ($_Groups2_Exist_Count != 0) {
                $_GU_cntr = 0;
                while ($_GU_cntr < $_Groups2_Exist_Count) { macros("_Groups2_Read"); }
                }
}

_Groups2_Read {
$_Groups2_EName = getpref(STRING, "k-meleon_Groups2." . $_GU_cntr);
$_Groups2_Match = $_Groups2_Name == $_Groups2_EName ? "true" : "false";
if ($_Groups2_Match == "true") {
                $_Groups2_Match_cntr = $_GU_cntr;
                $_GU_cntr = $_Groups2_Exist_Count;
        } else { $_GU_cntr = $_GU_cntr + 1; }
}

_Groups2_collapse {
while ($_Groups2_Match_cntr + 1 < $_Groups2_Exist_Count) {
                $_Groups2_collapse_value = getpref(STRING, "k-meleon_Groups2." . $_Groups2_Match_cntr + 1);
                setpref(STRING, "k-meleon_Groups2." . $_Groups2_Match_cntr, $_Groups2_collapse_value);
                $_Groups2_Match_cntr = $_Groups2_Match_cntr + 1;
                }
delpref("k-meleon_Groups2." . $_Groups2_Exist_Count - 1);
}

_Groups2_Get_Hg {
$_Groups2_DelMethod = $ARG ;
$_Groups2_HgCnt = 0;
while($_Groups2_HgCnt < 10) {
        ## Obtain true/false status of hotgroup #HgCnt
        $_Groups2_Exist_Hg = getpref(BOOL, "k-meleon_Groups2.HotGroup" . $_Groups2_HgCnt);
        if ($_Groups2_Exist_Hg == true) {
                $_Groups2_Exist_Hg = getpref(STRING, "kmeleon.plugins.macros.hotlink" . $_Groups2_HgCnt . ".url");
                if ($_Groups2_Name == $_Groups2_Exist_Hg) {
                        $_Groups2_DelMethod == "Replace" ? $_Groups2_RMHg = confirm( _("Do you wish to remove the hotlink?"), _("A hotlink exists for group '").$_Groups2_Name."' being replaced.", YESNO, QUESTION) : 0;
                        $_Groups2_DelMethod == "Delete"  ? $_Groups2_RMHg = confirm( _("Do you wish to remove the hotlink?"), _("A hotlink exists for group '").$_Groups2_Name."' being deleted.", YESNO, QUESTION) : 0;
                        $_Groups2_HgCnt2 = $_Groups2_HgCnt ;
                        $_Groups2_RMHg == "YES" ? &_Groups2_Del_Hg : 0;
                        $_Groups2_HgCnt = 10;
                }
        }        
        $_Groups2_HgCnt = $_Groups2_HgCnt + 1; 
}
}

_Groups2_Del_Hg {
togglepref(BOOL,"k-meleon_Groups2.HotGroup" .$_Groups2_HgCnt2) ;
setpref(STRING,"kmeleon.plugins.macros.hotlink" .$_Groups2_HgCnt2.".url", "");
}

_Groups2_Restore {
macroinfo = _("Restore a group deleted in the current session.");
$_Groups2_HisMax = getpref(INT,"k-meleon_Groups2_History.count");
$_Groups2_HisMax < 1 ? &_Groups2_NoHist : &_Groups2_Restore2 ;
}

_Groups2_NoHist {
alert(_("No groups available in history."), _("History data"),EXCLAIM);
}

_Groups2_Restore2 {
$_Groups2_HisCnt = 0 ; $_Groups2_HisName = "" ;
while ( $_Groups2_HisCnt < $_Groups2_HisMax ) {
        $_Groups2_HisN = getpref(STRING,"k-meleon_Groups2_History." . $_Groups2_HisCnt);
        $_Groups2_HisName = $_Groups2_HisName . $_Groups2_HisCnt . " ... " . $_Groups2_HisN . "\n" ;
        $_Groups2_HisCnt = $_Groups2_HisCnt + 1 ;
        }
## prompt for group
alert($_Groups2_HisName. "\n\n". _("Use the number at the next prompt"), _("Note the number by your choice"));
$_Groups2_HistRN = prompt(_("Enter the number for the group"));
## validate user's choice
$_Groups2_HistRN == "" ? &_Groups2_ReLCancel : &_Groups2_ReLRange ;
}

_Groups2_ReLCancel {
$_Groups2_CancelH = confirm(_("Did you mean to cancel?"),_("Choice was cancelled"),YESNO,QUESTION);
$_Groups2_CancelH == "YES" ? 0 : &_Groups2_Restore2 ;
}

_Groups2_ReLRange {
if ( $_Groups2_HistRN >= 0 ) {
        if ( $_Groups2_HistRN <= $_Groups2_HisMax -1) {
                macros(_Groups2_ReLoadMatch) ;
        } else { macros(_Groups2_BadRange); }
}
}

_Groups2_BadRange {
$_Groups2_ErrRange = confirm(_("Do you wish to try again?"),_("Your answer was out of range"),YESNO,QUESTION);
$_Groups2_ErrRange == "YES" ? &_Groups2_Restore2 : 0 ;
}

_Groups2_ReLoadMatch {
$_Groups2_NewRName = getpref(STRING,"k-meleon_Groups2_History." .$_Groups2_HistRN);
$_Groups2_HFindName = $_Groups2_NewRName ;  ## for reading history if name extended
$_Groups2_Exist_Count = getpref(INT, "k-meleon_Groups2.count");
$_Groups2_RMatch = "false" ;
macros(_Groups2_ReLoadMatch2);
}

_Groups2_ReLoadMatch2 {
if ($_Groups2_Exist_Count != 0) {
        $_GU_cntr = 0;
        while ($_GU_cntr < $_Groups2_Exist_Count) { 
                $_Groups2_EName = getpref(STRING, "k-meleon_Groups2." . $_GU_cntr);
                $_Groups2_RMatch = $_Groups2_NewRName == $_Groups2_EName ? "true" : "false";
                if ($_Groups2_RMatch == "true") {
                        $_GU_cntr = $_Groups2_Exist_Count;
                        } else { $_GU_cntr = $_GU_cntr + 1; }
        }
}
$_Groups2_RMatch == "true" ? &_Groups2_ReLoadMatch3 : &_Groups2_ReLoad ;        
}

_Groups2_ReLoadMatch3 {
$_Groups2_ExtNRN = "{" . $_Groups2_ExtCnt . "}" ;
$_Groups2_NewRName = $_Groups2_NewRName . " " . $_Groups2_ExtNRN ;
$_Groups2_ExtCnt = $_Groups2_ExtCnt + 1 ;
macros(_Groups2_ReLoadMatch2);
}

_Groups2_ReLoad {
statusbar(_("Groups2 Restore running"));
$_Groups2_NewRcnt = getpref(INT,"k-meleon_Groups2.count") ;
# raise the active count by 1 and assign last count to name from history
setpref(INT,"k-meleon_Groups2.count", $_Groups2_NewRcnt + 1 );
setpref(STRING, "k-meleon_Groups2." . $_Groups2_NewRcnt, $_Groups2_NewRName);
# get count of tabs from history and assign last count to name from history
$_Groups2_HTabCnt = getpref(INT,"k-meleon_Groups2_History." . $_Groups2_HFindName . ".count");
setpref(INT,"k-meleon_Groups2.". $_Groups2_NewRName . ".count", $_Groups2_HTabCnt ) ;
$_Groups2_HTcnt = 0 ;
while($_Groups2_HTcnt < $_Groups2_HTabCnt) {
        $_Groups2_hURL = getpref(STRING,"k-meleon_Groups2_History." . $_Groups2_HFindName . "." .$_Groups2_HTcnt);
        setpref(STRING,"k-meleon_Groups2." . $_Groups2_NewRName . "." .$_Groups2_HTcnt ,$_Groups2_hURL);
        $_Groups2_HTcnt = $_Groups2_HTcnt + 1;
}
macros("_Groups2_BuildGroupsMenu");
statusbar(_("Restore complete"));
}

_Groups2_RunCode_Paths {
menuchecked = getpref(BOOL, "k-meleon_Groups2.paths") == true;
# Checkmark value for the menu must be the first line in macro function.
togglepref(BOOL, "k-meleon_Groups2.paths");
}

_Groups2_RunCode_Export {
macroinfo = _("Export the current groups to an ini file.");
if (getpref(BOOL, "k-meleon_Groups2.paths") == true) {
                $_Groups2_Initial_Export_Path = getpref(STRING, "k-meleon_Groups2.exportpath");
                if (length($_Groups2_Initial_Export_Path) != 0) {
                                $_Groups2_Export_Path = promptforfolder(_("Select a folder to contain your exported file."), $_Groups2_Initial_Export_Path);
                                } else {
                                $_Groups2_Export_Path = promptforfolder(_("Select a folder to contain your exported file."), getfolder(UserMacroFolder));
                }
} else {
                $_Groups2_Export_Path = promptforfolder(_("Select a folder to contain your exported file."), getfolder(UserMacroFolder));
}
if ($_Groups2_Export_Path != "") {
                if (getpref(BOOL, "k-meleon_Groups2.paths") == true) {
                                setpref(STRING, "k-meleon_Groups2.exportpath", $_Groups2_Export_Path);
                }
                $_Groups2_Export_FullPath = $_Groups2_Export_Path . "\\Groups2.ini";
                ##  Count the groups
                $_Groups2_Export_Cnt = getpref(INT, "k-meleon_Groups2.count");
                if ($_Groups2_Export_Cnt == 0) {
                                alert(_("No groups found in K-Meleon prefs."), _("Warning"), EXCLAIM);
                } else {
                                $_Groups2_Backup = "false";
                                macros("_Groups2_RunCode_Export2");
                                }
                }
}

_Groups2_RunCode_Export2 {
statusbar(_("Exporting to ") . $_Groups2_Export_FullPath);
$_Groups2_Export_Section = "Groups";
$_Groups2_Export_Key = "Count";
$_Groups2_Export_Value = $_Groups2_Export_Cnt;
iniwrite($_Groups2_Export_Section, $_Groups2_Export_Key, $_Groups2_Export_Value, $_Groups2_Export_FullPath);
if ($_Groups2_Backup == "true") { delpref("k-meleon_Groups2.count"); }
$__GCnt = 0;
while ($__GCnt < $_Groups2_Export_Cnt) {
                $_Groups2_Export_Section = $__GCnt;
                $_Groups2_Export_Key = "Name";
                ##  Retain group name
                $_Groups2_Export_GName = getpref(STRING, "k-meleon_Groups2." . $__GCnt);
                ## next line is for deleting hotgroups if required
                $_Groups2_Name = $_Groups2_Export_GName ;
                if ($_Groups2_Backup == "true") { plugin(macros, "_Groups2_Get_Hg(Replace)"); }
                ##  Delete from menu if import backup
                if ($_Groups2_Backup == "true") {
                                setmenu("_Groups_List", macro, $_Groups2_Export_GName, "");
                                rebuildmenu("_Groups_List");
                                }
                $_Groups2_Export_Value = $_Groups2_Export_GName;
                iniwrite($_Groups2_Export_Section, $_Groups2_Export_Key, $_Groups2_Export_Value, $_Groups2_Export_FullPath);
                if ($_Groups2_Backup == "true") { delpref("k-meleon_Groups2." . $__GCnt); }
                ##  Write the count of URLs in the group
                $_Groups2_Export_Key = "GCount";
                $_Groups2_Export_GCount = getpref(INT, "k-meleon_Groups2." . $_Groups2_Export_GName . ".count");
                $_Groups2_Export_Value = $_Groups2_Export_GCount;
                iniwrite($_Groups2_Export_Section, $_Groups2_Export_Key, $_Groups2_Export_Value, $_Groups2_Export_FullPath);
                if ($_Groups2_Backup == "true") { delpref("k-meleon_Groups2." . $_Groups2_Export_GName . ".count"); }
                ##  Write the URLs in the group to file
                $__GnCnt = 0;
                while ($__GnCnt < $_Groups2_Export_GCount) {
                                ##  Write the name of an URL in the group
                                $_Groups2_Export_Key = "URL_" . $__GnCnt;
                                $_Groups2_Export_URL = getpref(STRING, "k-meleon_Groups2." . $_Groups2_Export_GName . "." . $__GnCnt);
                                $_Groups2_Export_Value = $_Groups2_Export_URL;
                                $_Gp2_URL_len = length($_Groups2_Export_URL);
                                if ($_Gp2_URL_len > 255) {
                                                alert(_("The next item will be trimmed to 256 characters in the exported ini file:") . "\n" . $_Groups2_Export_URL, _("Warning"), EXCLAIM);
                                                $_Groups2_Export_Value = substr($_Groups2_Export_URL, 0, 255);
                                }
                                iniwrite($_Groups2_Export_Section, $_Groups2_Export_Key, $_Groups2_Export_Value, $_Groups2_Export_FullPath);
                                if ($_Groups2_Backup == "true") { delpref("k-meleon_Groups2." . $_Groups2_Export_GName . "." . $__GnCnt); }
                                ##  Increment the groupcount variable
                                $__GnCnt = $__GnCnt + 1;
                }
##  Increment the count variable
$__GCnt = $__GCnt + 1;
}
if ($_Groups2_Backup == "true") {
                macros("_Groups2_BuildGroupsMenu");
                statusbar(_("Backup complete"));
                } else { statusbar(_("Export complete")); }
}

_Groups2_RunCode_Import {
macroinfo = _("Replace current groups with those from an ini file.");
if (getpref(BOOL, "k-meleon_Groups2.paths") == true ) {
                $_Groups2_Initial_Import_Path = getpref(STRING, "k-meleon_Groups2.importpath");
                if (length($_Groups2_Initial_Import_Path) != 0) {
                                $_Groups2_Import_Path = promptforfile($_Groups2_Initial_Import_Path, _("Groups2 ini files"), "Groups2.ini;G2BkUp.ini");
                                } else {
                                $_Groups2_Import_Path = promptforfile(getfolder(UserMacroFolder), _("Groups2 ini files"), "Groups2.ini;G2BkUp.ini");
                }
} else {
                $_Groups2_Import_Path = promptforfile(getfolder(UserMacroFolder), _("Groups2 ini files"), "Groups2.ini;G2BkUp.ini");
}
if ($_Groups2_Import_Path != "") {
                if (getpref(BOOL, "k-meleon_Groups2.paths") == true) {
                                setpref(STRING, "k-meleon_Groups2.importpath", $_Groups2_Import_Path);
                }
                ##  Value remains after delete because iniread is reading cached info in registry
                $__Value = iniread("", "", "", "");
                $_Groups2_Import_Section = "Groups";
                $_Groups2_Import_Key = "Count";
                $_Groups2_Import_Value = "";
                ##  Check count of groups in ini file
                $_Groups2_Import_Cnt = iniread($_Groups2_Import_Section, $_Groups2_Import_Key, $_Groups2_Import_Value, $_Groups2_Import_Path);
                if ($_Groups2_Import_Cnt == 0) {
                                alert(_("No groups found in the ini file."), _("Warning"), EXCLAIM);
                } else {
                                $_Groups2_Backup = "false";
                                $ARG == "Merge" ? plugin(macros, "_Groups2_RunCode_Import2(" . $_Groups2_Merge . ")") : macros("_Groups2_RunCode_Import2");
                                }
                }
}

_Groups2_RunCode_Import2 {
##  Check for currently existing groups
$_Groups2_Current_Cnt = getpref(INT, "k-meleon_Groups2.count");
if ($_Groups2_Current_Cnt != 0) {
                $ARG == "Merge" ? plugin(macros, "_Groups2_RunCode_BackUp(" . $_Groups2_Merge . ")") : macros("_Groups2_RunCode_BackUp");
} else {
                macros("_Groups2_RunCode_Import3");
                }
}

_Groups2_RunCode_BackUp {
##  Export all groups to an ini file
if (getpref(BOOL, "k-meleon_Groups2.paths") == true) {
                $_Groups2_Initial_Backup_Path = getpref(STRING, "k-meleon_Groups2.backuppath");
                if (length($_Groups2_Initial_Backup_Path) != 0) {
                                $_Groups2_Backup_Path = promptforfolder(_("Select a folder to contain your backup file."), $_Groups2_Initial_Backup_Path);
                                } else {
                                $_Groups2_Backup_Path = promptforfolder(_("Select a folder to contain your backup file."), getfolder(UserMacroFolder));
                }
} else {
                $_Groups2_Backup_Path = promptforfolder(_("Select a folder to contain your backup file."), getfolder(UserMacroFolder));
}
if ($_Groups2_Backup_Path != "") {
                if (getpref(BOOL, "k-meleon_Groups2.paths") == true) {
                                setpref(STRING, "k-meleon_Groups2.backuppath", $_Groups2_Backup_Path);
                }
                $_Groups2_Export_FullPath = $_Groups2_Backup_Path . "\\G2BkUp.ini";
                $_Groups2_Export_Cnt = $_Groups2_Current_Cnt;
                $ARG == "Merge" ? $_Groups2_Backup = "false" : $_Groups2_Backup = "true";
                macros("_Groups2_RunCode_Export2");
                $ARG == "Merge" ? macros("_Groups2_RunCode_Import4") : macros("_Groups2_RunCode_Import3");
                }
if ($_Groups2_Backup_Path == "") alert(_("No backup path was selected.\nBackup prior to import is required.\nImport is aborted."), _("Backup path selection cancelled"), EXCLAIM);
}

_Groups2_RunCode_Import3 {
statusbar(_("Importing from ") . $_Groups2_Import_Path);
##  Write the count of groups to pref "k-meleon_Groups2.count"
setpref(INT, "k-meleon_Groups2.count", $_Groups2_Import_Cnt);
$__GCnt = 0;
while ($__GCnt < $_Groups2_Import_Cnt) {
                $_Groups2_Import_Section = $__GCnt;
                $_Groups2_Import_Key = "Name";
                $_Groups2_Import_Value = iniread($_Groups2_Import_Section, $_Groups2_Import_Key, $_Groups2_Import_Value, $_Groups2_Import_Path);
                $_Groups2_Import_GName = $_Groups2_Import_Value;
                setpref(STRING, "k-meleon_Groups2." . $__GCnt, $_Groups2_Import_GName);
                $_Groups2_Import_Key = "GCount";
                $_Groups2_Import_Value = iniread($_Groups2_Import_Section, $_Groups2_Import_Key, $_Groups2_Import_Value, $_Groups2_Import_Path);
                $_Groups2_Import_GCount = $_Groups2_Import_Value;
                setpref(INT, "k-meleon_Groups2." . $_Groups2_Import_GName . ".count", $_Groups2_Import_GCount);
                $__GnCnt = 0;
                while ($__GnCnt < $_Groups2_Import_GCount) {
                                $_Groups2_Import_Key = "URL_" . $__GnCnt;
                                $_Groups2_Import_Value = iniread($_Groups2_Import_Section, $_Groups2_Import_Key, $_Groups2_Import_Value, $_Groups2_Import_Path);
                                $_Groups2_Import_URL = $_Groups2_Import_Value;
                                setpref(STRING, "k-meleon_Groups2." . $_Groups2_Import_GName . "." . $__GnCnt, $_Groups2_Import_URL);
                                ##  Increment the groupcount variable
                                $__GnCnt = $__GnCnt + 1;
                                }
                ##  Increment the count variable
                $__GCnt = $__GCnt + 1;
                }
macros("_Groups2_BuildGroupsMenu");
statusbar(_("Import complete"));
}

_Groups2_RunCode_Import4 {
statusbar(_("Importing from ") . $_Groups2_Import_Path);
$_Groups2_Exist_Count = getpref(INT, "k-meleon_Groups2.count");
$_Groups2_Import_New = 0;
$__GCnt = 0;
while ($__GCnt < $_Groups2_Import_Cnt) {
                $_Groups2_Import_Section = $__GCnt;
                $_Groups2_Import_Key = "Name";
                $_Groups2_Import_Value = iniread($_Groups2_Import_Section, $_Groups2_Import_Key, $_Groups2_Import_Value, $_Groups2_Import_Path);
                $_Groups2_Import_GName = $_Groups2_Import_Value;
                $_Groups2_Import_Key = "GCount";
                $_Groups2_Import_Value = iniread($_Groups2_Import_Section, $_Groups2_Import_Key, $_Groups2_Import_Value, $_Groups2_Import_Path);
                $_Groups2_Import_GCount = $_Groups2_Import_Value;
                $_Groups2_Import_exist = "false";
                #  Check if import group already exist
                $_GU_cntr = 0;
                while ($_GU_cntr < $_Groups2_Exist_Count) {
                                $_Groups2_EName = getpref(STRING, "k-meleon_Groups2." . $_GU_cntr);
                                if ($_Groups2_EName == $_Groups2_Import_GName) {
                                                $_Groups2_Import_exist = "true";
                                                $_GU_cntr = $_Groups2_Exist_Count;
                                } else {
                                                $_GU_cntr = $_GU_cntr + 1;
                                }
                }
                # If import group already exist confirm replace it
                if ($_Groups2_Import_exist == "true") {
                                $_Greplace = confirm(_("Group name: '") . $_Groups2_Import_GName . _("' already exist.\nDo you want replace it?"), _("Import Merge existing group"), YESNO, QUESTION);
                                if ($_Greplace == "YES") {
                                                $_Groups2_Local_GCount = getpref(INT, "k-meleon_Groups2." . $_Groups2_EName . ".count");
                                                setpref(INT, "k-meleon_Groups2." . $_Groups2_Import_GName . ".count", $_Groups2_Import_GCount);
                                                $__GnCnt = 0;
                                                while ($__GnCnt < $_Groups2_Import_GCount) {
                                                                $_Groups2_Import_Key = "URL_" . $__GnCnt;
                                                                $_Groups2_Import_Value = iniread($_Groups2_Import_Section, $_Groups2_Import_Key, $_Groups2_Import_Value, $_Groups2_Import_Path);
                                                                $_Groups2_Import_URL = $_Groups2_Import_Value;
                                                                setpref(STRING, "k-meleon_Groups2." . $_Groups2_Import_GName . "." . $__GnCnt, $_Groups2_Import_URL);
                                                                ##  Increment the groupcount variable
                                                                $__GnCnt = $__GnCnt + 1;
                                                                }
                                                while ($_Groups2_Local_GCount > $_Groups2_Import_GCount) {
                                                                delpref("k-meleon_Groups2." . $_Groups2_Import_GName . "." . $_Groups2_Local_GCount - 1);
                                                                $_Groups2_Local_GCount = $_Groups2_Local_GCount - 1;
                                                }
                                }
                } else {
                # If import group not exist add it to the end of group list
                                setpref(STRING, "k-meleon_Groups2." . ($_Groups2_Exist_Count + $_Groups2_Import_New), $_Groups2_Import_GName);
                                setpref(INT, "k-meleon_Groups2." . $_Groups2_Import_GName . ".count", $_Groups2_Import_GCount);
                                $__GnCnt = 0;
                                while ($__GnCnt < $_Groups2_Import_GCount) {
                                                $_Groups2_Import_Key = "URL_" . $__GnCnt;
                                                $_Groups2_Import_Value = iniread($_Groups2_Import_Section, $_Groups2_Import_Key, $_Groups2_Import_Value, $_Groups2_Import_Path);
                                                $_Groups2_Import_URL = $_Groups2_Import_Value;
                                                setpref(STRING, "k-meleon_Groups2." . $_Groups2_Import_GName . "." . $__GnCnt, $_Groups2_Import_URL);
                                                ##  Increment the groupcount variable
                                                $__GnCnt = $__GnCnt + 1;
                                }
                                #  New group to added
                                $_Groups2_Import_New = $_Groups2_Import_New + 1;
                }
                ##  Increment the count variable
                $__GCnt = $__GCnt + 1;
                }
##  Add new groups to the count of groups in pref "k-meleon_Groups2.count"
setpref(INT, "k-meleon_Groups2.count", ($_Groups2_Exist_Count + $_Groups2_Import_New));
$_Groups2_Merge = "";
macros("_Groups2_BuildGroupsMenu");
statusbar(_("Import complete"));
}

_Groups2_RunCode_Import_M {
macroinfo = _("Merge current groups with those in an ini file");
$_Groups2_Merge = "Merge";
plugin(macros, "_Groups2_RunCode_Import(" . $_Groups2_Merge . ")");
}

_Groups2_Sort {
macroinfo = _("Sort the list of groups by alphabetical order");
statusbar(_("Sorting groups"));
$_Groups2_Exist_Count = getpref(INT, "k-meleon_Groups2.count");
if ($_Groups2_Exist_Count > 1) {
                $_GU_cntr = 0;
                $_GU_cntr2 = 0;
                $_Groups2_List = "";
                #  Sort order is: z-a > Z-A > 9-0, by ANSI code value -> 1st item is the minor value
                $_Groups2_Glist_H = getpref(STRING, "k-meleon_Groups2." . $_GU_cntr2);
                $_Groups2_Glist_T = getpref(STRING, "k-meleon_Groups2." . $_GU_cntr2 + 1);
                $_Groups2_Glist_H2 = "";
                $_Groups2_Glist_T2 = "";
                #  H, ..., T => Head = minor value, Tail = major value -> in List_tmp
                #  H2, ..., T2 => Head2 = minor value, Tail2 = major value -> in final List
                #  The sorted method obtain the minor (Head) and major (Tail) values from List_tmp in each cicle.
                #  This values are stored in H2 and T2 and are added to the final List.
                #  At the end of proccess you obtain the sorted groups in List.
                #  How you obtain 2 values in each cicle (minor and major) the list is sorted in the half of cicles.
                while ($_GU_cntr2 < (($_Groups2_Exist_Count / 2) + 1)) {
                $_Groups2_List_tmp = $_Groups2_Glist_H . "\n" . $_Groups2_Glist_T . "\n";
                #  Compare with each group name
                while ($_GU_cntr < $_Groups2_Exist_Count) {
                                $_Groups2_EName = getpref(STRING, "k-meleon_Groups2." . $_GU_cntr);
                                #  Avoid items already added to the final List
                                if (index($_Groups2_List, $_Groups2_EName) == -1) {
                                #  If minor add to List_tmp in Head
                                                if ($_Groups2_EName < $_Groups2_Glist_H) {
                                                                $_Groups2_List_tmp = $_Groups2_EName . "\n" . $_Groups2_List_tmp;
                                                                $_Groups2_Glist_H = $_Groups2_EName;
                                                } else {
                                                #  If major add to List_tmp in Tail
                                                                if ($_Groups2_EName > $_Groups2_Glist_T) {
                                                                                $_Groups2_List_tmp = $_Groups2_List_tmp . $_Groups2_EName . "\n";
                                                                                $_Groups2_Glist_T = $_Groups2_EName;
                                                                } else {
                                                                #  If not minor and not major add in middle of List_tmp, before of Tail or after of Head
                                                                                $_Groups2_List_tmp = sub($_Groups2_Glist_T, $_Groups2_EName . "\n" . $_Groups2_Glist_T, $_Groups2_List_tmp);
                                                                }
                                                }
                                }
                                $_GU_cntr = $_GU_cntr + 1;
                                }
                #  If final List is empty, is the first cicle. Add Head and Tail to final List
                if ($_Groups2_List == "") {
                                $_Groups2_List = $_Groups2_Glist_H . "\n" . $_Groups2_Glist_T . "\n";
                } else {
                                #  Check Head not exist in final List to avoid duplicates in final List and add it after H2
                                if (index($_Groups2_List, $_Groups2_Glist_H) == -1) {
                                                $_Groups2_List = sub($_Groups2_Glist_H2 . "\n", $_Groups2_Glist_H2 . "\n" . $_Groups2_Glist_H . "\n", $_Groups2_List);
                                }
                                #  Check Tail not exist in final List to avoid duplicates in final List and add it before T2
                                if (index($_Groups2_List, $_Groups2_Glist_T) == -1) {
                                                $_Groups2_List = sub($_Groups2_Glist_T2, $_Groups2_Glist_T . "\n" . $_Groups2_Glist_T2, $_Groups2_List);
                                }
                }
                #  Move H to H2 and T to T2
                $_Groups2_Glist_H2 = $_Groups2_Glist_H;
                $_Groups2_Glist_T2 = $_Groups2_Glist_T;
                #  Reset item counter for group names
                $_GU_cntr = 0;
                #  Obtain new H and T values from List_tmp and delete it in List_tmp
                $_Groups2_List_tmp = sub($_Groups2_Glist_H . "\n", "", $_Groups2_List_tmp);
                $_Groups2_Glist_H = substr($_Groups2_List_tmp, 0, index($_Groups2_List_tmp, "\n"));
                $_Groups2_List_tmp = sub($_Groups2_Glist_H . "\n", "", $_Groups2_List_tmp);
                $_Groups2_Glist_T = substr($_Groups2_List_tmp, 0, index($_Groups2_List_tmp, "\n"));
                $_Groups2_List_tmp = sub($_Groups2_Glist_T . "\n", "", $_Groups2_List_tmp);
                $_GU_cntr2 = $_GU_cntr2 + 1;
                }
                #  All groups are sorted in $_Groups2_List
                #  Reorder Prefs:
                $_GU_cntr = 0;
                $_Groups2_EName = "";
                while ($_GU_cntr < $_Groups2_Exist_Count) {
                                $_Groups2_EName = substr($_Groups2_List, 0, index($_Groups2_List, "\n"));
                                setpref(STRING, "k-meleon_Groups2." . $_GU_cntr, $_Groups2_EName);
                                $_Groups2_List = sub($_Groups2_EName . "\n", "", $_Groups2_List);
                                $_GU_cntr = $_GU_cntr + 1;
                }
                #  Destroy the list of groups in menu and rebuild it sorted
                $_GU_cntr = 0;
                while ($_GU_cntr < $_Groups2_Exist_Count) {
                                $_Groups2_DelName = getpref(STRING, "k-meleon_Groups2." . $_GU_cntr);
                                $_Groups2_DelName != "" ? setmenu($_m, macro, $_Groups2_DelName, "") : 0;
                                $_GU_cntr = $_GU_cntr + 1;
                                }
                $_Groups2_DelName = "";
                &_Groups2_BuildGroupsMenu;
                statusbar(_("Sorting complete"));
                }
}

_Groups2_StartGroup {
macroinfo = _("Load a group at startup.");
$_startupGroup = getpref(STRING, "k-meleon_Groups2.startup");
$_Groups2_Name = prompt(_("Enter name of group to load at startup.  Enter '!' to disable."), _("Group Name at startup"), $_startupGroup);
if ($_Groups2_Name != "") {
                $_Groups2_Name != "!" ? setpref(STRING, "k-meleon_Groups2.startup", $_Groups2_Name) : delpref("k-meleon_Groups2.startup");
}
}

_Groups2_BuildMenu {
if ($kTabs) {
        $_g = "&Groups";
        setmenu(Main, popup, $_g, "&Tools");
        $__m = "_Groups";
        setmenu($_g, inline, $__m);
        setmenu($__m, macro, _("&Save a group ..."), _Groups2_RunCode_Save);
        setmenu($__m, macro, _("&Load a group ..."), _Groups2_RunCode_Load);
        setmenu($__m, macro, _("&Delete a group ..."), _Groups2_RunCode_Delete);
        setmenu($__m, separator, 3);
        setmenu($__m, popup, _("&Options"));
        setmenu(_("&Options"), macro, _("Start &with group ..."), _Groups2_StartGroup);
        setmenu(_("&Options"), macro, _("&Sort groups ..."), _Groups2_Sort);
        setmenu(_("&Options"), popup, _("&HotGroups"));
        &_Groups2_BuildHotGroupsMenu;
        setmenu(_("&Options"), separator, 3);
        setmenu(_("&Options"), macro, _("Res&tore"), _Groups2_Restore);
        setmenu(_("&Options"), separator, 5);                
        setmenu(_("&Options"), macro, _("&Export ..."), _Groups2_RunCode_Export);
        setmenu(_("&Options"), popup, _("&Import"));
        setmenu(_("&Import"), macro, _("&Merge ..."), _Groups2_RunCode_Import_M);
        setmenu(_("&Import"), macro, _("&Replace ..."), _Groups2_RunCode_Import);
        setmenu(_("&Options"), macro, _("Retain &paths"), _Groups2_RunCode_Paths);
        setmenu(_("&Options"), separator, 9);
        setmenu(_("&Options"), macro, _("&About"), _Groups2_About);        
        setmenu($__m, separator, 5);
        $_Groups2_DelName = "";
        &_Groups2_BuildGroupsMenu;
        }
}

_Groups2_BuildGroupsMenu {
$_g = "&Groups";
$_m = "_Groups_List";
setmenu($_g, inline, $_m);
$_Groups2_Exist_Count = getpref(INT, "k-meleon_Groups2.count");
$_GU_cntr = 0;
while ($_GU_cntr < $_Groups2_Exist_Count) {
        $_Groups2_EName = getpref(STRING, "k-meleon_Groups2." . $_GU_cntr);
        setmenu($_m, macro, $_Groups2_EName, "Groups2_OpenGroup(" . $_Groups2_EName . ")");
        $_GU_cntr = $_GU_cntr + 1;
        }
$_Groups2_DelName != "" ? setmenu($_m, macro, $_Groups2_DelName, "") : 0;
rebuildmenu($_g);
rebuildmenu($_m);
$_Groups2_DelName = "";
getpref(INT,"k-meleon_Groups2.count") == 0 ? delpref("k-meleon_Groups2.count") :0;
}

_Groups2_HotGroup0 {
macroinfo = _("Toggle Hotlink/HotGroup");
menuchecked = getpref(BOOL, "k-meleon_Groups2.HotGroup0");
togglepref(BOOL, "k-meleon_Groups2.HotGroup0");
statusbar(sub("%s", getpref(BOOL, "k-meleon_Groups2.HotGroup0") ? "HotGroup" : "Hotlink", _("Hotlink 0 as %s")));
}

_Groups2_HotGroup1 {
macroinfo = _("Toggle Hotlink/HotGroup");
menuchecked = getpref(BOOL, "k-meleon_Groups2.HotGroup1");
togglepref(BOOL, "k-meleon_Groups2.HotGroup1");
statusbar(sub("%s", getpref(BOOL, "k-meleon_Groups2.HotGroup1") ? "HotGroup" : "Hotlink", _("Hotlink 1 as %s")));
}

_Groups2_HotGroup2 {
macroinfo = _("Toggle Hotlink/HotGroup");
menuchecked = getpref(BOOL, "k-meleon_Groups2.HotGroup2");
togglepref(BOOL, "k-meleon_Groups2.HotGroup2");
statusbar(sub("%s", getpref(BOOL, "k-meleon_Groups2.HotGroup2") ? "HotGroup" : "Hotlink", _("Hotlink 2 as %s")));
}

_Groups2_HotGroup3 {
macroinfo = _("Toggle Hotlink/HotGroup");
menuchecked = getpref(BOOL, "k-meleon_Groups2.HotGroup3");
togglepref(BOOL, "k-meleon_Groups2.HotGroup3");
statusbar(sub("%s", getpref(BOOL, "k-meleon_Groups2.HotGroup3") ? "HotGroup" : "Hotlink", _("Hotlink 3 as %s")));
}

_Groups2_HotGroup4 {
macroinfo = _("Toggle Hotlink/HotGroup");
menuchecked = getpref(BOOL, "k-meleon_Groups2.HotGroup4");
togglepref(BOOL, "k-meleon_Groups2.HotGroup4");
statusbar(sub("%s", getpref(BOOL, "k-meleon_Groups2.HotGroup4") ? "HotGroup" : "Hotlink", _("Hotlink 4 as %s")));
}

_Groups2_HotGroup5 {
macroinfo = _("Toggle Hotlink/HotGroup");
menuchecked = getpref(BOOL, "k-meleon_Groups2.HotGroup5");
togglepref(BOOL, "k-meleon_Groups2.HotGroup5");
statusbar(sub("%s", getpref(BOOL, "k-meleon_Groups2.HotGroup5") ? "HotGroup" : "Hotlink", _("Hotlink 5 as %s")));
}

_Groups2_HotGroup6 {
macroinfo = _("Toggle Hotlink/HotGroup");
menuchecked = getpref(BOOL, "k-meleon_Groups2.HotGroup6");
togglepref(BOOL, "k-meleon_Groups2.HotGroup6");
statusbar(sub("%s", getpref(BOOL, "k-meleon_Groups2.HotGroup6") ? "HotGroup" : "Hotlink", _("Hotlink 6 as %s")));
}

_Groups2_HotGroup7 {
macroinfo = _("Toggle Hotlink/HotGroup");
menuchecked = getpref(BOOL, "k-meleon_Groups2.HotGroup7");
togglepref(BOOL, "k-meleon_Groups2.HotGroup7");
statusbar(sub("%s", getpref(BOOL, "k-meleon_Groups2.HotGroup7") ? "HotGroup" : "Hotlink", _("Hotlink 7 as %s")));
}

_Groups2_HotGroup8 {
macroinfo = _("Toggle Hotlink/HotGroup");
menuchecked = getpref(BOOL, "k-meleon_Groups2.HotGroup8");
togglepref(BOOL, "k-meleon_Groups2.HotGroup8");
statusbar(sub("%s", getpref(BOOL, "k-meleon_Groups2.HotGroup8") ? "HotGroup" : "Hotlink", _("Hotlink 8 as %s")));
}

_Groups2_HotGroup9 {
macroinfo = _("Toggle Hotlink/HotGroup");
menuchecked = getpref(BOOL, "k-meleon_Groups2.HotGroup9");
togglepref(BOOL, "k-meleon_Groups2.HotGroup9");
statusbar(sub("%s", getpref(BOOL, "k-meleon_Groups2.HotGroup9") ? "HotGroup" : "Hotlink", _("Hotlink 9 as %s")));
}

_Groups2_BuildHotGroupsMenu {
# Create HotGroups menu & accels:
setmenu(_("&HotGroups"), macro, _("&Set Hotlink as HotGroup..."), "kmPrefs(hotlinks)");
setmenu(_("&HotGroups"), separator, 1);
$_i=0; while($_i != 10) {
        setmenu(_("&HotGroups"), macro, _("HotGroup ") . $_i, "_Groups2_HotGroup" . $_i);
        setaccel("CTRL " . $_i, "macros(_Groups2_OpenHotGroup(" . $_i . "))"); $_i = $_i + 1;
        }
}

_Groups2_OpenURL {
# Open a Hotlink URL value:
$_Folder = pluginmsgex(bookmarks, FindNick, $OpenURL,STRING);
$_Folder ? 0 : $_Folder = pluginmsgex(hotlist, FindNick, $OpenURL, STRING);
$_Folder ? $URLBAR=$OpenURL : plugin(macros, "Groups2_OpenGroup(" . $OpenURL .")");
$_Folder ? id(ID_SELECT_URL) : 0; $_Folder ? id(ID_NAV_GO) : 0;
}

_Groups2_OpenHotGroup {
# Check if a Hotlink URL value is URI or Group/Nick name:
$OpenURL = getpref(STRING, $_hotlink . $ARG . ".url");
if (getpref(BOOL, "k-meleon_Groups2.HotGroup" . $ARG)) {
        $OpenURL == ""? 0 : &_Groups2_OpenURL;
        } else {
        $OpenURL == ""? 0 : (getpref(BOOL, $_hotlink.$ARG.".new")? &OpenURL_InNew : open($OpenURL));
        }
}

_Groups2_SetAccels {
setaccel("ALT VK_RETURN", "macros(Groups2_OpenGroup)");
}

_Groups2_Startup {
$_startupGroup = getpref(STRING, "k-meleon_Groups2.startup");
$_startupGroup != "" ? plugin(macros, "Groups2_OpenGroup(" . $_startupGroup . ")") : 0;
#  Merge variable initialization is needed
$_Groups2_Merge = "";
}

_Groups2_HistEOS {
# history count
$_Groups2_HisMax = getpref(INT,"k-meleon_Groups2_History.count");
delpref("k-meleon_Groups2_History.count");
$_Groups2_HisCnt = 0 ; $_Groups2_HisName = "" ;
while ( $_Groups2_HisCnt < $_Groups2_HisMax ) {
        # group name
        $_Groups2_HisName = getpref(STRING,"k-meleon_Groups2_History." . $_Groups2_HisCnt);
        delpref("k-meleon_Groups2_History." . $_Groups2_HisCnt);
        # group tab count
        $_Groups2_HTabCnt = getpref(INT,"k-meleon_Groups2_History." . $_Groups2_HisName . ".count");
        delpref("k-meleon_Groups2_History." . $_Groups2_HisName . ".count");
        $_Groups2_HTcnt = 0 ;
        while($_Groups2_HTcnt < $_Groups2_HTabCnt) {
                # group tab
                delpref("k-meleon_Groups2_History." . $_Groups2_HisName . "." .$_Groups2_HTcnt );
                $_Groups2_HTcnt = $_Groups2_HTcnt + 1;
        }
$_Groups2_HisCnt = $_Groups2_HisCnt + 1 ;        
}
$_Groups2_HisCnt = 0 ;
while ($_Groups2_HisCnt < 10 ) {
        # unused hotlink value
        getpref(STRING,"kmeleon.plugins.macros.hotlink".$_Groups2_HisCnt.".url") == "" ? delpref("kmeleon.plugins.macros.hotlink".$_Groups2_HisCnt.".url") :0;
        getpref(BOOL,"k-meleon_Groups2.HotGroup".$_Groups2_HisCnt) == false ? delpref("k-meleon_Groups2.HotGroup".$_Groups2_HisCnt) :0;
        $_Groups2_HisCnt = $_Groups2_HisCnt +1 ;
}
}

_Groups2_Initial {
$_Groups2_ExtCnt = 1;
}

$OnQuit = $OnQuit . "_Groups2_HistEOS;";
$OnInit = $OnInit . "_Groups2_SetAccels;_Groups2_BuildMenu;_Groups2_Initial;";
$OnStartup = $OnStartup . "_Groups2_Startup;";
$macroModules = $macroModules . "Groups2;";


Comments & Questions

K-Meleon

(c) 2000-2010 kmeleonbrowser.org. All rights reserved.
design by splif.