Fix #7420 - deprication warnings
[roobuilder] / src / Builder4 / RooProjectSettings.bjs
1 {
2  "build_module" : "builder",
3  "items" : [
4   {
5    "$ xns" : "Gtk",
6    "@ void buttonPressed" : "(string btn)",
7    "Gtk.PositionType position" : "Gtk.PositionType.RIGHT",
8    "Project.Project project" : "",
9    "bool done" : false,
10    "bool modal" : true,
11    "id" : "RooProjectSettings",
12    "items" : [
13     {
14      "$ homogeneous" : false,
15      "$ xns" : "Gtk",
16      "* pack" : "add",
17      "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
18      "border_width" : 5,
19      "items" : [
20       {
21        "$ xns" : "Gtk",
22        "* pack" : "pack_start,true,true,0",
23        "items" : [
24         {
25          "$ xns" : "Gtk",
26          "* pack" : false,
27          "id" : "label_global",
28          "utf8 label" : "Global",
29          "xtype" : "Label"
30         },
31         {
32          "$ xns" : "Gtk",
33          "* pack" : false,
34          "id" : "label_database",
35          "utf8 label" : "Database",
36          "xtype" : "Label"
37         },
38         {
39          "$ xns" : "Gtk",
40          "* pack" : "append_page,_this.label_global.el",
41          "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
42          "gboolean homogeneous" : false,
43          "items" : [
44           {
45            "$ homogeneous" : true,
46            "$ xns" : "Gtk",
47            "* pack" : "pack_start,false,false,4",
48            "id" : "grid",
49            "int margin_end" : 4,
50            "int margin_start" : 4,
51            "items" : [
52             {
53              "$ xns" : "Gtk",
54              "* pack" : "attach,0,0,1,1",
55              "gint margin" : 3,
56              "label" : "Filename",
57              "xalign" : 0,
58              "xtype" : "Label"
59             },
60             {
61              "$ xns" : "Gtk",
62              "* pack" : "attach,1,0,1,1",
63              "gint margin" : 3,
64              "id" : "path",
65              "label" : "filename",
66              "xalign" : 0,
67              "xtype" : "Label"
68             },
69             {
70              "$ xns" : "Gtk",
71              "* pack" : "attach,0,1,1,1",
72              "gint margin" : 3,
73              "label" : "HTML template file",
74              "xtype" : "Label"
75             },
76             {
77              "$ xns" : "Gtk",
78              "* init" : "this.el.add_attribute(_this.base_template_cellrenderer.el , \"markup\", 0 );",
79              "* pack" : "attach,1,1,1,1",
80              "bool loading" : false,
81              "id" : "base_template",
82              "items" : [
83               {
84                "$ xns" : "Gtk",
85                "* pack" : "pack_start,true",
86                "id" : "base_template_cellrenderer",
87                "xtype" : "CellRendererText"
88               },
89               {
90                "$ columns" : "typeof(string)",
91                "$ xns" : "Gtk",
92                "* pack" : "set_model",
93                "id" : "base_template_model",
94                "n_columns" : 1,
95                "xtype" : "ListStore",
96                "| void loadData" : [
97                 "  () {",
98                 "\t_this.base_template.loading = true;",
99                 "  ",
100                 "    this.el.clear();                                    ",
101                 "    Gtk.TreeIter iter;",
102                 "    var el = this.el;",
103                 "    ",
104                 "   /// el.append(out iter);",
105                 "    ",
106                 "   ",
107                 "    el.append(out iter);",
108                 "    el.set_value(iter, 0, \"roo.builder.html\");",
109                 "    _this.base_template.el.set_active_iter(iter);",
110                 "\tif (_this.project.base_template == \"roo.builder.html\") {",
111                 "\t   _this.base_template.el.set_active_iter(iter);",
112                 "    }",
113                 "",
114                 "    el.append(out iter);",
115                 "    el.set_value(iter, 0, \"bootstrap.builder.html\");",
116                 "  ",
117                 "\tprint(\"\\ncur template = %s\\n\", _this.project.base_template);",
118                 " ",
119                 "    if (_this.project.base_template == \"bootstrap.builder.html\") {",
120                 "\t   _this.base_template.el.set_active_iter(iter);",
121                 "    }",
122                 "\t  el.append(out iter);",
123                 "    el.set_value(iter, 0, \"bootstrap4.builder.html\");",
124                 "     if (_this.project.base_template == \"bootstrap4.builder.html\") {",
125                 "\t   _this.base_template.el.set_active_iter(iter);",
126                 "    }",
127                 "    ",
128                 "",
129                 "\tel.append(out iter);",
130                 "    el.set_value(iter, 0, \"mailer.builder.html\");",
131                 "",
132                 "\tif (_this.project.base_template == \"mailer.builder.html\") {",
133                 "\t    _this.base_template.el.set_active_iter(iter);",
134                 "    }",
135                 "\t_this.base_template.loading = false;",
136                 "                                     ",
137                 "}",
138                 ""
139                ]
140               }
141              ],
142              "listeners" : {
143               "changed" : [
144                "() => {",
145                "\tGtk.TreeIter iter;",
146                " ",
147                "\t// this get's called when we are filling in the data... ???",
148                "\tif (this.loading) {",
149                "\t\treturn;",
150                "\t}",
151                "\t",
152                " ",
153                "\tif (this.el.get_active_iter(out iter)) {",
154                "\t\tValue vfname;",
155                "\t\t_this.base_template_model.el.get_value (iter, 0, out vfname);",
156                "\t\t_this.project.base_template = ((string)vfname) ;",
157                "\t\t",
158                "\t\t print(\"\\nSET base template to %s\\n\", _this.project.base_template );",
159                "\t\t// is_bjs = ((string)vfname) == \"bjs\";",
160                "\t}",
161                "    ",
162                "  ",
163                "    // directory is only available for non-bjs ",
164                " ",
165                "",
166                "",
167                "}",
168                ""
169               ]
170              },
171              "xtype" : "ComboBox"
172             },
173             {
174              "$ xns" : "Gtk",
175              "* pack" : "attach,0,2,1,1",
176              "gint margin" : 3,
177              "label" : "root URL",
178              "xtype" : "Label"
179             },
180             {
181              "$ xns" : "Gtk",
182              "* pack" : "attach,1,2,1,1",
183              "id" : "rootURL",
184              "xtype" : "Entry"
185             },
186             {
187              "$ xns" : "Gtk",
188              "* pack" : "attach,0,3,1,1",
189              "gint margin" : 3,
190              "label" : "Generate HTML in",
191              "xtype" : "Label"
192             },
193             {
194              "$ xns" : "Gtk",
195              "* init" : "this.el.add_attribute(_this.html_gen_cellrenderer.el , \"markup\", 1 );",
196              "* pack" : "attach,1,3,1,1",
197              "id" : "html_gen",
198              "items" : [
199               {
200                "$ xns" : "Gtk",
201                "* pack" : "pack_start,true",
202                "id" : "html_gen_cellrenderer",
203                "xtype" : "CellRendererText"
204               },
205               {
206                "$ columns" : "typeof(string),typeof(string)",
207                "$ xns" : "Gtk",
208                "* pack" : "set_model",
209                "id" : "html_gen_model",
210                "n_columns" : 2,
211                "xtype" : "ListStore",
212                "| void loadData" : [
213                 "  (string cur) {",
214                 "    this.el.clear();                                    ",
215                 "    Gtk.TreeIter iter;",
216                 "    var el = this.el;",
217                 "    ",
218                 " ",
219                 "    el.append(out iter);",
220                 "",
221                 "    ",
222                 "    el.set_value(iter, 0, \"\");",
223                 "    el.set_value(iter, 1, \"Do not Generate\");",
224                 "    _this.html_gen.el.set_active_iter(iter);",
225                 "",
226                 "    el.append(out iter);",
227                 "    ",
228                 "    el.set_value(iter, 0, \"bjs\");",
229                 "    el.set_value(iter, 1, \"same directory as BJS file\");",
230                 "\tif (cur == \"bjs\") {",
231                 "\t    _this.html_gen.el.set_active_iter(iter);",
232                 "    }",
233                 "",
234                 "",
235                 "",
236                 "    el.append(out iter);",
237                 "    ",
238                 "    el.set_value(iter, 0, \"templates\");",
239                 "    el.set_value(iter, 1, \"in templates subdirectory\");",
240                 "",
241                 "\tif (cur == \"template\") {",
242                 "\t    _this.html_gen.el.set_active_iter(iter);",
243                 "    }",
244                 "",
245                 "                                     ",
246                 "}",
247                 ""
248                ]
249               }
250              ],
251              "xtype" : "ComboBox"
252             }
253            ],
254            "n_columns" : 2,
255            "n_rows" : 7,
256            "uint row_spacing" : 2,
257            "xtype" : "Grid"
258           },
259           {
260            "$ xns" : "Gtk",
261            "* pack" : "pack_start,false,false,0",
262            "label" : "HTML To insert at end of <HEAD>",
263            "xtype" : "Label"
264           },
265           {
266            "$ xns" : "Gtk",
267            "* pack" : "pack_start,true,true,0",
268            "items" : [
269             {
270              "$ xns" : "Gtk",
271              "* init" : [
272               " ",
273               "    ",
274               "this.css = new Gtk.CssProvider();",
275               "try {",
276               "\tthis.css.load_from_data(\"#roo-project-settings-view{ font: monospace 10px;}\");",
277               "} catch (Error e) {}",
278               "this.el.get_style_context().add_provider(this.css,Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);",
279               "        ",
280               "        "
281              ],
282              "* pack" : "add",
283              "Gtk.CssProvider css" : "",
284              "id" : "view",
285              "listeners" : {
286               "key_release_event" : [
287                " ( event) =>{",
288                "    if (event.keyval != 115) {",
289                "        return false;",
290                "         ",
291                "    }",
292                "    if   ( (event.state & Gdk.ModifierType.CONTROL_MASK ) < 1 ) {",
293                "        return false;",
294                "    }",
295                "     var buf =    this.el.get_buffer();",
296                "    Gtk.TextIter s;",
297                "    Gtk.TextIter e;",
298                "    buf.get_start_iter(out s);",
299                "    buf.get_end_iter(out e);",
300                "    _this.project.runhtml = buf.get_text(s,e,true);",
301                "    ",
302                "          ",
303                "    _this.buttonPressed(\"save\");",
304                "     ",
305                "    return false;",
306                "         ",
307                "}"
308               ]
309              },
310              "string name" : "roo-project-settings-view",
311              "xtype" : "SourceView"
312             }
313            ],
314            "xtype" : "ScrolledWindow"
315           }
316          ],
317          "xtype" : "Box"
318         },
319         {
320          "$ xns" : "Gtk",
321          "* pack" : "append_page,_this.label_database.el",
322          "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
323          "gboolean homogeneous" : false,
324          "items" : [
325           {
326            "$ xns" : "Gtk",
327            "* pack" : "pack_start,false,false,0",
328            "label" : "Type (eg. MySQL or PostgreSQL)",
329            "xalign" : 0,
330            "xtype" : "Label"
331           },
332           {
333            "$ xns" : "Gtk",
334            "* pack" : "pack_start,false,false,0",
335            "id" : "database_DBTYPE",
336            "listeners" : {
337             "key_press_event" : [
338              "(ev) => {",
339              "",
340              "    if (ev.keyval == Gdk.Key.Tab) {",
341              "        _this.database_DBNAME.el.grab_focus();",
342              "        return true;",
343              "    }",
344              "",
345              "",
346              "    return false;",
347              "}",
348              ""
349             ]
350            },
351            "xtype" : "Entry"
352           },
353           {
354            "$ xns" : "Gtk",
355            "* pack" : "pack_start,false,false,0",
356            "label" : "Name",
357            "xalign" : 0,
358            "xtype" : "Label"
359           },
360           {
361            "$ xns" : "Gtk",
362            "* pack" : "pack_start,false,false,0",
363            "id" : "database_DBNAME",
364            "listeners" : {
365             "key_press_event" : [
366              "(ev) => {",
367              "",
368              "    if (ev.keyval == Gdk.Key.Tab) {",
369              "        _this.database_DBUSERNAME.el.grab_focus();",
370              "        return true;",
371              "    }",
372              "",
373              "",
374              "    return false;",
375              "}",
376              ""
377             ]
378            },
379            "xtype" : "Entry"
380           },
381           {
382            "$ xns" : "Gtk",
383            "* pack" : "pack_start,false,false,0",
384            "label" : "Username",
385            "xalign" : 0,
386            "xtype" : "Label"
387           },
388           {
389            "$ xns" : "Gtk",
390            "* pack" : "pack_start,false,false,0",
391            "id" : "database_DBUSERNAME",
392            "listeners" : {
393             "key_press_event" : [
394              "(ev) => {",
395              "",
396              "    if (ev.keyval == Gdk.Key.Tab) {",
397              "        _this.database_DBPASSWORD.el.grab_focus();",
398              "        return true;",
399              "    }",
400              "",
401              "",
402              "    return false;",
403              "}",
404              ""
405             ]
406            },
407            "xtype" : "Entry"
408           },
409           {
410            "$ xns" : "Gtk",
411            "* pack" : "pack_start,false,false,0",
412            "label" : "Password",
413            "xalign" : 0,
414            "xtype" : "Label"
415           },
416           {
417            "$ xns" : "Gtk",
418            "* pack" : "pack_start,false,false,0",
419            "id" : "database_DBPASSWORD",
420            "xtype" : "Entry"
421           },
422           {
423            "$ xns" : "Gtk",
424            "* pack" : "pack_start,false,false,0",
425            "listeners" : {
426             "clicked" : [
427              "() => {",
428              "",
429              "",
430              "  _this.database_ERROR.el.label    = \"\";",
431              "    Gda.Connection cnc;",
432              "    try {",
433              "        // assumes localhost...",
434              "         cnc = Gda.Connection.open_from_string (",
435              "\t\t\t_this.database_DBTYPE.el.get_text(),",
436              "\t\t\t\"DB_NAME=\" + _this.database_DBNAME.el.get_text(), ",
437              "\t\t\t\"USERNAME=\" + _this.database_DBUSERNAME.el.get_text() + ",
438              "\t\t\t\";PASSWORD=\" + _this.database_DBPASSWORD.el.get_text(),",
439              "\t\t\tGda.ConnectionOptions.NONE",
440              "\t\t);",
441              "   //} catch (Gda.ConnectionError ce) { ",
442              "   //   _this.database_ERROR.el.label = ce.message;        ",
443              "   } catch(Gda.ConnectionError ue) {",
444              "      _this.database_ERROR.el.label = ue.message;",
445              "        return;",
446              "   }  catch(Gda.ConfigError ue) {",
447              "      _this.database_ERROR.el.label = ue.message;",
448              "        return;",
449              "   }",
450              "  _this.database_ERROR.el.label = \"Connection Succeeded\";",
451              "   cnc.close();",
452              "}"
453             ]
454            },
455            "utf8 label" : "Check Connection",
456            "xtype" : "Button"
457           },
458           {
459            "$ xns" : "Gtk",
460            "* pack" : "pack_start,false,false,0",
461            "gint margin" : 3,
462            "id" : "database_ERROR",
463            "label" : " ",
464            "xalign" : 0,
465            "xtype" : "Label"
466           }
467          ],
468          "xtype" : "Box"
469         }
470        ],
471        "xtype" : "Notebook"
472       },
473       {
474        "$ Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
475        "$ xns" : "Gtk",
476        "int margin_bottom" : 4,
477        "int margin_end" : 4,
478        "int margin_start" : 4,
479        "int margin_top" : 4,
480        "items" : [
481         {
482          "$ xns" : "Gtk",
483          "* pack" : "add",
484          "listeners" : {
485           "clicked" : [
486            "() => { ",
487            "",
488            "  _this.done = true;",
489            "    _this.el.hide(); ",
490            "}"
491           ]
492          },
493          "string label" : "Cancel",
494          "xtype" : "Button"
495         },
496         {
497          "$ xns" : "Gtk",
498          "* pack" : "add",
499          "listeners" : {
500           "clicked" : [
501            "( ) =>  { ",
502            "",
503            "   _this.buttonPressed(\"apply\");",
504            " ",
505            "   ",
506            "}"
507           ]
508          },
509          "string label" : "Apply / Keep editing",
510          "xtype" : "Button"
511         },
512         {
513          "$ xns" : "Gtk",
514          "* pack" : "add",
515          "listeners" : {
516           "clicked" : [
517            "( ) =>  { ",
518            "",
519            " ",
520            " _this.buttonPressed(\"save\");",
521            " ",
522            "\t// what about .js ?",
523            "   _this.done = true;",
524            "\t_this.el.hide();",
525            "",
526            "// hopefull this will work with bjs files..",
527            "\t",
528            " ",
529            "   ",
530            "}"
531           ]
532          },
533          "string label" : "Save",
534          "xtype" : "Button"
535         }
536        ],
537        "xtype" : "ButtonBox"
538       }
539      ],
540      "xtype" : "Box"
541     }
542    ],
543    "uint border_width" : 0,
544    "xtype" : "Popover",
545    "| void save" : [
546     "() {",
547     "   var buf =    _this.view.el.get_buffer();",
548     "   Gtk.TextIter s;",
549     "     Gtk.TextIter e;",
550     "    buf.get_start_iter(out s);",
551     "    buf.get_end_iter(out e);",
552     "\t_this.project.runhtml = buf.get_text(s,e,true);",
553     "      ",
554     "    _this.project.rootURL = _this.rootURL.el.get_text();",
555     "    ",
556     "    ",
557     "    Gtk.TreeIter iter;",
558     "    Value html_gen_val;",
559     "    _this.html_gen.el.get_active_iter(out iter);",
560     "    _this.html_gen_model.el.get_value (iter, 0, out html_gen_val);",
561     "    ",
562     "    _this.project.html_gen = (string)html_gen_val;",
563     "    ",
564     "    // set by event changed...",
565     "    //_this.project.base_template = _this.base_template.el.get_text();    ",
566     "    ",
567     "    var js = _this.project.json_project_data;",
568     "    js.set_string_member(\"DBTYPE\", _this.database_DBTYPE.el.get_text());",
569     "   js.set_string_member(\"DBNAME\", _this.database_DBNAME.el.get_text());",
570     "    js.set_string_member(\"DBUSERNAME\", _this.database_DBUSERNAME.el.get_text());",
571     "    js.set_string_member(\"DBPASSWORD\", _this.database_DBPASSWORD.el.get_text());",
572     "//    _this.project.set_string_member(\"DBHOST\", _this.DBTYPE.el.get_text());    ",
573     "    ",
574     "    // need to re-init the database ",
575     "    ",
576     "    _this.project.initRooDatabase();",
577     "     ",
578     "    ",
579     "}"
580    ],
581    "| void show" : [
582     " (Gtk.Widget btn, Project.Project project) {",
583     "    _this.done = false;",
584     "    ",
585     "    _this.project = project;",
586     "    _this.path.el.label = project.firstPath();",
587     "    // get the active project.",
588     "     var lm = Gtk.SourceLanguageManager.get_default();",
589     "                ",
590     "    ((Gtk.SourceBuffer)(_this.view.el.get_buffer())) .set_language(",
591     "        lm.get_language(\"html\")",
592     "    );",
593     "  ",
594     "    //print (project.fn);",
595     "    //project.runhtml = project.runhtml || '';",
596     "    _this.view.el.get_buffer().set_text(project.runhtml);",
597     "    ",
598     "      ",
599     "      ",
600     "    _this.rootURL.el.set_text( _this.project.rootURL );",
601     "    ",
602     "    _this.html_gen_model.loadData(_this.project.html_gen);",
603     "",
604     "    _this.base_template_model.loadData();",
605     "    ",
606     "     var js = _this.project;",
607     "    _this.database_DBTYPE.el.set_text(     js.get_string_member(\"DBTYPE\") );",
608     "    _this.database_DBNAME.el.set_text(    js.get_string_member(\"DBNAME\") );",
609     "    _this.database_DBUSERNAME.el.set_text(    js.get_string_member(\"DBUSERNAME\") );",
610     "    _this.database_DBPASSWORD.el.set_text(    js.get_string_member(\"DBPASSWORD\") );",
611     "    ",
612     "    \t//console.log('show all');",
613     "\tthis.el.set_modal(true);",
614     "\tthis.el.set_relative_to(btn);",
615     "",
616     "\tthis.el.set_position(Gtk.PositionType.RIGHT);",
617     "",
618     "\t// window + header?",
619     "\t print(\"SHOWALL - POPIP\\n\");",
620     "\tthis.el.show_all();",
621     "\tthis.el.set_size_request(800,600);",
622     "\tthis.view.el.grab_focus();",
623     "\t",
624     "    ",
625     "    //this.el.show_all();",
626     "}",
627     ""
628    ]
629   }
630  ],
631  "modOrder" : "",
632  "name" : "RooProjectSettings",
633  "parent" : "",
634  "path" : "/home/alan/gitlive/roobuilder/src/Builder4/RooProjectSettings.bjs",
635  "permname" : "",
636  "title" : ""
637 }