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          "xtype" : "Label",
38          "* pack" : false,
39          "$ xns" : "Gtk",
40          "utf8 label" : "Global"
41         },
42         {
43          "id" : "label_database",
44          "* pack" : false,
45          "xtype" : "Label",
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              "xtype" : "Label",
76              "* pack" : "pack_start,false,false,0",
77              "gint margin" : 3,
78              "$ xns" : "Gtk"
79             },
80             {
81              "id" : "base_template",
82              "xtype" : "Entry",
83              "* pack" : "add",
84              "$ xns" : "Gtk"
85             }
86            ]
87           },
88           {
89            "* pack" : "pack_start,false,false,0",
90            "xtype" : "Box",
91            "gboolean expand" : false,
92            "$ xns" : "Gtk",
93            "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
94            "$ homogeneous" : false,
95            "items" : [
96             {
97              "label" : "root URL",
98              "xtype" : "Label",
99              "* pack" : "pack_start,false,false,0",
100              "gint margin" : 3,
101              "$ xns" : "Gtk"
102             },
103             {
104              "id" : "rootURL",
105              "xtype" : "Entry",
106              "* pack" : "add",
107              "$ xns" : "Gtk"
108             }
109            ]
110           },
111           {
112            "label" : "HTML To insert at end of <HEAD>",
113            "xtype" : "Label",
114            "* pack" : "pack_start,false,false,0",
115            "$ xns" : "Gtk"
116           },
117           {
118            "* pack" : "pack_start,true,true,0",
119            "xtype" : "ScrolledWindow",
120            "$ xns" : "Gtk",
121            "items" : [
122             {
123              "listeners" : {
124               "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}"
125              },
126              "id" : "view",
127              "* init" : " \n    var description =   Pango.FontDescription.from_string(\"monospace\");\n    description.set_size(9000);\n    this.el.override_font(description);",
128              "xtype" : "View",
129              "* pack" : "add",
130              "$ xns" : "GtkSource"
131             }
132            ]
133           }
134          ]
135         },
136         {
137          "* pack" : "append_page,_this.label_database.el",
138          "xtype" : "Box",
139          "gboolean homogeneous" : false,
140          "$ xns" : "Gtk",
141          "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
142          "items" : [
143           {
144            "label" : "Type (eg. MySQL or PostgreSQL)",
145            "xalign" : 0,
146            "* pack" : "pack_start,false,false,0",
147            "xtype" : "Label",
148            "$ xns" : "Gtk"
149           },
150           {
151            "listeners" : {
152             "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"
153            },
154            "id" : "database_DBTYPE",
155            "* pack" : "pack_start,false,false,0",
156            "xtype" : "Entry",
157            "$ xns" : "Gtk"
158           },
159           {
160            "label" : "Name",
161            "xalign" : 0,
162            "* pack" : "pack_start,false,false,0",
163            "xtype" : "Label",
164            "$ xns" : "Gtk"
165           },
166           {
167            "listeners" : {
168             "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"
169            },
170            "id" : "database_DBNAME",
171            "xtype" : "Entry",
172            "* pack" : "pack_start,false,false,0",
173            "$ xns" : "Gtk"
174           },
175           {
176            "label" : "Username",
177            "xalign" : 0,
178            "* pack" : "pack_start,false,false,0",
179            "xtype" : "Label",
180            "$ xns" : "Gtk"
181           },
182           {
183            "listeners" : {
184             "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"
185            },
186            "id" : "database_DBUSERNAME",
187            "* pack" : "pack_start,false,false,0",
188            "xtype" : "Entry",
189            "$ xns" : "Gtk"
190           },
191           {
192            "label" : "Password",
193            "xalign" : 0,
194            "* pack" : "pack_start,false,false,0",
195            "xtype" : "Label",
196            "$ xns" : "Gtk"
197           },
198           {
199            "id" : "database_DBPASSWORD",
200            "xtype" : "Entry",
201            "* pack" : "pack_start,false,false,0",
202            "$ xns" : "Gtk"
203           },
204           {
205            "listeners" : {
206             "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}"
207            },
208            "* pack" : "pack_start,false,false,0",
209            "xtype" : "Button",
210            "$ xns" : "Gtk",
211            "utf8 label" : "Check Connection"
212           },
213           {
214            "label" : " ",
215            "id" : "database_ERROR",
216            "xalign" : 0,
217            "* pack" : "pack_start,false,false,0",
218            "xtype" : "Label",
219            "gint margin" : 3,
220            "$ xns" : "Gtk"
221           }
222          ]
223         }
224        ]
225       },
226       {
227        "* pack" : "pack_end,false,false,0",
228        "xtype" : "Box",
229        "gboolean expand" : false,
230        "$ xns" : "Gtk",
231        "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
232        "$ homogeneous" : true,
233        "gboolean vexpand" : false,
234        "items" : [
235         {
236          "listeners" : {
237           "button_press_event" : "() => {\n    _this.save();\n          \n    _this.buttonPressed(\"apply\");\n        return false;\n}"
238          },
239          "label" : "Apply",
240          "* pack" : "add",
241          "xtype" : "Button",
242          "$ xns" : "Gtk"
243         },
244         {
245          "listeners" : {
246           "button_press_event" : "() => {\n       _this.save();\n          \n    _this.buttonPressed(\"save\");\n        return false;\n}"
247          },
248          "label" : "Save",
249          "* pack" : "add",
250          "xtype" : "Button",
251          "$ xns" : "Gtk"
252         }
253        ]
254       }
255      ]
256     }
257    ]
258   }
259  ]
260 }