diff --git a/plasmoid/package/contents/code/activitiesTools.js b/plasmoid/package/contents/code/activitiesTools.js index a8e0f252..fbfddc89 100644 --- a/plasmoid/package/contents/code/activitiesTools.js +++ b/plasmoid/package/contents/code/activitiesTools.js @@ -1,366 +1,367 @@ /* * Copyright 2016 Smith AR * Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * Latte-Dock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ var currentActivity; var launchersOnActivities; //it is used as the first item in the stringList in order to check the list is ok var indicator = 'multi'; var plasmoid; function importLaunchersToNewArchitecture(){ if (plasmoid.configuration.launchers59.length>0 || plasmoid.configuration.launchers.length===0) return; console.log("------------- Importing Launchers To New Architecture --------------"); restoreLaunchers(); var newLaunchers = []; var size = launchersOnActivities.length; for(var i=size-1; i>=0; --i){ var activitySaving = get(launchersOnActivities[i].id); if(activitySaving.launchers.length>0){ //this fixes the segmentation fault of previous command.... for(var j=0; j 2){ // console.log("Pass 3 - "+values); var actId = values[0]; var subLaunchers = values.splice(2,values[1]); // console.log("To Be Restored launchers, "+actId+ ", "+subLaunchers.length+", "+subLaunchers); var activityRecord = get(actId); if(activityRecord){ // console.log("Activity item found..."); if(activityRecord.launchers) activityRecord.launchers.splice(0,activityRecord.launchers.length); activityRecord.launchers = subLaunchers; } else{ // console.log("Activity item is added..."); var res = {id:values[0], launchers:subLaunchers}; launchersOnActivities.push(res); } values.splice(0,2); } } if (get('*')) returnedStringList = returnedStringList.concat(get('*').launchers); else{ var result = {id:'*', launchers:[]}; launchersOnActivities.push(result); } if (get(currentActivity)) returnedStringList = returnedStringList.concat(get(currentActivity).launchers); // console.log("Restored Strings:"+returnedStringList); return returnedStringList; } else return []; } function saveLaunchers(){ // console.log("----------------------- Saving ---------------------"); var returnedStringList = []; returnedStringList.push(indicator); // console.log("Array Size:"+launchersOnActivities.length); var size = launchersOnActivities.length; for(var i=size-1; i>=0; --i){ var activitySaving = get(launchersOnActivities[i].id); // console.log("Saving, "+activitySaving.id + " - "+activitySaving.launchers.length+" - "+activitySaving.launchers); if(activitySaving.launchers.length>0){ /* console.log("------- "+activitySaving.id+" ----------"); for(var j=0; j 0){ tempList = launcherList.slice(0); } else{ tempList =[]; } // console.log("IMPORTANT SENT LIST: "+tempList.length+" - "+launcherList.length+" - "+tempList); // // console.log("In memory Defaults:" + get('*').launchers); // if(get(currentActivity)) // console.log("In memory Current: "+get(currentActivity).launchers.length+ ' - ' + get(currentActivity).launchers); var currentList = get(currentActivity); var resultedCurrent = []; // console.log("-------------"); for(var i=tempList.length-1; i>=0; --i){ var index=-1; if(currentList){ index = getIndex(String(tempList[i]), currentList.launchers); } if(index >=0 || isInSpecificActivity(tempList[i])){ var result = tempList.splice(i,1); resultedCurrent.unshift(String(result)); } } // console.log("Resulted Current: "+resultedCurrent); /* console.log("---- To Be Set List ------"); for(var j=0; j=0) return true; // console.log("Check exists:"+id+ " - "+ "pos:"+index+" ,,, "+ get('*').activities); return false; } function isInSpecificActivity(id){ for(var i=0; i=0) return true; } } return false; } function setDefaultLaunchers(launchersList){ // console.log("Set Default Launchers"); if(!get('*')){ var result = {id:'*', launchers:launchersList}; launchersOnActivities.push(result); } else{ if (get('*').launchers) get('*').launchers.splice(0,get('*').launchers.length); get('*').launchers=launchersList; } // console.log("Default:::: "+get('*').launchers); } function setActivityLaunchers(launchersList, actId){ // console.log("Set Activity Launchers"); var currentList = get(actId); // console.log("-------------"); // console.log("ResultedForMemory: "+launchersList); if(currentList){ if(currentList.launchers) currentList.launchers.splice(0,currentList.launchers.length); // console.log("list exists"); currentList.launchers=launchersList; } else{ // console.log("new list"); var res = {id:actId, launchers:launchersList}; launchersOnActivities.push(res); } /* console.log("New Memory List: "+get(actId).launchers); for(var j=0; j= 0){ activityList.splice(index, 1); } } } function addToList(id, activityId){ var activity = get(activityId); if(!activity){ var res = {id:activityId, launchers:[]}; res.launchers.push(id); launchersOnActivities.push(res); } else{ var launcherList = activity.launchers; var index = getIndex(id,launcherList); if(index<0){ launcherList.push(id); } } }