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:
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.
Open your User Macro Folder (Edit > Configuration > User-Defined Macros) or your Macro Folder (Edit > Configuration > Macros) and create the following text file:
# 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.startup = Start group name # : k-meleon_Groups2.exportpath, k-meleon_Groups2.importpath, # : k-meleon_Groups2.backuppath, k-meleon_Groups2.paths # Version : 0.6.3 2010-06-02 # Authors : JamesD and desga2 # --------------------------------------------------------------------------------------- _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")); 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_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 == "" ? $_Group = $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."); $_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"); $_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_Delete_Loop { $_Groups2_Tab_Count == 0 ? delpref("k-meleon_Groups2." . $_Groups2_Name . ".count") : 0; delpref("k-meleon_Groups2." . $_Groups2_Name . "." . $_Groups2_Tab_Count); $_Groups2_Tab_Count = $_Groups2_Tab_Count + 1; } _Groups2_ObtainC { $_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_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); ## 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"), separator, 2); 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($__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"); if ($_Groups2_Exist_Count != 0) { $_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 = ""; } _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 = ""; } $OnInit = $OnInit . "_Groups2_SetAccels;_Groups2_BuildMenu;"; $OnStartup = $OnStartup . "_Groups2_Startup;"; $macroModules = $macroModules . "Groups2;";