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,3,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" : "html_gen",
145              "* init" : "this.el.add_attribute(_this.ftdbcellrenderer.el , \"markup\", 1 );",
146              "* pack" : "attach,1,3,1,1",
147              "xtype" : "ComboBox",
148              "$ xns" : "Gtk",
149              "items" : [
150               {
151                "id" : "html_gen_cellrenderer",
152                "xtype" : "CellRendererText",
153                "* pack" : "pack_start,true",
154                "$ xns" : "Gtk"
155               },
156               {
157                "id" : "html_gen_model",
158                "xtype" : "ListStore",
159                "* pack" : "set_model",
160                "$ columns" : "typeof(string),typeof(string)",
161                "n_columns" : 2,
162                "$ xns" : "Gtk",
163                "| 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"
164               }
165              ]
166             }
167            ]
168           },
169           {
170            "label" : "HTML To insert at end of <HEAD>",
171            "xtype" : "Label",
172            "* pack" : "pack_start,false,false,0",
173            "$ xns" : "Gtk"
174           },
175           {
176            "* pack" : "pack_start,true,true,0",
177            "xtype" : "ScrolledWindow",
178            "$ xns" : "Gtk",
179            "items" : [
180             {
181              "listeners" : {
182               "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}"
183              },
184              "id" : "view",
185              "* init" : " \n    var description =   Pango.FontDescription.from_string(\"monospace\");\n    description.set_size(9000);\n    this.el.override_font(description);",
186              "xtype" : "View",
187              "* pack" : "add",
188              "$ xns" : "GtkSource"
189             }
190            ]
191           }
192          ]
193         },
194         {
195          "* pack" : "append_page,_this.label_database.el",
196          "xtype" : "Box",
197          "gboolean homogeneous" : false,
198          "$ xns" : "Gtk",
199          "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
200          "items" : [
201           {
202            "label" : "Type (eg. MySQL or PostgreSQL)",
203            "xalign" : 0,
204            "* pack" : "pack_start,false,false,0",
205            "xtype" : "Label",
206            "$ xns" : "Gtk"
207           },
208           {
209            "listeners" : {
210             "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"
211            },
212            "id" : "database_DBTYPE",
213            "xtype" : "Entry",
214            "* pack" : "pack_start,false,false,0",
215            "$ xns" : "Gtk"
216           },
217           {
218            "label" : "Name",
219            "xalign" : 0,
220            "* pack" : "pack_start,false,false,0",
221            "xtype" : "Label",
222            "$ xns" : "Gtk"
223           },
224           {
225            "listeners" : {
226             "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"
227            },
228            "id" : "database_DBNAME",
229            "* pack" : "pack_start,false,false,0",
230            "xtype" : "Entry",
231            "$ xns" : "Gtk"
232           },
233           {
234            "label" : "Username",
235            "xalign" : 0,
236            "* pack" : "pack_start,false,false,0",
237            "xtype" : "Label",
238            "$ xns" : "Gtk"
239           },
240           {
241            "listeners" : {
242             "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"
243            },
244            "id" : "database_DBUSERNAME",
245            "xtype" : "Entry",
246            "* pack" : "pack_start,false,false,0",
247            "$ xns" : "Gtk"
248           },
249           {
250            "label" : "Password",
251            "xalign" : 0,
252            "* pack" : "pack_start,false,false,0",
253            "xtype" : "Label",
254            "$ xns" : "Gtk"
255           },
256           {
257            "id" : "database_DBPASSWORD",
258            "* pack" : "pack_start,false,false,0",
259            "xtype" : "Entry",
260            "$ xns" : "Gtk"
261           },
262           {
263            "listeners" : {
264             "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}"
265            },
266            "* pack" : "pack_start,false,false,0",
267            "xtype" : "Button",
268            "$ xns" : "Gtk",
269            "utf8 label" : "Check Connection"
270           },
271           {
272            "label" : " ",
273            "id" : "database_ERROR",
274            "xalign" : 0,
275            "* pack" : "pack_start,false,false,0",
276            "xtype" : "Label",
277            "gint margin" : 3,
278            "$ xns" : "Gtk"
279           }
280          ]
281         }
282        ]
283       },
284       {
285        "* pack" : "pack_end,false,false,0",
286        "xtype" : "Box",
287        "gboolean expand" : false,
288        "$ xns" : "Gtk",
289        "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
290        "$ homogeneous" : true,
291        "gboolean vexpand" : false,
292        "items" : [
293         {
294          "listeners" : {
295           "button_press_event" : "() => {\n    _this.save();\n          \n    _this.buttonPressed(\"apply\");\n        return false;\n}"
296          },
297          "label" : "Apply",
298          "xtype" : "Button",
299          "* pack" : "add",
300          "$ xns" : "Gtk"
301         },
302         {
303          "listeners" : {
304           "button_press_event" : "() => {\n       _this.save();\n          \n    _this.buttonPressed(\"save\");\n        return false;\n}"
305          },
306          "label" : "Save",
307          "xtype" : "Button",
308          "* pack" : "add",
309          "$ xns" : "Gtk"
310         }
311        ]
312       }
313      ]
314     }
315    ]
316   }
317  ]
318 }