2 "build_module" : "builder",
3 "gen_extended" : false,
6 "# JsRender.JsRender file" : "null",
7 "# Project.Project project" : "",
8 "# bool new_window" : true,
10 "@ void success" : "(Project.Project pr, JsRender.JsRender file)",
11 "Xcls_MainWindow mainwindow" : "null",
15 "id" : "PopoverFileDetails",
20 "* pack" : "set_child",
21 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
22 "bool hexpand" : true,
23 "bool homogeneous" : false,
24 "int margin_bottom" : 4,
26 "int margin_start" : 4,
33 "bool hexpand" : true,
35 "int column_spacing" : 4,
37 "int margin_start" : 4,
40 "$ justify" : "Gtk.Justification.RIGHT",
42 "id" : "filetype_lbl",
43 "label" : "File type",
45 "xalign" : 0.90000000000000002,
50 "bool hexpand" : true,
56 "id" : "filetype_model",
58 "xtype" : "StringList",
63 " while (el.get_n_items() > 0) {",
66 " \tel.append(\"bjs - User Interface File\");",
69 " switch(_this.project.xtype) {",
71 " \t \tel.append(\"js - Javascript File\");",
72 " \t \tel.append(\"css - CSS File\");",
73 " \t \tel.append(\"php - Javascript File\");",
77 "\tcase \"Gtk\":\t\t",
79 " \t \tel.append(\"vala - Vala File\");",
80 " \t \tel.append(\"css - CSS File\");",
81 " \t \tel.append(\"other - Other Type\");",
95 "notify[\"selected\"]" : [
100 " // directory is only available for non-bjs ",
101 " this.showhide( );",
106 "xtype" : "DropDown",
107 "| string getValue" : [
110 "\tif (!_this.is_new) {",
111 "\t\treturn _this.file.xtype != \"Plainfile\" ? \"bjs\" : _this.file.file_ext;",
114 "\tif (this.el.selected == Gtk.INVALID_LIST_POSITION) {",
118 "\treturn _this.filetype_model.el.get_string(this.el.selected).split(\" \")[0];",
121 "| void setValue" : [
123 "\tvar el = _this.filetype_model.el;",
124 "\tfor(var i= 0; i < el.get_n_items();i++) {",
125 "\t\tif (el.get_string(i).has_prefix(cur)) {",
126 "\t\t\tthis.el.selected = i;",
132 "| void showhide" : [
136 "\t_this.path_lbl.el.hide();",
137 " _this.path.el.hide();",
140 " _this.name_lbl.el.hide();",
141 " _this.name.el.hide();",
143 " _this.dir_dropdown_lbl.el.hide();",
144 " _this.dir_dropdown.el.hide();",
146 "\t_this.title_lbl.el.hide();",
147 "\t_this.title.el.hide();",
149 "\t_this.region_lbl.el.hide();",
150 "\t_this.region.el.hide();",
152 "\t_this.parent_lbl.el.hide();",
153 "\t_this.parent.el.hide();",
155 "\t_this.permname_lbl.el.hide();",
156 "\t_this.permname.el.hide();",
158 "\t_this.modOrder_lbl.el.hide();",
159 "\t_this.modOrder.el.hide();",
161 "\t_this.build_module_lbl.el.hide();",
162 "\t_this.build_module.el.hide();",
164 "\t_this.gen_lbl.el.hide();",
165 "\t_this.gen.el.hide();",
168 "\tvar sel = this.getValue();",
170 "\tGLib.debug(\"showhide is new ? %s / sel = '%s'\" , _this.is_new ? \"YES\" :\"NO\", sel); ",
172 " if (_this.is_new) {",
173 "\t\tif (sel == \"\" && _this.project.xtype == \"Gtk\") {",
178 " _this.dir_dropdown_lbl.el.show();",
179 "\t _this.dir_dropdown.el.show();",
181 " _this.name_lbl.el.show();",
182 " \t_this.name.el.show();",
187 " _this.path.el.set_text(_this.file.relpath);",
193 "\tswitch(_this.project.xtype) {",
196 "\t\t\tif (sel == \"bjs\") {",
197 "\t\t\t\t_this.title_lbl.el.show();",
198 "\t\t\t\t_this.title.el.show();",
200 "\t\t\t\t_this.region_lbl.el.show();",
201 "\t\t\t\t_this.region.el.show();",
203 "\t\t\t\t_this.parent_lbl.el.show();",
204 "\t\t\t\t_this.parent.el.show();",
206 "\t\t\t\t_this.permname_lbl.el.show();",
207 "\t\t\t\t_this.permname.el.show();",
209 "\t\t\t\t_this.modOrder_lbl.el.show();",
210 "\t\t\t\t_this.modOrder.el.show();",
213 "\t\t\t_this.build_module_model.load(null);",
217 "\t\tdefault: // vala..",
219 "\t \t\t_this.build_module_lbl.el.show();",
220 "\t\t\t_this.build_module.el.show();",
224 "\t\t\tif (sel == \"bjs\" || sel == \"vala\") {",
225 "\t\t\t\t _this.project.loadDirsToStringList(_this.dir_model.el, \"/src\");",
226 "\t\t\t\t _this.dir_dropdown.el.selected = Gtk.INVALID_LIST_POSITION;",
227 "\t\t _this.name_lbl.el.label = \"Component Name (Filename with-out extension)\";\t\t\t\t ",
229 "\t\t if (sel == \"bjs\") {",
230 "\t\t\t _this.gen_lbl.el.show();",
231 "\t\t\t _this.gen.el.show();",
237 "\t\t _this.project.loadDirsToStringList(_this.dir_model.el, \"\");",
238 "\t\t _this.dir_dropdown.el.selected = Gtk.INVALID_LIST_POSITION;",
239 "\t\t _this.name_lbl.el.label = \"File Name (with extension)\";",
244 " // load up the directories",
245 " //??? why can we not create bjs files in other directories??",
246 "\t//if (!is_bjs && _this.file.path.length < 1) {",
259 "$ justify" : "Gtk.Justification.RIGHT",
262 "id" : "dir_dropdown_lbl",
263 "label" : "Create File in this Directory",
265 "xalign" : 0.90000000000000002,
270 "id" : "dir_dropdown",
278 "xtype" : "StringList"
281 "xtype" : "DropDown",
282 "| string getValue" : [
284 "\treturn _this.dir_model.el.get_string(this.el.selected);",
289 "$ justify" : "Gtk.Justification.RIGHT",
292 "label" : "Component Name (File name without extension)",
294 "xalign" : 0.90000000000000002,
300 "bool hexpand" : true,
305 "$ justify" : "Gtk.Justification.RIGHT",
311 "xalign" : 0.90000000000000002,
317 "* pack" : "attach,1,2,1,1",
318 "bool hexpand" : true,
323 "$ justify" : "Gtk.Justification.RIGHT",
328 "tooltip_text" : "center, north, south, east, west",
330 "xalign" : 0.90000000000000002,
336 "bool hexpand" : true,
341 "$ justify" : "Gtk.Justification.RIGHT",
345 "label" : "Parent Name",
347 "xalign" : 0.90000000000000002,
357 "$ justify" : "Gtk.Justification.RIGHT",
360 "id" : "permname_lbl",
361 "label" : "Permission Name",
363 "xalign" : 0.90000000000000002,
373 "$ justify" : "Gtk.Justification.RIGHT",
376 "id" : "modOrder_lbl",
377 "label" : "Order (for tabs)",
379 "xalign" : 0.90000000000000002,
389 "$ justify" : "Gtk.Justification.RIGHT",
392 "id" : "build_module_lbl",
393 "label" : "Module to build",
395 "xalign" : 0.90000000000000002,
400 "id" : "build_module",
405 "id" : "build_module_model",
407 "xtype" : "StringList",
409 "(Gee.HashMap<string,Project.GtkValaSettings>? compilegroups)",
412 "\t_this.build_module.el.hide();",
413 "\t\t_this.build_module_lbl.el.hide();",
414 "\tvar el = _this.build_module_model.el;",
415 "\t while (el.get_n_items() > 0) {",
416 "\t\t\tel.remove(0);",
419 "\tif (compilegroups == null) {",
422 "\tforeach(var k in compilegroups.keys) {",
423 "\t\tthis.el.append(k);",
425 "\tif (compilegroups.keys.size > 0) {",
426 "\t\t_this.build_module.el.selected = 0;",
427 "\t\t_this.build_module.el.show();",
428 "\t\t_this.build_module_lbl.el.show();",
437 "xtype" : "DropDown",
438 "| string getValue" : [
441 "\tif (this.el.selected < 0) {",
445 "\treturn _this.build_module_model.el.get_string(this.el.selected);",
449 "| void setValue" : [
451 "\tvar m = _this.build_module_model.el;",
452 "\tfor(var i = 0; i < m.get_n_items(); i++) {",
453 "\t\tif (m.get_string(i) == str) {",
454 "\t\t\tthis.el.selected = i;",
463 "$ justify" : "Gtk.Justification.RIGHT",
468 "label" : "Full path",
470 "xalign" : 0.90000000000000002,
476 "bool editable" : false,
477 "bool hexpand" : true,
483 "$ justify" : "Gtk.Justification.RIGHT",
488 "label" : "Generate as Extended (no working)",
490 "xalign" : 0.90000000000000002,
500 "\tthis.el.label = this.el.active ? \"Extended\" : \"Wrapped\";",
506 "string label" : "Wrapped",
507 "xtype" : "CheckButton"
510 "uint row_spacing" : 2,
512 "| void xhideRow" : [
515 "\tvar el = _this.grid.el.get_child_at(0,row);",
518 "\tel = _this.grid.el.get_child_at(1,row);",
523 "| void xshowAllRows" : [
525 "\tfor (var i = 2; i < 10;i++) {",
526 "\t\tvar el = _this.grid.el.get_child_at(0,i);",
528 "\t\tel = _this.grid.el.get_child_at(1,i);",
539 "* prop" : "titlebar",
540 "bool show_title_buttons" : false,
544 "* pack" : "pack_start",
548 " \t_this.done = true;",
549 " _this.el.hide(); ",
553 "string label" : "Cancel",
557 "$ css_classes" : "{ \"suggested-action\" }",
559 "* pack" : "pack_end",
560 "bool always_show_image" : true,
561 "bool hexpand" : false,
570 "\tif (_this.name.el.get_text().length < 1) {",
571 "\t Xcls_StandardErrorDialog.singleton().show(",
572 "\t _this.mainwindow.el,",
573 "\t \"You have to set a Component name \"",
578 "\t// what does this do?",
580 "\tvar isNew = _this.file.name.length > 0 ? false : true;",
582 "\tif (!isNew && this.file.name != _this.name.el.get_text()) {",
583 "\t Xcls_StandardErrorDialog.singleton().show(",
585 "\t \"Sorry changing names does not work yet. \"",
593 "\t// FIXME - this may be more complicated...",
594 "\t//for (var i in this.def) {",
595 "\t// this.file[i] = this.get(i).el.get_text();",
601 "\t \tvar old_target = _this.file.build_module;",
602 " _this.updateFileFromEntry();",
603 "\t if (_this.project.xtype == \"Gtk\" && old_target != _this.file.build_module) {",
604 "\t \tvar gp = (JsRender.Gtk)_this.file;",
605 "\t \tgp.updateCompileGroup(old_target, _this.file.build_module);",
608 "\t _this.done = true;",
609 "\t _this.file.save();",
610 "\t _this.el.hide();",
614 "\t// ---------------- NEW FILES...",
615 "\tvar ftype = _this.filetype.getValue();",
617 "\tif (ftype == \"\") {",
618 "\t\t// should not happen...",
619 "\t\t// so we are jut going to return without ",
620 "\t\tXcls_StandardErrorDialog.singleton().show(",
621 "\t _this.mainwindow.el,",
622 "\t \"You must select a file type. \"",
629 "\tvar fn = _this.name.el.get_text();",
632 "\tvar ext = ftype;",
633 "\t//var dir = _this.project.path; ",
635 "\t var dir = _this.dir_dropdown.getValue();",
640 "\tvar targetfile = _this.project.path;",
641 "\tif (dir != \"\") {",
642 "\t\ttargetfile += dir;",
644 "\ttargetfile += \"/\" + fn;",
646 "\t// strip the file type off the end..",
649 "\t\tvar rx = new GLib.Regex(\"\\\\.\" + ext + \"$\",GLib.RegexCompileFlags.CASELESS);",
650 "\t\tfn = rx.replace(targetfile, targetfile.length, 0, \"\"); ",
651 "\t } catch (RegexError e) {} // ignore.",
653 "\t targetfile += \".\" + ext;",
656 "\tif (GLib.FileUtils.test(targetfile, GLib.FileTest.EXISTS)) {",
657 "\t Xcls_StandardErrorDialog.singleton().show(",
658 "\t _this.mainwindow.el,",
659 "\t \"That file already exists\"",
663 "\tJsRender.JsRender f;",
665 "\t f = JsRender.JsRender.factory(",
666 "\t\t\text == \"bjs\" ? _this.file.project.xtype : \"PlainFile\", ",
667 "\t\t\t_this.file.project, ",
668 "\t\t\ttargetfile);",
669 "\t} catch (JsRender.Error e) {",
670 "\t\tXcls_StandardErrorDialog.singleton().show(",
671 "\t _this.mainwindow.el,",
672 "\t \"Error creating file\"",
681 "\t_this.updateFileFromEntry();",
682 "\t_this.file.loaded = true;",
683 "\t_this.file.save();",
684 " _this.file.project.addFile(_this.file);",
688 "\t// what about .js ?",
689 " _this.done = true;",
690 "\t_this.el.hide();",
692 "// hopefull this will work with bjs files..",
694 "\t_this.success(_this.project, _this.file);",
699 "string icon_name" : "document-save",
700 "string label" : "Save",
704 "title" : "Add / Edit File",
705 "xtype" : "HeaderBar"
711 "\t_this.el.hide();",
717 "string title" : "Add / Edit File",
718 "uint border_width" : 0,
721 "(JsRender.JsRender c, Gtk.Window pwin, bool new_window) ",
724 " this.project = c.project;",
725 " this.done = false;",
726 " this.new_window = new_window;",
728 " //if (!this.el) {",
732 " this.is_new = c.name == \"\";",
734 " _this.name.el.set_text(c.name);",
735 " _this.title.el.set_text(c.title);",
736 " _this.parent.el.set_text(c.parent); ",
737 " _this.region.el.set_text(c.region);",
738 " _this.modOrder.el.set_text(c.modOrder);",
739 " _this.permname.el.set_text(c.permname);",
741 " _this.gen.el.active = c.gen_extended;",
745 " if (this.project.xtype == \"Gtk\") {",
746 " \tvar p = (Project.Gtk) this.project;",
747 "\t this.build_module_model.load(p.compilegroups);",
748 "\t // it will select first if available...",
749 "\t // only for new files.",
750 "\t if (!this.is_new) {",
751 "\t\t this.build_module.setValue(c.build_module);",
758 " // this.el.set_size_request( 550, 100); // should expand height, but give a min width.",
760 " this.el.set_transient_for(pwin);",
762 " // window + header?",
765 " // this.name.el.grab_focus();",
768 " if (!this.is_new) {",
769 "\t this.save_btn.el.set_label(\"Save\");",
770 "\t\tthis.filetype_lbl.el.hide();",
771 "\t\tthis.filetype.el.hide();",
772 "\t\tthis.filetype.showhide(); // as we only work on bjs files currently",
775 "\t\t//_this.project.loadDirsToStringList(this.dir_model.el, \"\");",
776 "\t\t//_this.dir_dropdown.el.selected = Gtk.INVALID_LIST_POSITION;",
778 " this.save_btn.el.set_label(\"Create\");",
779 "\t this.filetype.el.show();",
780 "\t this.filetype_lbl.el.show();",
781 "\t this.filetype_model.load();",
782 "\t\tthis.filetype.el.selected = Gtk.INVALID_LIST_POSITION;",
783 "\t this.filetype.showhide();",
788 " //this.success = c.success;",
793 "| void updateFileFromEntry" : [
796 " _this.file.title = _this.title.el.get_text();",
797 " _this.file.region = _this.region.el.get_text(); ",
798 " _this.file.parent = _this.parent.el.get_text(); ",
799 " _this.file.permname = _this.permname.el.get_text(); ",
800 " _this.file.modOrder = _this.modOrder.el.get_text();",
801 " _this.file.gen_extended = _this.gen.el.active;",
802 " var new_name = _this.name.el.get_text();",
803 " if (_this.file.name.length > 0 && _this.file.name != new_name) {",
805 " \t_this.file.renameTo( new_name );",
806 " \t} catch (JsRender.Error e) { } // do nothing?",
809 " _this.file.build_module = _this.build_module.getValue();",
819 "name" : "PopoverFileDetails"