2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2008 - INRIA - Pierre MARECHAL
4 // Copyright (C) 2012 - DIGITEO - Vincent COUVERT
5 // Copyright (C) 2014 - Scilab Enterprises - Anais AUBERT
7 // Copyright (C) 2012 - 2016 - Scilab Enterprises
9 // This file is hereby licensed under the terms of the GNU GPL v2.0,
10 // pursuant to article 5.3.4 of the CeCILL v.2.1.
11 // This file was originally licensed under the terms of the CeCILL v2.1,
12 // and continues to be available under such terms.
13 // For more information, see the COPYING file which you should have received
14 // along with this program.
19 global demolist; // Demos list is defined in scilab.start
21 if isempty(demolist) then
22 if isempty(demolistlock) then
24 // we load scilab demos only when it is required
25 modules = getmodules();
26 for i=1:size(modules,"*")
27 if isfile("SCI/modules/"+modules(i)+"/demos/" + modules(i) + ".dem.gateway.sce") then
28 exec("SCI/modules/"+modules(i)+"/demos/" + modules(i) + ".dem.gateway.sce",-1);
32 clearglobal demolistlock;
36 // define a local demolist variable
38 clear demolist // The global one must stay in en_US
39 demolist = gettext(tmp);
41 if get("scilab_demo_fig") <> [] then
42 set("scilab_demo_fig", "visible", "on");
48 // =========================================================================
49 // We get the user Preferences for the GUI: dockable / not dockable
50 File = SCIHOME + "/XConfiguration.xml";
51 r = xmlGetValues("//general/demonstrations/body/demos","demoGUIisDockable", File);
53 // We tune accordingly the predefined demo GUI
54 File = SCI + "/modules/demo_tools/gui/demo_gui.xml";
55 File2 = TMPDIR + "/demo_gui_dockable.xml";
57 if ~isfile(File2) then
58 r = copyfile(File, File2);
60 xmlSetValues("/scilabgui/figure", ..
62 "infobar_visible" "on"
64 "menubar_visible" "on"]', doc);
71 // We load the preset GUI
72 demo_fig = loadGui(File);
73 demo_fig.figure_name = _("Demonstrations");
77 // =========================================================================
78 demo_fig.userdata = struct();
79 demo_fig.userdata.frame_number = 1; // Frame number
80 demo_fig.userdata.subdemolist = [];
82 lst_vars_locals = ["%h_delete";
91 clear_vars_str = strcat("clear " + lst_vars_locals, ";") + ";";
93 callback_close_str = "delete(get(""scilab_demo_fig""));";
94 callback_close_str = callback_close_str + clear_vars_str + "clearglobal demolistlock;";
96 b = get("frame_1", "border");
97 b.title = _("Demonstrations");
98 set("frame_1", "border", b);
99 set("listbox_1", "string", "<html>"+demolist(:, 1)+" ‣ </html>");
100 set("listbox_1", "userdata", demolist);
102 demo_fig.closerequestfcn = callback_close_str;
104 demo_fig.visible = "on"; // Display now