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" : "ProjectSettings",
13    "| void show" : " (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    //this.el.show_all();\n}\n",
14    "xtype" : "Popover",
15    "| 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}",
16    "$ xns" : "Gtk",
17    "Project.Project project" : "",
18    "uint border_width" : 0,
19    "items" : [
20     {
21      "xtype" : "Box",
22      "* pack" : "add",
23      "$ xns" : "Gtk",
24      "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
25      "border_width" : 5,
26      "$ homogeneous" : false,
27      "items" : [
28       {
29        "* pack" : "pack_start,false,false,0",
30        "xtype" : "Box",
31        "gboolean expand" : false,
32        "$ xns" : "Gtk",
33        "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
34        "$ homogeneous" : true,
35        "gboolean vexpand" : false,
36        "items" : [
37         {
38          "listeners" : {
39           "button_press_event" : "() => {\n    _this.save();\n          \n    _this.buttonPressed(\"apply\");\n        return false;\n}"
40          },
41          "label" : "Apply",
42          "* pack" : "add",
43          "xtype" : "Button",
44          "$ xns" : "Gtk"
45         },
46         {
47          "listeners" : {
48           "button_press_event" : "() => {\n       _this.save();\n          \n    _this.buttonPressed(\"save\");\n        return false;\n}"
49          },
50          "label" : "Save",
51          "* pack" : "add",
52          "xtype" : "Button",
53          "$ xns" : "Gtk"
54         }
55        ]
56       },
57       {
58        "* pack" : "pack_end,true,true,0",
59        "xtype" : "Notebook",
60        "$ xns" : "Gtk",
61        "items" : [
62         {
63          "id" : "label_global",
64          "xtype" : "Label",
65          "* pack" : false,
66          "$ xns" : "Gtk",
67          "utf8 label" : "Global"
68         },
69         {
70          "id" : "label_database",
71          "* pack" : false,
72          "xtype" : "Label",
73          "$ xns" : "Gtk",
74          "utf8 label" : "Database"
75         },
76         {
77          "* pack" : "append_page,_this.label_global.el",
78          "xtype" : "Box",
79          "gboolean homogeneous" : false,
80          "$ xns" : "Gtk",
81          "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
82          "items" : [
83           {
84            "label" : "filename",
85            "id" : "path",
86            "xalign" : 0,
87            "* pack" : "pack_start,false,false,0",
88            "xtype" : "Label",
89            "gint margin" : 3,
90            "$ xns" : "Gtk"
91           },
92           {
93            "* pack" : "pack_start,false,false,0",
94            "xtype" : "Box",
95            "gboolean expand" : false,
96            "$ xns" : "Gtk",
97            "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
98            "$ homogeneous" : false,
99            "items" : [
100             {
101              "label" : "HTML template file",
102              "xtype" : "Label",
103              "* pack" : "pack_start,false,false,0",
104              "gint margin" : 3,
105              "$ xns" : "Gtk"
106             },
107             {
108              "id" : "base_template",
109              "xtype" : "Entry",
110              "* pack" : "add",
111              "$ xns" : "Gtk"
112             }
113            ]
114           },
115           {
116            "* pack" : "pack_start,false,false,0",
117            "xtype" : "Box",
118            "gboolean expand" : false,
119            "$ xns" : "Gtk",
120            "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
121            "$ homogeneous" : false,
122            "items" : [
123             {
124              "label" : "root URL",
125              "xtype" : "Label",
126              "* pack" : "pack_start,false,false,0",
127              "gint margin" : 3,
128              "$ xns" : "Gtk"
129             },
130             {
131              "id" : "rootURL",
132              "xtype" : "Entry",
133              "* pack" : "add",
134              "$ xns" : "Gtk"
135             }
136            ]
137           },
138           {
139            "label" : "HTML To insert at end of <HEAD>",
140            "xtype" : "Label",
141            "* pack" : "pack_start,false,false,0",
142            "$ xns" : "Gtk"
143           },
144           {
145            "* pack" : "pack_start,true,true,0",
146            "xtype" : "ScrolledWindow",
147            "$ xns" : "Gtk",
148            "items" : [
149             {
150              "listeners" : {
151               "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}"
152              },
153              "id" : "view",
154              "* init" : " \n    var description =   Pango.FontDescription.from_string(\"monospace\");\n    description.set_size(9000);\n    this.el.override_font(description);",
155              "xtype" : "View",
156              "* pack" : "add",
157              "$ xns" : "GtkSource"
158             }
159            ]
160           }
161          ]
162         },
163         {
164          "* pack" : "append_page,_this.label_database.el",
165          "xtype" : "Box",
166          "gboolean homogeneous" : false,
167          "$ xns" : "Gtk",
168          "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
169          "items" : [
170           {
171            "label" : "Type (eg. MySQL or PostgreSQL)",
172            "xalign" : 0,
173            "* pack" : "pack_start,false,false,0",
174            "xtype" : "Label",
175            "$ xns" : "Gtk"
176           },
177           {
178            "listeners" : {
179             "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"
180            },
181            "id" : "database_DBTYPE",
182            "* pack" : "pack_start,false,false,0",
183            "xtype" : "Entry",
184            "$ xns" : "Gtk"
185           },
186           {
187            "label" : "Name",
188            "xalign" : 0,
189            "* pack" : "pack_start,false,false,0",
190            "xtype" : "Label",
191            "$ xns" : "Gtk"
192           },
193           {
194            "listeners" : {
195             "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"
196            },
197            "id" : "database_DBNAME",
198            "xtype" : "Entry",
199            "* pack" : "pack_start,false,false,0",
200            "$ xns" : "Gtk"
201           },
202           {
203            "label" : "Username",
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_DBPASSWORD.el.grab_focus();\n        return true;\n    }\n\n\n    return false;\n}\n"
212            },
213            "id" : "database_DBUSERNAME",
214            "* pack" : "pack_start,false,false,0",
215            "xtype" : "Entry",
216            "$ xns" : "Gtk"
217           },
218           {
219            "label" : "Password",
220            "xalign" : 0,
221            "* pack" : "pack_start,false,false,0",
222            "xtype" : "Label",
223            "$ xns" : "Gtk"
224           },
225           {
226            "id" : "database_DBPASSWORD",
227            "xtype" : "Entry",
228            "* pack" : "pack_start,false,false,0",
229            "$ xns" : "Gtk"
230           },
231           {
232            "listeners" : {
233             "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}"
234            },
235            "* pack" : "pack_start,false,false,0",
236            "xtype" : "Button",
237            "$ xns" : "Gtk",
238            "utf8 label" : "Check Connection"
239           },
240           {
241            "label" : " ",
242            "id" : "database_ERROR",
243            "xalign" : 0,
244            "* pack" : "pack_start,false,false,0",
245            "xtype" : "Label",
246            "gint margin" : 3,
247            "$ xns" : "Gtk"
248           }
249          ]
250         }
251        ]
252       }
253      ]
254     }
255    ]
256   }
257  ]
258 }