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);
121 var ar = new Gee.ArrayList<string>();
122 _this.dbmodel.loadData(ar,"");
123 // load the modules... if relivant..
124 if (this.project.xtype == "Gtk") {
125 var p = (Project.Gtk)c.project;
126 var cg = p.compilegroups;
128 var iter = cg.map_iterator();
130 var key = iter.get_key();
131 if (key == "_default_") {
136 _this.dbmodel.loadData(ar, c.build_module);
142 //console.log('show all');
143 this.el.set_modal(true);
144 this.el.set_relative_to(btn);
146 this.el.set_position(Gtk.PositionType.RIGHT);
149 print("SHOWALL - POPIP\n");
151 this.name.el.grab_focus();
155 if (c.path.length > 0) {
156 this.save_btn.el.set_label("Save");
157 _this.filetype.el.hide();
158 _this.filetypelbl.el.hide();
159 _this.filetype.showhide(true); // as we only work on bjs files currently
161 this.save_btn.el.set_label("Create");
162 _this.ftdbmodel.loadData("bjs"); // fixme - need to determine type..
163 _this.filetype.el.show();
164 _this.filetypelbl.el.show();
168 //this.success = c.success;
172 public class Xcls_Box2 : Object
175 private Xcls_PopoverFileDetails _this;
181 public Xcls_Box2(Xcls_PopoverFileDetails _owner )
184 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
188 // set gobject values
189 this.el.homogeneous = false;
190 var child_0 = new Xcls_HeaderBar3( _this );
192 this.el.pack_start ( child_0.el , false,true,0 );
193 var child_1 = new Xcls_grid( _this );
195 this.el.pack_start ( child_1.el , false,false,4 );
196 var child_2 = new Xcls_HButtonBox29( _this );
198 this.el.pack_end ( child_2.el , false,true,0 );
201 // user defined functions
203 public class Xcls_HeaderBar3 : Object
205 public Gtk.HeaderBar el;
206 private Xcls_PopoverFileDetails _this;
212 public Xcls_HeaderBar3(Xcls_PopoverFileDetails _owner )
215 this.el = new Gtk.HeaderBar();
219 // set gobject values
220 this.el.title = "Add / Edit File";
223 // user defined functions
226 public class Xcls_grid : Object
229 private Xcls_PopoverFileDetails _this;
235 public Xcls_grid(Xcls_PopoverFileDetails _owner )
239 this.el = new Gtk.Grid();
243 // set gobject values
244 this.el.margin_right = 4;
245 this.el.margin_left = 4;
246 this.el.row_spacing = 2;
247 var child_0 = new Xcls_filetypelbl( _this );
249 this.el.attach ( child_0.el , 0,0,1,1 );
250 var child_1 = new Xcls_filetype( _this );
252 this.el.attach ( child_1.el , 1,0,1,1 );
253 var child_2 = new Xcls_Label9( _this );
255 this.el.attach ( child_2.el , 0,1,1,1 );
256 var child_3 = new Xcls_name( _this );
258 this.el.attach ( child_3.el , 1,1,1,1 );
259 var child_4 = new Xcls_Label11( _this );
261 this.el.attach ( child_4.el , 0,2,1,1 );
262 var child_5 = new Xcls_title( _this );
264 this.el.attach ( child_5.el , 1,2,1,1 );
265 var child_6 = new Xcls_Label13( _this );
267 this.el.attach ( child_6.el , 0,3,1,1 );
268 var child_7 = new Xcls_region( _this );
270 this.el.attach ( child_7.el , 1,3,1,1 );
271 var child_8 = new Xcls_Label15( _this );
273 this.el.attach ( child_8.el , 0,4,1,1 );
274 var child_9 = new Xcls_parent( _this );
276 this.el.attach ( child_9.el , 1,4,1,1 );
277 var child_10 = new Xcls_Label17( _this );
279 this.el.attach ( child_10.el , 0,5,1,1 );
280 var child_11 = new Xcls_permname( _this );
282 this.el.attach ( child_11.el , 1,5,1,1 );
283 var child_12 = new Xcls_Label19( _this );
285 this.el.attach ( child_12.el , 0,6,1,1 );
286 var child_13 = new Xcls_modOrder( _this );
288 this.el.attach ( child_13.el , 1,6,1,1 );
289 var child_14 = new Xcls_Label21( _this );
291 this.el.attach ( child_14.el , 0,7,1,1 );
292 var child_15 = new Xcls_build_module( _this );
294 this.el.attach ( child_15.el , 1,7,1,1 );
295 var child_16 = new Xcls_Label25( _this );
297 this.el.attach ( child_16.el , 0,8 );
298 var child_17 = new Xcls_dir( _this );
300 this.el.attach ( child_17.el , 1,8 );
303 // user defined functions
305 public class Xcls_filetypelbl : Object
308 private Xcls_PopoverFileDetails _this;
314 public Xcls_filetypelbl(Xcls_PopoverFileDetails _owner )
317 _this.filetypelbl = this;
318 this.el = new Gtk.Label( "File type" );
322 // set gobject values
323 this.el.justify = Gtk.Justification.RIGHT;
324 this.el.xalign = 0.900000f;
327 // user defined functions
330 public class Xcls_filetype : Object
332 public Gtk.ComboBox el;
333 private Xcls_PopoverFileDetails _this;
339 public Xcls_filetype(Xcls_PopoverFileDetails _owner )
342 _this.filetype = this;
343 this.el = new Gtk.ComboBox();
347 // set gobject values
348 var child_0 = new Xcls_ftdbcellrenderer( _this );
350 this.el.pack_start ( child_0.el , true );
351 var child_1 = new Xcls_ftdbmodel( _this );
353 this.el.set_model ( child_1.el );
357 this.el.add_attribute(_this.ftdbcellrenderer.el , "markup", 1 );
360 this.el.changed.connect( () => {
363 if (this.el.get_active_iter(out iter)) {
365 _this.ftdbmodel.el.get_value (iter, 0, out vfname);
366 is_bjs = ((string)vfname) == "bjs";
370 // directory is only available for non-bjs
371 this.showhide(is_bjs);
377 // user defined functions
378 public void showhide (bool is_bjs) {
379 for (var i = 2; i < 9;i++) {
380 var el = _this.grid.el.get_child_at(0,i);
382 var showhide= is_bjs;
384 showhide = !showhide;
392 el = _this.grid.el.get_child_at(1,i);
399 // load up the directories
400 //??? why can we not create bjs files in other directories??
401 if (!is_bjs && _this.file.path.length < 1) {
402 _this.dirmodel.loadData();
410 public class Xcls_ftdbcellrenderer : Object
412 public Gtk.CellRendererText el;
413 private Xcls_PopoverFileDetails _this;
419 public Xcls_ftdbcellrenderer(Xcls_PopoverFileDetails _owner )
422 _this.ftdbcellrenderer = this;
423 this.el = new Gtk.CellRendererText();
427 // set gobject values
430 // user defined functions
433 public class Xcls_ftdbmodel : Object
435 public Gtk.ListStore el;
436 private Xcls_PopoverFileDetails _this;
442 public Xcls_ftdbmodel(Xcls_PopoverFileDetails _owner )
445 _this.ftdbmodel = this;
446 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
450 // set gobject values
453 // user defined functions
454 public void loadData (string cur) {
459 /// el.append(out iter);
462 // el.set_value(iter, 0, "");
463 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
468 el.set_value(iter, 0, "bjs");
469 el.set_value(iter, 1, "User Interface File (bjs)");
470 _this.filetype.el.set_active_iter(iter);
474 el.set_value(iter, 0, "vala");
475 el.set_value(iter, 1, "Vala");
477 _this.filetype.el.set_active_iter(iter);
484 el.set_value(iter, 0, "js");
485 el.set_value(iter, 1, "Javascript");
488 _this.filetype.el.set_active_iter(iter);
493 el.set_value(iter, 0, "css");
494 el.set_value(iter, 1, "CSS");
497 _this.filetype.el.set_active_iter(iter);
504 public class Xcls_Label9 : Object
507 private Xcls_PopoverFileDetails _this;
513 public Xcls_Label9(Xcls_PopoverFileDetails _owner )
516 this.el = new Gtk.Label( "Component Name" );
520 // set gobject values
521 this.el.justify = Gtk.Justification.RIGHT;
522 this.el.xalign = 0.900000f;
525 // user defined functions
528 public class Xcls_name : Object
531 private Xcls_PopoverFileDetails _this;
537 public Xcls_name(Xcls_PopoverFileDetails _owner )
541 this.el = new Gtk.Entry();
545 // set gobject values
546 this.el.visible = true;
549 // user defined functions
552 public class Xcls_Label11 : Object
555 private Xcls_PopoverFileDetails _this;
561 public Xcls_Label11(Xcls_PopoverFileDetails _owner )
564 this.el = new Gtk.Label( "Title" );
568 // set gobject values
569 this.el.justify = Gtk.Justification.RIGHT;
570 this.el.xalign = 0.900000f;
571 this.el.visible = true;
574 // user defined functions
577 public class Xcls_title : Object
580 private Xcls_PopoverFileDetails _this;
586 public Xcls_title(Xcls_PopoverFileDetails _owner )
590 this.el = new Gtk.Entry();
594 // set gobject values
595 this.el.visible = true;
598 // user defined functions
601 public class Xcls_Label13 : Object
604 private Xcls_PopoverFileDetails _this;
610 public Xcls_Label13(Xcls_PopoverFileDetails _owner )
613 this.el = new Gtk.Label( "Region" );
617 // set gobject values
618 this.el.justify = Gtk.Justification.RIGHT;
619 this.el.xalign = 0.900000f;
620 this.el.tooltip_text = "center, north, south, east, west";
621 this.el.visible = true;
624 // user defined functions
627 public class Xcls_region : Object
630 private Xcls_PopoverFileDetails _this;
636 public Xcls_region(Xcls_PopoverFileDetails _owner )
640 this.el = new Gtk.Entry();
644 // set gobject values
645 this.el.visible = true;
648 // user defined functions
651 public class Xcls_Label15 : Object
654 private Xcls_PopoverFileDetails _this;
660 public Xcls_Label15(Xcls_PopoverFileDetails _owner )
663 this.el = new Gtk.Label( "Parent Name" );
667 // set gobject values
668 this.el.justify = Gtk.Justification.RIGHT;
669 this.el.xalign = 0.900000f;
670 this.el.visible = true;
673 // user defined functions
676 public class Xcls_parent : Object
679 private Xcls_PopoverFileDetails _this;
685 public Xcls_parent(Xcls_PopoverFileDetails _owner )
689 this.el = new Gtk.Entry();
693 // set gobject values
694 this.el.visible = true;
697 // user defined functions
700 public class Xcls_Label17 : Object
703 private Xcls_PopoverFileDetails _this;
709 public Xcls_Label17(Xcls_PopoverFileDetails _owner )
712 this.el = new Gtk.Label( "Permission Name" );
716 // set gobject values
717 this.el.justify = Gtk.Justification.RIGHT;
718 this.el.xalign = 0.900000f;
719 this.el.visible = true;
722 // user defined functions
725 public class Xcls_permname : Object
728 private Xcls_PopoverFileDetails _this;
734 public Xcls_permname(Xcls_PopoverFileDetails _owner )
737 _this.permname = this;
738 this.el = new Gtk.Entry();
742 // set gobject values
743 this.el.visible = true;
746 // user defined functions
749 public class Xcls_Label19 : Object
752 private Xcls_PopoverFileDetails _this;
758 public Xcls_Label19(Xcls_PopoverFileDetails _owner )
761 this.el = new Gtk.Label( "Order (for tabs)" );
765 // set gobject values
766 this.el.justify = Gtk.Justification.RIGHT;
767 this.el.xalign = 0.900000f;
768 this.el.visible = true;
771 // user defined functions
774 public class Xcls_modOrder : Object
777 private Xcls_PopoverFileDetails _this;
783 public Xcls_modOrder(Xcls_PopoverFileDetails _owner )
786 _this.modOrder = this;
787 this.el = new Gtk.Entry();
791 // set gobject values
792 this.el.visible = true;
795 // user defined functions
798 public class Xcls_Label21 : Object
801 private Xcls_PopoverFileDetails _this;
807 public Xcls_Label21(Xcls_PopoverFileDetails _owner )
810 this.el = new Gtk.Label( "Module to build (Vala only)" );
814 // set gobject values
815 this.el.justify = Gtk.Justification.RIGHT;
816 this.el.xalign = 0.900000f;
817 this.el.visible = true;
820 // user defined functions
823 public class Xcls_build_module : Object
825 public Gtk.ComboBox el;
826 private Xcls_PopoverFileDetails _this;
832 public Xcls_build_module(Xcls_PopoverFileDetails _owner )
835 _this.build_module = this;
836 this.el = new Gtk.ComboBox();
840 // set gobject values
841 var child_0 = new Xcls_dbcellrenderer( _this );
843 this.el.pack_start ( child_0.el , true );
844 var child_1 = new Xcls_dbmodel( _this );
846 this.el.set_model ( child_1.el );
850 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
853 // user defined functions
855 public class Xcls_dbcellrenderer : Object
857 public Gtk.CellRendererText el;
858 private Xcls_PopoverFileDetails _this;
864 public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
867 _this.dbcellrenderer = this;
868 this.el = new Gtk.CellRendererText();
872 // set gobject values
875 // user defined functions
878 public class Xcls_dbmodel : Object
880 public Gtk.ListStore el;
881 private Xcls_PopoverFileDetails _this;
887 public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
890 _this.dbmodel = this;
891 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
895 // set gobject values
898 // user defined functions
899 public void loadData (Gee.ArrayList<string> data, string cur) {
904 /// el.append(out iter);
907 // el.set_value(iter, 0, "");
908 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
913 el.set_value(iter, 0, "");
914 el.set_value(iter, 1, "-- select a module --");
915 _this.build_module.el.set_active_iter(iter);
917 for (var i = 0; i < data.size;i++) {
922 el.set_value(iter, 0, data.get(i));
923 el.set_value(iter, 1, data.get(i));
925 if (data.get(i) == cur) {
926 _this.build_module.el.set_active_iter(iter);
930 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
936 public class Xcls_Label25 : Object
939 private Xcls_PopoverFileDetails _this;
945 public Xcls_Label25(Xcls_PopoverFileDetails _owner )
948 this.el = new Gtk.Label( "Directory" );
952 // set gobject values
953 this.el.justify = Gtk.Justification.RIGHT;
954 this.el.xalign = 0.900000f;
955 this.el.visible = true;
958 // user defined functions
961 public class Xcls_dir : Object
963 public Gtk.ComboBox el;
964 private Xcls_PopoverFileDetails _this;
970 public Xcls_dir(Xcls_PopoverFileDetails _owner )
974 this.el = new Gtk.ComboBox();
978 // set gobject values
979 var child_0 = new Xcls_dircellrenderer( _this );
981 this.el.pack_start ( child_0.el , true );
982 var child_1 = new Xcls_dirmodel( _this );
984 this.el.set_model ( child_1.el );
988 this.el.add_attribute(_this.dircellrenderer.el , "markup", 1 );
991 // user defined functions
993 public class Xcls_dircellrenderer : Object
995 public Gtk.CellRendererText el;
996 private Xcls_PopoverFileDetails _this;
1002 public Xcls_dircellrenderer(Xcls_PopoverFileDetails _owner )
1005 _this.dircellrenderer = this;
1006 this.el = new Gtk.CellRendererText();
1010 // set gobject values
1013 // user defined functions
1016 public class Xcls_dirmodel : Object
1018 public Gtk.ListStore el;
1019 private Xcls_PopoverFileDetails _this;
1025 public Xcls_dirmodel(Xcls_PopoverFileDetails _owner )
1028 _this.dirmodel = this;
1029 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
1033 // set gobject values
1036 // user defined functions
1037 public void loadData () {
1043 if (!(_this.project is Project.Gtk)) {
1046 var sd = ((Project.Gtk)_this.project).sourcedirs();
1051 /// el.append(out iter);
1054 // el.set_value(iter, 0, "");
1055 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
1057 // el.append(out iter);
1060 // el.set_value(iter, 0, "");
1061 // el.set_value(iter, 1, "-- select a directoyr --");
1062 //_this.build_module.el.set_active_iter(iter);
1064 for (var i = 0; i < sd.length;i++) {
1067 el.append(out iter);
1069 el.set_value(iter, 0, sd[i]);
1070 el.set_value(iter, 1, sd[i]);
1072 //if (data.get(i) == cur) {
1073 // _this.build_module.el.set_active_iter(iter);
1077 // this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
1084 public class Xcls_HButtonBox29 : Object
1086 public Gtk.HButtonBox el;
1087 private Xcls_PopoverFileDetails _this;
1093 public Xcls_HButtonBox29(Xcls_PopoverFileDetails _owner )
1096 this.el = new Gtk.HButtonBox();
1100 // set gobject values
1101 this.el.margin_right = 4;
1102 this.el.margin_left = 4;
1103 this.el.margin_bottom = 4;
1104 var child_0 = new Xcls_Button30( _this );
1106 this.el.add ( child_0.el );
1107 var child_1 = new Xcls_save_btn( _this );
1109 this.el.add ( child_1.el );
1112 // user defined functions
1114 public class Xcls_Button30 : Object
1116 public Gtk.Button el;
1117 private Xcls_PopoverFileDetails _this;
1123 public Xcls_Button30(Xcls_PopoverFileDetails _owner )
1126 this.el = new Gtk.Button();
1130 // set gobject values
1131 this.el.label = "Cancel";
1134 this.el.clicked.connect( () => {
1141 // user defined functions
1144 public class Xcls_save_btn : Object
1146 public Gtk.Button el;
1147 private Xcls_PopoverFileDetails _this;
1153 public Xcls_save_btn(Xcls_PopoverFileDetails _owner )
1156 _this.save_btn = this;
1157 this.el = new Gtk.Button();
1161 // set gobject values
1162 this.el.label = "Save";
1165 this.el.clicked.connect( ( ) => {
1170 if (_this.name.el.get_text().length < 1) {
1171 StandardErrorDialog.show(
1172 _this.mainwindow.el,
1173 "You have to set Component name "
1178 // what does this do?
1180 var isNew = _this.file.name.length > 0 ? false : true;
1182 if (!isNew && this.file.name != _this.name.el.get_text()) {
1183 Xcls_StandardErrorDialog.singleton().show(
1185 "Sorry changing names does not work yet. "
1194 // FIXME - this may be more complicated...
1195 //for (var i in this.def) {
1196 // this.file[i] = this.get(i).el.get_text();
1201 _this.updateFileFromEntry();
1202 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
1203 Xcls_StandardErrorDialog.singleton().show(
1204 _this.mainwindow.el,
1205 "The name you used already exists "
1217 // ---------------- NEW FILES...
1220 var fn = _this.name.el.get_text();
1223 _this.ftdbmodel.el.get_value (iter, 0, out ftypename);
1224 var ext = ((string)ftypename);
1228 var dir = _this.project.firstPath(); // fixme.. should be based on a pulldown?
1230 if (!_this.dir.el.get_active_iter(out iter)) {
1231 // should not happen...
1232 // so we are jut going to return without
1233 StandardErrorDialog.show(
1234 _this.mainwindow.el,
1235 "You must select a directory "
1241 var targetfile = dir + "/" + fn;
1243 // strip the file type off the end..
1245 if (!_this.filetype.el.get_active_iter(out iter)) {
1246 // should not happen...
1247 // so we are jut going to return without
1248 StandardErrorDialog.show(
1249 _this.mainwindow.el,
1250 "You must select a file type. "
1254 var rx = new GLib.Regex("\\." + ext + "$",GLib.RegexCompileFlags.CASELESS);
1255 targetfile = rx.replace(targetfile, targetfile.length, 0, "");
1257 if (GLib.FileUtils.test(targetfile + "." + ext, GLib.FileTest.EXISTS)) {
1258 Xcls_StandardErrorDialog.singleton().show(
1259 _this.mainwindow.el,
1260 "That file already exists"
1265 var f = JsRender.JsRender.factory(
1266 ext == "bjs" ? _this.file.project.xtype : "PlainFile",
1268 targetfile + "." + ext);
1274 _this.updateFileFromEntry();
1275 _this.file.loaded = true;
1278 _this.file.project.addFile(_this.file);
1286 // hopefull this will work with bjs files..
1288 _this.success(_this.project, _this.file);
1293 // user defined functions