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_filetypelbl filetypelbl;
16 public Xcls_filetype filetype;
17 public Xcls_ftdbcellrenderer ftdbcellrenderer;
18 public Xcls_ftdbmodel ftdbmodel;
19 public Xcls_name name;
20 public Xcls_title title;
21 public Xcls_region region;
22 public Xcls_parent parent;
23 public Xcls_permname permname;
24 public Xcls_modOrder modOrder;
25 public Xcls_build_module build_module;
26 public Xcls_dbcellrenderer dbcellrenderer;
27 public Xcls_dbmodel dbmodel;
28 public Xcls_save_btn save_btn;
31 public signal void success (Project.Project pr, JsRender.JsRender file);
33 public Project.Project project;
34 public JsRender.JsRender file;
35 public Xcls_MainWindow mainwindow;
38 public Xcls_PopoverFileDetails()
41 this.el = new Gtk.Popover( null );
46 this.mainwindow = null;
49 this.el.border_width = 0;
51 this.el.position = Gtk.PositionType.RIGHT;
52 var child_0 = new Xcls_Box2( _this );
54 this.el.add ( child_0.el );
57 this.el.closed.connect( () => {
65 // user defined functions
66 public void updateFileFromEntry () {
68 _this.file.title = _this.title.el.get_text();
69 _this.file.region = _this.region.el.get_text();
70 _this.file.parent = _this.parent.el.get_text();
71 _this.file.permname = _this.permname.el.get_text();
72 _this.file.modOrder = _this.modOrder.el.get_text();
74 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
75 _this.file.renameTo(_this.name.el.get_text());
77 // store the module...
78 _this.file.build_module = "";
80 if (_this.build_module.el.get_active_iter (out iter)) {
82 this.dbmodel.el.get_value (iter, 0, out vfname);
83 if (((string)vfname).length > 0) {
84 _this.file.build_module = (string)vfname;
93 public void show (JsRender.JsRender c, Gtk.Widget btn)
95 this.project = c.project;
103 _this.name.el.set_text(c.name);
104 _this.title.el.set_text(c.title);
105 _this.parent.el.set_text(c.parent);
106 _this.region.el.set_text(c.region);
107 _this.modOrder.el.set_text(c.modOrder);
108 _this.permname.el.set_text(c.permname);
112 _this.ftdbmodel.loadData("bjs"); // fixme - need to determine type..
113 _this.filetype.el.hide();
114 _this.filetypelbl.el.hide();
117 if (c.path.length > 0) {
118 this.save_btn.el.set_label("Save");
120 this.save_btn.el.set_label("Create");
121 _this.filetype.el.show();
122 _this.filetypelbl.el.show();
125 var ar = new Gee.ArrayList<string>();
126 _this.dbmodel.loadData(ar,"");
127 // load the modules... if relivant..
128 if (this.project.xtype == "Gtk") {
129 var p = (Project.Gtk)c.project;
130 var cg = p.compilegroups;
132 var iter = cg.map_iterator();
134 var key = iter.get_key();
135 if (key == "_default_") {
140 _this.dbmodel.loadData(ar, c.build_module);
146 //console.log('show all');
147 this.el.set_modal(true);
148 this.el.set_relative_to(btn);
150 this.el.set_position(Gtk.PositionType.RIGHT);
153 print("SHOWALL - POPIP\n");
155 this.name.el.grab_focus();
157 //this.success = c.success;
161 public class Xcls_Box2 : Object
164 private Xcls_PopoverFileDetails _this;
170 public Xcls_Box2(Xcls_PopoverFileDetails _owner )
173 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
177 // set gobject values
178 this.el.homogeneous = false;
179 var child_0 = new Xcls_HeaderBar3( _this );
181 this.el.pack_start ( child_0.el , false,true,0 );
182 var child_1 = new Xcls_Grid4( _this );
184 this.el.pack_start ( child_1.el , false,false,4 );
185 var child_2 = new Xcls_HButtonBox25( _this );
187 this.el.pack_end ( child_2.el , false,true,0 );
190 // user defined functions
192 public class Xcls_HeaderBar3 : Object
194 public Gtk.HeaderBar el;
195 private Xcls_PopoverFileDetails _this;
201 public Xcls_HeaderBar3(Xcls_PopoverFileDetails _owner )
204 this.el = new Gtk.HeaderBar();
208 // set gobject values
209 this.el.title = "Add / Edit File";
212 // user defined functions
215 public class Xcls_Grid4 : Object
218 private Xcls_PopoverFileDetails _this;
224 public Xcls_Grid4(Xcls_PopoverFileDetails _owner )
227 this.el = new Gtk.Grid();
231 // set gobject values
232 this.el.margin_right = 4;
233 this.el.margin_left = 4;
234 this.el.row_spacing = 2;
235 var child_0 = new Xcls_filetypelbl( _this );
237 this.el.attach ( child_0.el , 0,0,1,1 );
238 var child_1 = new Xcls_filetype( _this );
240 this.el.attach ( child_1.el , 1,0,1,1 );
241 var child_2 = new Xcls_Label9( _this );
243 this.el.attach ( child_2.el , 0,1,1,1 );
244 var child_3 = new Xcls_name( _this );
246 this.el.attach ( child_3.el , 1,1,1,1 );
247 var child_4 = new Xcls_Label11( _this );
249 this.el.attach ( child_4.el , 0,2,1,1 );
250 var child_5 = new Xcls_title( _this );
252 this.el.attach ( child_5.el , 1,2,1,1 );
253 var child_6 = new Xcls_Label13( _this );
255 this.el.attach ( child_6.el , 0,3,1,1 );
256 var child_7 = new Xcls_region( _this );
258 this.el.attach ( child_7.el , 1,3,1,1 );
259 var child_8 = new Xcls_Label15( _this );
261 this.el.attach ( child_8.el , 0,4,1,1 );
262 var child_9 = new Xcls_parent( _this );
264 this.el.attach ( child_9.el , 1,4,1,1 );
265 var child_10 = new Xcls_Label17( _this );
267 this.el.attach ( child_10.el , 0,5,1,1 );
268 var child_11 = new Xcls_permname( _this );
270 this.el.attach ( child_11.el , 1,5,1,1 );
271 var child_12 = new Xcls_Label19( _this );
273 this.el.attach ( child_12.el , 0,6,1,1 );
274 var child_13 = new Xcls_modOrder( _this );
276 this.el.attach ( child_13.el , 1,6,1,1 );
277 var child_14 = new Xcls_Label21( _this );
279 this.el.attach ( child_14.el , 0,7,1,1 );
280 var child_15 = new Xcls_build_module( _this );
282 this.el.attach ( child_15.el , 1,7,1,1 );
285 // user defined functions
287 public class Xcls_filetypelbl : Object
290 private Xcls_PopoverFileDetails _this;
296 public Xcls_filetypelbl(Xcls_PopoverFileDetails _owner )
299 _this.filetypelbl = this;
300 this.el = new Gtk.Label( "File type" );
304 // set gobject values
305 this.el.justify = Gtk.Justification.RIGHT;
306 this.el.xalign = 0.900000f;
309 // user defined functions
312 public class Xcls_filetype : Object
314 public Gtk.ComboBox el;
315 private Xcls_PopoverFileDetails _this;
321 public Xcls_filetype(Xcls_PopoverFileDetails _owner )
324 _this.filetype = this;
325 this.el = new Gtk.ComboBox();
329 // set gobject values
330 var child_0 = new Xcls_ftdbcellrenderer( _this );
332 this.el.pack_start ( child_0.el , true );
333 var child_1 = new Xcls_ftdbmodel( _this );
335 this.el.set_model ( child_1.el );
339 this.el.add_attribute(_this.ftdbcellrenderer.el , "markup", 1 );
342 this.el.changed.connect( () => {
344 if (!this.el.get_active_iter(out iter)) {
348 this.ftdbmodel.el.get_value (iter, 0, out vfname);
349 var is_bjs = ((string)vfname) == "BJS";
363 // user defined functions
365 public class Xcls_ftdbcellrenderer : Object
367 public Gtk.CellRendererText el;
368 private Xcls_PopoverFileDetails _this;
374 public Xcls_ftdbcellrenderer(Xcls_PopoverFileDetails _owner )
377 _this.ftdbcellrenderer = this;
378 this.el = new Gtk.CellRendererText();
382 // set gobject values
385 // user defined functions
388 public class Xcls_ftdbmodel : Object
390 public Gtk.ListStore el;
391 private Xcls_PopoverFileDetails _this;
397 public Xcls_ftdbmodel(Xcls_PopoverFileDetails _owner )
400 _this.ftdbmodel = this;
401 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
405 // set gobject values
408 // user defined functions
409 public void loadData (string cur) {
414 /// el.append(out iter);
417 // el.set_value(iter, 0, "");
418 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
423 el.set_value(iter, 0, "bjs");
424 el.set_value(iter, 1, "User Interface File (bjs)");
425 _this.filetype.el.set_active_iter(iter);
429 el.set_value(iter, 0, "vala");
430 el.set_value(iter, 1, "Vala");
432 _this.filetype.el.set_active_iter(iter);
439 el.set_value(iter, 0, "js");
440 el.set_value(iter, 1, "Javascript");
443 _this.filetype.el.set_active_iter(iter);
448 el.set_value(iter, 0, "css");
449 el.set_value(iter, 1, "CSS");
452 _this.filetype.el.set_active_iter(iter);
459 public class Xcls_Label9 : Object
462 private Xcls_PopoverFileDetails _this;
468 public Xcls_Label9(Xcls_PopoverFileDetails _owner )
471 this.el = new Gtk.Label( "Component Name" );
475 // set gobject values
476 this.el.justify = Gtk.Justification.RIGHT;
477 this.el.xalign = 0.900000f;
480 // user defined functions
483 public class Xcls_name : Object
486 private Xcls_PopoverFileDetails _this;
492 public Xcls_name(Xcls_PopoverFileDetails _owner )
496 this.el = new Gtk.Entry();
500 // set gobject values
501 this.el.visible = true;
504 // user defined functions
507 public class Xcls_Label11 : Object
510 private Xcls_PopoverFileDetails _this;
516 public Xcls_Label11(Xcls_PopoverFileDetails _owner )
519 this.el = new Gtk.Label( "Title" );
523 // set gobject values
524 this.el.justify = Gtk.Justification.RIGHT;
525 this.el.xalign = 0.900000f;
526 this.el.visible = true;
529 // user defined functions
532 public class Xcls_title : Object
535 private Xcls_PopoverFileDetails _this;
541 public Xcls_title(Xcls_PopoverFileDetails _owner )
545 this.el = new Gtk.Entry();
549 // set gobject values
550 this.el.visible = true;
553 // user defined functions
556 public class Xcls_Label13 : Object
559 private Xcls_PopoverFileDetails _this;
565 public Xcls_Label13(Xcls_PopoverFileDetails _owner )
568 this.el = new Gtk.Label( "Region" );
572 // set gobject values
573 this.el.justify = Gtk.Justification.RIGHT;
574 this.el.xalign = 0.900000f;
575 this.el.tooltip_text = "center, north, south, east, west";
576 this.el.visible = true;
579 // user defined functions
582 public class Xcls_region : Object
585 private Xcls_PopoverFileDetails _this;
591 public Xcls_region(Xcls_PopoverFileDetails _owner )
595 this.el = new Gtk.Entry();
599 // set gobject values
600 this.el.visible = true;
603 // user defined functions
606 public class Xcls_Label15 : Object
609 private Xcls_PopoverFileDetails _this;
615 public Xcls_Label15(Xcls_PopoverFileDetails _owner )
618 this.el = new Gtk.Label( "Parent Name" );
622 // set gobject values
623 this.el.justify = Gtk.Justification.RIGHT;
624 this.el.xalign = 0.900000f;
625 this.el.visible = true;
628 // user defined functions
631 public class Xcls_parent : Object
634 private Xcls_PopoverFileDetails _this;
640 public Xcls_parent(Xcls_PopoverFileDetails _owner )
644 this.el = new Gtk.Entry();
648 // set gobject values
649 this.el.visible = true;
652 // user defined functions
655 public class Xcls_Label17 : Object
658 private Xcls_PopoverFileDetails _this;
664 public Xcls_Label17(Xcls_PopoverFileDetails _owner )
667 this.el = new Gtk.Label( "Permission Name" );
671 // set gobject values
672 this.el.justify = Gtk.Justification.RIGHT;
673 this.el.xalign = 0.900000f;
674 this.el.visible = true;
677 // user defined functions
680 public class Xcls_permname : Object
683 private Xcls_PopoverFileDetails _this;
689 public Xcls_permname(Xcls_PopoverFileDetails _owner )
692 _this.permname = this;
693 this.el = new Gtk.Entry();
697 // set gobject values
698 this.el.visible = true;
701 // user defined functions
704 public class Xcls_Label19 : Object
707 private Xcls_PopoverFileDetails _this;
713 public Xcls_Label19(Xcls_PopoverFileDetails _owner )
716 this.el = new Gtk.Label( "Order (for tabs)" );
720 // set gobject values
721 this.el.justify = Gtk.Justification.RIGHT;
722 this.el.xalign = 0.900000f;
723 this.el.visible = true;
726 // user defined functions
729 public class Xcls_modOrder : Object
732 private Xcls_PopoverFileDetails _this;
738 public Xcls_modOrder(Xcls_PopoverFileDetails _owner )
741 _this.modOrder = this;
742 this.el = new Gtk.Entry();
746 // set gobject values
747 this.el.visible = true;
750 // user defined functions
753 public class Xcls_Label21 : Object
756 private Xcls_PopoverFileDetails _this;
762 public Xcls_Label21(Xcls_PopoverFileDetails _owner )
765 this.el = new Gtk.Label( "Module to build (Vala only)" );
769 // set gobject values
770 this.el.justify = Gtk.Justification.RIGHT;
771 this.el.xalign = 0.900000f;
772 this.el.visible = true;
775 // user defined functions
778 public class Xcls_build_module : Object
780 public Gtk.ComboBox el;
781 private Xcls_PopoverFileDetails _this;
787 public Xcls_build_module(Xcls_PopoverFileDetails _owner )
790 _this.build_module = this;
791 this.el = new Gtk.ComboBox();
795 // set gobject values
796 var child_0 = new Xcls_dbcellrenderer( _this );
798 this.el.pack_start ( child_0.el , true );
799 var child_1 = new Xcls_dbmodel( _this );
801 this.el.set_model ( child_1.el );
805 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
808 // user defined functions
810 public class Xcls_dbcellrenderer : Object
812 public Gtk.CellRendererText el;
813 private Xcls_PopoverFileDetails _this;
819 public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
822 _this.dbcellrenderer = this;
823 this.el = new Gtk.CellRendererText();
827 // set gobject values
830 // user defined functions
833 public class Xcls_dbmodel : Object
835 public Gtk.ListStore el;
836 private Xcls_PopoverFileDetails _this;
842 public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
845 _this.dbmodel = this;
846 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
850 // set gobject values
853 // user defined functions
854 public void loadData (Gee.ArrayList<string> data, string cur) {
859 /// el.append(out iter);
862 // el.set_value(iter, 0, "");
863 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
868 el.set_value(iter, 0, "");
869 el.set_value(iter, 1, "-- select a module --");
870 _this.build_module.el.set_active_iter(iter);
872 for (var i = 0; i < data.size;i++) {
877 el.set_value(iter, 0, data.get(i));
878 el.set_value(iter, 1, data.get(i));
880 if (data.get(i) == cur) {
881 _this.build_module.el.set_active_iter(iter);
885 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
892 public class Xcls_HButtonBox25 : Object
894 public Gtk.HButtonBox el;
895 private Xcls_PopoverFileDetails _this;
901 public Xcls_HButtonBox25(Xcls_PopoverFileDetails _owner )
904 this.el = new Gtk.HButtonBox();
908 // set gobject values
909 this.el.margin_right = 4;
910 this.el.margin_left = 4;
911 this.el.margin_bottom = 4;
912 var child_0 = new Xcls_Button26( _this );
914 this.el.add ( child_0.el );
915 var child_1 = new Xcls_save_btn( _this );
917 this.el.add ( child_1.el );
920 // user defined functions
922 public class Xcls_Button26 : Object
924 public Gtk.Button el;
925 private Xcls_PopoverFileDetails _this;
931 public Xcls_Button26(Xcls_PopoverFileDetails _owner )
934 this.el = new Gtk.Button();
938 // set gobject values
939 this.el.label = "Cancel";
942 this.el.clicked.connect( () => {
949 // user defined functions
952 public class Xcls_save_btn : Object
954 public Gtk.Button el;
955 private Xcls_PopoverFileDetails _this;
961 public Xcls_save_btn(Xcls_PopoverFileDetails _owner )
964 _this.save_btn = this;
965 this.el = new Gtk.Button();
969 // set gobject values
970 this.el.label = "Save";
973 this.el.clicked.connect( ( ) => {
978 if (_this.name.el.get_text().length < 1) {
979 StandardErrorDialog.show(
981 "You have to set Component name "
986 // what does this do?
988 var isNew = _this.file.name.length > 0 ? false : true;
990 if (!isNew && this.file.name != _this.name.el.get_text()) {
991 Xcls_StandardErrorDialog.singleton().show(
993 "Sorry changing names does not work yet. "
1002 // FIXME - this may be more complicated...
1003 //for (var i in this.def) {
1004 // this.file[i] = this.get(i).el.get_text();
1009 _this.updateFileFromEntry();
1010 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
1011 Xcls_StandardErrorDialog.singleton().show(
1012 _this.mainwindow.el,
1013 "The name you used already exists "
1024 var fn = _this.name.el.get_text();
1025 var dir = _this.project.firstPath();
1027 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
1028 Xcls_StandardErrorDialog.singleton().show(
1029 _this.mainwindow.el,
1030 "That file already exists"
1035 var f = JsRender.JsRender.factory(
1036 _this.file.project.xtype,
1038 dir + "/" + fn + ".bjs");
1044 _this.updateFileFromEntry();
1045 _this.file.loaded = true;
1047 _this.file.project.addFile(_this.file);
1056 _this.success(_this.project, _this.file);
1061 // user defined functions