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