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;
30 public Xcls_dircellrenderer dircellrenderer;
31 public Xcls_dirmodel dirmodel;
32 public Xcls_save_btn save_btn;
35 public signal void success (Project.Project pr, JsRender.JsRender file);
37 public Project.Project project;
38 public JsRender.JsRender file;
39 public Xcls_MainWindow mainwindow;
42 public Xcls_PopoverFileDetails()
45 this.el = new Gtk.Popover( null );
50 this.mainwindow = null;
53 this.el.border_width = 0;
55 this.el.position = Gtk.PositionType.RIGHT;
56 var child_0 = new Xcls_Box2( _this );
58 this.el.add ( child_0.el );
61 this.el.closed.connect( () => {
69 // user defined functions
70 public void updateFileFromEntry () {
72 _this.file.title = _this.title.el.get_text();
73 _this.file.region = _this.region.el.get_text();
74 _this.file.parent = _this.parent.el.get_text();
75 _this.file.permname = _this.permname.el.get_text();
76 _this.file.modOrder = _this.modOrder.el.get_text();
78 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
79 _this.file.renameTo(_this.name.el.get_text());
81 // store the module...
82 _this.file.build_module = "";
84 if (_this.build_module.el.get_active_iter (out iter)) {
86 this.dbmodel.el.get_value (iter, 0, out vfname);
87 if (((string)vfname).length > 0) {
88 _this.file.build_module = (string)vfname;
97 public void show (JsRender.JsRender c, Gtk.Widget btn)
99 this.project = c.project;
107 _this.name.el.set_text(c.name);
108 _this.title.el.set_text(c.title);
109 _this.parent.el.set_text(c.parent);
110 _this.region.el.set_text(c.region);
111 _this.modOrder.el.set_text(c.modOrder);
112 _this.permname.el.set_text(c.permname);
120 if (c.path.length > 0) {
122 this.save_btn.el.set_label("Save");
124 this.save_btn.el.set_label("Create");
129 var ar = new Gee.ArrayList<string>();
130 _this.dbmodel.loadData(ar,"");
131 // load the modules... if relivant..
132 if (this.project.xtype == "Gtk") {
133 var p = (Project.Gtk)c.project;
134 var cg = p.compilegroups;
136 var iter = cg.map_iterator();
138 var key = iter.get_key();
139 if (key == "_default_") {
144 _this.dbmodel.loadData(ar, c.build_module);
150 //console.log('show all');
151 this.el.set_modal(true);
152 this.el.set_relative_to(btn);
154 this.el.set_position(Gtk.PositionType.RIGHT);
157 print("SHOWALL - POPIP\n");
159 this.name.el.grab_focus();
163 if (c.path.length > 0) {
164 _this.filetype.el.hide();
165 _this.filetypelbl.el.hide();
169 _this.ftdbmodel.loadData("bjs"); // fixme - need to determine type..
170 _this.filetype.el.show();
171 _this.filetypelbl.el.show();
175 //this.success = c.success;
179 public class Xcls_Box2 : Object
182 private Xcls_PopoverFileDetails _this;
188 public Xcls_Box2(Xcls_PopoverFileDetails _owner )
191 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
195 // set gobject values
196 this.el.homogeneous = false;
197 var child_0 = new Xcls_HeaderBar3( _this );
199 this.el.pack_start ( child_0.el , false,true,0 );
200 var child_1 = new Xcls_grid( _this );
202 this.el.pack_start ( child_1.el , false,false,4 );
203 var child_2 = new Xcls_HButtonBox29( _this );
205 this.el.pack_end ( child_2.el , false,true,0 );
208 // user defined functions
210 public class Xcls_HeaderBar3 : Object
212 public Gtk.HeaderBar el;
213 private Xcls_PopoverFileDetails _this;
219 public Xcls_HeaderBar3(Xcls_PopoverFileDetails _owner )
222 this.el = new Gtk.HeaderBar();
226 // set gobject values
227 this.el.title = "Add / Edit File";
230 // user defined functions
233 public class Xcls_grid : Object
236 private Xcls_PopoverFileDetails _this;
242 public Xcls_grid(Xcls_PopoverFileDetails _owner )
246 this.el = new Gtk.Grid();
250 // set gobject values
251 this.el.margin_right = 4;
252 this.el.margin_left = 4;
253 this.el.row_spacing = 2;
254 var child_0 = new Xcls_filetypelbl( _this );
256 this.el.attach ( child_0.el , 0,0,1,1 );
257 var child_1 = new Xcls_filetype( _this );
259 this.el.attach ( child_1.el , 1,0,1,1 );
260 var child_2 = new Xcls_Label9( _this );
262 this.el.attach ( child_2.el , 0,1,1,1 );
263 var child_3 = new Xcls_name( _this );
265 this.el.attach ( child_3.el , 1,1,1,1 );
266 var child_4 = new Xcls_Label11( _this );
268 this.el.attach ( child_4.el , 0,2,1,1 );
269 var child_5 = new Xcls_title( _this );
271 this.el.attach ( child_5.el , 1,2,1,1 );
272 var child_6 = new Xcls_Label13( _this );
274 this.el.attach ( child_6.el , 0,3,1,1 );
275 var child_7 = new Xcls_region( _this );
277 this.el.attach ( child_7.el , 1,3,1,1 );
278 var child_8 = new Xcls_Label15( _this );
280 this.el.attach ( child_8.el , 0,4,1,1 );
281 var child_9 = new Xcls_parent( _this );
283 this.el.attach ( child_9.el , 1,4,1,1 );
284 var child_10 = new Xcls_Label17( _this );
286 this.el.attach ( child_10.el , 0,5,1,1 );
287 var child_11 = new Xcls_permname( _this );
289 this.el.attach ( child_11.el , 1,5,1,1 );
290 var child_12 = new Xcls_Label19( _this );
292 this.el.attach ( child_12.el , 0,6,1,1 );
293 var child_13 = new Xcls_modOrder( _this );
295 this.el.attach ( child_13.el , 1,6,1,1 );
296 var child_14 = new Xcls_Label21( _this );
298 this.el.attach ( child_14.el , 0,7,1,1 );
299 var child_15 = new Xcls_build_module( _this );
301 this.el.attach ( child_15.el , 1,7,1,1 );
302 var child_16 = new Xcls_Label25( _this );
304 this.el.attach ( child_16.el , 0,8 );
305 var child_17 = new Xcls_dir( _this );
307 this.el.attach ( child_17.el , 1,8 );
310 // user defined functions
312 public class Xcls_filetypelbl : Object
315 private Xcls_PopoverFileDetails _this;
321 public Xcls_filetypelbl(Xcls_PopoverFileDetails _owner )
324 _this.filetypelbl = this;
325 this.el = new Gtk.Label( "File type" );
329 // set gobject values
330 this.el.justify = Gtk.Justification.RIGHT;
331 this.el.xalign = 0.900000f;
334 // user defined functions
337 public class Xcls_filetype : Object
339 public Gtk.ComboBox el;
340 private Xcls_PopoverFileDetails _this;
346 public Xcls_filetype(Xcls_PopoverFileDetails _owner )
349 _this.filetype = this;
350 this.el = new Gtk.ComboBox();
354 // set gobject values
355 var child_0 = new Xcls_ftdbcellrenderer( _this );
357 this.el.pack_start ( child_0.el , true );
358 var child_1 = new Xcls_ftdbmodel( _this );
360 this.el.set_model ( child_1.el );
364 this.el.add_attribute(_this.ftdbcellrenderer.el , "markup", 1 );
367 this.el.changed.connect( () => {
370 if (this.el.get_active_iter(out iter)) {
372 _this.ftdbmodel.el.get_value (iter, 0, out vfname);
373 is_bjs = ((string)vfname) == "bjs";
377 // directory is only available for non-bjs
384 // user defined functions
385 public void showhide (bool is_bjs) {
386 for (var i = 2; i < 9;i++) {
387 var el = _this.grid.el.get_child_at(0,i);
389 var showhide= is_bjs;
391 showhide = !showhide;
399 el = _this.grid.el.get_child_at(1,i);
408 public class Xcls_ftdbcellrenderer : Object
410 public Gtk.CellRendererText el;
411 private Xcls_PopoverFileDetails _this;
417 public Xcls_ftdbcellrenderer(Xcls_PopoverFileDetails _owner )
420 _this.ftdbcellrenderer = this;
421 this.el = new Gtk.CellRendererText();
425 // set gobject values
428 // user defined functions
431 public class Xcls_ftdbmodel : Object
433 public Gtk.ListStore el;
434 private Xcls_PopoverFileDetails _this;
440 public Xcls_ftdbmodel(Xcls_PopoverFileDetails _owner )
443 _this.ftdbmodel = this;
444 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
448 // set gobject values
451 // user defined functions
452 public void loadData (string cur) {
457 /// el.append(out iter);
460 // el.set_value(iter, 0, "");
461 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
466 el.set_value(iter, 0, "bjs");
467 el.set_value(iter, 1, "User Interface File (bjs)");
468 _this.filetype.el.set_active_iter(iter);
472 el.set_value(iter, 0, "vala");
473 el.set_value(iter, 1, "Vala");
475 _this.filetype.el.set_active_iter(iter);
482 el.set_value(iter, 0, "js");
483 el.set_value(iter, 1, "Javascript");
486 _this.filetype.el.set_active_iter(iter);
491 el.set_value(iter, 0, "css");
492 el.set_value(iter, 1, "CSS");
495 _this.filetype.el.set_active_iter(iter);
502 public class Xcls_Label9 : Object
505 private Xcls_PopoverFileDetails _this;
511 public Xcls_Label9(Xcls_PopoverFileDetails _owner )
514 this.el = new Gtk.Label( "Component Name" );
518 // set gobject values
519 this.el.justify = Gtk.Justification.RIGHT;
520 this.el.xalign = 0.900000f;
523 // user defined functions
526 public class Xcls_name : Object
529 private Xcls_PopoverFileDetails _this;
535 public Xcls_name(Xcls_PopoverFileDetails _owner )
539 this.el = new Gtk.Entry();
543 // set gobject values
544 this.el.visible = true;
547 // user defined functions
550 public class Xcls_Label11 : Object
553 private Xcls_PopoverFileDetails _this;
559 public Xcls_Label11(Xcls_PopoverFileDetails _owner )
562 this.el = new Gtk.Label( "Title" );
566 // set gobject values
567 this.el.justify = Gtk.Justification.RIGHT;
568 this.el.xalign = 0.900000f;
569 this.el.visible = true;
572 // user defined functions
575 public class Xcls_title : Object
578 private Xcls_PopoverFileDetails _this;
584 public Xcls_title(Xcls_PopoverFileDetails _owner )
588 this.el = new Gtk.Entry();
592 // set gobject values
593 this.el.visible = true;
596 // user defined functions
599 public class Xcls_Label13 : Object
602 private Xcls_PopoverFileDetails _this;
608 public Xcls_Label13(Xcls_PopoverFileDetails _owner )
611 this.el = new Gtk.Label( "Region" );
615 // set gobject values
616 this.el.justify = Gtk.Justification.RIGHT;
617 this.el.xalign = 0.900000f;
618 this.el.tooltip_text = "center, north, south, east, west";
619 this.el.visible = true;
622 // user defined functions
625 public class Xcls_region : Object
628 private Xcls_PopoverFileDetails _this;
634 public Xcls_region(Xcls_PopoverFileDetails _owner )
638 this.el = new Gtk.Entry();
642 // set gobject values
643 this.el.visible = true;
646 // user defined functions
649 public class Xcls_Label15 : Object
652 private Xcls_PopoverFileDetails _this;
658 public Xcls_Label15(Xcls_PopoverFileDetails _owner )
661 this.el = new Gtk.Label( "Parent Name" );
665 // set gobject values
666 this.el.justify = Gtk.Justification.RIGHT;
667 this.el.xalign = 0.900000f;
668 this.el.visible = true;
671 // user defined functions
674 public class Xcls_parent : Object
677 private Xcls_PopoverFileDetails _this;
683 public Xcls_parent(Xcls_PopoverFileDetails _owner )
687 this.el = new Gtk.Entry();
691 // set gobject values
692 this.el.visible = true;
695 // user defined functions
698 public class Xcls_Label17 : Object
701 private Xcls_PopoverFileDetails _this;
707 public Xcls_Label17(Xcls_PopoverFileDetails _owner )
710 this.el = new Gtk.Label( "Permission Name" );
714 // set gobject values
715 this.el.justify = Gtk.Justification.RIGHT;
716 this.el.xalign = 0.900000f;
717 this.el.visible = true;
720 // user defined functions
723 public class Xcls_permname : Object
726 private Xcls_PopoverFileDetails _this;
732 public Xcls_permname(Xcls_PopoverFileDetails _owner )
735 _this.permname = this;
736 this.el = new Gtk.Entry();
740 // set gobject values
741 this.el.visible = true;
744 // user defined functions
747 public class Xcls_Label19 : Object
750 private Xcls_PopoverFileDetails _this;
756 public Xcls_Label19(Xcls_PopoverFileDetails _owner )
759 this.el = new Gtk.Label( "Order (for tabs)" );
763 // set gobject values
764 this.el.justify = Gtk.Justification.RIGHT;
765 this.el.xalign = 0.900000f;
766 this.el.visible = true;
769 // user defined functions
772 public class Xcls_modOrder : Object
775 private Xcls_PopoverFileDetails _this;
781 public Xcls_modOrder(Xcls_PopoverFileDetails _owner )
784 _this.modOrder = this;
785 this.el = new Gtk.Entry();
789 // set gobject values
790 this.el.visible = true;
793 // user defined functions
796 public class Xcls_Label21 : Object
799 private Xcls_PopoverFileDetails _this;
805 public Xcls_Label21(Xcls_PopoverFileDetails _owner )
808 this.el = new Gtk.Label( "Module to build (Vala only)" );
812 // set gobject values
813 this.el.justify = Gtk.Justification.RIGHT;
814 this.el.xalign = 0.900000f;
815 this.el.visible = true;
818 // user defined functions
821 public class Xcls_build_module : Object
823 public Gtk.ComboBox el;
824 private Xcls_PopoverFileDetails _this;
830 public Xcls_build_module(Xcls_PopoverFileDetails _owner )
833 _this.build_module = this;
834 this.el = new Gtk.ComboBox();
838 // set gobject values
839 var child_0 = new Xcls_dbcellrenderer( _this );
841 this.el.pack_start ( child_0.el , true );
842 var child_1 = new Xcls_dbmodel( _this );
844 this.el.set_model ( child_1.el );
848 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
851 // user defined functions
853 public class Xcls_dbcellrenderer : Object
855 public Gtk.CellRendererText el;
856 private Xcls_PopoverFileDetails _this;
862 public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
865 _this.dbcellrenderer = this;
866 this.el = new Gtk.CellRendererText();
870 // set gobject values
873 // user defined functions
876 public class Xcls_dbmodel : Object
878 public Gtk.ListStore el;
879 private Xcls_PopoverFileDetails _this;
885 public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
888 _this.dbmodel = this;
889 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
893 // set gobject values
896 // user defined functions
897 public void loadData (Gee.ArrayList<string> data, string cur) {
902 /// el.append(out iter);
905 // el.set_value(iter, 0, "");
906 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
911 el.set_value(iter, 0, "");
912 el.set_value(iter, 1, "-- select a module --");
913 _this.build_module.el.set_active_iter(iter);
915 for (var i = 0; i < data.size;i++) {
920 el.set_value(iter, 0, data.get(i));
921 el.set_value(iter, 1, data.get(i));
923 if (data.get(i) == cur) {
924 _this.build_module.el.set_active_iter(iter);
928 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
934 public class Xcls_Label25 : Object
937 private Xcls_PopoverFileDetails _this;
943 public Xcls_Label25(Xcls_PopoverFileDetails _owner )
946 this.el = new Gtk.Label( "Directory" );
950 // set gobject values
951 this.el.justify = Gtk.Justification.RIGHT;
952 this.el.xalign = 0.900000f;
953 this.el.visible = true;
956 // user defined functions
959 public class Xcls_dir : Object
961 public Gtk.ComboBox el;
962 private Xcls_PopoverFileDetails _this;
968 public Xcls_dir(Xcls_PopoverFileDetails _owner )
972 this.el = new Gtk.ComboBox();
976 // set gobject values
977 var child_0 = new Xcls_dircellrenderer( _this );
979 this.el.pack_start ( child_0.el , true );
980 var child_1 = new Xcls_dirmodel( _this );
982 this.el.set_model ( child_1.el );
986 this.el.add_attribute(_this.dircellrenderer.el , "markup", 1 );
989 // user defined functions
991 public class Xcls_dircellrenderer : Object
993 public Gtk.CellRendererText el;
994 private Xcls_PopoverFileDetails _this;
1000 public Xcls_dircellrenderer(Xcls_PopoverFileDetails _owner )
1003 _this.dircellrenderer = this;
1004 this.el = new Gtk.CellRendererText();
1008 // set gobject values
1011 // user defined functions
1014 public class Xcls_dirmodel : Object
1016 public Gtk.ListStore el;
1017 private Xcls_PopoverFileDetails _this;
1023 public Xcls_dirmodel(Xcls_PopoverFileDetails _owner )
1026 _this.dirmodel = this;
1027 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
1031 // set gobject values
1034 // user defined functions
1035 public void loadData (Gee.ArrayList<string> data, string cur) {
1040 /// el.append(out iter);
1043 // el.set_value(iter, 0, "");
1044 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
1046 el.append(out iter);
1049 el.set_value(iter, 0, "");
1050 el.set_value(iter, 1, "-- select a module --");
1051 _this.build_module.el.set_active_iter(iter);
1053 for (var i = 0; i < data.size;i++) {
1056 el.append(out iter);
1058 el.set_value(iter, 0, data.get(i));
1059 el.set_value(iter, 1, data.get(i));
1061 if (data.get(i) == cur) {
1062 _this.build_module.el.set_active_iter(iter);
1066 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
1073 public class Xcls_HButtonBox29 : Object
1075 public Gtk.HButtonBox el;
1076 private Xcls_PopoverFileDetails _this;
1082 public Xcls_HButtonBox29(Xcls_PopoverFileDetails _owner )
1085 this.el = new Gtk.HButtonBox();
1089 // set gobject values
1090 this.el.margin_right = 4;
1091 this.el.margin_left = 4;
1092 this.el.margin_bottom = 4;
1093 var child_0 = new Xcls_Button30( _this );
1095 this.el.add ( child_0.el );
1096 var child_1 = new Xcls_save_btn( _this );
1098 this.el.add ( child_1.el );
1101 // user defined functions
1103 public class Xcls_Button30 : Object
1105 public Gtk.Button el;
1106 private Xcls_PopoverFileDetails _this;
1112 public Xcls_Button30(Xcls_PopoverFileDetails _owner )
1115 this.el = new Gtk.Button();
1119 // set gobject values
1120 this.el.label = "Cancel";
1123 this.el.clicked.connect( () => {
1130 // user defined functions
1133 public class Xcls_save_btn : Object
1135 public Gtk.Button el;
1136 private Xcls_PopoverFileDetails _this;
1142 public Xcls_save_btn(Xcls_PopoverFileDetails _owner )
1145 _this.save_btn = this;
1146 this.el = new Gtk.Button();
1150 // set gobject values
1151 this.el.label = "Save";
1154 this.el.clicked.connect( ( ) => {
1159 if (_this.name.el.get_text().length < 1) {
1160 StandardErrorDialog.show(
1161 _this.mainwindow.el,
1162 "You have to set Component name "
1167 // what does this do?
1169 var isNew = _this.file.name.length > 0 ? false : true;
1171 if (!isNew && this.file.name != _this.name.el.get_text()) {
1172 Xcls_StandardErrorDialog.singleton().show(
1174 "Sorry changing names does not work yet. "
1183 // FIXME - this may be more complicated...
1184 //for (var i in this.def) {
1185 // this.file[i] = this.get(i).el.get_text();
1190 _this.updateFileFromEntry();
1191 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
1192 Xcls_StandardErrorDialog.singleton().show(
1193 _this.mainwindow.el,
1194 "The name you used already exists "
1206 // ---------------- NEW FILES...
1208 var fn = _this.name.el.get_text();
1209 var dir = _this.project.firstPath(); // fixme.. should be based on a pulldown?
1211 var targetfile = dir + "/" + fn;
1213 // strip the file type off the end..
1216 if (!_this.filetype.el.get_active_iter(out iter)) {
1217 // should not happen...
1218 // so we are jut going to return without
1219 StandardErrorDialog.show(
1220 _this.mainwindow.el,
1221 "You must select a file type. "
1225 _this.ftdbmodel.el.get_value (iter, 0, out ftypename);
1226 var ext = ((string)ftypename);
1228 var rx = new GLib.Regex("\\." + ext + "$",GLib.RegexCompileFlags.CASELESS);
1229 targetfile = rx.replace(targetfile, targetfile.length, 0, "");
1231 if (GLib.FileUtils.test(targetfile + "." + ext, GLib.FileTest.EXISTS)) {
1232 Xcls_StandardErrorDialog.singleton().show(
1233 _this.mainwindow.el,
1234 "That file already exists"
1239 var f = JsRender.JsRender.factory(
1240 ext == "bjs" ? _this.file.project.xtype : "PlainFile",
1242 targetfile + "." + ext);
1248 _this.updateFileFromEntry();
1249 _this.file.loaded = true;
1252 _this.file.project.addFile(_this.file);
1260 // hopefull this will work with bjs files..
1262 _this.success(_this.project, _this.file);
1267 // user defined functions