src/Builder4/ProjectSettings.bjs
[app.Builder.js] / src / Builder4 / ProjectSettings.bjs
1 {
2  "name" : "ProjectSettings",
3  "parent" : "",
4  "title" : "",
5  "path" : "/home/alan/gitlive/app.Builder.js/src/Builder4/ProjectSettings.bjs",
6  "permname" : "",
7  "modOrder" : "",
8  "items" : [
9   {
10    "@ void buttonPressed" : "(string btn)",
11    "id" : "ProjectSettings",
12    "| 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",
13    "# Project.Project project" : "",
14    "xtype" : "VBox",
15    "| void save" : "()\n{\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    \n    \n}",
16    "$ xns" : "Gtk",
17    "border_width" : 5,
18    "$ homogeneous" : false,
19    "items" : [
20     {
21      "* pack" : "pack_start,false,false,0",
22      "xtype" : "HBox",
23      "gboolean expand" : false,
24      "$ xns" : "Gtk",
25      "$ homogeneous" : true,
26      "gboolean vexpand" : false,
27      "items" : [
28       {
29        "listeners" : {
30         "button_press_event" : "() => {\n    _this.save();\n          \n    _this.buttonPressed(\"apply\");\n        return false;\n}"
31        },
32        "label" : "Apply",
33        "* pack" : "add",
34        "xtype" : "Button",
35        "$ xns" : "Gtk"
36       },
37       {
38        "listeners" : {
39         "button_press_event" : "() => {\n       _this.save();\n          \n    _this.buttonPressed(\"save\");\n        return false;\n}"
40        },
41        "label" : "Save",
42        "* pack" : "add",
43        "xtype" : "Button",
44        "$ xns" : "Gtk"
45       }
46      ]
47     },
48     {
49      "* pack" : "pack_end,true,true,0",
50      "xtype" : "Notebook",
51      "$ xns" : "Gtk",
52      "items" : [
53       {
54        "id" : "label_global",
55        "xtype" : "Label",
56        "* pack" : false,
57        "$ xns" : "Gtk",
58        "utf8 label" : "Global"
59       },
60       {
61        "id" : "label_database",
62        "* pack" : false,
63        "xtype" : "Label",
64        "$ xns" : "Gtk",
65        "utf8 label" : "Database"
66       },
67       {
68        "* pack" : "append_page,_this.label_global.el",
69        "xtype" : "VBox",
70        "gboolean homogeneous" : false,
71        "$ xns" : "Gtk",
72        "items" : [
73         {
74          "label" : "filename",
75          "id" : "path",
76          "xalign" : 0,
77          "* pack" : "pack_start,false,false,0",
78          "xtype" : "Label",
79          "gint margin" : 3,
80          "$ xns" : "Gtk"
81         },
82         {
83          "* pack" : "pack_start,false,false,0",
84          "xtype" : "HBox",
85          "gboolean expand" : false,
86          "$ xns" : "Gtk",
87          "$ homogeneous" : false,
88          "items" : [
89           {
90            "label" : "HTML template file",
91            "xtype" : "Label",
92            "* pack" : "pack_start,false,false,0",
93            "gint margin" : 3,
94            "$ xns" : "Gtk"
95           },
96           {
97            "id" : "base_template",
98            "xtype" : "Entry",
99            "* pack" : "add",
100            "$ xns" : "Gtk"
101           }
102          ]
103         },
104         {
105          "* pack" : "pack_start,false,false,0",
106          "xtype" : "HBox",
107          "gboolean expand" : false,
108          "$ xns" : "Gtk",
109          "$ homogeneous" : false,
110          "items" : [
111           {
112            "label" : "root URL",
113            "xtype" : "Label",
114            "* pack" : "pack_start,false,false,0",
115            "gint margin" : 3,
116            "$ xns" : "Gtk"
117           },
118           {
119            "id" : "rootURL",
120            "xtype" : "Entry",
121            "* pack" : "add",
122            "$ xns" : "Gtk"
123           }
124          ]
125         },
126         {
127          "label" : "HTML To insert at end of <HEAD>",
128          "xtype" : "Label",
129          "* pack" : "pack_start,false,false,0",
130          "$ xns" : "Gtk"
131         },
132         {
133          "* pack" : "pack_start,true,true,0",
134          "xtype" : "ScrolledWindow",
135          "$ xns" : "Gtk",
136          "items" : [
137           {
138            "listeners" : {
139             "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}"
140            },
141            "id" : "view",
142            "* init" : " \n    var description =   Pango.FontDescription.from_string(\"monospace\");\n    description.set_size(9000);\n    this.el.override_font(description);",
143            "xtype" : "View",
144            "* pack" : "add",
145            "$ xns" : "GtkSource"
146           }
147          ]
148         }
149        ]
150       },
151       {
152        "* init" : "{\n   var chain = new GLib.List<Gtk.Widget>();\n   chain.append(_this.database_DBTYPE.el);\n   chain.append(_this.database_DBNAME.el);\n     chain.append(_this.database_DBUSERNAME.el);\n   chain.append(_this.database_DBPASSWORD.el);\n   this.el.set_focus_chain(chain);\n}\n\n",
153        "* pack" : "append_page,_this.label_database.el",
154        "xtype" : "VBox",
155        "gboolean homogeneous" : false,
156        "$ xns" : "Gtk",
157        "items" : [
158         {
159          "label" : "Type (eg. MySQL or PostgreSQL)",
160          "xalign" : 0,
161          "* pack" : "pack_start,false,false,0",
162          "xtype" : "Label",
163          "$ xns" : "Gtk"
164         },
165         {
166          "id" : "database_DBTYPE",
167          "* pack" : "pack_start,false,false,0",
168          "xtype" : "Entry",
169          "$ xns" : "Gtk"
170         },
171         {
172          "label" : "Name",
173          "xalign" : 0,
174          "* pack" : "pack_start,false,false,0",
175          "xtype" : "Label",
176          "$ xns" : "Gtk"
177         },
178         {
179          "id" : "database_DBNAME",
180          "xtype" : "Entry",
181          "* pack" : "pack_start,false,false,0",
182          "$ xns" : "Gtk"
183         },
184         {
185          "label" : "Username",
186          "xalign" : 0,
187          "* pack" : "pack_start,false,false,0",
188          "xtype" : "Label",
189          "$ xns" : "Gtk"
190         },
191         {
192          "id" : "database_DBUSERNAME",
193          "* pack" : "pack_start,false,false,0",
194          "xtype" : "Entry",
195          "$ xns" : "Gtk"
196         },
197         {
198          "label" : "Password",
199          "xalign" : 0,
200          "* pack" : "pack_start,false,false,0",
201          "xtype" : "Label",
202          "$ xns" : "Gtk"
203         },
204         {
205          "id" : "database_DBPASSWORD",
206          "xtype" : "Entry",
207          "* pack" : "pack_start,false,false,0",
208          "$ xns" : "Gtk"
209         },
210         {
211          "listeners" : {
212           "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(Error ue) {\n      _this.database_ERROR.el.label = ue.message;\n        return;\n   }\n  _this.database_ERROR.el.label = \"Connection Succeeded\";\n   cnc.close();\n}"
213          },
214          "* pack" : "pack_start,false,false,0",
215          "xtype" : "Button",
216          "$ xns" : "Gtk",
217          "utf8 label" : "Check Connection"
218         },
219         {
220          "label" : " ",
221          "id" : "database_ERROR",
222          "xalign" : 0,
223          "* pack" : "pack_start,false,false,0",
224          "xtype" : "Label",
225          "gint margin" : 3,
226          "$ xns" : "Gtk"
227         }
228        ]
229       }
230      ]
231     }
232    ]
233   }
234  ]
235 }