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 bool new_window;
36 public signal void success (Project.Project pr, JsRender.JsRender file);
37 public JsRender.JsRender file;
38 public Project.Project project;
39 public Xcls_MainWindow mainwindow;
43 public Xcls_PopoverFileDetails()
46 this.el = new Gtk.Popover( null );
49 this.new_window = true;
51 this.mainwindow = null;
55 this.el.border_width = 0;
57 this.el.position = Gtk.PositionType.RIGHT;
58 var child_0 = new Xcls_Box2( _this );
60 this.el.add ( child_0.el );
63 this.el.closed.connect( () => {
69 this.el.hide.connect( ( ) => {
78 // user defined functions
79 public void show (JsRender.JsRender c, Gtk.Widget btn, bool new_window)
81 this.project = c.project;
83 this.new_window = new_window;
89 _this.name.el.set_text(c.name);
90 _this.title.el.set_text(c.title);
91 _this.parent.el.set_text(c.parent);
92 _this.region.el.set_text(c.region);
93 _this.modOrder.el.set_text(c.modOrder);
94 _this.permname.el.set_text(c.permname);
103 var ar = new Gee.ArrayList<string>();
104 _this.dbmodel.loadData(ar,"");
105 // load the modules... if relivant..
106 if (this.project.xtype == "Gtk") {
107 var p = (Project.Gtk)c.project;
108 var cg = p.compilegroups;
110 var iter = cg.map_iterator();
112 var key = iter.get_key();
113 if (key == "_default_") {
118 _this.dbmodel.loadData(ar, c.build_module);
124 //console.log('show all');
125 this.el.set_modal(true);
126 this.el.set_relative_to(btn);
128 this.el.set_position(Gtk.PositionType.RIGHT);
131 print("SHOWALL - POPIP\n");
133 this.name.el.grab_focus();
137 if (c.path.length > 0) {
138 this.save_btn.el.set_label("Save");
139 _this.filetype.el.hide();
140 _this.filetypelbl.el.hide();
141 _this.filetype.showhide(true); // as we only work on bjs files currently
143 this.save_btn.el.set_label("Create");
144 _this.ftdbmodel.loadData("bjs"); // fixme - need to determine type..
145 _this.filetype.el.show();
146 _this.filetypelbl.el.show();
150 //this.success = c.success;
154 public void updateFileFromEntry () {
156 _this.file.title = _this.title.el.get_text();
157 _this.file.region = _this.region.el.get_text();
158 _this.file.parent = _this.parent.el.get_text();
159 _this.file.permname = _this.permname.el.get_text();
160 _this.file.modOrder = _this.modOrder.el.get_text();
162 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
163 _this.file.renameTo(_this.name.el.get_text());
165 // store the module...
166 _this.file.build_module = "";
168 if (_this.build_module.el.get_active_iter (out iter)) {
170 this.dbmodel.el.get_value (iter, 0, out vfname);
171 if (((string)vfname).length > 0) {
172 _this.file.build_module = (string)vfname;
181 public class Xcls_Box2 : Object
184 private Xcls_PopoverFileDetails _this;
190 public Xcls_Box2(Xcls_PopoverFileDetails _owner )
193 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
197 // set gobject values
198 this.el.homogeneous = false;
199 var child_0 = new Xcls_HeaderBar3( _this );
201 this.el.pack_start ( child_0.el , false,true,0 );
202 var child_1 = new Xcls_grid( _this );
204 this.el.pack_start ( child_1.el , false,false,4 );
205 var child_2 = new Xcls_ButtonBox29( _this );
207 this.el.add ( child_2.el );
210 // user defined functions
212 public class Xcls_HeaderBar3 : Object
214 public Gtk.HeaderBar el;
215 private Xcls_PopoverFileDetails _this;
221 public Xcls_HeaderBar3(Xcls_PopoverFileDetails _owner )
224 this.el = new Gtk.HeaderBar();
228 // set gobject values
229 this.el.title = "Add / Edit File";
232 // user defined functions
235 public class Xcls_grid : Object
238 private Xcls_PopoverFileDetails _this;
244 public Xcls_grid(Xcls_PopoverFileDetails _owner )
248 this.el = new Gtk.Grid();
252 // set gobject values
253 this.el.margin_right = 4;
254 this.el.margin_left = 4;
255 this.el.row_spacing = 2;
256 var child_0 = new Xcls_filetypelbl( _this );
258 this.el.attach ( child_0.el , 0,0,1,1 );
259 var child_1 = new Xcls_filetype( _this );
261 this.el.attach ( child_1.el , 1,0,1,1 );
262 var child_2 = new Xcls_Label9( _this );
264 this.el.attach ( child_2.el , 0,1,1,1 );
265 var child_3 = new Xcls_name( _this );
267 this.el.attach ( child_3.el , 1,1,1,1 );
268 var child_4 = new Xcls_Label11( _this );
270 this.el.attach ( child_4.el , 0,2,1,1 );
271 var child_5 = new Xcls_title( _this );
273 this.el.attach ( child_5.el , 1,2,1,1 );
274 var child_6 = new Xcls_Label13( _this );
276 this.el.attach ( child_6.el , 0,3,1,1 );
277 var child_7 = new Xcls_region( _this );
279 this.el.attach ( child_7.el , 1,3,1,1 );
280 var child_8 = new Xcls_Label15( _this );
282 this.el.attach ( child_8.el , 0,4,1,1 );
283 var child_9 = new Xcls_parent( _this );
285 this.el.attach ( child_9.el , 1,4,1,1 );
286 var child_10 = new Xcls_Label17( _this );
288 this.el.attach ( child_10.el , 0,5,1,1 );
289 var child_11 = new Xcls_permname( _this );
291 this.el.attach ( child_11.el , 1,5,1,1 );
292 var child_12 = new Xcls_Label19( _this );
294 this.el.attach ( child_12.el , 0,6,1,1 );
295 var child_13 = new Xcls_modOrder( _this );
297 this.el.attach ( child_13.el , 1,6,1,1 );
298 var child_14 = new Xcls_Label21( _this );
300 this.el.attach ( child_14.el , 0,7,1,1 );
301 var child_15 = new Xcls_build_module( _this );
303 this.el.attach ( child_15.el , 1,7,1,1 );
304 var child_16 = new Xcls_Label25( _this );
306 this.el.attach ( child_16.el , 0,8,1,1 );
307 var child_17 = new Xcls_dir( _this );
309 this.el.attach ( child_17.el , 1,8,1,1 );
312 // user defined functions
314 public class Xcls_filetypelbl : Object
317 private Xcls_PopoverFileDetails _this;
323 public Xcls_filetypelbl(Xcls_PopoverFileDetails _owner )
326 _this.filetypelbl = this;
327 this.el = new Gtk.Label( "File type" );
331 // set gobject values
332 this.el.justify = Gtk.Justification.RIGHT;
333 this.el.xalign = 0.900000f;
336 // user defined functions
339 public class Xcls_filetype : Object
341 public Gtk.ComboBox el;
342 private Xcls_PopoverFileDetails _this;
348 public Xcls_filetype(Xcls_PopoverFileDetails _owner )
351 _this.filetype = this;
352 this.el = new Gtk.ComboBox();
356 // set gobject values
357 var child_0 = new Xcls_ftdbcellrenderer( _this );
359 this.el.pack_start ( child_0.el , true );
360 var child_1 = new Xcls_ftdbmodel( _this );
362 this.el.set_model ( child_1.el );
366 this.el.add_attribute(_this.ftdbcellrenderer.el , "markup", 1 );
369 this.el.changed.connect( () => {
372 if (this.el.get_active_iter(out iter)) {
374 _this.ftdbmodel.el.get_value (iter, 0, out vfname);
375 is_bjs = ((string)vfname) == "bjs";
379 // directory is only available for non-bjs
380 this.showhide(is_bjs);
386 // user defined functions
387 public void showhide (bool is_bjs) {
390 if (_this.project.xtype != "Roo") {
394 for (var i = 2; i < 9;i++) {
395 var el = _this.grid.el.get_child_at(0,i);
397 var showhide= is_bjs;
399 showhide = !showhide;
407 el = _this.grid.el.get_child_at(1,i);
414 // load up the directories
415 //??? why can we not create bjs files in other directories??
416 //if (!is_bjs && _this.file.path.length < 1) {
418 _this.dirmodel.loadData();
426 public class Xcls_ftdbcellrenderer : Object
428 public Gtk.CellRendererText el;
429 private Xcls_PopoverFileDetails _this;
435 public Xcls_ftdbcellrenderer(Xcls_PopoverFileDetails _owner )
438 _this.ftdbcellrenderer = this;
439 this.el = new Gtk.CellRendererText();
443 // set gobject values
446 // user defined functions
449 public class Xcls_ftdbmodel : Object
451 public Gtk.ListStore el;
452 private Xcls_PopoverFileDetails _this;
458 public Xcls_ftdbmodel(Xcls_PopoverFileDetails _owner )
461 _this.ftdbmodel = this;
462 this.el = new Gtk.ListStore.newv( { typeof(string),typeof(string) } );
466 // set gobject values
469 // user defined functions
470 public void loadData (string cur) {
475 /// el.append(out iter);
478 // el.set_value(iter, 0, "");
479 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
484 el.set_value(iter, 0, "bjs");
485 el.set_value(iter, 1, "User Interface File (bjs)");
486 _this.filetype.el.set_active_iter(iter);
490 el.set_value(iter, 0, "vala");
491 el.set_value(iter, 1, "Vala");
493 _this.filetype.el.set_active_iter(iter);
500 el.set_value(iter, 0, "js");
501 el.set_value(iter, 1, "Javascript");
504 _this.filetype.el.set_active_iter(iter);
509 el.set_value(iter, 0, "css");
510 el.set_value(iter, 1, "CSS");
513 _this.filetype.el.set_active_iter(iter);
520 public class Xcls_Label9 : Object
523 private Xcls_PopoverFileDetails _this;
529 public Xcls_Label9(Xcls_PopoverFileDetails _owner )
532 this.el = new Gtk.Label( "Component Name" );
536 // set gobject values
537 this.el.justify = Gtk.Justification.RIGHT;
538 this.el.xalign = 0.900000f;
541 // user defined functions
544 public class Xcls_name : Object
547 private Xcls_PopoverFileDetails _this;
553 public Xcls_name(Xcls_PopoverFileDetails _owner )
557 this.el = new Gtk.Entry();
561 // set gobject values
562 this.el.visible = true;
565 // user defined functions
568 public class Xcls_Label11 : Object
571 private Xcls_PopoverFileDetails _this;
577 public Xcls_Label11(Xcls_PopoverFileDetails _owner )
580 this.el = new Gtk.Label( "Title" );
584 // set gobject values
585 this.el.justify = Gtk.Justification.RIGHT;
586 this.el.xalign = 0.900000f;
587 this.el.visible = true;
590 // user defined functions
593 public class Xcls_title : Object
596 private Xcls_PopoverFileDetails _this;
602 public Xcls_title(Xcls_PopoverFileDetails _owner )
606 this.el = new Gtk.Entry();
610 // set gobject values
611 this.el.visible = true;
614 // user defined functions
617 public class Xcls_Label13 : Object
620 private Xcls_PopoverFileDetails _this;
626 public Xcls_Label13(Xcls_PopoverFileDetails _owner )
629 this.el = new Gtk.Label( "Region" );
633 // set gobject values
634 this.el.justify = Gtk.Justification.RIGHT;
635 this.el.xalign = 0.900000f;
636 this.el.tooltip_text = "center, north, south, east, west";
637 this.el.visible = true;
640 // user defined functions
643 public class Xcls_region : Object
646 private Xcls_PopoverFileDetails _this;
652 public Xcls_region(Xcls_PopoverFileDetails _owner )
656 this.el = new Gtk.Entry();
660 // set gobject values
661 this.el.visible = true;
664 // user defined functions
667 public class Xcls_Label15 : Object
670 private Xcls_PopoverFileDetails _this;
676 public Xcls_Label15(Xcls_PopoverFileDetails _owner )
679 this.el = new Gtk.Label( "Parent Name" );
683 // set gobject values
684 this.el.justify = Gtk.Justification.RIGHT;
685 this.el.xalign = 0.900000f;
686 this.el.visible = true;
689 // user defined functions
692 public class Xcls_parent : Object
695 private Xcls_PopoverFileDetails _this;
701 public Xcls_parent(Xcls_PopoverFileDetails _owner )
705 this.el = new Gtk.Entry();
709 // set gobject values
710 this.el.visible = true;
713 // user defined functions
716 public class Xcls_Label17 : Object
719 private Xcls_PopoverFileDetails _this;
725 public Xcls_Label17(Xcls_PopoverFileDetails _owner )
728 this.el = new Gtk.Label( "Permission Name" );
732 // set gobject values
733 this.el.justify = Gtk.Justification.RIGHT;
734 this.el.xalign = 0.900000f;
735 this.el.visible = true;
738 // user defined functions
741 public class Xcls_permname : Object
744 private Xcls_PopoverFileDetails _this;
750 public Xcls_permname(Xcls_PopoverFileDetails _owner )
753 _this.permname = this;
754 this.el = new Gtk.Entry();
758 // set gobject values
759 this.el.visible = true;
762 // user defined functions
765 public class Xcls_Label19 : Object
768 private Xcls_PopoverFileDetails _this;
774 public Xcls_Label19(Xcls_PopoverFileDetails _owner )
777 this.el = new Gtk.Label( "Order (for tabs)" );
781 // set gobject values
782 this.el.justify = Gtk.Justification.RIGHT;
783 this.el.xalign = 0.900000f;
784 this.el.visible = true;
787 // user defined functions
790 public class Xcls_modOrder : Object
793 private Xcls_PopoverFileDetails _this;
799 public Xcls_modOrder(Xcls_PopoverFileDetails _owner )
802 _this.modOrder = this;
803 this.el = new Gtk.Entry();
807 // set gobject values
808 this.el.visible = true;
811 // user defined functions
814 public class Xcls_Label21 : Object
817 private Xcls_PopoverFileDetails _this;
823 public Xcls_Label21(Xcls_PopoverFileDetails _owner )
826 this.el = new Gtk.Label( "Module to build (Vala only)" );
830 // set gobject values
831 this.el.justify = Gtk.Justification.RIGHT;
832 this.el.xalign = 0.900000f;
833 this.el.visible = true;
836 // user defined functions
839 public class Xcls_build_module : Object
841 public Gtk.ComboBox el;
842 private Xcls_PopoverFileDetails _this;
848 public Xcls_build_module(Xcls_PopoverFileDetails _owner )
851 _this.build_module = this;
852 this.el = new Gtk.ComboBox();
856 // set gobject values
857 var child_0 = new Xcls_dbcellrenderer( _this );
859 this.el.pack_start ( child_0.el , true );
860 var child_1 = new Xcls_dbmodel( _this );
862 this.el.set_model ( child_1.el );
866 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
869 // user defined functions
871 public class Xcls_dbcellrenderer : Object
873 public Gtk.CellRendererText el;
874 private Xcls_PopoverFileDetails _this;
880 public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
883 _this.dbcellrenderer = this;
884 this.el = new Gtk.CellRendererText();
888 // set gobject values
891 // user defined functions
894 public class Xcls_dbmodel : Object
896 public Gtk.ListStore el;
897 private Xcls_PopoverFileDetails _this;
903 public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
906 _this.dbmodel = this;
907 this.el = new Gtk.ListStore.newv( { typeof(string),typeof(string) } );
911 // set gobject values
914 // user defined functions
915 public void loadData (Gee.ArrayList<string> data, string cur) {
920 /// el.append(out iter);
923 // el.set_value(iter, 0, "");
924 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
929 el.set_value(iter, 0, "");
930 el.set_value(iter, 1, "-- select a module --");
931 _this.build_module.el.set_active_iter(iter);
933 for (var i = 0; i < data.size;i++) {
938 el.set_value(iter, 0, data.get(i));
939 el.set_value(iter, 1, data.get(i));
941 if (data.get(i) == cur) {
942 _this.build_module.el.set_active_iter(iter);
946 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
952 public class Xcls_Label25 : Object
955 private Xcls_PopoverFileDetails _this;
961 public Xcls_Label25(Xcls_PopoverFileDetails _owner )
964 this.el = new Gtk.Label( "Directory" );
968 // set gobject values
969 this.el.justify = Gtk.Justification.RIGHT;
970 this.el.xalign = 0.900000f;
971 this.el.visible = true;
974 // user defined functions
977 public class Xcls_dir : Object
979 public Gtk.ComboBox el;
980 private Xcls_PopoverFileDetails _this;
986 public Xcls_dir(Xcls_PopoverFileDetails _owner )
990 this.el = new Gtk.ComboBox();
994 // set gobject values
995 var child_0 = new Xcls_dircellrenderer( _this );
997 this.el.pack_start ( child_0.el , true );
998 var child_1 = new Xcls_dirmodel( _this );
1000 this.el.set_model ( child_1.el );
1004 this.el.add_attribute(_this.dircellrenderer.el , "markup", 1 );
1007 // user defined functions
1009 public class Xcls_dircellrenderer : Object
1011 public Gtk.CellRendererText el;
1012 private Xcls_PopoverFileDetails _this;
1018 public Xcls_dircellrenderer(Xcls_PopoverFileDetails _owner )
1021 _this.dircellrenderer = this;
1022 this.el = new Gtk.CellRendererText();
1026 // set gobject values
1029 // user defined functions
1032 public class Xcls_dirmodel : Object
1034 public Gtk.ListStore el;
1035 private Xcls_PopoverFileDetails _this;
1041 public Xcls_dirmodel(Xcls_PopoverFileDetails _owner )
1044 _this.dirmodel = this;
1045 this.el = new Gtk.ListStore.newv( { typeof(string),typeof(string) } );
1049 // set gobject values
1052 // user defined functions
1053 public void loadData () {
1059 if (!(_this.project is Project.Gtk)) {
1062 var sd = ((Project.Gtk)_this.project).sourcedirs();
1067 /// el.append(out iter);
1070 // el.set_value(iter, 0, "");
1071 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
1073 // el.append(out iter);
1076 // el.set_value(iter, 0, "");
1077 // el.set_value(iter, 1, "-- select a directoyr --");
1078 //_this.build_module.el.set_active_iter(iter);
1080 for (var i = 0; i < sd.length;i++) {
1083 el.append(out iter);
1085 el.set_value(iter, 0, sd[i]);
1086 el.set_value(iter, 1, sd[i]);
1088 //if (data.get(i) == cur) {
1089 // _this.build_module.el.set_active_iter(iter);
1093 // this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
1100 public class Xcls_ButtonBox29 : Object
1102 public Gtk.ButtonBox el;
1103 private Xcls_PopoverFileDetails _this;
1109 public Xcls_ButtonBox29(Xcls_PopoverFileDetails _owner )
1112 this.el = new Gtk.ButtonBox( Gtk.Orientation.HORIZONTAL );
1116 // set gobject values
1117 this.el.margin_right = 4;
1118 this.el.margin_left = 4;
1119 this.el.margin_bottom = 4;
1120 this.el.margin_top = 4;
1121 var child_0 = new Xcls_Button30( _this );
1123 this.el.add ( child_0.el );
1124 var child_1 = new Xcls_save_btn( _this );
1126 this.el.add ( child_1.el );
1129 // user defined functions
1131 public class Xcls_Button30 : Object
1133 public Gtk.Button el;
1134 private Xcls_PopoverFileDetails _this;
1140 public Xcls_Button30(Xcls_PopoverFileDetails _owner )
1143 this.el = new Gtk.Button();
1147 // set gobject values
1148 this.el.label = "Cancel";
1151 this.el.clicked.connect( () => {
1158 // user defined functions
1161 public class Xcls_save_btn : Object
1163 public Gtk.Button el;
1164 private Xcls_PopoverFileDetails _this;
1170 public Xcls_save_btn(Xcls_PopoverFileDetails _owner )
1173 _this.save_btn = this;
1174 this.el = new Gtk.Button();
1178 // set gobject values
1179 this.el.label = "Save";
1182 this.el.clicked.connect( ( ) => {
1187 if (_this.name.el.get_text().length < 1) {
1188 Xcls_StandardErrorDialog.singleton().show(
1189 _this.mainwindow.el,
1190 "You have to set Component name "
1195 // what does this do?
1197 var isNew = _this.file.name.length > 0 ? false : true;
1199 if (!isNew && this.file.name != _this.name.el.get_text()) {
1200 Xcls_StandardErrorDialog.singleton().show(
1202 "Sorry changing names does not work yet. "
1211 // FIXME - this may be more complicated...
1212 //for (var i in this.def) {
1213 // this.file[i] = this.get(i).el.get_text();
1218 _this.updateFileFromEntry();
1219 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
1220 Xcls_StandardErrorDialog.singleton().show(
1221 _this.mainwindow.el,
1222 "The name you used already exists "
1234 // ---------------- NEW FILES...
1237 if (!_this.filetype.el.get_active_iter(out iter)) {
1238 // should not happen...
1239 // so we are jut going to return without
1240 Xcls_StandardErrorDialog.singleton().show(
1241 _this.mainwindow.el,
1242 "You must select a file type. "
1249 var fn = _this.name.el.get_text();
1252 _this.ftdbmodel.el.get_value (iter, 0, out ftypename);
1253 var ext = ((string)ftypename);
1254 var dir = _this.project.firstPath();
1257 if (!_this.dir.el.get_active_iter(out iter)) {
1258 // should not happen...
1259 // so we are jut going to return without
1260 Xcls_StandardErrorDialog.singleton().show(
1261 _this.mainwindow.el,
1262 "You must select a directory "
1267 _this.dirmodel.el.get_value (iter, 0, out vdir);
1271 var targetfile = dir + "/" + fn;
1273 // strip the file type off the end..
1276 var rx = new GLib.Regex("\\." + ext + "$",GLib.RegexCompileFlags.CASELESS);
1277 targetfile = rx.replace(targetfile, targetfile.length, 0, "");
1279 if (GLib.FileUtils.test(targetfile + "." + ext, GLib.FileTest.EXISTS)) {
1280 Xcls_StandardErrorDialog.singleton().show(
1281 _this.mainwindow.el,
1282 "That file already exists"
1287 var f = JsRender.JsRender.factory(
1288 ext == "bjs" ? _this.file.project.xtype : "PlainFile",
1290 targetfile + "." + ext);
1296 _this.updateFileFromEntry();
1297 _this.file.loaded = true;
1300 _this.file.project.addFile(_this.file);
1308 // hopefull this will work with bjs files..
1310 _this.success(_this.project, _this.file);
1315 // user defined functions