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",
14 "id" : "PopoverFileDetails",
19 "* pack" : "set_child",
20 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
21 "bool hexpand" : true,
22 "bool homogeneous" : false,
23 "int margin_bottom" : 4,
25 "int margin_start" : 4,
32 "bool hexpand" : true,
34 "int column_spacing" : 4,
36 "int margin_start" : 4,
39 "$ justify" : "Gtk.Justification.RIGHT",
42 "id" : "dir_dropdown_lbl",
43 "label" : "Create File in this Directory",
45 "xalign" : 0.90000000000000002,
50 "id" : "dir_dropdown",
58 "xtype" : "StringList"
62 "| string getValue" : [
64 "\treturn _this.dir_model.el.get_string(this.el.selected);",
69 "$ justify" : "Gtk.Justification.RIGHT",
71 "id" : "filetype_lbl",
72 "label" : "File type",
74 "xalign" : 0.90000000000000002,
79 "bool hexpand" : true,
85 "id" : "filetype_model",
87 "xtype" : "StringList",
92 " while (el.get_n_items() > 0) {",
95 " \tel.append(\"bjs - User Interface File\");",
98 " switch(_this.project.xtype) {",
100 " \t \tel.append(\"js - Javascript File\");",
101 " \t \tel.append(\"css - CSS File\");",
102 " \t \tel.append(\"php - Javascript File\");",
106 "\tcase \"Gtk\":\t\t",
108 " \t \tel.append(\"vala - Vala File\");",
109 " \t \tel.append(\"css - CSS File\");",
110 " \t \tel.append(\"other - Other Type\");",
124 "notify[\"selected\"]" : [
129 " // directory is only available for non-bjs ",
130 " this.showhide( );",
135 "xtype" : "DropDown",
136 "| string getValue" : [
138 "\tif (this.el.selected == Gtk.INVALID_LIST_POSITION) {",
142 "\treturn _this.filetype_model.el.get_string(this.el.selected).split(\" \")[0];",
145 "| void setValue" : [
147 "\tvar el = _this.filetype_model.el;",
148 "\tfor(var i= 0; i < el.get_n_items();i++) {",
149 "\t\tif (el.get_string(i).has_prefix(cur)) {",
150 "\t\t\tthis.el.selected = i;",
156 "| void showhide" : [
162 "\t_this.title_lbl.el.hide();",
163 "\t_this.title.el.hide();",
165 "\t_this.region_lbl.el.hide();",
166 "\t_this.region.el.hide();",
168 "\t_this.parent_lbl.el.hide();",
169 "\t_this.parent.el.hide();",
171 "\t_this.permname_lbl.el.hide();",
172 "\t_this.permname.el.hide();",
174 "\t_this.modOrder_lbl.el.hide();",
175 "\t_this.modOrder.el.hide();",
177 "\t_this.build_module_lbl.el.hide();",
178 "\t_this.build_module.el.hide();",
180 "\t_this.gen_lbl.el.hide();",
181 "\t_this.gen.el.hide();",
183 "\tvar sel = this.getValue();",
185 "\tswitch(_this.project.xtype) {",
188 "\t\t\tif (sel == \"bjs\") {",
189 "\t\t\t\t_this.title_lbl.el.show();",
190 "\t\t\t\t_this.title.el.show();",
192 "\t\t\t\t_this.region_lbl.el.show();",
193 "\t\t\t\t_this.region.el.show();",
195 "\t\t\t\t_this.parent_lbl.el.show();",
196 "\t\t\t\t_this.parent.el.show();",
198 "\t\t\t\t_this.permname_lbl.el.show();",
199 "\t\t\t\t_this.permname.el.show();",
201 "\t\t\t\t_this.modOrder_lbl.el.show();",
202 "\t\t\t\t_this.modOrder.el.show();",
205 "\t\t\t_this.build_module_model.load(null);",
209 "\t\tdefault: // vala..",
211 "\t \t\t_this.build_module_lbl.el.show();",
212 "\t\t\t_this.build_module.el.show();",
214 "\t\t\t_this.gen_lbl.el.show();",
215 "\t\t\t_this.gen.el.show();",
220 " // load up the directories",
221 " //??? why can we not create bjs files in other directories??",
222 "\t//if (!is_bjs && _this.file.path.length < 1) {",
235 "$ justify" : "Gtk.Justification.RIGHT",
237 "label" : "Component Name (File name without extension)",
239 "xalign" : 0.90000000000000002,
245 "bool hexpand" : true,
250 "$ justify" : "Gtk.Justification.RIGHT",
256 "xalign" : 0.90000000000000002,
262 "* pack" : "attach,1,2,1,1",
263 "bool hexpand" : true,
268 "$ justify" : "Gtk.Justification.RIGHT",
273 "tooltip_text" : "center, north, south, east, west",
275 "xalign" : 0.90000000000000002,
281 "bool hexpand" : true,
286 "$ justify" : "Gtk.Justification.RIGHT",
290 "label" : "Parent Name",
292 "xalign" : 0.90000000000000002,
302 "$ justify" : "Gtk.Justification.RIGHT",
305 "id" : "permname_lbl",
306 "label" : "Permission Name",
308 "xalign" : 0.90000000000000002,
318 "$ justify" : "Gtk.Justification.RIGHT",
321 "id" : "modOrder_lbl",
322 "label" : "Order (for tabs)",
324 "xalign" : 0.90000000000000002,
334 "$ justify" : "Gtk.Justification.RIGHT",
337 "id" : "build_module_lbl",
338 "label" : "Module to build",
340 "xalign" : 0.90000000000000002,
345 "id" : "build_module",
350 "id" : "build_module_model",
352 "xtype" : "StringList",
354 "(Gee.HashMap<string,Project.GtkValaSettings>? compilegroups)",
357 "\t_this.build_module.el.hide();",
358 "\t\t_this.build_module_lbl.el.hide();",
359 "\tvar el = _this.build_module_model.el;",
360 "\t while (el.get_n_items() > 0) {",
361 "\t\t\tel.remove(0);",
364 "\tif (compilegroups == null) {",
367 "\tforeach(var k in compilegroups.keys) {",
368 "\t\tthis.el.append(k);",
370 "\tif (compilegroups.keys.size > 0) {",
371 "\t\t_this.build_module.el.selected = 0;",
372 "\t\t_this.build_module.el.show();",
373 "\t\t_this.build_module_lbl.el.show();",
382 "xtype" : "DropDown",
383 "| string getValue" : [
386 "\tif (this.el.selected < 0) {",
390 "\treturn _this.build_module_model.el.get_string(this.el.selected);",
394 "| void setValue" : [
396 "\tvar m = _this.build_module_model.el;",
397 "\tfor(var i = 0; i < m.get_n_items(); i++) {",
398 "\t\tif (m.get_string(i) == str) {",
399 "\t\t\tthis.el.selected = i;",
408 "$ justify" : "Gtk.Justification.RIGHT",
413 "label" : "Full path",
415 "xalign" : 0.90000000000000002,
421 "bool editable" : false,
422 "bool hexpand" : true,
428 "$ justify" : "Gtk.Justification.RIGHT",
433 "label" : "Generate as Extended (experimental)",
435 "xalign" : 0.90000000000000002,
445 "\tthis.el.label = this.el.active ? \"Extended\" : \"Wrapped\";",
451 "string label" : "Wrapped",
452 "xtype" : "CheckButton"
455 "uint row_spacing" : 2,
460 "\tvar el = _this.grid.el.get_child_at(0,row);",
463 "\tel = _this.grid.el.get_child_at(1,row);",
468 "| void showAllRows" : [
470 "\tfor (var i = 2; i < 10;i++) {",
471 "\t\tvar el = _this.grid.el.get_child_at(0,i);",
473 "\t\tel = _this.grid.el.get_child_at(1,i);",
484 "* prop" : "titlebar",
485 "bool show_title_buttons" : false,
489 "* pack" : "pack_start",
493 " \t_this.done = true;",
494 " _this.el.hide(); ",
498 "string label" : "Cancel",
502 "$ css_classes" : "{ \"suggested-action\" }",
504 "* pack" : "pack_end",
505 "bool always_show_image" : true,
506 "bool hexpand" : false,
515 "\tif (_this.name.el.get_text().length < 1) {",
516 "\t Xcls_StandardErrorDialog.singleton().show(",
517 "\t _this.mainwindow.el,",
518 "\t \"You have to set a Component name \"",
523 "\t// what does this do?",
525 "\tvar isNew = _this.file.name.length > 0 ? false : true;",
527 "\tif (!isNew && this.file.name != _this.name.el.get_text()) {",
528 "\t Xcls_StandardErrorDialog.singleton().show(",
530 "\t \"Sorry changing names does not work yet. \"",
538 "\t// FIXME - this may be more complicated...",
539 "\t//for (var i in this.def) {",
540 "\t// this.file[i] = this.get(i).el.get_text();",
546 "\t \tvar old_target = _this.file.build_module;",
547 " _this.updateFileFromEntry();",
548 "\t if (_this.project.xtype == \"Gtk\" && old_target != _this.file.build_module) {",
549 "\t \tvar gp = (JsRender.Gtk)_this.file;",
550 "\t \tgp.updateCompileGroup(old_target, _this.file.build_module);",
553 "\t _this.done = true;",
554 "\t _this.file.save();",
555 "\t _this.el.hide();",
559 "\t// ---------------- NEW FILES...",
560 "\tvar ftype = _this.filetype.getValue();",
562 "\tif (ftype == \"\") {",
563 "\t\t// should not happen...",
564 "\t\t// so we are jut going to return without ",
565 "\t\tXcls_StandardErrorDialog.singleton().show(",
566 "\t _this.mainwindow.el,",
567 "\t \"You must select a file type. \"",
574 "\tvar fn = _this.name.el.get_text();",
577 "\tvar ext = ftype;",
578 "\t//var dir = _this.project.path; ",
580 "\t var dir = _this.dir_dropdown.getValue();",
585 "\tvar targetfile = _this.project.path;",
586 "\tif (dir != \"\") {",
587 "\t\ttargetfile += dir;",
589 "\ttargetfile += \"/\" + fn;",
591 "\t// strip the file type off the end..",
594 "\t\tvar rx = new GLib.Regex(\"\\\\.\" + ext + \"$\",GLib.RegexCompileFlags.CASELESS);",
595 "\t\tfn = rx.replace(targetfile, targetfile.length, 0, \"\"); ",
596 "\t } catch (RegexError e) {} // ignore.",
598 "\t targetfile += \".\" + ext;",
601 "\tif (GLib.FileUtils.test(targetfile, GLib.FileTest.EXISTS)) {",
602 "\t Xcls_StandardErrorDialog.singleton().show(",
603 "\t _this.mainwindow.el,",
604 "\t \"That file already exists\"",
608 "\tJsRender.JsRender f;",
610 "\t f = JsRender.JsRender.factory(",
611 "\t\t\text == \"bjs\" ? _this.file.project.xtype : \"PlainFile\", ",
612 "\t\t\t_this.file.project, ",
613 "\t\t\ttargetfile);",
614 "\t} catch (JsRender.Error e) {",
615 "\t\tXcls_StandardErrorDialog.singleton().show(",
616 "\t _this.mainwindow.el,",
617 "\t \"Error creating file\"",
626 "\t_this.updateFileFromEntry();",
627 "\t_this.file.loaded = true;",
628 "\t_this.file.save();",
629 " _this.file.project.addFile(_this.file);",
633 "\t// what about .js ?",
634 " _this.done = true;",
635 "\t_this.el.hide();",
637 "// hopefull this will work with bjs files..",
639 "\t_this.success(_this.project, _this.file);",
644 "string icon_name" : "document-save",
645 "string label" : "Save",
649 "title" : "Add / Edit File",
650 "xtype" : "HeaderBar"
656 "\t_this.el.hide();",
662 "string title" : "Add / Edit File",
663 "uint border_width" : 0,
666 "(JsRender.JsRender c, Gtk.Window pwin, bool new_window) ",
669 " this.project = c.project;",
670 " this.done = false;",
671 " this.new_window = new_window;",
673 " //if (!this.el) {",
679 " _this.name.el.set_text(c.name);",
680 " _this.title.el.set_text(c.title);",
681 " _this.parent.el.set_text(c.parent); ",
682 " _this.region.el.set_text(c.region);",
683 " _this.modOrder.el.set_text(c.modOrder);",
684 " _this.permname.el.set_text(c.permname);",
686 " _this.gen.el.active = c.gen_extended;",
688 "\t_this.path_lbl.el.show();",
689 " _this.path.el.show();",
690 " _this.dir_dropdown_lbl.el.hide();",
691 " _this.dir_dropdown.el.hide();",
692 " if (c.name == \"\") {",
693 " \t_this.path_lbl.el.hide();",
694 "\t _this.path.el.hide();",
695 "\t this.filetype_model.load();",
696 " _this.dir_dropdown_lbl.el.show();",
697 "\t _this.dir_dropdown.el.show();",
700 " _this.path.el.set_text(c.relpath);",
704 " if (this.project.xtype == \"Gtk\") {",
705 " \tvar p = (Project.Gtk) this.project;",
706 "\t this.build_module_model.load(p.compilegroups);",
707 "\t // it will select first if available...",
708 "\t // only for new files.",
709 "\t if (c.name != \"\") {",
710 "\t\t this.build_module.setValue(c.build_module);",
717 " // this.el.set_size_request( 550, 100); // should expand height, but give a min width.",
719 " this.el.set_transient_for(pwin);",
721 " // window + header?",
722 " print(\"SHOWALL - POPIP\\n\");",
724 " this.name.el.grab_focus();",
726 " _this.project.loadDirsToStringList(this.dir_model.el);",
728 " if (c.path.length > 0) {",
729 "\t this.save_btn.el.set_label(\"Save\");",
730 "\t\t_this.filetype_lbl.el.hide();",
731 "\t\t_this.filetype.el.hide();",
732 "\t\t_this.filetype.showhide(); // as we only work on bjs files currently",
734 " this.save_btn.el.set_label(\"Create\");",
735 "\t _this.filetype.el.show();",
736 "\t _this.filetype_lbl.el.show();",
737 "\t _this.filetype.showhide();",
741 " //this.success = c.success;",
746 "| void updateFileFromEntry" : [
749 " _this.file.title = _this.title.el.get_text();",
750 " _this.file.region = _this.region.el.get_text(); ",
751 " _this.file.parent = _this.parent.el.get_text(); ",
752 " _this.file.permname = _this.permname.el.get_text(); ",
753 " _this.file.modOrder = _this.modOrder.el.get_text();",
754 " _this.file.gen_extended = _this.gen.el.active;",
755 " var new_name = _this.name.el.get_text();",
756 " if (_this.file.name.length > 0 && _this.file.name != new_name) {",
758 " \t_this.file.renameTo( new_name );",
759 " \t} catch (JsRender.Error e) { } // do nothing?",
762 " _this.file.build_module = _this.build_module.getValue();",
772 "name" : "PopoverFileDetails"