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    \n        lm.get_language(\"html\"));\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    _this.base_template.el.set_text(_this.project.base_template);    \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    _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            "label" : "filename",
58            "id" : "path",
59            "xalign" : 0,
60            "* pack" : "pack_start,false,false,0",
61            "xtype" : "Label",
62            "gint margin" : 3,
63            "$ xns" : "Gtk"
64           },
65           {
66            "* pack" : "pack_start,false,false,0",
67            "xtype" : "Box",
68            "gboolean expand" : false,
69            "$ xns" : "Gtk",
70            "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
71            "$ homogeneous" : false,
72            "items" : [
73             {
74              "label" : "HTML template file",
75              "* pack" : "pack_start,false,false,0",
76              "xtype" : "Label",
77              "gint margin" : 3,
78              "$ xns" : "Gtk"
79             },
80             {
81              "listeners" : {
82               "changed" : "() => {\n\tGtk.TreeIter iter;\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// is_bjs = ((string)vfname) == \"bjs\";\n\t}\n    \n  \n    // directory is only available for non-bjs \n \n\n\n}\n"
83              },
84              "id" : "base_template",
85              "* init" : "this.el.add_attribute(_this.base_template_cellrenderer.el , \"markup\", 1 );",
86              "* pack" : "attach,1,0,1,1",
87              "xtype" : "ComboBox",
88              "$ xns" : "Gtk",
89              "items" : [
90               {
91                "id" : "base_template_cellrenderer",
92                "xtype" : "CellRendererText",
93                "* pack" : "pack_start,true",
94                "$ xns" : "Gtk"
95               },
96               {
97                "id" : "base_template_model",
98                "xtype" : "ListStore",
99                "* pack" : "set_model",
100                "$ columns" : "typeof(string),typeof(string)",
101                "n_columns" : 2,
102                "$ xns" : "Gtk",
103                "| 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, \"roo.builder.html\");\n    _this.filetype.el.set_active_iter(iter);\n\n    el.append(out iter);\n    el.set_value(iter, 0, \"bootstrap.builder.html\");\n    if (cur == \"bootstrap.builder.html\") {\n\t   _this.base_template.el.set_active_iter(iter);\n   }\n\tel.append(out iter);\n\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"
104               }
105              ]
106             }
107            ]
108           },
109           {
110            "* pack" : "pack_start,false,false,0",
111            "xtype" : "Box",
112            "gboolean expand" : false,
113            "$ xns" : "Gtk",
114            "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
115            "$ homogeneous" : false,
116            "items" : [
117             {
118              "label" : "root URL",
119              "* pack" : "pack_start,false,false,0",
120              "xtype" : "Label",
121              "gint margin" : 3,
122              "$ xns" : "Gtk"
123             },
124             {
125              "id" : "rootURL",
126              "* pack" : "add",
127              "xtype" : "Entry",
128              "$ xns" : "Gtk"
129             }
130            ]
131           },
132           {
133            "label" : "HTML To insert at end of <HEAD>",
134            "* pack" : "pack_start,false,false,0",
135            "xtype" : "Label",
136            "$ xns" : "Gtk"
137           },
138           {
139            "* pack" : "pack_start,true,true,0",
140            "xtype" : "ScrolledWindow",
141            "$ xns" : "Gtk",
142            "items" : [
143             {
144              "listeners" : {
145               "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}"
146              },
147              "id" : "view",
148              "* init" : " \n    var description =   Pango.FontDescription.from_string(\"monospace\");\n    description.set_size(9000);\n    this.el.override_font(description);",
149              "xtype" : "View",
150              "* pack" : "add",
151              "$ xns" : "GtkSource"
152             }
153            ]
154           }
155          ]
156         },
157         {
158          "* pack" : "append_page,_this.label_database.el",
159          "xtype" : "Box",
160          "gboolean homogeneous" : false,
161          "$ xns" : "Gtk",
162          "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
163          "items" : [
164           {
165            "label" : "Type (eg. MySQL or PostgreSQL)",
166            "xalign" : 0,
167            "* pack" : "pack_start,false,false,0",
168            "xtype" : "Label",
169            "$ xns" : "Gtk"
170           },
171           {
172            "listeners" : {
173             "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"
174            },
175            "id" : "database_DBTYPE",
176            "xtype" : "Entry",
177            "* pack" : "pack_start,false,false,0",
178            "$ xns" : "Gtk"
179           },
180           {
181            "label" : "Name",
182            "xalign" : 0,
183            "* pack" : "pack_start,false,false,0",
184            "xtype" : "Label",
185            "$ xns" : "Gtk"
186           },
187           {
188            "listeners" : {
189             "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"
190            },
191            "id" : "database_DBNAME",
192            "* pack" : "pack_start,false,false,0",
193            "xtype" : "Entry",
194            "$ xns" : "Gtk"
195           },
196           {
197            "label" : "Username",
198            "xalign" : 0,
199            "* pack" : "pack_start,false,false,0",
200            "xtype" : "Label",
201            "$ xns" : "Gtk"
202           },
203           {
204            "listeners" : {
205             "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"
206            },
207            "id" : "database_DBUSERNAME",
208            "xtype" : "Entry",
209            "* pack" : "pack_start,false,false,0",
210            "$ xns" : "Gtk"
211           },
212           {
213            "label" : "Password",
214            "xalign" : 0,
215            "* pack" : "pack_start,false,false,0",
216            "xtype" : "Label",
217            "$ xns" : "Gtk"
218           },
219           {
220            "id" : "database_DBPASSWORD",
221            "* pack" : "pack_start,false,false,0",
222            "xtype" : "Entry",
223            "$ xns" : "Gtk"
224           },
225           {
226            "listeners" : {
227             "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}"
228            },
229            "* pack" : "pack_start,false,false,0",
230            "xtype" : "Button",
231            "$ xns" : "Gtk",
232            "utf8 label" : "Check Connection"
233           },
234           {
235            "label" : " ",
236            "id" : "database_ERROR",
237            "xalign" : 0,
238            "* pack" : "pack_start,false,false,0",
239            "xtype" : "Label",
240            "gint margin" : 3,
241            "$ xns" : "Gtk"
242           }
243          ]
244         }
245        ]
246       },
247       {
248        "* pack" : "pack_end,false,false,0",
249        "xtype" : "Box",
250        "gboolean expand" : false,
251        "$ xns" : "Gtk",
252        "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
253        "$ homogeneous" : true,
254        "gboolean vexpand" : false,
255        "items" : [
256         {
257          "listeners" : {
258           "button_press_event" : "() => {\n    _this.save();\n          \n    _this.buttonPressed(\"apply\");\n        return false;\n}"
259          },
260          "label" : "Apply",
261          "xtype" : "Button",
262          "* pack" : "add",
263          "$ xns" : "Gtk"
264         },
265         {
266          "listeners" : {
267           "button_press_event" : "() => {\n       _this.save();\n          \n    _this.buttonPressed(\"save\");\n        return false;\n}"
268          },
269          "label" : "Save",
270          "xtype" : "Button",
271          "* pack" : "add",
272          "$ xns" : "Gtk"
273         }
274        ]
275       }
276      ]
277     }
278    ]
279   }
280  ]
281 }