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)) {
353 // user defined functions
355 public class Xcls_ftdbcellrenderer : Object
357 public Gtk.CellRendererText el;
358 private Xcls_PopoverFileDetails _this;
364 public Xcls_ftdbcellrenderer(Xcls_PopoverFileDetails _owner )
367 _this.ftdbcellrenderer = this;
368 this.el = new Gtk.CellRendererText();
372 // set gobject values
375 // user defined functions
378 public class Xcls_ftdbmodel : Object
380 public Gtk.ListStore el;
381 private Xcls_PopoverFileDetails _this;
387 public Xcls_ftdbmodel(Xcls_PopoverFileDetails _owner )
390 _this.ftdbmodel = this;
391 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
395 // set gobject values
398 // user defined functions
399 public void loadData (string cur) {
404 /// el.append(out iter);
407 // el.set_value(iter, 0, "");
408 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
413 el.set_value(iter, 0, "bjs");
414 el.set_value(iter, 1, "User Interface File (bjs)");
415 _this.filetype.el.set_active_iter(iter);
419 el.set_value(iter, 0, "vala");
420 el.set_value(iter, 1, "Vala");
422 _this.filetype.el.set_active_iter(iter);
429 el.set_value(iter, 0, "js");
430 el.set_value(iter, 1, "Javascript");
433 _this.filetype.el.set_active_iter(iter);
438 el.set_value(iter, 0, "css");
439 el.set_value(iter, 1, "CSS");
442 _this.filetype.el.set_active_iter(iter);
449 public class Xcls_Label9 : Object
452 private Xcls_PopoverFileDetails _this;
458 public Xcls_Label9(Xcls_PopoverFileDetails _owner )
461 this.el = new Gtk.Label( "Component Name" );
465 // set gobject values
466 this.el.justify = Gtk.Justification.RIGHT;
467 this.el.xalign = 0.900000f;
470 // user defined functions
473 public class Xcls_name : Object
476 private Xcls_PopoverFileDetails _this;
482 public Xcls_name(Xcls_PopoverFileDetails _owner )
486 this.el = new Gtk.Entry();
490 // set gobject values
491 this.el.visible = true;
494 // user defined functions
497 public class Xcls_Label11 : Object
500 private Xcls_PopoverFileDetails _this;
506 public Xcls_Label11(Xcls_PopoverFileDetails _owner )
509 this.el = new Gtk.Label( "Title" );
513 // set gobject values
514 this.el.justify = Gtk.Justification.RIGHT;
515 this.el.xalign = 0.900000f;
516 this.el.visible = true;
519 // user defined functions
522 public class Xcls_title : Object
525 private Xcls_PopoverFileDetails _this;
531 public Xcls_title(Xcls_PopoverFileDetails _owner )
535 this.el = new Gtk.Entry();
539 // set gobject values
540 this.el.visible = true;
543 // user defined functions
546 public class Xcls_Label13 : Object
549 private Xcls_PopoverFileDetails _this;
555 public Xcls_Label13(Xcls_PopoverFileDetails _owner )
558 this.el = new Gtk.Label( "Region" );
562 // set gobject values
563 this.el.justify = Gtk.Justification.RIGHT;
564 this.el.xalign = 0.900000f;
565 this.el.tooltip_text = "center, north, south, east, west";
566 this.el.visible = true;
569 // user defined functions
572 public class Xcls_region : Object
575 private Xcls_PopoverFileDetails _this;
581 public Xcls_region(Xcls_PopoverFileDetails _owner )
585 this.el = new Gtk.Entry();
589 // set gobject values
590 this.el.visible = true;
593 // user defined functions
596 public class Xcls_Label15 : Object
599 private Xcls_PopoverFileDetails _this;
605 public Xcls_Label15(Xcls_PopoverFileDetails _owner )
608 this.el = new Gtk.Label( "Parent Name" );
612 // set gobject values
613 this.el.justify = Gtk.Justification.RIGHT;
614 this.el.xalign = 0.900000f;
615 this.el.visible = true;
618 // user defined functions
621 public class Xcls_parent : Object
624 private Xcls_PopoverFileDetails _this;
630 public Xcls_parent(Xcls_PopoverFileDetails _owner )
634 this.el = new Gtk.Entry();
638 // set gobject values
639 this.el.visible = true;
642 // user defined functions
645 public class Xcls_Label17 : Object
648 private Xcls_PopoverFileDetails _this;
654 public Xcls_Label17(Xcls_PopoverFileDetails _owner )
657 this.el = new Gtk.Label( "Permission Name" );
661 // set gobject values
662 this.el.justify = Gtk.Justification.RIGHT;
663 this.el.xalign = 0.900000f;
664 this.el.visible = true;
667 // user defined functions
670 public class Xcls_permname : Object
673 private Xcls_PopoverFileDetails _this;
679 public Xcls_permname(Xcls_PopoverFileDetails _owner )
682 _this.permname = this;
683 this.el = new Gtk.Entry();
687 // set gobject values
688 this.el.visible = true;
691 // user defined functions
694 public class Xcls_Label19 : Object
697 private Xcls_PopoverFileDetails _this;
703 public Xcls_Label19(Xcls_PopoverFileDetails _owner )
706 this.el = new Gtk.Label( "Order (for tabs)" );
710 // set gobject values
711 this.el.justify = Gtk.Justification.RIGHT;
712 this.el.xalign = 0.900000f;
713 this.el.visible = true;
716 // user defined functions
719 public class Xcls_modOrder : Object
722 private Xcls_PopoverFileDetails _this;
728 public Xcls_modOrder(Xcls_PopoverFileDetails _owner )
731 _this.modOrder = this;
732 this.el = new Gtk.Entry();
736 // set gobject values
737 this.el.visible = true;
740 // user defined functions
743 public class Xcls_Label21 : Object
746 private Xcls_PopoverFileDetails _this;
752 public Xcls_Label21(Xcls_PopoverFileDetails _owner )
755 this.el = new Gtk.Label( "Module to build (Vala only)" );
759 // set gobject values
760 this.el.justify = Gtk.Justification.RIGHT;
761 this.el.xalign = 0.900000f;
762 this.el.visible = true;
765 // user defined functions
768 public class Xcls_build_module : Object
770 public Gtk.ComboBox el;
771 private Xcls_PopoverFileDetails _this;
777 public Xcls_build_module(Xcls_PopoverFileDetails _owner )
780 _this.build_module = this;
781 this.el = new Gtk.ComboBox();
785 // set gobject values
786 var child_0 = new Xcls_dbcellrenderer( _this );
788 this.el.pack_start ( child_0.el , true );
789 var child_1 = new Xcls_dbmodel( _this );
791 this.el.set_model ( child_1.el );
795 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
798 // user defined functions
800 public class Xcls_dbcellrenderer : Object
802 public Gtk.CellRendererText el;
803 private Xcls_PopoverFileDetails _this;
809 public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
812 _this.dbcellrenderer = this;
813 this.el = new Gtk.CellRendererText();
817 // set gobject values
820 // user defined functions
823 public class Xcls_dbmodel : Object
825 public Gtk.ListStore el;
826 private Xcls_PopoverFileDetails _this;
832 public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
835 _this.dbmodel = this;
836 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
840 // set gobject values
843 // user defined functions
844 public void loadData (Gee.ArrayList<string> data, string cur) {
849 /// el.append(out iter);
852 // el.set_value(iter, 0, "");
853 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
858 el.set_value(iter, 0, "");
859 el.set_value(iter, 1, "-- select a module --");
860 _this.build_module.el.set_active_iter(iter);
862 for (var i = 0; i < data.size;i++) {
867 el.set_value(iter, 0, data.get(i));
868 el.set_value(iter, 1, data.get(i));
870 if (data.get(i) == cur) {
871 _this.build_module.el.set_active_iter(iter);
875 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
882 public class Xcls_HButtonBox25 : Object
884 public Gtk.HButtonBox el;
885 private Xcls_PopoverFileDetails _this;
891 public Xcls_HButtonBox25(Xcls_PopoverFileDetails _owner )
894 this.el = new Gtk.HButtonBox();
898 // set gobject values
899 this.el.margin_right = 4;
900 this.el.margin_left = 4;
901 this.el.margin_bottom = 4;
902 var child_0 = new Xcls_Button26( _this );
904 this.el.add ( child_0.el );
905 var child_1 = new Xcls_save_btn( _this );
907 this.el.add ( child_1.el );
910 // user defined functions
912 public class Xcls_Button26 : Object
914 public Gtk.Button el;
915 private Xcls_PopoverFileDetails _this;
921 public Xcls_Button26(Xcls_PopoverFileDetails _owner )
924 this.el = new Gtk.Button();
928 // set gobject values
929 this.el.label = "Cancel";
932 this.el.clicked.connect( () => {
939 // user defined functions
942 public class Xcls_save_btn : Object
944 public Gtk.Button el;
945 private Xcls_PopoverFileDetails _this;
951 public Xcls_save_btn(Xcls_PopoverFileDetails _owner )
954 _this.save_btn = this;
955 this.el = new Gtk.Button();
959 // set gobject values
960 this.el.label = "Save";
963 this.el.clicked.connect( ( ) => {
968 if (_this.name.el.get_text().length < 1) {
969 StandardErrorDialog.show(
971 "You have to set Component name "
976 // what does this do?
978 var isNew = _this.file.name.length > 0 ? false : true;
980 if (!isNew && this.file.name != _this.name.el.get_text()) {
981 Xcls_StandardErrorDialog.singleton().show(
983 "Sorry changing names does not work yet. "
992 // FIXME - this may be more complicated...
993 //for (var i in this.def) {
994 // this.file[i] = this.get(i).el.get_text();
999 _this.updateFileFromEntry();
1000 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
1001 Xcls_StandardErrorDialog.singleton().show(
1002 _this.mainwindow.el,
1003 "The name you used already exists "
1014 var fn = _this.name.el.get_text();
1015 var dir = _this.project.firstPath();
1017 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
1018 Xcls_StandardErrorDialog.singleton().show(
1019 _this.mainwindow.el,
1020 "That file already exists"
1025 var f = JsRender.JsRender.factory(
1026 _this.file.project.xtype,
1028 dir + "/" + fn + ".bjs");
1034 _this.updateFileFromEntry();
1035 _this.file.loaded = true;
1037 _this.file.project.addFile(_this.file);
1046 _this.success(_this.project, _this.file);
1051 // user defined functions