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( () => {
345 if (this.el.get_active_iter(out iter)) {
347 _this.ftdbmodel.el.get_value (iter, 0, out vfname);
348 is_bjs = ((string)vfname) == "BJS";
351 for (var i = 2; i < 8;i++) {
352 var el = this.el.get_child_at(0,i);
358 var el = this.el.get_child_at(1,i);
372 // user defined functions
374 public class Xcls_ftdbcellrenderer : Object
376 public Gtk.CellRendererText el;
377 private Xcls_PopoverFileDetails _this;
383 public Xcls_ftdbcellrenderer(Xcls_PopoverFileDetails _owner )
386 _this.ftdbcellrenderer = this;
387 this.el = new Gtk.CellRendererText();
391 // set gobject values
394 // user defined functions
397 public class Xcls_ftdbmodel : Object
399 public Gtk.ListStore el;
400 private Xcls_PopoverFileDetails _this;
406 public Xcls_ftdbmodel(Xcls_PopoverFileDetails _owner )
409 _this.ftdbmodel = this;
410 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
414 // set gobject values
417 // user defined functions
418 public void loadData (string cur) {
423 /// el.append(out iter);
426 // el.set_value(iter, 0, "");
427 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
432 el.set_value(iter, 0, "bjs");
433 el.set_value(iter, 1, "User Interface File (bjs)");
434 _this.filetype.el.set_active_iter(iter);
438 el.set_value(iter, 0, "vala");
439 el.set_value(iter, 1, "Vala");
441 _this.filetype.el.set_active_iter(iter);
448 el.set_value(iter, 0, "js");
449 el.set_value(iter, 1, "Javascript");
452 _this.filetype.el.set_active_iter(iter);
457 el.set_value(iter, 0, "css");
458 el.set_value(iter, 1, "CSS");
461 _this.filetype.el.set_active_iter(iter);
468 public class Xcls_Label9 : Object
471 private Xcls_PopoverFileDetails _this;
477 public Xcls_Label9(Xcls_PopoverFileDetails _owner )
480 this.el = new Gtk.Label( "Component Name" );
484 // set gobject values
485 this.el.justify = Gtk.Justification.RIGHT;
486 this.el.xalign = 0.900000f;
489 // user defined functions
492 public class Xcls_name : Object
495 private Xcls_PopoverFileDetails _this;
501 public Xcls_name(Xcls_PopoverFileDetails _owner )
505 this.el = new Gtk.Entry();
509 // set gobject values
510 this.el.visible = true;
513 // user defined functions
516 public class Xcls_Label11 : Object
519 private Xcls_PopoverFileDetails _this;
525 public Xcls_Label11(Xcls_PopoverFileDetails _owner )
528 this.el = new Gtk.Label( "Title" );
532 // set gobject values
533 this.el.justify = Gtk.Justification.RIGHT;
534 this.el.xalign = 0.900000f;
535 this.el.visible = true;
538 // user defined functions
541 public class Xcls_title : Object
544 private Xcls_PopoverFileDetails _this;
550 public Xcls_title(Xcls_PopoverFileDetails _owner )
554 this.el = new Gtk.Entry();
558 // set gobject values
559 this.el.visible = true;
562 // user defined functions
565 public class Xcls_Label13 : Object
568 private Xcls_PopoverFileDetails _this;
574 public Xcls_Label13(Xcls_PopoverFileDetails _owner )
577 this.el = new Gtk.Label( "Region" );
581 // set gobject values
582 this.el.justify = Gtk.Justification.RIGHT;
583 this.el.xalign = 0.900000f;
584 this.el.tooltip_text = "center, north, south, east, west";
585 this.el.visible = true;
588 // user defined functions
591 public class Xcls_region : Object
594 private Xcls_PopoverFileDetails _this;
600 public Xcls_region(Xcls_PopoverFileDetails _owner )
604 this.el = new Gtk.Entry();
608 // set gobject values
609 this.el.visible = true;
612 // user defined functions
615 public class Xcls_Label15 : Object
618 private Xcls_PopoverFileDetails _this;
624 public Xcls_Label15(Xcls_PopoverFileDetails _owner )
627 this.el = new Gtk.Label( "Parent Name" );
631 // set gobject values
632 this.el.justify = Gtk.Justification.RIGHT;
633 this.el.xalign = 0.900000f;
634 this.el.visible = true;
637 // user defined functions
640 public class Xcls_parent : Object
643 private Xcls_PopoverFileDetails _this;
649 public Xcls_parent(Xcls_PopoverFileDetails _owner )
653 this.el = new Gtk.Entry();
657 // set gobject values
658 this.el.visible = true;
661 // user defined functions
664 public class Xcls_Label17 : Object
667 private Xcls_PopoverFileDetails _this;
673 public Xcls_Label17(Xcls_PopoverFileDetails _owner )
676 this.el = new Gtk.Label( "Permission Name" );
680 // set gobject values
681 this.el.justify = Gtk.Justification.RIGHT;
682 this.el.xalign = 0.900000f;
683 this.el.visible = true;
686 // user defined functions
689 public class Xcls_permname : Object
692 private Xcls_PopoverFileDetails _this;
698 public Xcls_permname(Xcls_PopoverFileDetails _owner )
701 _this.permname = this;
702 this.el = new Gtk.Entry();
706 // set gobject values
707 this.el.visible = true;
710 // user defined functions
713 public class Xcls_Label19 : Object
716 private Xcls_PopoverFileDetails _this;
722 public Xcls_Label19(Xcls_PopoverFileDetails _owner )
725 this.el = new Gtk.Label( "Order (for tabs)" );
729 // set gobject values
730 this.el.justify = Gtk.Justification.RIGHT;
731 this.el.xalign = 0.900000f;
732 this.el.visible = true;
735 // user defined functions
738 public class Xcls_modOrder : Object
741 private Xcls_PopoverFileDetails _this;
747 public Xcls_modOrder(Xcls_PopoverFileDetails _owner )
750 _this.modOrder = this;
751 this.el = new Gtk.Entry();
755 // set gobject values
756 this.el.visible = true;
759 // user defined functions
762 public class Xcls_Label21 : Object
765 private Xcls_PopoverFileDetails _this;
771 public Xcls_Label21(Xcls_PopoverFileDetails _owner )
774 this.el = new Gtk.Label( "Module to build (Vala only)" );
778 // set gobject values
779 this.el.justify = Gtk.Justification.RIGHT;
780 this.el.xalign = 0.900000f;
781 this.el.visible = true;
784 // user defined functions
787 public class Xcls_build_module : Object
789 public Gtk.ComboBox el;
790 private Xcls_PopoverFileDetails _this;
796 public Xcls_build_module(Xcls_PopoverFileDetails _owner )
799 _this.build_module = this;
800 this.el = new Gtk.ComboBox();
804 // set gobject values
805 var child_0 = new Xcls_dbcellrenderer( _this );
807 this.el.pack_start ( child_0.el , true );
808 var child_1 = new Xcls_dbmodel( _this );
810 this.el.set_model ( child_1.el );
814 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
817 // user defined functions
819 public class Xcls_dbcellrenderer : Object
821 public Gtk.CellRendererText el;
822 private Xcls_PopoverFileDetails _this;
828 public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
831 _this.dbcellrenderer = this;
832 this.el = new Gtk.CellRendererText();
836 // set gobject values
839 // user defined functions
842 public class Xcls_dbmodel : Object
844 public Gtk.ListStore el;
845 private Xcls_PopoverFileDetails _this;
851 public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
854 _this.dbmodel = this;
855 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
859 // set gobject values
862 // user defined functions
863 public void loadData (Gee.ArrayList<string> data, string cur) {
868 /// el.append(out iter);
871 // el.set_value(iter, 0, "");
872 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
877 el.set_value(iter, 0, "");
878 el.set_value(iter, 1, "-- select a module --");
879 _this.build_module.el.set_active_iter(iter);
881 for (var i = 0; i < data.size;i++) {
886 el.set_value(iter, 0, data.get(i));
887 el.set_value(iter, 1, data.get(i));
889 if (data.get(i) == cur) {
890 _this.build_module.el.set_active_iter(iter);
894 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
901 public class Xcls_HButtonBox25 : Object
903 public Gtk.HButtonBox el;
904 private Xcls_PopoverFileDetails _this;
910 public Xcls_HButtonBox25(Xcls_PopoverFileDetails _owner )
913 this.el = new Gtk.HButtonBox();
917 // set gobject values
918 this.el.margin_right = 4;
919 this.el.margin_left = 4;
920 this.el.margin_bottom = 4;
921 var child_0 = new Xcls_Button26( _this );
923 this.el.add ( child_0.el );
924 var child_1 = new Xcls_save_btn( _this );
926 this.el.add ( child_1.el );
929 // user defined functions
931 public class Xcls_Button26 : Object
933 public Gtk.Button el;
934 private Xcls_PopoverFileDetails _this;
940 public Xcls_Button26(Xcls_PopoverFileDetails _owner )
943 this.el = new Gtk.Button();
947 // set gobject values
948 this.el.label = "Cancel";
951 this.el.clicked.connect( () => {
958 // user defined functions
961 public class Xcls_save_btn : Object
963 public Gtk.Button el;
964 private Xcls_PopoverFileDetails _this;
970 public Xcls_save_btn(Xcls_PopoverFileDetails _owner )
973 _this.save_btn = this;
974 this.el = new Gtk.Button();
978 // set gobject values
979 this.el.label = "Save";
982 this.el.clicked.connect( ( ) => {
987 if (_this.name.el.get_text().length < 1) {
988 StandardErrorDialog.show(
990 "You have to set Component name "
995 // what does this do?
997 var isNew = _this.file.name.length > 0 ? false : true;
999 if (!isNew && this.file.name != _this.name.el.get_text()) {
1000 Xcls_StandardErrorDialog.singleton().show(
1002 "Sorry changing names does not work yet. "
1011 // FIXME - this may be more complicated...
1012 //for (var i in this.def) {
1013 // this.file[i] = this.get(i).el.get_text();
1018 _this.updateFileFromEntry();
1019 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
1020 Xcls_StandardErrorDialog.singleton().show(
1021 _this.mainwindow.el,
1022 "The name you used already exists "
1033 var fn = _this.name.el.get_text();
1034 var dir = _this.project.firstPath();
1036 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
1037 Xcls_StandardErrorDialog.singleton().show(
1038 _this.mainwindow.el,
1039 "That file already exists"
1044 var f = JsRender.JsRender.factory(
1045 _this.file.project.xtype,
1047 dir + "/" + fn + ".bjs");
1053 _this.updateFileFromEntry();
1054 _this.file.loaded = true;
1056 _this.file.project.addFile(_this.file);
1065 _this.success(_this.project, _this.file);
1070 // user defined functions