1 static Xcls_PopoverFileDetails _PopoverFileDetails;
3 public class Xcls_PopoverFileDetails : Object
6 private Xcls_PopoverFileDetails _this;
8 public static Xcls_PopoverFileDetails singleton()
10 if (_PopoverFileDetails == null) {
11 _PopoverFileDetails= new Xcls_PopoverFileDetails();
13 return _PopoverFileDetails;
15 public Xcls_grid grid;
16 public Xcls_filetypelbl filetypelbl;
17 public Xcls_filetype filetype;
18 public Xcls_ftdbcellrenderer ftdbcellrenderer;
19 public Xcls_ftdbmodel ftdbmodel;
20 public Xcls_name name;
21 public Xcls_title title;
22 public Xcls_region region;
23 public Xcls_parent parent;
24 public Xcls_permname permname;
25 public Xcls_modOrder modOrder;
26 public Xcls_build_module build_module;
27 public Xcls_dbcellrenderer dbcellrenderer;
28 public Xcls_dbmodel dbmodel;
29 public Xcls_save_btn save_btn;
32 public signal void success (Project.Project pr, JsRender.JsRender file);
34 public Project.Project project;
35 public JsRender.JsRender file;
36 public Xcls_MainWindow mainwindow;
39 public Xcls_PopoverFileDetails()
42 this.el = new Gtk.Popover( null );
47 this.mainwindow = null;
50 this.el.border_width = 0;
52 this.el.position = Gtk.PositionType.RIGHT;
53 var child_0 = new Xcls_Box2( _this );
55 this.el.add ( child_0.el );
58 this.el.closed.connect( () => {
66 // user defined functions
67 public void updateFileFromEntry () {
69 _this.file.title = _this.title.el.get_text();
70 _this.file.region = _this.region.el.get_text();
71 _this.file.parent = _this.parent.el.get_text();
72 _this.file.permname = _this.permname.el.get_text();
73 _this.file.modOrder = _this.modOrder.el.get_text();
75 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
76 _this.file.renameTo(_this.name.el.get_text());
78 // store the module...
79 _this.file.build_module = "";
81 if (_this.build_module.el.get_active_iter (out iter)) {
83 this.dbmodel.el.get_value (iter, 0, out vfname);
84 if (((string)vfname).length > 0) {
85 _this.file.build_module = (string)vfname;
94 public void show (JsRender.JsRender c, Gtk.Widget btn)
96 this.project = c.project;
104 _this.name.el.set_text(c.name);
105 _this.title.el.set_text(c.title);
106 _this.parent.el.set_text(c.parent);
107 _this.region.el.set_text(c.region);
108 _this.modOrder.el.set_text(c.modOrder);
109 _this.permname.el.set_text(c.permname);
117 if (c.path.length > 0) {
119 this.save_btn.el.set_label("Save");
121 this.save_btn.el.set_label("Create");
126 var ar = new Gee.ArrayList<string>();
127 _this.dbmodel.loadData(ar,"");
128 // load the modules... if relivant..
129 if (this.project.xtype == "Gtk") {
130 var p = (Project.Gtk)c.project;
131 var cg = p.compilegroups;
133 var iter = cg.map_iterator();
135 var key = iter.get_key();
136 if (key == "_default_") {
141 _this.dbmodel.loadData(ar, c.build_module);
147 //console.log('show all');
148 this.el.set_modal(true);
149 this.el.set_relative_to(btn);
151 this.el.set_position(Gtk.PositionType.RIGHT);
154 print("SHOWALL - POPIP\n");
156 this.name.el.grab_focus();
160 if (c.path.length > 0) {
161 _this.filetype.el.hide();
162 _this.filetypelbl.el.hide();
166 _this.ftdbmodel.loadData("bjs"); // fixme - need to determine type..
167 _this.filetype.el.show();
168 _this.filetypelbl.el.show();
172 //this.success = c.success;
176 public class Xcls_Box2 : Object
179 private Xcls_PopoverFileDetails _this;
185 public Xcls_Box2(Xcls_PopoverFileDetails _owner )
188 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
192 // set gobject values
193 this.el.homogeneous = false;
194 var child_0 = new Xcls_HeaderBar3( _this );
196 this.el.pack_start ( child_0.el , false,true,0 );
197 var child_1 = new Xcls_grid( _this );
199 this.el.pack_start ( child_1.el , false,false,4 );
200 var child_2 = new Xcls_HButtonBox25( _this );
202 this.el.pack_end ( child_2.el , false,true,0 );
205 // user defined functions
207 public class Xcls_HeaderBar3 : Object
209 public Gtk.HeaderBar el;
210 private Xcls_PopoverFileDetails _this;
216 public Xcls_HeaderBar3(Xcls_PopoverFileDetails _owner )
219 this.el = new Gtk.HeaderBar();
223 // set gobject values
224 this.el.title = "Add / Edit File";
227 // user defined functions
230 public class Xcls_grid : Object
233 private Xcls_PopoverFileDetails _this;
239 public Xcls_grid(Xcls_PopoverFileDetails _owner )
243 this.el = new Gtk.Grid();
247 // set gobject values
248 this.el.margin_right = 4;
249 this.el.margin_left = 4;
250 this.el.row_spacing = 2;
251 var child_0 = new Xcls_filetypelbl( _this );
253 this.el.attach ( child_0.el , 0,0,1,1 );
254 var child_1 = new Xcls_filetype( _this );
256 this.el.attach ( child_1.el , 1,0,1,1 );
257 var child_2 = new Xcls_Label9( _this );
259 this.el.attach ( child_2.el , 0,1,1,1 );
260 var child_3 = new Xcls_name( _this );
262 this.el.attach ( child_3.el , 1,1,1,1 );
263 var child_4 = new Xcls_Label11( _this );
265 this.el.attach ( child_4.el , 0,2,1,1 );
266 var child_5 = new Xcls_title( _this );
268 this.el.attach ( child_5.el , 1,2,1,1 );
269 var child_6 = new Xcls_Label13( _this );
271 this.el.attach ( child_6.el , 0,3,1,1 );
272 var child_7 = new Xcls_region( _this );
274 this.el.attach ( child_7.el , 1,3,1,1 );
275 var child_8 = new Xcls_Label15( _this );
277 this.el.attach ( child_8.el , 0,4,1,1 );
278 var child_9 = new Xcls_parent( _this );
280 this.el.attach ( child_9.el , 1,4,1,1 );
281 var child_10 = new Xcls_Label17( _this );
283 this.el.attach ( child_10.el , 0,5,1,1 );
284 var child_11 = new Xcls_permname( _this );
286 this.el.attach ( child_11.el , 1,5,1,1 );
287 var child_12 = new Xcls_Label19( _this );
289 this.el.attach ( child_12.el , 0,6,1,1 );
290 var child_13 = new Xcls_modOrder( _this );
292 this.el.attach ( child_13.el , 1,6,1,1 );
293 var child_14 = new Xcls_Label21( _this );
295 this.el.attach ( child_14.el , 0,7,1,1 );
296 var child_15 = new Xcls_build_module( _this );
298 this.el.attach ( child_15.el , 1,7,1,1 );
301 // user defined functions
303 public class Xcls_filetypelbl : Object
306 private Xcls_PopoverFileDetails _this;
312 public Xcls_filetypelbl(Xcls_PopoverFileDetails _owner )
315 _this.filetypelbl = this;
316 this.el = new Gtk.Label( "File type" );
320 // set gobject values
321 this.el.justify = Gtk.Justification.RIGHT;
322 this.el.xalign = 0.900000f;
325 // user defined functions
328 public class Xcls_filetype : Object
330 public Gtk.ComboBox el;
331 private Xcls_PopoverFileDetails _this;
337 public Xcls_filetype(Xcls_PopoverFileDetails _owner )
340 _this.filetype = this;
341 this.el = new Gtk.ComboBox();
345 // set gobject values
346 var child_0 = new Xcls_ftdbcellrenderer( _this );
348 this.el.pack_start ( child_0.el , true );
349 var child_1 = new Xcls_ftdbmodel( _this );
351 this.el.set_model ( child_1.el );
355 this.el.add_attribute(_this.ftdbcellrenderer.el , "markup", 1 );
358 this.el.changed.connect( () => {
361 if (this.el.get_active_iter(out iter)) {
363 _this.ftdbmodel.el.get_value (iter, 0, out vfname);
364 is_bjs = ((string)vfname) == "bjs";
367 for (var i = 2; i < 8;i++) {
368 var el = _this.grid.el.get_child_at(0,i);
374 el = _this.grid.el.get_child_at(1,i);
388 // user defined functions
390 public class Xcls_ftdbcellrenderer : Object
392 public Gtk.CellRendererText el;
393 private Xcls_PopoverFileDetails _this;
399 public Xcls_ftdbcellrenderer(Xcls_PopoverFileDetails _owner )
402 _this.ftdbcellrenderer = this;
403 this.el = new Gtk.CellRendererText();
407 // set gobject values
410 // user defined functions
413 public class Xcls_ftdbmodel : Object
415 public Gtk.ListStore el;
416 private Xcls_PopoverFileDetails _this;
422 public Xcls_ftdbmodel(Xcls_PopoverFileDetails _owner )
425 _this.ftdbmodel = this;
426 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
430 // set gobject values
433 // user defined functions
434 public void loadData (string cur) {
439 /// el.append(out iter);
442 // el.set_value(iter, 0, "");
443 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
448 el.set_value(iter, 0, "bjs");
449 el.set_value(iter, 1, "User Interface File (bjs)");
450 _this.filetype.el.set_active_iter(iter);
454 el.set_value(iter, 0, "vala");
455 el.set_value(iter, 1, "Vala");
457 _this.filetype.el.set_active_iter(iter);
464 el.set_value(iter, 0, "js");
465 el.set_value(iter, 1, "Javascript");
468 _this.filetype.el.set_active_iter(iter);
473 el.set_value(iter, 0, "css");
474 el.set_value(iter, 1, "CSS");
477 _this.filetype.el.set_active_iter(iter);
484 public class Xcls_Label9 : Object
487 private Xcls_PopoverFileDetails _this;
493 public Xcls_Label9(Xcls_PopoverFileDetails _owner )
496 this.el = new Gtk.Label( "Component Name" );
500 // set gobject values
501 this.el.justify = Gtk.Justification.RIGHT;
502 this.el.xalign = 0.900000f;
505 // user defined functions
508 public class Xcls_name : Object
511 private Xcls_PopoverFileDetails _this;
517 public Xcls_name(Xcls_PopoverFileDetails _owner )
521 this.el = new Gtk.Entry();
525 // set gobject values
526 this.el.visible = true;
529 // user defined functions
532 public class Xcls_Label11 : Object
535 private Xcls_PopoverFileDetails _this;
541 public Xcls_Label11(Xcls_PopoverFileDetails _owner )
544 this.el = new Gtk.Label( "Title" );
548 // set gobject values
549 this.el.justify = Gtk.Justification.RIGHT;
550 this.el.xalign = 0.900000f;
551 this.el.visible = true;
554 // user defined functions
557 public class Xcls_title : Object
560 private Xcls_PopoverFileDetails _this;
566 public Xcls_title(Xcls_PopoverFileDetails _owner )
570 this.el = new Gtk.Entry();
574 // set gobject values
575 this.el.visible = true;
578 // user defined functions
581 public class Xcls_Label13 : Object
584 private Xcls_PopoverFileDetails _this;
590 public Xcls_Label13(Xcls_PopoverFileDetails _owner )
593 this.el = new Gtk.Label( "Region" );
597 // set gobject values
598 this.el.justify = Gtk.Justification.RIGHT;
599 this.el.xalign = 0.900000f;
600 this.el.tooltip_text = "center, north, south, east, west";
601 this.el.visible = true;
604 // user defined functions
607 public class Xcls_region : Object
610 private Xcls_PopoverFileDetails _this;
616 public Xcls_region(Xcls_PopoverFileDetails _owner )
620 this.el = new Gtk.Entry();
624 // set gobject values
625 this.el.visible = true;
628 // user defined functions
631 public class Xcls_Label15 : Object
634 private Xcls_PopoverFileDetails _this;
640 public Xcls_Label15(Xcls_PopoverFileDetails _owner )
643 this.el = new Gtk.Label( "Parent Name" );
647 // set gobject values
648 this.el.justify = Gtk.Justification.RIGHT;
649 this.el.xalign = 0.900000f;
650 this.el.visible = true;
653 // user defined functions
656 public class Xcls_parent : Object
659 private Xcls_PopoverFileDetails _this;
665 public Xcls_parent(Xcls_PopoverFileDetails _owner )
669 this.el = new Gtk.Entry();
673 // set gobject values
674 this.el.visible = true;
677 // user defined functions
680 public class Xcls_Label17 : Object
683 private Xcls_PopoverFileDetails _this;
689 public Xcls_Label17(Xcls_PopoverFileDetails _owner )
692 this.el = new Gtk.Label( "Permission Name" );
696 // set gobject values
697 this.el.justify = Gtk.Justification.RIGHT;
698 this.el.xalign = 0.900000f;
699 this.el.visible = true;
702 // user defined functions
705 public class Xcls_permname : Object
708 private Xcls_PopoverFileDetails _this;
714 public Xcls_permname(Xcls_PopoverFileDetails _owner )
717 _this.permname = this;
718 this.el = new Gtk.Entry();
722 // set gobject values
723 this.el.visible = true;
726 // user defined functions
729 public class Xcls_Label19 : Object
732 private Xcls_PopoverFileDetails _this;
738 public Xcls_Label19(Xcls_PopoverFileDetails _owner )
741 this.el = new Gtk.Label( "Order (for tabs)" );
745 // set gobject values
746 this.el.justify = Gtk.Justification.RIGHT;
747 this.el.xalign = 0.900000f;
748 this.el.visible = true;
751 // user defined functions
754 public class Xcls_modOrder : Object
757 private Xcls_PopoverFileDetails _this;
763 public Xcls_modOrder(Xcls_PopoverFileDetails _owner )
766 _this.modOrder = this;
767 this.el = new Gtk.Entry();
771 // set gobject values
772 this.el.visible = true;
775 // user defined functions
778 public class Xcls_Label21 : Object
781 private Xcls_PopoverFileDetails _this;
787 public Xcls_Label21(Xcls_PopoverFileDetails _owner )
790 this.el = new Gtk.Label( "Module to build (Vala only)" );
794 // set gobject values
795 this.el.justify = Gtk.Justification.RIGHT;
796 this.el.xalign = 0.900000f;
797 this.el.visible = true;
800 // user defined functions
803 public class Xcls_build_module : Object
805 public Gtk.ComboBox el;
806 private Xcls_PopoverFileDetails _this;
812 public Xcls_build_module(Xcls_PopoverFileDetails _owner )
815 _this.build_module = this;
816 this.el = new Gtk.ComboBox();
820 // set gobject values
821 var child_0 = new Xcls_dbcellrenderer( _this );
823 this.el.pack_start ( child_0.el , true );
824 var child_1 = new Xcls_dbmodel( _this );
826 this.el.set_model ( child_1.el );
830 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
833 // user defined functions
835 public class Xcls_dbcellrenderer : Object
837 public Gtk.CellRendererText el;
838 private Xcls_PopoverFileDetails _this;
844 public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
847 _this.dbcellrenderer = this;
848 this.el = new Gtk.CellRendererText();
852 // set gobject values
855 // user defined functions
858 public class Xcls_dbmodel : Object
860 public Gtk.ListStore el;
861 private Xcls_PopoverFileDetails _this;
867 public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
870 _this.dbmodel = this;
871 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
875 // set gobject values
878 // user defined functions
879 public void loadData (Gee.ArrayList<string> data, string cur) {
884 /// el.append(out iter);
887 // el.set_value(iter, 0, "");
888 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
893 el.set_value(iter, 0, "");
894 el.set_value(iter, 1, "-- select a module --");
895 _this.build_module.el.set_active_iter(iter);
897 for (var i = 0; i < data.size;i++) {
902 el.set_value(iter, 0, data.get(i));
903 el.set_value(iter, 1, data.get(i));
905 if (data.get(i) == cur) {
906 _this.build_module.el.set_active_iter(iter);
910 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
917 public class Xcls_HButtonBox25 : Object
919 public Gtk.HButtonBox el;
920 private Xcls_PopoverFileDetails _this;
926 public Xcls_HButtonBox25(Xcls_PopoverFileDetails _owner )
929 this.el = new Gtk.HButtonBox();
933 // set gobject values
934 this.el.margin_right = 4;
935 this.el.margin_left = 4;
936 this.el.margin_bottom = 4;
937 var child_0 = new Xcls_Button26( _this );
939 this.el.add ( child_0.el );
940 var child_1 = new Xcls_save_btn( _this );
942 this.el.add ( child_1.el );
945 // user defined functions
947 public class Xcls_Button26 : Object
949 public Gtk.Button el;
950 private Xcls_PopoverFileDetails _this;
956 public Xcls_Button26(Xcls_PopoverFileDetails _owner )
959 this.el = new Gtk.Button();
963 // set gobject values
964 this.el.label = "Cancel";
967 this.el.clicked.connect( () => {
974 // user defined functions
977 public class Xcls_save_btn : Object
979 public Gtk.Button el;
980 private Xcls_PopoverFileDetails _this;
986 public Xcls_save_btn(Xcls_PopoverFileDetails _owner )
989 _this.save_btn = this;
990 this.el = new Gtk.Button();
994 // set gobject values
995 this.el.label = "Save";
998 this.el.clicked.connect( ( ) => {
1003 if (_this.name.el.get_text().length < 1) {
1004 StandardErrorDialog.show(
1005 _this.mainwindow.el,
1006 "You have to set Component name "
1011 // what does this do?
1013 var isNew = _this.file.name.length > 0 ? false : true;
1015 if (!isNew && this.file.name != _this.name.el.get_text()) {
1016 Xcls_StandardErrorDialog.singleton().show(
1018 "Sorry changing names does not work yet. "
1027 // FIXME - this may be more complicated...
1028 //for (var i in this.def) {
1029 // this.file[i] = this.get(i).el.get_text();
1034 _this.updateFileFromEntry();
1035 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
1036 Xcls_StandardErrorDialog.singleton().show(
1037 _this.mainwindow.el,
1038 "The name you used already exists "
1050 // ---------------- NEW FILES...
1052 var fn = _this.name.el.get_text();
1053 var dir = _this.project.firstPath(); // fixme.. should be based on a pulldown?
1055 var targetfile = dir + "/" + fn;
1057 // strip the file type off the end..
1060 if (!_this.filetype.el.get_active_iter(out iter)) {
1061 // should not happen...
1062 // so we are jut going to return without
1063 StandardErrorDialog.show(
1064 _this.mainwindow.el,
1065 "You must select a file type. "
1069 _this.ftdbmodel.el.get_value (iter, 0, out ftypename);
1070 var ext = ((string)vfname);
1073 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
1074 Xcls_StandardErrorDialog.singleton().show(
1075 _this.mainwindow.el,
1076 "That file already exists"
1081 var f = JsRender.JsRender.factory(
1082 _this.file.project.xtype,
1084 dir + "/" + fn + ".bjs");
1090 _this.updateFileFromEntry();
1091 _this.file.loaded = true;
1093 _this.file.project.addFile(_this.file);
1102 _this.success(_this.project, _this.file);
1107 // user defined functions