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 "* pack" : "attach,1,2,1,1",
213 "bool hexpand" : true,
218 "$ justify" : "Gtk.Justification.RIGHT",
223 "tooltip_text" : "center, north, south, east, west",
225 "xalign" : 0.90000000000000002,
231 "bool hexpand" : true,
236 "$ justify" : "Gtk.Justification.RIGHT",
240 "label" : "Parent Name",
242 "xalign" : 0.90000000000000002,
252 "$ justify" : "Gtk.Justification.RIGHT",
255 "id" : "permname_lbl",
256 "label" : "Permission Name",
258 "xalign" : 0.90000000000000002,
268 "$ justify" : "Gtk.Justification.RIGHT",
271 "id" : "modOrder_lbl",
272 "label" : "Order (for tabs)",
274 "xalign" : 0.90000000000000002,
284 "$ justify" : "Gtk.Justification.RIGHT",
287 "id" : "build_module_lbl",
288 "label" : "Module to build",
290 "xalign" : 0.90000000000000002,
295 "id" : "build_module",
300 "id" : "build_module_model",
302 "xtype" : "StringList",
304 "(Gee.HashMap<string,Project.GtkValaSettings>? compilegroups)",
307 "\t_this.build_module.el.hide();",
308 "\t\t_this.build_module_lbl.el.hide();",
309 "\tvar el = _this.build_module_model.el;",
310 "\t while (el.get_n_items() > 0) {",
311 "\t\t\tel.remove(0);",
314 "\tif (compilegroups == null) {",
317 "\tforeach(var k in compilegroups.keys) {",
318 "\t\tthis.el.append(k);",
320 "\tif (compilegroups.keys.size > 0) {",
321 "\t\t_this.build_module.el.selected = 0;",
322 "\t\t_this.build_module.el.show();",
323 "\t\t_this.build_module_lbl.el.show();",
332 "xtype" : "DropDown",
333 "| string getValue" : [
336 "\tif (this.el.selected < 0) {",
340 "\treturn _this.build_module_model.el.get_string(this.el.selected);",
344 "| void setValue" : [
346 "\tvar m = _this.build_module_model.el;",
347 "\tfor(var i = 0; i < m.get_n_items(); i++) {",
348 "\t\tif (m.get_string(i) == str) {",
349 "\t\t\tthis.el.selected = i;",
358 "$ justify" : "Gtk.Justification.RIGHT",
363 "label" : "Full path",
365 "xalign" : 0.90000000000000002,
371 "bool editable" : false,
372 "bool hexpand" : true,
378 "$ justify" : "Gtk.Justification.RIGHT",
383 "label" : "Generate as Extended (no working)",
385 "xalign" : 0.90000000000000002,
395 "\tthis.el.label = this.el.active ? \"Extended\" : \"Wrapped\";",
401 "string label" : "Wrapped",
402 "xtype" : "CheckButton"
405 "uint row_spacing" : 2,
407 "| void xhideRow" : [
410 "\tvar el = _this.grid.el.get_child_at(0,row);",
413 "\tel = _this.grid.el.get_child_at(1,row);",
418 "| void xshowAllRows" : [
420 "\tfor (var i = 2; i < 10;i++) {",
421 "\t\tvar el = _this.grid.el.get_child_at(0,i);",
423 "\t\tel = _this.grid.el.get_child_at(1,i);",
434 "* prop" : "titlebar",
435 "bool show_title_buttons" : false,
439 "* pack" : "pack_start",
443 " \t_this.done = true;",
444 " _this.el.hide(); ",
448 "string label" : "Cancel",
452 "$ css_classes" : "{ \"suggested-action\" }",
454 "* pack" : "pack_end",
455 "bool always_show_image" : true,
456 "bool hexpand" : false,
465 "\tif (_this.name.el.get_text().length < 1) {",
466 "\t Xcls_StandardErrorDialog.singleton().show(",
467 "\t _this.mainwindow.el,",
468 "\t \"You have to set a Component name \"",
473 "\t// what does this do?",
477 "\tif (!isNew && this.file.name != _this.name.el.get_text()) {",
478 "\t Xcls_StandardErrorDialog.singleton().show(",
480 "\t \"Sorry changing names does not work yet. \"",
488 "\t// FIXME - this may be more complicated...",
489 "\t//for (var i in this.def) {",
490 "\t// this.file[i] = this.get(i).el.get_text();",
493 "\tif (!_this.is_new) {",
496 "\t \tvar old_target = _this.file.build_module;",
497 " _this.updateFileFromEntry();",
498 "\t if (_this.project.xtype == \"Gtk\" && old_target != _this.file.build_module) {",
499 "\t \tvar gp = (JsRender.Gtk)_this.file;",
500 "\t \tgp.updateCompileGroup(old_target, _this.file.build_module);",
503 "\t _this.done = true;",
504 "\t _this.file.save();",
505 "\t _this.el.hide();",
509 "\t// ---------------- NEW FILES...",
510 "\tvar ftype = _this.filetype.getValue();",
512 "\tif (ftype == \"\") {",
513 "\t\t// should not happen...",
514 "\t\t// so we are jut going to return without ",
515 "\t\tXcls_StandardErrorDialog.singleton().show(",
516 "\t _this.mainwindow.el,",
517 "\t \"You must select a file type. \"",
524 "\tvar fn = _this.name.el.get_text();",
527 "\tvar ext = ftype;",
528 "\t//var dir = _this.project.path; ",
530 "\t var dir = _this.dir_dropdown.getValue();",
535 "\tvar targetfile = _this.project.path;",
536 "\tif (dir != \"\") {",
537 "\t\ttargetfile += dir;",
539 "\ttargetfile += \"/\" + fn;",
541 "\t// strip the file type off the end..",
544 "\t\tvar rx = new GLib.Regex(\"\\\\.\" + ext + \"$\",GLib.RegexCompileFlags.CASELESS);",
545 "\t\tfn = rx.replace(targetfile, targetfile.length, 0, \"\"); ",
546 "\t } catch (RegexError e) {} // ignore.",
548 "\t targetfile += \".\" + ext;",
551 "\tif (GLib.FileUtils.test(targetfile, GLib.FileTest.EXISTS)) {",
552 "\t Xcls_StandardErrorDialog.singleton().show(",
553 "\t _this.mainwindow.el,",
554 "\t \"That file already exists\"",
558 "\tJsRender.JsRender f;",
560 "\t f = JsRender.JsRender.factory(",
561 "\t\t\text == \"bjs\" ? _this.file.project.xtype : \"PlainFile\", ",
562 "\t\t\t_this.file.project, ",
563 "\t\t\ttargetfile);",
564 "\t} catch (JsRender.Error e) {",
565 "\t\tXcls_StandardErrorDialog.singleton().show(",
566 "\t _this.mainwindow.el,",
567 "\t \"Error creating file\"",
576 "\t_this.updateFileFromEntry();",
577 "\t_this.file.loaded = true;",
578 "\t_this.file.save();",
579 " _this.file.project.addFile(_this.file);",
580 " var sel = _this.filetype.getValue();",
581 "\t if (_this.file.project.xtype == \"Gtk\" && ",
582 "\t \t_this.file.build_module.length > 0 &&",
583 "\t \t( sel == \"bjs\" || sel == \"vala\")) {",
585 "\t\tvar pr = (Project.Gtk) _this.file.project;",
586 "\t\tif (pr.compilegroups.has_key(_this.file.build_module)) {",
587 "\t\t\tvar cg = pr.compilegroups.get(_this.file.build_module);",
588 "\t\t\tif (!cg.sources.contains(_this.file.relpath)) {",
589 "\t\t\t\tcg.sources.add(_this.file.relpath);",
596 "\t// what about .js ?",
597 " _this.done = true;",
598 "\t_this.el.hide();",
600 "// hopefull this will work with bjs files..",
602 "\t_this.success(_this.project, _this.file);",
607 "string icon_name" : "document-save",
608 "string label" : "Save",
612 "title" : "Add / Edit File",
613 "xtype" : "HeaderBar"
619 "\t_this.el.hide();",
625 "string title" : "Add / Edit File",
626 "uint border_width" : 0,
632 "\tthis.path_lbl.el.hide();",
633 " this.path.el.hide();",
636 " this.name_lbl.el.hide();",
637 " this.name.el.hide();",
639 " this.dir_dropdown_lbl.el.hide();",
640 " this.dir_dropdown.el.hide();",
642 "\tthis.title_lbl.el.hide();",
643 "\tthis.title.el.hide();",
645 "\tthis.region_lbl.el.hide();",
646 "\tthis.region.el.hide();",
648 "\tthis.parent_lbl.el.hide();",
649 "\tthis.parent.el.hide();",
651 "\tthis.permname_lbl.el.hide();",
652 "\tthis.permname.el.hide();",
654 "\tthis.modOrder_lbl.el.hide();",
655 "\tthis.modOrder.el.hide();",
657 "\tthis.build_module_lbl.el.hide();",
658 "\tthis.build_module.el.hide();",
660 "\tthis.gen_lbl.el.hide();",
661 "\tthis.gen.el.hide();",
662 "\t\tthis.filetype_lbl.el.hide();",
663 "\t\tthis.filetype.el.hide();",
666 "| void onDirChanged" : [
668 "if (this.dir_dropdown.el.selected == Gtk.INVALID_LIST_POSITION) {",
669 "\t\tthis.build_module_lbl.el.hide();",
670 "\t\tthis.build_module.el.hide();",
671 "\t\tthis.name_lbl.el.hide();",
672 "\t\tthis.name.el.hide();",
674 " \tthis.gen_lbl.el.hide();",
675 "\t\tthis.gen.el.hide();",
681 "\t// directory selected",
682 "\tvar sel = this.filetype.getValue();",
684 "\tif (this.file.project.xtype==\"Gtk\" && (sel == \"bjs\" || sel == \"vala\")) {",
685 "\t\tthis.build_module_lbl.el.show();",
686 "\t\tthis.build_module.el.show();",
688 "\tthis.name_lbl.el.show();",
689 "\tthis.name.el.show();",
691 "\tif (sel == \"bjs\") {",
692 " _this.gen_lbl.el.show();",
693 " _this.gen.el.show();",
696 " if (this.file.project.xtype == \"Roo\" && sel == \"bjs\") {",
697 " \tthis.title_lbl.el.show();",
698 "\t\tthis.title.el.show();",
700 "\t\tthis.region_lbl.el.show();",
701 "\t\tthis.region.el.show();",
703 "\t\tthis.parent_lbl.el.show();",
704 "\t\tthis.parent.el.show();",
706 "\t\tthis.permname_lbl.el.show();",
707 "\t\tthis.permname.el.show();",
709 "\t\tthis.modOrder_lbl.el.show();",
710 "\t\tthis.modOrder.el.show();",
716 "| void onFileTypeChange" : [
718 "\tif (this.filetype.el.selected == Gtk.INVALID_LIST_POSITION) {",
719 "\t\tthis.dir_dropdown.el.hide();",
720 "\t\tthis.dir_dropdown_lbl.el.hide();",
721 "\t\tthis.build_module_lbl.el.hide();",
722 "\t\tthis.build_module.el.hide();",
723 "\t\tthis.name_lbl.el.hide();",
724 "\t\tthis.name.el.hide();",
726 " \tthis.gen_lbl.el.hide();",
727 "\t\tthis.gen.el.hide();",
730 " \tthis.title_lbl.el.hide();",
731 "\t\tthis.title.el.hide();",
733 "\t\tthis.region_lbl.el.hide();",
734 "\t\tthis.region.el.hide();",
736 "\t\tthis.parent_lbl.el.hide();",
737 "\t\tthis.parent.el.hide();",
739 "\t\tthis.permname_lbl.el.hide();",
740 "\t\tthis.permname.el.hide();",
742 "\t\tthis.modOrder_lbl.el.hide();",
743 "\t\tthis.modOrder.el.hide();",
749 "\tthis.dir_dropdown.el.show();",
750 "\tthis.dir_dropdown_lbl.el.show();",
751 "\tvar sel = this.filetype.getValue();",
753 "\tvar old_sel = _this.dir_dropdown.el.selected != Gtk.INVALID_LIST_POSITION;",
754 "\tvar olddir = this.dir_dropdown.getValue();",
755 "\tGLib.debug(\"old dir = %s\", olddir);",
756 "\tif (this.file.project.xtype==\"Gtk\" && (sel == \"bjs\" || sel == \"vala\")) {",
757 "\t\t_this.project.loadDirsToStringList(_this.dir_model.el, \"/src\");",
758 "\t\tif (old_sel && olddir.has_prefix(\"/src\")) {",
759 "\t\t \tthis.dir_dropdown.setValue(olddir);",
761 "\t \t _this.dir_dropdown.el.selected = Gtk.INVALID_LIST_POSITION;",
766 " _this.project.loadDirsToStringList(_this.dir_model.el, \"\");",
767 "\t\tif (old_sel) {",
768 "\t\t\tthis.dir_dropdown.setValue(olddir);",
770 "\t\t _this.dir_dropdown.el.selected = Gtk.INVALID_LIST_POSITION;",
776 " // is this confusing? - should we just strip out / add if necessary..",
777 " if (sel == \"bjs\" || sel == \"vala\" || sel == \"js\" || sel == \"css\" || sel == \"php\") {",
778 " _this.name_lbl.el.label = \"Component Name (Filename with-out extension)\";\t\t\t\t ",
780 "\t _this.name_lbl.el.label = \"File Name (with extension)\";",
786 "(JsRender.JsRender c, Gtk.Window pwin, bool new_window) ",
789 " this.project = c.project;",
790 " this.done = false;",
791 " this.new_window = new_window;",
793 " //if (!this.el) {",
797 " this.is_new = c.name == \"\";",
799 " _this.name.el.set_text(c.name);",
800 " _this.title.el.set_text(c.title);",
801 " _this.parent.el.set_text(c.parent); ",
802 " _this.region.el.set_text(c.region);",
803 " _this.modOrder.el.set_text(c.modOrder);",
804 " _this.permname.el.set_text(c.permname);",
806 " _this.gen.el.active = c.gen_extended;",
810 " if (this.project.xtype == \"Gtk\") {",
811 " \tvar p = (Project.Gtk) this.project;",
812 "\t this.build_module_model.load(p.compilegroups);",
813 "\t // it will select first if available...",
814 "\t // only for new files.",
815 "\t if (!this.is_new) {",
816 "\t\t this.build_module.setValue(c.build_module);",
823 " // this.el.set_size_request( 550, 100); // should expand height, but give a min width.",
825 " this.el.set_transient_for(pwin);",
827 " // window + header?",
830 " // this.name.el.grab_focus();",
833 " if (!this.is_new) {",
834 "\t this.showEditFile();",
836 " \tthis.showNewFile();",
843 " //this.success = c.success;",
848 "| void showEditFile" : [
850 " \tthis.save_btn.el.set_label(\"Save\");",
851 "\tthis.filetype_lbl.el.hide();",
852 "\tthis.filetype.el.hide();",
854 "\tvar sel = this.filetype.getValue();",
855 "\tswitch(_this.project.xtype) {",
856 "\t\tcase \"Roo\":\t ",
857 "\t\t\t if (sel == \"bjs\") {",
858 "\t\t\t\t_this.title_lbl.el.show();",
859 "\t\t\t\t_this.title.el.show();",
861 "\t\t\t\t_this.region_lbl.el.show();",
862 "\t\t\t\t_this.region.el.show();",
864 "\t\t\t\t_this.parent_lbl.el.show();",
865 "\t\t\t\t_this.parent.el.show();",
867 "\t\t\t\t_this.permname_lbl.el.show();",
868 "\t\t\t\t_this.permname.el.show();",
870 "\t\t\t\t_this.modOrder_lbl.el.show();",
871 "\t\t\t\t_this.modOrder.el.show();",
876 "\t\t\t_this.build_module_lbl.el.show();",
877 "\t\t\t_this.build_module.el.show();\t",
879 "\t\t\tif (sel == \"bjs\") {",
881 "\t\t\t\t _this.gen_lbl.el.show();",
882 "\t\t\t\t_this.gen.el.show();",
886 "\tthis.path.el.show();",
887 "\tthis.path_lbl.el.show();",
888 "\tthis.path.el.set_text(_this.file.relpath);",
891 "| void showNewFile" : [
893 " \tthis.save_btn.el.set_label(\"Create\");",
894 " \tthis.hideAll();",
895 " \tthis.filetype.el.show();",
896 " this.filetype_lbl.el.show();",
897 " this.filetype_model.load();",
898 "\tthis.filetype.el.selected = Gtk.INVALID_LIST_POSITION;",
903 "| void updateFileFromEntry" : [
906 " _this.file.title = _this.title.el.get_text();",
907 " _this.file.region = _this.region.el.get_text(); ",
908 " _this.file.parent = _this.parent.el.get_text(); ",
909 " _this.file.permname = _this.permname.el.get_text(); ",
910 " _this.file.modOrder = _this.modOrder.el.get_text();",
911 " _this.file.gen_extended = _this.gen.el.active;",
912 " var new_name = _this.name.el.get_text();",
913 " if (_this.file.name.length > 0 && _this.file.name != new_name) {",
915 " \t_this.file.renameTo( new_name );",
916 " \t} catch (JsRender.Error e) { } // do nothing?",
919 " _this.file.build_module = _this.build_module.getValue();",
929 "name" : "PopoverFileDetails"