5a33cbf90cd859cbf804894874cbdfd422522409
[scilab.git] / scilab / modules / gui / sci_gateway / cpp / sci_getinstalledlookandfeels.cpp
1 /*\r
2  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab\r
3  * Copyright (C) 2008 - DIGITEO - Allan CORNET\r
4  * \r
5  * This file must be used under the terms of the CeCILL.\r
6  * This source file is licensed as described in the file COPYING, which\r
7  * you should have received as part of this distribution.  The terms\r
8  * are also available at    \r
9  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt\r
10  *\r
11  */\r
12  \r
13 #include "LookAndFeelManager.hxx"\r
14 \r
15 extern "C"\r
16 {\r
17 #include <stdlib.h>\r
18 #include "gw_gui.h"\r
19 #include "stack-c.h"\r
20 #include "getScilabJavaVM.h"\r
21 #include "Scierror.h"\r
22 #include "localization.h"\r
23 /*--------------------------------------------------------------------------*/\r
24 int sci_getinstalledlookandfeels(char *fname,unsigned long fname_len)\r
25 {\r
26         CheckRhs(0,0);\r
27         CheckLhs(1,1);\r
28 \r
29         org_scilab_modules_gui_utils::LookAndFeelManager *lnf = new org_scilab_modules_gui_utils::LookAndFeelManager(getScilabJavaVM());\r
30         if (lnf)\r
31         {\r
32                 char **lookandfeels = NULL;\r
33                 int nbElems = 0;\r
34                 int nbCol = 0;\r
35 \r
36                 lookandfeels = lnf->getInstalledLookAndFeels();\r
37                 nbElems = lnf->numbersOfInstalledLookAndFeels();\r
38                 delete lnf;\r
39 \r
40                 nbCol = 1;\r
41                 CreateVarFromPtr( Rhs+1,MATRIX_OF_STRING_DATATYPE, &nbElems, &nbCol,lookandfeels );\r
42 \r
43                 LhsVar(1)=Rhs+1;\r
44                 C2F(putlhsvar)();\r
45 \r
46                 if (lookandfeels)\r
47                 {\r
48                         int i = 0;\r
49                         for (i=0;i<nbElems;i++)\r
50                         {\r
51                                 if (lookandfeels[i])\r
52                                 {\r
53                                         free(lookandfeels[i]); /* free because giws uses malloc */\r
54                                         lookandfeels[i] = NULL;\r
55                                 }\r
56                         }\r
57                         free(lookandfeels);\r
58                         lookandfeels = NULL;\r
59                 }\r
60         }\r
61         else\r
62         {\r
63                 Scierror(999,_("%s: No more memory.\n"),fname);\r
64         }\r
65         return 0;\r
66 }\r
67 /*--------------------------------------------------------------------------*/\r
68 }\r
69 /* END OF extern "C" */\r
70 /*--------------------------------------------------------------------------*/\r
71 \r
72 \r