1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) 2010 - DIGITEO - Pierre MARECHAL <pierre.marechal@scilab.org>
4 // This file must be used under the terms of the CeCILL.
5 // This source file is licensed as described in the file COPYING, which
6 // you should have received as part of this distribution. The terms
7 // are also available at
8 // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
13 // Returns a struct that contains the followings fields:
14 // - elements("items_str")
15 // - elements("items_mat")
16 // - elements("title")
19 function elements = atomsGetLeftListboxElts(category)
23 // Check number of input arguments
24 // =========================================================================
27 error(msprintf(gettext("%s: Wrong number of input argument: %d expected.\n"),"getLeftListboxElements",1));
30 // Check input argument types
31 // =========================================================================
33 if category<>[] & type(category) <> 10 then
34 error(msprintf(gettext("%s: Wrong type for input argument #%d: Single string expected.\n"),"getLeftListboxElements",1));
37 if category<>[] & type(category) <> 10 then
38 error(msprintf(gettext("%s: Wrong type for input argument #%d: Single string expected.\n"),"getLeftListboxElements",1));
41 if size(category(1,:),"*") > 2 then
42 error(msprintf(gettext("%s: Wrong size for input argument #%d: mx1 or mx2 string matrix expected.\n"),"atomsIsCategory",1));
46 // =========================================================================
51 atomsfig = findobj("tag","atomsFigure");
52 allModules = atomsfig("UserData");
54 background = "#ffffff";
56 // 1st case, All main categories
57 // -------------------------------------------------------------------------
59 if category=="filter:main" then
61 categories = atomsCategoryGet("filter:main");
64 thisItem = thisItem + "<table style=""background-color:#ffffff;color:#000000;""><tr>";
65 thisItem = thisItem + "<td><img src=""file:///"+SCI+"/modules/gui/images/icons/16x16/places/user-home.png"" /></td>";
66 thisItem = thisItem + "<td style=""width:132px;""><div style=""width:118px;text-align:left;font-weight:bold;"">"+gettext("All modules")+"</div></td>";
67 thisItem = thisItem + "</tr></table>";
68 thisItem = thisItem + "</html>";
70 items_str = [items_str ; thisItem ];
71 items_mat = [items_mat ; "category" "filter:all"];
73 for i=1:size(categories, "*")
75 if background == "#eeeeee" then
76 background = "#ffffff";
78 background = "#eeeeee";
82 thisItem = thisItem + "<table style=""background-color:"+background+";color:#000000;"" ><tr>";
83 thisItem = thisItem + "<td><img src=""file:///"+SCI+"/modules/gui/images/icons/16x16/places/folder.png"" /></td>";
84 thisItem = thisItem + "<td style=""width:132px;""><div style=""width:118px;text-align:left;"">"+categories(i)+"</div></td>";
85 thisItem = thisItem + "</tr></table>";
86 thisItem = thisItem + "</html>";
88 items_str = [items_str ; thisItem ];
89 items_mat = [items_mat ; "category" categories(i)];
92 // 2nd case: Sub categories + modules
93 // -------------------------------------------------------------------------
98 // ---------------------------------------------------------------------
100 index_start = regexp(category,"/ - /");
101 // if index_start == [], category is a main category
102 // otherwise, category is a subcategory
104 if category=="filter:all" then
106 top_str = gettext("Main categories");
107 top_mat = ["category" "filter:main"];
109 elseif index_start==[] then
110 categories = atomsCategoryGet(category);
111 top_str = gettext("Main categories");
112 top_mat = ["category" "filter:main"];
116 parent = part(category,1:index_start-1);
118 top_mat = ["category" parent];
123 thisItem = thisItem + "<table style=""background-color:#ffffff;color:#000000;"" ><tr>";
124 thisItem = thisItem + "<td><img src=""file:///"+SCI+"/modules/gui/images/icons/16x16/places/user-home.png"" /></td>";
125 thisItem = thisItem + "<td style=""width:132px;""><div style=""width:118px;text-align:left;font-weight:bold;"">"+top_str+"</div></td>";
127 thisItem = thisItem + "</tr></table>";
128 thisItem = thisItem + "</html>";
130 items_str = [items_str ; thisItem ];
131 items_mat = [items_mat ; top_mat ];
133 for i=1:size(categories, "*")
135 if background == "#eeeeee" then
136 background = "#ffffff";
138 background = "#eeeeee";
142 thisItem = thisItem + "<table style=""background-color:"+background+";color:#000000;"" ><tr>";
143 thisItem = thisItem + "<td><img src=""file:///"+SCI+"/modules/gui/images/icons/16x16/places/folder.png"" /></td>";
144 thisItem = thisItem + "<td style=""width:132px;""><div style=""width:118px;text-align:left;"">"+categories(i)+"</div></td>";
145 thisItem = thisItem + "</tr></table>";
146 thisItem = thisItem + "</html>";
148 items_str = [items_str ; thisItem ];
149 items_mat = [items_mat ; "category" category+" - "+categories(i) ];
153 // ---------------------------------------------------------------------
155 if category=="filter:all" then
156 modulesNames = atomsGetAvailable([],%T);
158 modulesNames = atomsGetAvailable(category,%T);
161 MRVersionAvailable = atomsGetMRVersion(modulesNames);
162 modulesIsInstalled = atomsIsInstalled(modulesNames);
164 for i=1:size(modulesNames, "*")
166 thisModuleTitle = allModules(modulesNames(i))(MRVersionAvailable(i)).Title;
168 if modulesIsInstalled(i) then
170 MRVersionInstalled = atomsVersionSort(atomsGetInstalledVers(modulesNames(i)),"DESC");
171 MRVersionInstalled = MRVersionInstalled(1);
172 thisModuleTitle = allModules(modulesNames(i))(MRVersionInstalled).Title;
174 if atomsVersionCompare(MRVersionInstalled,MRVersionAvailable(i)) == -1 then
176 icon = "software-update-notuptodate.png";
178 // The Most Recent Version is already installed
179 icon = "software-update-installed.png";
183 icon = "software-update-notinstalled.png";
186 if background == "#eeeeee" then
187 background = "#ffffff";
189 background = "#eeeeee";
193 thisItem = thisItem + "<table style=""background-color:"+background+";color:#000000;"" ><tr>";
194 thisItem = thisItem + "<td><img src=""file:///"+SCI+"/modules/atoms/images/icons/16x16/status/"+icon+""" /></td>";
195 thisItem = thisItem + "<td style=""width:132px;""><div style=""width:118px;text-align:left;"">"+thisModuleTitle+"</div></td>";
196 thisItem = thisItem + "</tr></table>";
197 thisItem = thisItem + "</html>";
199 items_str = [items_str ; thisItem ];
200 items_mat = [items_mat ; "module" modulesNames(i)];
206 if items_str==[] then
207 elements("items_str") = "";
209 elements("items_str") = items_str;
212 elements("items_mat") = items_mat;
214 if category=="filter:main" then
215 elements("title") = gettext("Main categories");
216 elseif category=="filter:all" then
217 elements("title") = gettext("All modules");
219 elements("title") = category;