Fix #8048 - context provider start work - fix meson build flag - project settings...
[roobuilder] / src / Builder4 / DialogSaveModule.bjs
1 {
2  "build_module" : "builder",
3  "gen_extended" : false,
4  "items" : [
5   {
6    "# JsRender.Node data" : "",
7    "# Project.Project project" : "",
8    "$ modal" : true,
9    "$ xns" : "Gtk",
10    "@ void complete" : "(string result)",
11    "default_height" : 200,
12    "default_width" : 400,
13    "items" : [
14     {
15      "$ xns" : "Gtk",
16      "* pack" : " get_content_area().append",
17      "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
18      "items" : [
19       {
20        "$ xns" : "Gtk",
21        "* pack" : "append",
22        "label" : "Name",
23        "xtype" : "Label"
24       },
25       {
26        "$ xns" : "Gtk",
27        "* pack" : "append",
28        "id" : "name",
29        "xtype" : "Entry"
30       }
31      ],
32      "xtype" : "Box"
33     },
34     {
35      "$ xns" : "Gtk",
36      "* pack" : "add_action_widget,0",
37      "label" : "Cancel",
38      "xtype" : "Button"
39     },
40     {
41      "$ xns" : "Gtk",
42      "* pack" : "add_action_widget,1",
43      "label" : "OK",
44      "xtype" : "Button"
45     }
46    ],
47    "listeners" : {
48     "response" : [
49      "(response_id) => {",
50      " \tif (response_id < 1) {",
51      "        this.el.hide();",
52      "         this.complete(\"\");",
53      "    }",
54      "        ",
55      "   var  name = _this.name.el.get_text();",
56      "    if (name.length < 1) {",
57      "        Xcls_StandardErrorDialog.singleton().show(",
58      "             _this.el,",
59      "            \"You must give the template a name. \"",
60      "        );",
61      "         return;",
62      "    }",
63      "    if (!Regex.match_simple (\"^[A-Za-z][A-Za-z0-9.]+$\", name) )",
64      "    {",
65      "        Xcls_StandardErrorDialog.singleton().show(",
66      "             _this.el.transient_for,",
67      "            \"Template Name must contain only letters dots\"",
68      "        );",
69      "        return;;",
70      "    }",
71      "    ",
72      "    var targetfile = project.path + \"/templates/\" + name + \".bjs\";",
73      "    ",
74      "    ",
75      "    if (GLib.FileUtils.test(targetfile, GLib.FileTest.EXISTS)) {",
76      "\t    Xcls_StandardErrorDialog.singleton().show(",
77      "\t        _this.el.transient_for,",
78      "\t        \"That file already exists\"",
79      "\t    ); ",
80      "\t    return;",
81      "\t}",
82      "\tJsRender.JsRender f;",
83      "     try {",
84      "\t   f =  JsRender.JsRender.factory(",
85      "\t\t\t  project.xtype ,  ",
86      "\t\t\tproject, ",
87      "\t\t\ttargetfile);",
88      "\t} catch (JsRender.Error e) {",
89      "\t\tXcls_StandardErrorDialog.singleton().show(",
90      "\t        _this.el.transient_for,",
91      "\t        \"Error creating file\"",
92      "\t    ); ",
93      "\t\treturn;",
94      "\t}",
95      "    ",
96      "",
97      "    f.tree =  _this.data.deepClone();",
98      "    f.save();",
99      "     project.addFile(f);",
100      "    // now we save it..",
101      "    this.el.hide();",
102      "    this.complete(name);",
103      "   ",
104      "",
105      "}",
106      ""
107     ]
108    },
109    "xtype" : "Dialog",
110    "| void showIt" : [
111     " (Gtk.Window parent, Project.Project project, JsRender.Node data) {",
112     " ",
113     "     ",
114     "    this.el.set_transient_for(parent);",
115     "    this.el.modal = true;",
116     "    ",
117     "    this.data = data;",
118     "    this.project = project;",
119     "    this.name.el.set_text(\"\");",
120     "    this.el.show();",
121     "",
122     "     ",
123     "    ",
124     "}",
125     ""
126    ]
127   }
128  ],
129  "name" : "DialogSaveModule"
130 }