RepoStatusPopover.bjs
[gitlive] / RepoStatusPopover.bjs
1 {
2  "name" : "RepoStatusPopover",
3  "parent" : "",
4  "title" : "",
5  "path" : "/home/alan/gitlive/gitlive/RepoStatusPopover.bjs",
6  "permname" : "",
7  "modOrder" : "",
8  "build_module" : "gitlive",
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      \n    _this.rootURL.el.set_text( _this.project.rootURL );\n    \n    _this.html_gen_model.loadData(_this.project.html_gen);\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\t_this.project.runhtml = buf.get_text(s,e,true);\n      \n    _this.project.rootURL = _this.rootURL.el.get_text();\n    \n    \n    Gtk.TreeIter iter;\n    Value html_gen_val;\n    _this.html_gen.el.get_active_iter(out iter);\n    _this.html_gen_model.el.get_value (iter, 0, out html_gen_val);\n    \n    _this.project.html_gen = (string)html_gen_val;\n    \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_status",
37          "* pack" : false,
38          "xtype" : "Label",
39          "$ xns" : "Gtk",
40          "utf8 label" : "Status"
41         },
42         {
43          "id" : "label_diff",
44          "xtype" : "Label",
45          "* pack" : false,
46          "$ xns" : "Gtk",
47          "utf8 label" : "Diff"
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,3,1,1",
136              "xtype" : "Label",
137              "gint margin" : 3,
138              "$ xns" : "Gtk"
139             },
140             {
141              "id" : "html_gen",
142              "* init" : "this.el.add_attribute(_this.html_gen_cellrenderer.el , \"markup\", 1 );",
143              "* pack" : "attach,1,3,1,1",
144              "xtype" : "ComboBox",
145              "$ xns" : "Gtk",
146              "items" : [
147               {
148                "id" : "html_gen_cellrenderer",
149                "xtype" : "CellRendererText",
150                "* pack" : "pack_start,true",
151                "$ xns" : "Gtk"
152               },
153               {
154                "id" : "html_gen_model",
155                "xtype" : "ListStore",
156                "* pack" : "set_model",
157                "$ columns" : "typeof(string),typeof(string)",
158                "n_columns" : 2,
159                "$ xns" : "Gtk",
160                "| void loadData" : "  (string cur) {\n    this.el.clear();                                    \n    Gtk.TreeIter iter;\n    var el = this.el;\n    \n \n    el.append(out iter);\n\n    \n    el.set_value(iter, 0, \"\");\n    el.set_value(iter, 1, \"Do not Generate\");\n    _this.html_gen.el.set_active_iter(iter);\n\n    el.append(out iter);\n    \n    el.set_value(iter, 0, \"bjs\");\n    el.set_value(iter, 1, \"same directory as BJS file\");\n\tif (cur == \"bjs\") {\n\t    _this.html_gen.el.set_active_iter(iter);\n    }\n\n\n\n    el.append(out iter);\n    \n    el.set_value(iter, 0, \"templates\");\n    el.set_value(iter, 1, \"in templates subdirectory\");\n\n\tif (cur == \"template\") {\n\t    _this.html_gen.el.set_active_iter(iter);\n    }\n\n                                     \n}\n"
161               }
162              ]
163             }
164            ]
165           },
166           {
167            "label" : "HTML To insert at end of <HEAD>",
168            "xtype" : "Label",
169            "* pack" : "pack_start,false,false,0",
170            "$ xns" : "Gtk"
171           },
172           {
173            "* pack" : "pack_start,true,true,0",
174            "xtype" : "ScrolledWindow",
175            "$ xns" : "Gtk",
176            "items" : [
177             {
178              "listeners" : {
179               "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}"
180              },
181              "id" : "view",
182              "* init" : " \n    var description =   Pango.FontDescription.from_string(\"monospace\");\n    description.set_size(9000);\n    this.el.override_font(description);",
183              "xtype" : "View",
184              "* pack" : "add",
185              "$ xns" : "GtkSource"
186             }
187            ]
188           }
189          ]
190         },
191         {
192          "* pack" : "append_page,_this.label_database.el",
193          "xtype" : "Box",
194          "gboolean homogeneous" : false,
195          "$ xns" : "Gtk",
196          "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
197          "items" : [
198           {
199            "label" : "Type (eg. MySQL or PostgreSQL)",
200            "xalign" : 0,
201            "* pack" : "pack_start,false,false,0",
202            "xtype" : "Label",
203            "$ xns" : "Gtk"
204           },
205           {
206            "listeners" : {
207             "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"
208            },
209            "id" : "database_DBTYPE",
210            "xtype" : "Entry",
211            "* pack" : "pack_start,false,false,0",
212            "$ xns" : "Gtk"
213           },
214           {
215            "label" : "Name",
216            "xalign" : 0,
217            "* pack" : "pack_start,false,false,0",
218            "xtype" : "Label",
219            "$ xns" : "Gtk"
220           },
221           {
222            "listeners" : {
223             "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"
224            },
225            "id" : "database_DBNAME",
226            "* pack" : "pack_start,false,false,0",
227            "xtype" : "Entry",
228            "$ xns" : "Gtk"
229           },
230           {
231            "label" : "Username",
232            "xalign" : 0,
233            "* pack" : "pack_start,false,false,0",
234            "xtype" : "Label",
235            "$ xns" : "Gtk"
236           },
237           {
238            "listeners" : {
239             "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"
240            },
241            "id" : "database_DBUSERNAME",
242            "xtype" : "Entry",
243            "* pack" : "pack_start,false,false,0",
244            "$ xns" : "Gtk"
245           },
246           {
247            "label" : "Password",
248            "xalign" : 0,
249            "* pack" : "pack_start,false,false,0",
250            "xtype" : "Label",
251            "$ xns" : "Gtk"
252           },
253           {
254            "id" : "database_DBPASSWORD",
255            "* pack" : "pack_start,false,false,0",
256            "xtype" : "Entry",
257            "$ xns" : "Gtk"
258           },
259           {
260            "listeners" : {
261             "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}"
262            },
263            "* pack" : "pack_start,false,false,0",
264            "xtype" : "Button",
265            "$ xns" : "Gtk",
266            "utf8 label" : "Check Connection"
267           },
268           {
269            "label" : " ",
270            "id" : "database_ERROR",
271            "xalign" : 0,
272            "* pack" : "pack_start,false,false,0",
273            "xtype" : "Label",
274            "gint margin" : 3,
275            "$ xns" : "Gtk"
276           }
277          ]
278         }
279        ]
280       },
281       {
282        "* pack" : "pack_end,false,false,0",
283        "xtype" : "Box",
284        "gboolean expand" : false,
285        "$ xns" : "Gtk",
286        "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
287        "$ homogeneous" : true,
288        "gboolean vexpand" : false,
289        "items" : [
290         {
291          "listeners" : {
292           "button_press_event" : "() => {\n    _this.save();\n          \n    _this.buttonPressed(\"apply\");\n        return false;\n}"
293          },
294          "label" : "Apply",
295          "xtype" : "Button",
296          "* pack" : "add",
297          "$ xns" : "Gtk"
298         },
299         {
300          "listeners" : {
301           "button_press_event" : "() => {\n       _this.save();\n          \n    _this.buttonPressed(\"save\");\n        return false;\n}"
302          },
303          "label" : "Save",
304          "xtype" : "Button",
305          "* pack" : "add",
306          "$ xns" : "Gtk"
307         }
308        ]
309       }
310      ]
311     }
312    ]
313   }
314  ]
315 }