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,
51 "bool in_showhide" : false,
57 "id" : "filetype_model",
59 "xtype" : "StringList",
64 " while (el.get_n_items() > 0) {",
67 " \tel.append(\"bjs - User Interface File\");",
70 " switch(_this.project.xtype) {",
72 " \t \tel.append(\"js - Javascript File\");",
73 " \t \tel.append(\"css - CSS File\");",
74 " \t \tel.append(\"php - Javascript File\");",
78 "\tcase \"Gtk\":\t\t",
80 " \t \tel.append(\"vala - Vala File\");",
81 " \t \tel.append(\"css - CSS File\");",
82 " \t \tel.append(\"other - Other Type\");",
96 "notify[\"selected\"]" : [
99 " \t_this.onFileTypeChange();",
104 "xtype" : "DropDown",
105 "| string getValue" : [
108 "\tif (!_this.is_new) {",
109 "\t\treturn _this.file.xtype != \"Plainfile\" ? \"bjs\" : _this.file.file_ext;",
112 "\tif (this.el.selected == Gtk.INVALID_LIST_POSITION) {",
116 "\treturn _this.filetype_model.el.get_string(this.el.selected).split(\" \")[0];",
119 "| void setValue" : [
121 "\tvar el = _this.filetype_model.el;",
122 "\tfor(var i= 0; i < el.get_n_items();i++) {",
123 "\t\tif (el.get_string(i).has_prefix(cur)) {",
124 "\t\t\tthis.el.selected = i;",
132 "$ justify" : "Gtk.Justification.RIGHT",
135 "id" : "dir_dropdown_lbl",
136 "label" : "Create File in this Directory",
138 "xalign" : 0.90000000000000002,
143 "id" : "dir_dropdown",
151 "xtype" : "StringList"
155 "notify[\"selected\"]" : [
158 "\t _this.onDirChanged();",
165 "xtype" : "DropDown",
166 "| string getValue" : [
168 "\treturn _this.dir_model.el.get_string(this.el.selected);",
171 "| void setValue" : [
173 "\tvar el = _this.dir_model.el;",
174 "\tfor(var i= 0; i < el.get_n_items();i++) {",
175 "\t\tif (el.get_string(i) == cur) {",
176 "\t\t\tthis.el.selected = i;",
184 "$ justify" : "Gtk.Justification.RIGHT",
187 "label" : "Component Name (File name without extension)",
189 "xalign" : 0.90000000000000002,
195 "bool hexpand" : true,
200 "$ justify" : "Gtk.Justification.RIGHT",
206 "xalign" : 0.90000000000000002,
212 "bool hexpand" : true,
217 "$ justify" : "Gtk.Justification.RIGHT",
222 "tooltip_text" : "center, north, south, east, west",
224 "xalign" : 0.90000000000000002,
230 "bool hexpand" : true,
235 "$ justify" : "Gtk.Justification.RIGHT",
239 "label" : "Parent Name",
241 "xalign" : 0.90000000000000002,
251 "$ justify" : "Gtk.Justification.RIGHT",
254 "id" : "permname_lbl",
255 "label" : "Permission Name",
257 "xalign" : 0.90000000000000002,
267 "$ justify" : "Gtk.Justification.RIGHT",
270 "id" : "modOrder_lbl",
271 "label" : "Order (for tabs)",
273 "xalign" : 0.90000000000000002,
283 "$ justify" : "Gtk.Justification.RIGHT",
286 "id" : "build_module_lbl",
287 "label" : "Module to build",
289 "xalign" : 0.90000000000000002,
294 "id" : "build_module",
299 "id" : "build_module_model",
301 "xtype" : "StringList",
303 "(Gee.HashMap<string,Project.GtkValaSettings>? compilegroups)",
306 "\t_this.build_module.el.hide();",
307 "\t\t_this.build_module_lbl.el.hide();",
308 "\tvar el = _this.build_module_model.el;",
309 "\t while (el.get_n_items() > 0) {",
310 "\t\t\tel.remove(0);",
313 "\tif (compilegroups == null) {",
316 "\tforeach(var k in compilegroups.keys) {",
317 "\t\tthis.el.append(k);",
319 "\tif (compilegroups.keys.size > 0) {",
320 "\t\t_this.build_module.el.selected = 0;",
321 "\t\t_this.build_module.el.show();",
322 "\t\t_this.build_module_lbl.el.show();",
331 "xtype" : "DropDown",
332 "| string getValue" : [
335 "\tif (this.el.selected < 0) {",
339 "\treturn _this.build_module_model.el.get_string(this.el.selected);",
343 "| void setValue" : [
345 "\tvar m = _this.build_module_model.el;",
346 "\tfor(var i = 0; i < m.get_n_items(); i++) {",
347 "\t\tif (m.get_string(i) == str) {",
348 "\t\t\tthis.el.selected = i;",
357 "$ justify" : "Gtk.Justification.RIGHT",
362 "label" : "Full path",
364 "xalign" : 0.90000000000000002,
370 "bool editable" : false,
371 "bool hexpand" : true,
377 "$ justify" : "Gtk.Justification.RIGHT",
382 "label" : "Generate as Extended (no working)",
384 "xalign" : 0.90000000000000002,
394 "\tthis.el.label = this.el.active ? \"Extended\" : \"Wrapped\";",
400 "string label" : "Wrapped",
401 "xtype" : "CheckButton"
404 "uint row_spacing" : 2,
406 "| void xhideRow" : [
409 "\tvar el = _this.grid.el.get_child_at(0,row);",
412 "\tel = _this.grid.el.get_child_at(1,row);",
417 "| void xshowAllRows" : [
419 "\tfor (var i = 2; i < 10;i++) {",
420 "\t\tvar el = _this.grid.el.get_child_at(0,i);",
422 "\t\tel = _this.grid.el.get_child_at(1,i);",
433 "* prop" : "titlebar",
434 "bool show_title_buttons" : false,
438 "* pack" : "pack_start",
442 " \t_this.done = true;",
443 " _this.el.hide(); ",
447 "string label" : "Cancel",
451 "$ css_classes" : "{ \"suggested-action\" }",
453 "* pack" : "pack_end",
454 "bool always_show_image" : true,
455 "bool hexpand" : false,
464 "\tif (_this.name.el.get_text().length < 1) {",
465 "\t var msg = new Adw.MessageDialog(",
466 "\t _this.mainwindow.el,",
468 "\t \"You have to set a Component name \"",
470 "\t msg.modal = true;",
477 "\tif (!_this.is_new) {",
480 "\t \tvar old_target = _this.file.build_module;",
481 " _this.updateFileFromEntry();",
482 "\t if (_this.project.xtype == \"Gtk\" && old_target != _this.file.build_module) {",
483 "\t \tvar gp = (JsRender.Gtk)_this.file;",
484 "\t \tgp.updateCompileGroup(old_target, _this.file.build_module);",
487 "\t _this.done = true;",
488 "\t _this.file.save();",
489 "\t _this.el.hide();",
493 "\t// ---------------- NEW FILES...",
494 "\tvar ftype = _this.filetype.getValue();",
496 "\tif (ftype == \"\") {",
497 "\t\t// should not happen...",
498 "\t\t// so we are jut going to return without ",
499 "\t\tXcls_StandardErrorDialog.singleton().show(",
500 "\t _this.mainwindow.el,",
501 "\t \"You must select a file type. \"",
508 "\tvar fn = _this.name.el.get_text();",
511 "\tvar ext = ftype;",
512 "\t//var dir = _this.project.path; ",
514 "\t var dir = _this.dir_dropdown.getValue();",
519 "\tvar targetfile = _this.project.path;",
520 "\tif (dir != \"\") {",
521 "\t\ttargetfile += dir;",
523 "\ttargetfile += \"/\" + fn;",
525 "\t// strip the file type off the end..",
528 "\t\tvar rx = new GLib.Regex(\"\\\\.\" + ext + \"$\",GLib.RegexCompileFlags.CASELESS);",
529 "\t\tfn = rx.replace(targetfile, targetfile.length, 0, \"\"); ",
530 "\t } catch (RegexError e) {} // ignore.",
532 "\t targetfile += \".\" + ext;",
535 "\tif (GLib.FileUtils.test(targetfile, GLib.FileTest.EXISTS)) {",
536 "\t Xcls_StandardErrorDialog.singleton().show(",
537 "\t _this.mainwindow.el,",
538 "\t \"That file already exists\"",
542 "\tJsRender.JsRender f;",
544 "\t f = JsRender.JsRender.factory(",
545 "\t\t\text == \"bjs\" ? _this.file.project.xtype : \"PlainFile\", ",
546 "\t\t\t_this.file.project, ",
547 "\t\t\ttargetfile);",
548 "\t} catch (JsRender.Error e) {",
549 "\t\tXcls_StandardErrorDialog.singleton().show(",
550 "\t _this.mainwindow.el,",
551 "\t \"Error creating file\"",
560 "\t_this.updateFileFromEntry();",
561 "\t_this.file.loaded = true;",
562 "\t_this.file.save();",
563 " _this.file.project.addFile(_this.file);",
564 " var sel = _this.filetype.getValue();",
565 "\t if (_this.file.project.xtype == \"Gtk\" && ",
566 "\t \t_this.file.build_module.length > 0 &&",
567 "\t \t( sel == \"bjs\" || sel == \"vala\")) {",
569 "\t\tvar pr = (Project.Gtk) _this.file.project;",
570 "\t\tif (pr.compilegroups.has_key(_this.file.build_module)) {",
571 "\t\t\tvar cg = pr.compilegroups.get(_this.file.build_module);",
572 "\t\t\tif (!cg.sources.contains(_this.file.relpath)) {",
573 "\t\t\t\tcg.sources.add(_this.file.relpath);",
580 "\t// what about .js ?",
581 " _this.done = true;",
582 "\t_this.el.hide();",
584 "// hopefull this will work with bjs files..",
586 "\t_this.success(_this.project, _this.file);",
591 "string icon_name" : "document-save",
592 "string label" : "Save",
596 "title" : "Add / Edit File",
597 "xtype" : "HeaderBar"
603 "\t_this.el.hide();",
609 "string title" : "Add / Edit File",
610 "uint border_width" : 0,
616 "\tthis.path_lbl.el.hide();",
617 " this.path.el.hide();",
620 " this.name_lbl.el.hide();",
621 " this.name.el.hide();",
623 " this.dir_dropdown_lbl.el.hide();",
624 " this.dir_dropdown.el.hide();",
626 "\tthis.title_lbl.el.hide();",
627 "\tthis.title.el.hide();",
629 "\tthis.region_lbl.el.hide();",
630 "\tthis.region.el.hide();",
632 "\tthis.parent_lbl.el.hide();",
633 "\tthis.parent.el.hide();",
635 "\tthis.permname_lbl.el.hide();",
636 "\tthis.permname.el.hide();",
638 "\tthis.modOrder_lbl.el.hide();",
639 "\tthis.modOrder.el.hide();",
641 "\tthis.build_module_lbl.el.hide();",
642 "\tthis.build_module.el.hide();",
644 "\tthis.gen_lbl.el.hide();",
645 "\tthis.gen.el.hide();",
646 "\t\tthis.filetype_lbl.el.hide();",
647 "\t\tthis.filetype.el.hide();",
650 "| void onDirChanged" : [
652 "if (this.dir_dropdown.el.selected == Gtk.INVALID_LIST_POSITION) {",
653 "\t\tthis.build_module_lbl.el.hide();",
654 "\t\tthis.build_module.el.hide();",
655 "\t\tthis.name_lbl.el.hide();",
656 "\t\tthis.name.el.hide();",
658 " \tthis.gen_lbl.el.hide();",
659 "\t\tthis.gen.el.hide();",
665 "\t// directory selected",
666 "\tvar sel = this.filetype.getValue();",
668 "\tif (this.file.project.xtype==\"Gtk\" && (sel == \"bjs\" || sel == \"vala\")) {",
669 "\t\tthis.build_module_lbl.el.show();",
670 "\t\tthis.build_module.el.show();",
672 "\tthis.name_lbl.el.show();",
673 "\tthis.name.el.show();",
675 "\tif (sel == \"bjs\") {",
676 " _this.gen_lbl.el.show();",
677 " _this.gen.el.show();",
680 " if (this.file.project.xtype == \"Roo\" && sel == \"bjs\") {",
681 " \tthis.title_lbl.el.show();",
682 "\t\tthis.title.el.show();",
684 "\t\tthis.region_lbl.el.show();",
685 "\t\tthis.region.el.show();",
687 "\t\tthis.parent_lbl.el.show();",
688 "\t\tthis.parent.el.show();",
690 "\t\tthis.permname_lbl.el.show();",
691 "\t\tthis.permname.el.show();",
693 "\t\tthis.modOrder_lbl.el.show();",
694 "\t\tthis.modOrder.el.show();",
700 "| void onFileTypeChange" : [
702 "\tif (this.filetype.el.selected == Gtk.INVALID_LIST_POSITION) {",
703 "\t\tthis.dir_dropdown.el.hide();",
704 "\t\tthis.dir_dropdown_lbl.el.hide();",
705 "\t\tthis.build_module_lbl.el.hide();",
706 "\t\tthis.build_module.el.hide();",
707 "\t\tthis.name_lbl.el.hide();",
708 "\t\tthis.name.el.hide();",
710 " \tthis.gen_lbl.el.hide();",
711 "\t\tthis.gen.el.hide();",
714 " \tthis.title_lbl.el.hide();",
715 "\t\tthis.title.el.hide();",
717 "\t\tthis.region_lbl.el.hide();",
718 "\t\tthis.region.el.hide();",
720 "\t\tthis.parent_lbl.el.hide();",
721 "\t\tthis.parent.el.hide();",
723 "\t\tthis.permname_lbl.el.hide();",
724 "\t\tthis.permname.el.hide();",
726 "\t\tthis.modOrder_lbl.el.hide();",
727 "\t\tthis.modOrder.el.hide();",
733 "\tthis.dir_dropdown.el.show();",
734 "\tthis.dir_dropdown_lbl.el.show();",
735 "\tvar sel = this.filetype.getValue();",
737 "\tvar old_sel = _this.dir_dropdown.el.selected != Gtk.INVALID_LIST_POSITION;",
738 "\tvar olddir = this.dir_dropdown.getValue();",
739 "\tGLib.debug(\"old dir = %s\", olddir);",
740 "\tif (this.file.project.xtype==\"Gtk\" && (sel == \"bjs\" || sel == \"vala\")) {",
741 "\t\t_this.project.loadDirsToStringList(_this.dir_model.el, \"/src\");",
742 "\t\tif (old_sel && olddir.has_prefix(\"/src\")) {",
743 "\t\t \tthis.dir_dropdown.setValue(olddir);",
745 "\t \t _this.dir_dropdown.el.selected = Gtk.INVALID_LIST_POSITION;",
750 " _this.project.loadDirsToStringList(_this.dir_model.el, \"\");",
751 "\t\tif (old_sel) {",
752 "\t\t\tthis.dir_dropdown.setValue(olddir);",
754 "\t\t _this.dir_dropdown.el.selected = Gtk.INVALID_LIST_POSITION;",
760 " // is this confusing? - should we just strip out / add if necessary..",
761 " if (sel == \"bjs\" || sel == \"vala\" || sel == \"js\" || sel == \"css\" || sel == \"php\") {",
762 " _this.name_lbl.el.label = \"Component Name (Filename with-out extension)\";\t\t\t\t ",
764 "\t _this.name_lbl.el.label = \"File Name (with extension)\";",
770 "(JsRender.JsRender c, Gtk.Window pwin, bool new_window) ",
773 " this.project = c.project;",
774 " this.done = false;",
775 " this.new_window = new_window;",
777 " //if (!this.el) {",
781 " this.is_new = c.name == \"\";",
783 " _this.name.el.set_text(c.name);",
784 " _this.title.el.set_text(c.title);",
785 " _this.parent.el.set_text(c.parent); ",
786 " _this.region.el.set_text(c.region);",
787 " _this.modOrder.el.set_text(c.modOrder);",
788 " _this.permname.el.set_text(c.permname);",
790 " _this.gen.el.active = c.gen_extended;",
794 " if (this.project.xtype == \"Gtk\") {",
795 " \tvar p = (Project.Gtk) this.project;",
796 "\t this.build_module_model.load(p.compilegroups);",
797 "\t // it will select first if available...",
798 "\t // only for new files.",
799 "\t if (!this.is_new) {",
800 "\t\t this.build_module.setValue(c.build_module);",
807 " // this.el.set_size_request( 550, 100); // should expand height, but give a min width.",
809 " this.el.set_transient_for(pwin);",
811 " // window + header?",
814 " // this.name.el.grab_focus();",
817 " if (!this.is_new) {",
818 "\t this.showEditFile();",
820 " \tthis.showNewFile();",
827 " //this.success = c.success;",
832 "| void showEditFile" : [
834 " \tthis.save_btn.el.set_label(\"Save\");",
835 "\tthis.filetype_lbl.el.hide();",
836 "\tthis.filetype.el.hide();",
838 "\tvar sel = this.filetype.getValue();",
839 "\tswitch(_this.project.xtype) {",
840 "\t\tcase \"Roo\":\t ",
841 "\t\t\t if (sel == \"bjs\") {",
842 "\t\t\t\t_this.title_lbl.el.show();",
843 "\t\t\t\t_this.title.el.show();",
845 "\t\t\t\t_this.region_lbl.el.show();",
846 "\t\t\t\t_this.region.el.show();",
848 "\t\t\t\t_this.parent_lbl.el.show();",
849 "\t\t\t\t_this.parent.el.show();",
851 "\t\t\t\t_this.permname_lbl.el.show();",
852 "\t\t\t\t_this.permname.el.show();",
854 "\t\t\t\t_this.modOrder_lbl.el.show();",
855 "\t\t\t\t_this.modOrder.el.show();",
860 "\t\t\t_this.build_module_lbl.el.show();",
861 "\t\t\t_this.build_module.el.show();\t",
863 "\t\t\tif (sel == \"bjs\") {",
865 "\t\t\t\t _this.gen_lbl.el.show();",
866 "\t\t\t\t_this.gen.el.show();",
870 "\tthis.path.el.show();",
871 "\tthis.path_lbl.el.show();",
872 "\tthis.path.el.set_text(_this.file.relpath);",
875 "| void showNewFile" : [
877 " \tthis.save_btn.el.set_label(\"Create\");",
878 " \tthis.hideAll();",
879 " \tthis.filetype.el.show();",
880 " this.filetype_lbl.el.show();",
881 " this.filetype_model.load();",
882 "\tthis.filetype.el.selected = Gtk.INVALID_LIST_POSITION;",
887 "| void updateFileFromEntry" : [
890 " _this.file.title = _this.title.el.get_text();",
891 " _this.file.region = _this.region.el.get_text(); ",
892 " _this.file.parent = _this.parent.el.get_text(); ",
893 " _this.file.permname = _this.permname.el.get_text(); ",
894 " _this.file.modOrder = _this.modOrder.el.get_text();",
895 " _this.file.gen_extended = _this.gen.el.active;",
896 " var new_name = _this.name.el.get_text();",
897 " if (_this.file.name.length > 0 && _this.file.name != new_name) {",
899 " \t_this.file.renameTo( new_name );",
900 " \t} catch (JsRender.Error e) { } // do nothing?",
903 " _this.file.build_module = _this.build_module.getValue();",
913 "name" : "PopoverFileDetails"