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