2 "build_module" : "builder",
5 "# JsRender.JsRender file" : "null",
6 "# Project.Project project" : "",
7 "# bool new_window" : true,
9 "@ void success" : "(Project.Project pr, JsRender.JsRender file)",
10 "Gtk.PositionType position" : "Gtk.PositionType.RIGHT",
11 "Xcls_MainWindow mainwindow" : "null",
14 "id" : "PopoverFileDetails",
20 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
21 "bool homogeneous" : false,
25 "* pack" : "pack_start,false,true,0",
26 "string title" : "Add / Edit File",
30 "$ homogeneous" : true,
32 "* pack" : "pack_start,false,false,4",
34 "int margin_left" : 4,
35 "int margin_right" : 4,
38 "$ justify" : "Gtk.Justification.RIGHT",
40 "* pack" : "attach,0,0,1,1",
42 "label" : "File type",
44 "xalign" : 0.90000000000000002,
49 "* init" : "this.el.add_attribute(_this.ftdbcellrenderer.el , \"markup\", 1 );",
50 "* pack" : "attach,1,0,1,1",
55 "* pack" : "pack_start,true",
56 "id" : "ftdbcellrenderer",
57 "xtype" : "CellRendererText"
60 "$ columns" : "typeof(string),typeof(string)",
62 "* pack" : "set_model",
65 "xtype" : "ListStore",
69 " Gtk.TreeIter iter;",
72 " /// el.append(out iter);",
75 " // el.set_value(iter, 0, \"\");",
76 " // el.set_value(iter, 1, \"aaa - Just add Element - aaa\");",
78 " el.append(out iter);",
81 " el.set_value(iter, 0, \"bjs\");",
82 " el.set_value(iter, 1, \"User Interface File (bjs)\");",
83 " _this.filetype.el.set_active_iter(iter);",
85 " el.append(out iter);",
87 " el.set_value(iter, 0, \"vala\");",
88 " el.set_value(iter, 1, \"Vala\");",
89 "\tif (cur == \"vala\") {",
90 "\t _this.filetype.el.set_active_iter(iter);",
95 " el.append(out iter);",
97 " el.set_value(iter, 0, \"js\");",
98 " el.set_value(iter, 1, \"Javascript\");",
100 "\tif (cur == \"js\") {",
101 "\t _this.filetype.el.set_active_iter(iter);",
104 " el.append(out iter);",
106 " el.set_value(iter, 0, \"css\");",
107 " el.set_value(iter, 1, \"CSS\");",
109 "\tif (cur == \"css\") {",
110 "\t _this.filetype.el.set_active_iter(iter);",
121 "\tGtk.TreeIter iter;",
122 "\tbool is_bjs = true;",
123 "\tif (this.el.get_active_iter(out iter)) {",
125 "\t\t_this.ftdbmodel.el.get_value (iter, 0, out vfname);",
126 "\t\t is_bjs = ((string)vfname) == \"bjs\";",
130 " // directory is only available for non-bjs ",
131 " this.showhide(is_bjs);",
138 "xtype" : "ComboBox",
139 "| void showhide" : [
143 "\tif (_this.project.xtype != \"Roo\") {",
144 "\t \tis_bjs = false;",
147 "\tfor (var i = 2; i < 9;i++) {",
148 "\t\tvar el = _this.grid.el.get_child_at(0,i);",
150 "\t\tvar showhide= is_bjs;",
152 "\t\t\tshowhide = !showhide;",
155 "\t\tif (showhide) {",
160 "\t\t el = _this.grid.el.get_child_at(1,i);",
161 "\t\tif (showhide) {",
167 " // load up the directories",
168 " //??? why can we not create bjs files in other directories??",
169 "\t//if (!is_bjs && _this.file.path.length < 1) {",
171 "\t\t_this.dirmodel.loadData();",
182 "$ justify" : "Gtk.Justification.RIGHT",
184 "* pack" : "attach,0,1,1,1",
185 "label" : "Component Name",
187 "xalign" : 0.90000000000000002,
193 "* pack" : "attach,1,1,1,1",
198 "$ justify" : "Gtk.Justification.RIGHT",
201 "* pack" : "attach,0,2,1,1",
204 "xalign" : 0.90000000000000002,
210 "* pack" : "attach,1,2,1,1",
215 "$ justify" : "Gtk.Justification.RIGHT",
218 "* pack" : "attach,0,3,1,1",
220 "tooltip_text" : "center, north, south, east, west",
222 "xalign" : 0.90000000000000002,
228 "* pack" : "attach,1,3,1,1",
233 "$ justify" : "Gtk.Justification.RIGHT",
236 "* pack" : "attach,0,4,1,1",
237 "label" : "Parent Name",
239 "xalign" : 0.90000000000000002,
245 "* pack" : "attach,1,4,1,1",
250 "$ justify" : "Gtk.Justification.RIGHT",
253 "* pack" : "attach,0,5,1,1",
254 "label" : "Permission Name",
256 "xalign" : 0.90000000000000002,
262 "* pack" : "attach,1,5,1,1",
267 "$ justify" : "Gtk.Justification.RIGHT",
270 "* pack" : "attach,0,6,1,1",
271 "label" : "Order (for tabs)",
273 "xalign" : 0.90000000000000002,
279 "* pack" : "attach,1,6,1,1",
284 "$ justify" : "Gtk.Justification.RIGHT",
287 "* pack" : "attach,0,7,1,1",
288 "label" : "Module to build (Vala only)",
290 "xalign" : 0.90000000000000002,
295 "* init" : "this.el.add_attribute(_this.dbcellrenderer.el , \"markup\", 1 );",
296 "* pack" : "attach,1,7,1,1",
297 "id" : "build_module",
301 "* pack" : "pack_start,true",
302 "id" : "dbcellrenderer",
303 "xtype" : "CellRendererText"
306 "$ columns" : "typeof(string),typeof(string)",
308 "* pack" : "set_model",
311 "xtype" : "ListStore",
312 "| void loadData" : [
313 " (Gee.ArrayList<string> data, string cur) {",
314 " this.el.clear(); ",
315 " Gtk.TreeIter iter;",
316 " var el = this.el;",
318 " /// el.append(out iter);",
321 " // el.set_value(iter, 0, \"\");",
322 " // el.set_value(iter, 1, \"aaa - Just add Element - aaa\");",
324 " el.append(out iter);",
327 " el.set_value(iter, 0, \"\");",
328 " el.set_value(iter, 1, \"-- select a module --\");",
329 " _this.build_module.el.set_active_iter(iter);",
331 " for (var i = 0; i < data.size;i++) {",
334 " el.append(out iter);",
336 " el.set_value(iter, 0, data.get(i));",
337 " el.set_value(iter, 1, data.get(i));",
339 " if (data.get(i) == cur) {",
340 " _this.build_module.el.set_active_iter(iter);",
344 " this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); ",
354 "$ justify" : "Gtk.Justification.RIGHT",
357 "* pack" : "attach,0,8,1,1",
358 "label" : "Directory",
360 "xalign" : 0.90000000000000002,
365 "* init" : "this.el.add_attribute(_this.dircellrenderer.el , \"markup\", 1 );",
366 "* pack" : "attach,1,8,1,1",
371 "* pack" : "pack_start,true",
372 "id" : "dircellrenderer",
373 "xtype" : "CellRendererText"
376 "$ columns" : "typeof(string),typeof(string)",
378 "* pack" : "set_model",
381 "xtype" : "ListStore",
382 "| void loadData" : [
387 " this.el.clear(); ",
389 " if (!(_this.project is Project.Gtk)) {",
392 " var sd = ((Project.Gtk)_this.project).sourcedirs();",
394 " Gtk.TreeIter iter;",
395 " var el = this.el;",
397 " /// el.append(out iter);",
400 " // el.set_value(iter, 0, \"\");",
401 " // el.set_value(iter, 1, \"aaa - Just add Element - aaa\");",
403 "// el.append(out iter);",
406 "// el.set_value(iter, 0, \"\");",
407 " // el.set_value(iter, 1, \"-- select a directoyr --\");",
408 " //_this.build_module.el.set_active_iter(iter);",
410 " for (var i = 0; i < sd.length;i++) {",
413 " el.append(out iter);",
415 " el.set_value(iter, 0, sd[i]);",
416 " el.set_value(iter, 1, sd[i]);",
418 " //if (data.get(i) == cur) {",
419 " // _this.build_module.el.set_active_iter(iter);",
423 " // this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); ",
433 "$ justify" : "Gtk.Justification.RIGHT",
436 "* pack" : "attach,0,9,1,1",
438 "label" : "Full path",
440 "xalign" : 0.90000000000000002,
446 "* pack" : "attach,1,9,1,1",
447 "bool editable" : false,
455 "uint row_spacing" : 2,
461 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
462 "int margin_bottom" : 4,
463 "int margin_left" : 4,
464 "int margin_right" : 4,
465 "int margin_top" : 4,
474 " _this.done = true;",
475 " _this.el.hide(); ",
479 "string label" : "Cancel",
493 "\tif (_this.name.el.get_text().length < 1) {",
494 "\t Xcls_StandardErrorDialog.singleton().show(",
495 "\t _this.mainwindow.el,",
496 "\t \"You have to set Component name \"",
501 "\t// what does this do?",
503 "\tvar isNew = _this.file.name.length > 0 ? false : true;",
505 "\tif (!isNew && this.file.name != _this.name.el.get_text()) {",
506 "\t Xcls_StandardErrorDialog.singleton().show(",
508 "\t \"Sorry changing names does not work yet. \"",
517 "\t// FIXME - this may be more complicated...",
518 "\t//for (var i in this.def) {",
519 "\t// this.file[i] = this.get(i).el.get_text();",
524 "\t _this.updateFileFromEntry();",
525 "\t } catch( JsRender.Error.RENAME_FILE_EXISTS er) {",
526 "\t Xcls_StandardErrorDialog.singleton().show(",
527 "\t _this.mainwindow.el,",
528 "\t \"The name you used already exists \"",
534 "\t _this.done = true;",
535 "\t _this.file.save();",
536 "\t _this.el.hide();",
540 "\t// ---------------- NEW FILES...",
541 "\tGtk.TreeIter iter;",
543 "\tif (!_this.filetype.el.get_active_iter(out iter)) {",
544 "\t\t// should not happen...",
545 "\t\t// so we are jut going to return without ",
546 "\t\tXcls_StandardErrorDialog.singleton().show(",
547 "\t _this.mainwindow.el,",
548 "\t \"You must select a file type. \"",
555 "\tvar fn = _this.name.el.get_text();",
557 "\tValue ftypename;",
558 "\t_this.ftdbmodel.el.get_value (iter, 0, out ftypename);",
559 "\tvar ext = ((string)ftypename);",
560 "\tvar dir = _this.project.firstPath(); ",
561 "\tif (ext != \"bjs\") {",
563 "\t\tif (!_this.dir.el.get_active_iter(out iter)) {",
564 "\t\t\t// should not happen...",
565 "\t\t\t// so we are jut going to return without ",
566 "\t\t\tXcls_StandardErrorDialog.singleton().show(",
567 "\t\t\t _this.mainwindow.el,",
568 "\t\t\t \"You must select a directory \"",
573 "\t\t_this.dirmodel.el.get_value (iter, 0, out vdir);",
574 "\t\tdir = (string)vdir;",
577 "\tvar targetfile = dir + \"/\" + fn;",
579 "\t// strip the file type off the end..",
582 " var rx = new GLib.Regex(\"\\\\.\" + ext + \"$\",GLib.RegexCompileFlags.CASELESS);",
583 " targetfile = rx.replace(targetfile, targetfile.length, 0, \"\"); ",
585 "\tif (GLib.FileUtils.test(targetfile + \".\" + ext, GLib.FileTest.EXISTS)) {",
586 "\t Xcls_StandardErrorDialog.singleton().show(",
587 "\t _this.mainwindow.el,",
588 "\t \"That file already exists\"",
593 " var f = JsRender.JsRender.factory(",
594 "\t\text == \"bjs\" ? _this.file.project.xtype : \"PlainFile\", ",
595 "\t\t_this.file.project, ",
596 "\t\ttargetfile + \".\" + ext);",
602 "\t_this.updateFileFromEntry();",
603 "\t_this.file.loaded = true;",
604 "\t_this.file.save();",
605 "\tif (ext == \"bjs\") {",
606 "\t\t_this.file.project.addFile(_this.file);",
610 "\t// what about .js ?",
611 " _this.done = true;",
612 "\t_this.el.hide();",
614 "// hopefull this will work with bjs files..",
616 "\t_this.success(_this.project, _this.file);",
621 "string label" : "Save",
625 "xtype" : "ButtonBox"
634 " if (!this.done) {",
643 " if (!this.done) {",
651 "uint border_width" : 0,
654 "(JsRender.JsRender c, Gtk.Widget btn, bool new_window) ",
656 " this.project = c.project;",
657 " this.done = false;",
658 " this.new_window = new_window;",
660 " //if (!this.el) {",
663 " _this.path.el.set_text(c.path);",
664 " _this.name.el.set_text(c.name);",
665 " _this.title.el.set_text(c.title);",
666 " _this.parent.el.set_text(c.parent); ",
667 " _this.region.el.set_text(c.region);",
668 " _this.modOrder.el.set_text(c.modOrder);",
669 " _this.permname.el.set_text(c.permname);",
678 " var ar = new Gee.ArrayList<string>();",
679 " _this.dbmodel.loadData(ar,\"\");",
680 " // load the modules... if relivant..",
681 " if (this.project.xtype == \"Gtk\") {",
682 " var p = (Project.Gtk)c.project;",
683 " var cg = p.compilegroups;",
685 " var iter = cg.map_iterator();",
686 " while(iter.next()) {",
687 " var key = iter.get_key();",
688 " if (key == \"_default_\") {",
693 " _this.dbmodel.loadData(ar, c.build_module);",
699 " //console.log('show all');",
700 " this.el.set_modal(true);",
701 " this.el.set_relative_to(btn);",
703 " this.el.set_position(Gtk.PositionType.TOP);",
706 " this.mainwindow.el.get_size(out w, out h);",
707 " this.el.set_size_request( 550, h);",
711 " // window + header?",
712 " print(\"SHOWALL - POPIP\\n\");",
713 " this.el.show_all();",
714 " this.name.el.grab_focus();",
718 " if (c.path.length > 0) {",
719 "\t this.save_btn.el.set_label(\"Save\");",
720 "\t\t_this.filetype.el.hide();",
721 "\t\t_this.filetypelbl.el.hide();",
722 "\t\t_this.filetype.showhide(true); // as we only work on bjs files currently",
724 " this.save_btn.el.set_label(\"Create\");",
725 " _this.ftdbmodel.loadData(\"bjs\"); // fixme - need to determine type..",
726 "\t _this.filetype.el.show();",
727 "\t _this.filetypelbl.el.show();",
731 " //this.success = c.success;",
736 "| void updateFileFromEntry" : [
739 " _this.file.title = _this.title.el.get_text();",
740 " _this.file.region = _this.region.el.get_text(); ",
741 " _this.file.parent = _this.parent.el.get_text(); ",
742 " _this.file.permname = _this.permname.el.get_text(); ",
743 " _this.file.modOrder = _this.modOrder.el.get_text();",
745 " if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {",
746 " _this.file.renameTo(_this.name.el.get_text());",
748 " // store the module...",
749 " _this.file.build_module = \"\"; ",
750 " Gtk.TreeIter iter; ",
751 " if (_this.build_module.el.get_active_iter (out iter)) {",
753 " this.dbmodel.el.get_value (iter, 0, out vfname);",
754 " if (((string)vfname).length > 0) {",
755 " _this.file.build_module = (string)vfname;",
768 "name" : "PopoverFileDetails",
770 "path" : "/home/alan/gitlive/roobuilder/src/Builder4/PopoverFileDetails.bjs",