src/Builder4/RooProjectSettings.bjs
[roobuilder] / src / Builder4 / RooProjectSettings.bjs
1 {
2  "name" : "RooProjectSettings",
3  "parent" : "",
4  "title" : "",
5  "path" : "/home/alan/gitlive/roobuilder/src/Builder4/RooProjectSettings.bjs",
6  "permname" : "",
7  "modOrder" : "",
8  "build_module" : "builder",
9  "items" : [
10   {
11    "@ void buttonPressed" : "(string btn)",
12    "id" : "RooProjectSettings",
13    "| void show" : " (Gtk.Widget btn, Project.Project project) {\n    _this.project = project;\n    _this.path.el.label = project.firstPath();\n    // get the active project.\n     var lm = Gtk.SourceLanguageManager.get_default();\n                \n    ((Gtk.SourceBuffer)(_this.view.el.get_buffer())) .set_language(\n        lm.get_language(\"html\")\n    );\n  \n    //print (project.fn);\n    //project.runhtml = project.runhtml || '';\n    _this.view.el.get_buffer().set_text(project.runhtml);\n    \n       \n    _this.rootURL.el.set_text( _this.project.rootURL );\n    \n\n    _this.base_template_model.loadData();\n    \n     var js = _this.project;\n    _this.database_DBTYPE.el.set_text(     js.get_string_member(\"DBTYPE\") );\n    _this.database_DBNAME.el.set_text(    js.get_string_member(\"DBNAME\") );\n    _this.database_DBUSERNAME.el.set_text(    js.get_string_member(\"DBUSERNAME\") );\n    _this.database_DBPASSWORD.el.set_text(    js.get_string_member(\"DBPASSWORD\") );\n    \n    \t//console.log('show all');\n\tthis.el.set_modal(true);\n\tthis.el.set_relative_to(btn);\n\n\tthis.el.set_position(Gtk.PositionType.RIGHT);\n\n\t// window + header?\n\t print(\"SHOWALL - POPIP\\n\");\n\tthis.el.show_all();\n\tthis.el.set_size_request(800,500);\n\tthis.view.el.grab_focus();\n\t\n    \n    //this.el.show_all();\n}\n",
14    "xtype" : "Popover",
15    "Gtk.PositionType position" : "Gtk.PositionType.RIGHT",
16    "| void save" : "() {\n   var buf =    _this.view.el.get_buffer();\n   Gtk.TextIter s;\n     Gtk.TextIter e;\n    buf.get_start_iter(out s);\n    buf.get_end_iter(out e);\n      _this.project.runhtml = buf.get_text(s,e,true);\n      \n    _this.project.rootURL = _this.rootURL.el.get_text();\n    // set by event changed...\n    //_this.project.base_template = _this.base_template.el.get_text();    \n    \n    var js = _this.project.json_project_data;\n    js.set_string_member(\"DBTYPE\", _this.database_DBTYPE.el.get_text());\n   js.set_string_member(\"DBNAME\", _this.database_DBNAME.el.get_text());\n    js.set_string_member(\"DBUSERNAME\", _this.database_DBUSERNAME.el.get_text());\n    js.set_string_member(\"DBPASSWORD\", _this.database_DBPASSWORD.el.get_text());\n//    _this.project.set_string_member(\"DBHOST\", _this.DBTYPE.el.get_text());    \n    \n    // need to re-init the database \n    \n    _this.project.initRooDatabase();\n     \n    \n}",
17    "$ xns" : "Gtk",
18    "Project.Project project" : "",
19    "bool modal" : true,
20    "uint border_width" : 0,
21    "items" : [
22     {
23      "xtype" : "Box",
24      "* pack" : "add",
25      "$ xns" : "Gtk",
26      "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
27      "border_width" : 5,
28      "$ homogeneous" : false,
29      "items" : [
30       {
31        "* pack" : "pack_start,true,true,0",
32        "xtype" : "Notebook",
33        "$ xns" : "Gtk",
34        "items" : [
35         {
36          "id" : "label_global",
37          "* pack" : false,
38          "xtype" : "Label",
39          "$ xns" : "Gtk",
40          "utf8 label" : "Global"
41         },
42         {
43          "id" : "label_database",
44          "xtype" : "Label",
45          "* pack" : false,
46          "$ xns" : "Gtk",
47          "utf8 label" : "Database"
48         },
49         {
50          "* pack" : "append_page,_this.label_global.el",
51          "xtype" : "Box",
52          "gboolean homogeneous" : false,
53          "$ xns" : "Gtk",
54          "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
55          "items" : [
56           {
57            "id" : "grid",
58            "int margin_right" : 4,
59            "* pack" : "pack_start,false,false,4",
60            "xtype" : "Grid",
61            "uint row_spacing" : 2,
62            "n_columns" : 2,
63            "$ xns" : "Gtk",
64            "n_rows" : 7,
65            "$ homogeneous" : true,
66            "int margin_left" : 4,
67            "items" : [
68             {
69              "label" : "Filename",
70              "xalign" : 0,
71              "* pack" : "attach,0,0,1,1",
72              "xtype" : "Label",
73              "gint margin" : 3,
74              "$ xns" : "Gtk"
75             },
76             {
77              "label" : "filename",
78              "id" : "path",
79              "xalign" : 0,
80              "* pack" : "attach,1,0,1,1",
81              "xtype" : "Label",
82              "gint margin" : 3,
83              "$ xns" : "Gtk"
84             },
85             {
86              "label" : "HTML template file",
87              "xtype" : "Label",
88              "* pack" : "attach,0,1,1,1",
89              "gint margin" : 3,
90              "$ xns" : "Gtk"
91             },
92             {
93              "listeners" : {
94               "changed" : "() => {\n\tGtk.TreeIter iter;\n \n\t// this get's called when we are filling in the data... ???\n\tif (this.loading) {\n\t\treturn;\n\t}\n\t\n \n\tif (this.el.get_active_iter(out iter)) {\n\t\tValue vfname;\n\t\t_this.base_template_model.el.get_value (iter, 0, out vfname);\n\t\t_this.project.base_template = ((string)vfname) ;\n\t\t\n\t\t print(\"\\nSET base template to %s\\n\", _this.project.base_template );\n\t\t// is_bjs = ((string)vfname) == \"bjs\";\n\t}\n    \n  \n    // directory is only available for non-bjs \n \n\n\n}\n"
95              },
96              "id" : "base_template",
97              "* init" : "this.el.add_attribute(_this.base_template_cellrenderer.el , \"markup\", 0 );",
98              "bool loading" : false,
99              "* pack" : "attach,1,1,1,1",
100              "xtype" : "ComboBox",
101              "$ xns" : "Gtk",
102              "items" : [
103               {
104                "id" : "base_template_cellrenderer",
105                "* pack" : "pack_start,true",
106                "xtype" : "CellRendererText",
107                "$ xns" : "Gtk"
108               },
109               {
110                "id" : "base_template_model",
111                "* pack" : "set_model",
112                "xtype" : "ListStore",
113                "$ columns" : "typeof(string)",
114                "n_columns" : 1,
115                "$ xns" : "Gtk",
116                "| void loadData" : "  () {\n\t_this.base_template.loading = true;\n  \n    this.el.clear();                                    \n    Gtk.TreeIter iter;\n    var el = this.el;\n    \n   /// el.append(out iter);\n    \n   \n    el.append(out iter);\n    el.set_value(iter, 0, \"roo.builder.html\");\n    _this.base_template.el.set_active_iter(iter);\n\tif (_this.project.base_template == \"roo.builder.html\") {\n\t   _this.base_template.el.set_active_iter(iter);\n    }\n\n    el.append(out iter);\n    el.set_value(iter, 0, \"bootstrap.builder.html\");\n \n\tprint(\"\\ncur template = %s\\n\", _this.project.base_template);\n \n    if (_this.project.base_template == \"bootstrap.builder.html\") {\n\t   _this.base_template.el.set_active_iter(iter);\n    }\n\n\tel.append(out iter);\n    el.set_value(iter, 0, \"mailer.builder.html\");\n\n\tif (_this.project.base_template == \"mailer.builder.html\") {\n\t    _this.base_template.el.set_active_iter(iter);\n    }\n\t_this.base_template.loading = false;\n                                     \n}\n"
117               }
118              ]
119             },
120             {
121              "label" : "root URL",
122              "xtype" : "Label",
123              "* pack" : "attach,0,2,1,1",
124              "gint margin" : 3,
125              "$ xns" : "Gtk"
126             },
127             {
128              "id" : "rootURL",
129              "xtype" : "Entry",
130              "* pack" : "attach,1,2,1,1",
131              "$ xns" : "Gtk"
132             },
133             {
134              "label" : "Generate HTML in",
135              "* pack" : "attach,0,1,1,1",
136              "xtype" : "Label",
137              "gint margin" : 3,
138              "$ xns" : "Gtk"
139             },
140             {
141              "listeners" : {
142               "changed" : "() => {\n\tGtk.TreeIter iter;\n\tbool is_bjs = true;\n\tif (this.el.get_active_iter(out iter)) {\n\t\tValue vfname;\n\t\t_this.ftdbmodel.el.get_value (iter, 0, out vfname);\n\t\t is_bjs = ((string)vfname) == \"bjs\";\n\t}\n    \n  \n    // directory is only available for non-bjs \n    this.showhide(is_bjs);\n\n\n}\n"
143              },
144              "id" : "filetype",
145              "* init" : "this.el.add_attribute(_this.ftdbcellrenderer.el , \"markup\", 1 );",
146              "* pack" : "attach,1,0,1,1",
147              "xtype" : "ComboBox",
148              "| void showhide" : "(bool is_bjs) {\n\tfor (var i = 2; i < 9;i++) {\n\t\tvar el = _this.grid.el.get_child_at(0,i);\n\t\t\n\t\tvar showhide= is_bjs;\n\t\tif (i> 7) {\n\t\t\tshowhide = !showhide;\n\t\t}\n\t\t\n\t\tif (showhide) {\n\t\t   el.show();\n\t\t} else {\n\t\t\tel.hide();\n\t\t}\n\t\t el = _this.grid.el.get_child_at(1,i);\n\t\tif (showhide) {\n\t\t   el.show();\n\t\t} else {\n\t\t\tel.hide();\n\t\t}     \n    }\n    // load up the directories\n    //??? why can we not create bjs files in other directories??\n\tif (!is_bjs && _this.file.path.length < 1) {\n\t\t_this.dirmodel.loadData();\n\t\t\n\t\t\n\t}\n   \n    \n}\n",
149              "$ xns" : "Gtk",
150              "items" : [
151               {
152                "id" : "ftdbcellrenderer",
153                "xtype" : "CellRendererText",
154                "* pack" : "pack_start,true",
155                "$ xns" : "Gtk"
156               },
157               {
158                "id" : "ftdbmodel",
159                "xtype" : "ListStore",
160                "* pack" : "set_model",
161                "$ columns" : "typeof(string),typeof(string)",
162                "n_columns" : 2,
163                "$ xns" : "Gtk",
164                "| void loadData" : "  (string cur) {\n    this.el.clear();                                    \n    Gtk.TreeIter iter;\n    var el = this.el;\n    \n   /// el.append(out iter);\n    \n     \n   // el.set_value(iter, 0, \"\");\n   // el.set_value(iter, 1, \"aaa  - Just add Element - aaa\");\n\n    el.append(out iter);\n\n    \n    el.set_value(iter, 0, \"bjs\");\n    el.set_value(iter, 1, \"User Interface File (bjs)\");\n    _this.filetype.el.set_active_iter(iter);\n\n    el.append(out iter);\n    \n    el.set_value(iter, 0, \"vala\");\n    el.set_value(iter, 1, \"Vala\");\n\tif (cur == \"vala\") {\n\t    _this.filetype.el.set_active_iter(iter);\n    }\n\n\n\n    el.append(out iter);\n    \n    el.set_value(iter, 0, \"js\");\n    el.set_value(iter, 1, \"Javascript\");\n\n\tif (cur == \"js\") {\n\t    _this.filetype.el.set_active_iter(iter);\n    }\n\n    el.append(out iter);\n    \n    el.set_value(iter, 0, \"css\");\n    el.set_value(iter, 1, \"CSS\");\n\n\tif (cur == \"css\") {\n\t    _this.filetype.el.set_active_iter(iter);\n    }\n                                     \n}\n"
165               }
166              ]
167             }
168            ]
169           },
170           {
171            "label" : "HTML To insert at end of <HEAD>",
172            "xtype" : "Label",
173            "* pack" : "pack_start,false,false,0",
174            "$ xns" : "Gtk"
175           },
176           {
177            "* pack" : "pack_start,true,true,0",
178            "xtype" : "ScrolledWindow",
179            "$ xns" : "Gtk",
180            "items" : [
181             {
182              "listeners" : {
183               "key_release_event" : " ( event) =>{\n    if (event.keyval != 115) {\n        return false;\n         \n    }\n    if   ( (event.state & Gdk.ModifierType.CONTROL_MASK ) < 1 ) {\n        return false;\n    }\n     var buf =    this.el.get_buffer();\n    Gtk.TextIter s;\n    Gtk.TextIter e;\n    buf.get_start_iter(out s);\n    buf.get_end_iter(out e);\n    _this.project.runhtml = buf.get_text(s,e,true);\n    \n          \n    _this.buttonPressed(\"save\");\n     \n    return false;\n         \n}"
184              },
185              "id" : "view",
186              "* init" : " \n    var description =   Pango.FontDescription.from_string(\"monospace\");\n    description.set_size(9000);\n    this.el.override_font(description);",
187              "xtype" : "View",
188              "* pack" : "add",
189              "$ xns" : "GtkSource"
190             }
191            ]
192           }
193          ]
194         },
195         {
196          "* pack" : "append_page,_this.label_database.el",
197          "xtype" : "Box",
198          "gboolean homogeneous" : false,
199          "$ xns" : "Gtk",
200          "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
201          "items" : [
202           {
203            "label" : "Type (eg. MySQL or PostgreSQL)",
204            "xalign" : 0,
205            "* pack" : "pack_start,false,false,0",
206            "xtype" : "Label",
207            "$ xns" : "Gtk"
208           },
209           {
210            "listeners" : {
211             "key_press_event" : "(ev) => {\n\n    if (ev.keyval == Gdk.Key.Tab) {\n        _this.database_DBNAME.el.grab_focus();\n        return true;\n    }\n\n\n    return false;\n}\n"
212            },
213            "id" : "database_DBTYPE",
214            "xtype" : "Entry",
215            "* pack" : "pack_start,false,false,0",
216            "$ xns" : "Gtk"
217           },
218           {
219            "label" : "Name",
220            "xalign" : 0,
221            "* pack" : "pack_start,false,false,0",
222            "xtype" : "Label",
223            "$ xns" : "Gtk"
224           },
225           {
226            "listeners" : {
227             "key_press_event" : "(ev) => {\n\n    if (ev.keyval == Gdk.Key.Tab) {\n        _this.database_DBUSERNAME.el.grab_focus();\n        return true;\n    }\n\n\n    return false;\n}\n"
228            },
229            "id" : "database_DBNAME",
230            "* pack" : "pack_start,false,false,0",
231            "xtype" : "Entry",
232            "$ xns" : "Gtk"
233           },
234           {
235            "label" : "Username",
236            "xalign" : 0,
237            "* pack" : "pack_start,false,false,0",
238            "xtype" : "Label",
239            "$ xns" : "Gtk"
240           },
241           {
242            "listeners" : {
243             "key_press_event" : "(ev) => {\n\n    if (ev.keyval == Gdk.Key.Tab) {\n        _this.database_DBPASSWORD.el.grab_focus();\n        return true;\n    }\n\n\n    return false;\n}\n"
244            },
245            "id" : "database_DBUSERNAME",
246            "xtype" : "Entry",
247            "* pack" : "pack_start,false,false,0",
248            "$ xns" : "Gtk"
249           },
250           {
251            "label" : "Password",
252            "xalign" : 0,
253            "* pack" : "pack_start,false,false,0",
254            "xtype" : "Label",
255            "$ xns" : "Gtk"
256           },
257           {
258            "id" : "database_DBPASSWORD",
259            "* pack" : "pack_start,false,false,0",
260            "xtype" : "Entry",
261            "$ xns" : "Gtk"
262           },
263           {
264            "listeners" : {
265             "clicked" : "() => {\n\n\n  _this.database_ERROR.el.label    = \"\";\n    Gda.Connection cnc;\n    try {\n        // assumes localhost...\n         cnc = Gda.Connection.open_from_string (\n\t\t\t_this.database_DBTYPE.el.get_text(),\n\t\t\t\"DB_NAME=\" + _this.database_DBNAME.el.get_text(), \n\t\t\t\"USERNAME=\" + _this.database_DBUSERNAME.el.get_text() + \n\t\t\t\";PASSWORD=\" + _this.database_DBPASSWORD.el.get_text(),\n\t\t\tGda.ConnectionOptions.NONE\n\t\t);\n   //} catch (Gda.ConnectionError ce) { \n   //   _this.database_ERROR.el.label = ce.message;        \n   } catch(Gda.ConnectionError ue) {\n      _this.database_ERROR.el.label = ue.message;\n        return;\n   }  catch(Gda.ConfigError ue) {\n      _this.database_ERROR.el.label = ue.message;\n        return;\n   }\n  _this.database_ERROR.el.label = \"Connection Succeeded\";\n   cnc.close();\n}"
266            },
267            "* pack" : "pack_start,false,false,0",
268            "xtype" : "Button",
269            "$ xns" : "Gtk",
270            "utf8 label" : "Check Connection"
271           },
272           {
273            "label" : " ",
274            "id" : "database_ERROR",
275            "xalign" : 0,
276            "* pack" : "pack_start,false,false,0",
277            "xtype" : "Label",
278            "gint margin" : 3,
279            "$ xns" : "Gtk"
280           }
281          ]
282         }
283        ]
284       },
285       {
286        "* pack" : "pack_end,false,false,0",
287        "xtype" : "Box",
288        "gboolean expand" : false,
289        "$ xns" : "Gtk",
290        "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
291        "$ homogeneous" : true,
292        "gboolean vexpand" : false,
293        "items" : [
294         {
295          "listeners" : {
296           "button_press_event" : "() => {\n    _this.save();\n          \n    _this.buttonPressed(\"apply\");\n        return false;\n}"
297          },
298          "label" : "Apply",
299          "xtype" : "Button",
300          "* pack" : "add",
301          "$ xns" : "Gtk"
302         },
303         {
304          "listeners" : {
305           "button_press_event" : "() => {\n       _this.save();\n          \n    _this.buttonPressed(\"save\");\n        return false;\n}"
306          },
307          "label" : "Save",
308          "xtype" : "Button",
309          "* pack" : "add",
310          "$ xns" : "Gtk"
311         }
312        ]
313       }
314      ]
315     }
316    ]
317   }
318  ]
319 }