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;
29 public Xcls_save_btn save_btn;
32 public signal void success (Project.Project pr, JsRender.JsRender file);
34 public Project.Project project;
35 public JsRender.JsRender file;
36 public Xcls_MainWindow mainwindow;
39 public Xcls_PopoverFileDetails()
42 this.el = new Gtk.Popover( null );
47 this.mainwindow = null;
50 this.el.border_width = 0;
52 this.el.position = Gtk.PositionType.RIGHT;
53 var child_0 = new Xcls_Box2( _this );
55 this.el.add ( child_0.el );
58 this.el.closed.connect( () => {
66 // user defined functions
67 public void updateFileFromEntry () {
69 _this.file.title = _this.title.el.get_text();
70 _this.file.region = _this.region.el.get_text();
71 _this.file.parent = _this.parent.el.get_text();
72 _this.file.permname = _this.permname.el.get_text();
73 _this.file.modOrder = _this.modOrder.el.get_text();
75 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
76 _this.file.renameTo(_this.name.el.get_text());
78 // store the module...
79 _this.file.build_module = "";
81 if (_this.build_module.el.get_active_iter (out iter)) {
83 this.dbmodel.el.get_value (iter, 0, out vfname);
84 if (((string)vfname).length > 0) {
85 _this.file.build_module = (string)vfname;
94 public void show (JsRender.JsRender c, Gtk.Widget btn)
96 this.project = c.project;
104 _this.name.el.set_text(c.name);
105 _this.title.el.set_text(c.title);
106 _this.parent.el.set_text(c.parent);
107 _this.region.el.set_text(c.region);
108 _this.modOrder.el.set_text(c.modOrder);
109 _this.permname.el.set_text(c.permname);
113 _this.ftdbmodel.loadData("bjs"); // fixme - need to determine type..
114 _this.filetype.el.hide();
115 _this.filetypelbl.el.hide();
118 if (c.path.length > 0) {
119 this.save_btn.el.set_label("Save");
121 this.save_btn.el.set_label("Create");
122 _this.filetype.el.show();
123 _this.filetypelbl.el.show();
126 var ar = new Gee.ArrayList<string>();
127 _this.dbmodel.loadData(ar,"");
128 // load the modules... if relivant..
129 if (this.project.xtype == "Gtk") {
130 var p = (Project.Gtk)c.project;
131 var cg = p.compilegroups;
133 var iter = cg.map_iterator();
135 var key = iter.get_key();
136 if (key == "_default_") {
141 _this.dbmodel.loadData(ar, c.build_module);
147 //console.log('show all');
148 this.el.set_modal(true);
149 this.el.set_relative_to(btn);
151 this.el.set_position(Gtk.PositionType.RIGHT);
154 print("SHOWALL - POPIP\n");
156 this.name.el.grab_focus();
158 //this.success = c.success;
162 public class Xcls_Box2 : Object
165 private Xcls_PopoverFileDetails _this;
171 public Xcls_Box2(Xcls_PopoverFileDetails _owner )
174 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
178 // set gobject values
179 this.el.homogeneous = false;
180 var child_0 = new Xcls_HeaderBar3( _this );
182 this.el.pack_start ( child_0.el , false,true,0 );
183 var child_1 = new Xcls_grid( _this );
185 this.el.pack_start ( child_1.el , false,false,4 );
186 var child_2 = new Xcls_HButtonBox25( _this );
188 this.el.pack_end ( child_2.el , false,true,0 );
191 // user defined functions
193 public class Xcls_HeaderBar3 : Object
195 public Gtk.HeaderBar el;
196 private Xcls_PopoverFileDetails _this;
202 public Xcls_HeaderBar3(Xcls_PopoverFileDetails _owner )
205 this.el = new Gtk.HeaderBar();
209 // set gobject values
210 this.el.title = "Add / Edit File";
213 // user defined functions
216 public class Xcls_grid : Object
219 private Xcls_PopoverFileDetails _this;
225 public Xcls_grid(Xcls_PopoverFileDetails _owner )
229 this.el = new Gtk.Grid();
233 // set gobject values
234 this.el.margin_right = 4;
235 this.el.margin_left = 4;
236 this.el.row_spacing = 2;
237 var child_0 = new Xcls_filetypelbl( _this );
239 this.el.attach ( child_0.el , 0,0,1,1 );
240 var child_1 = new Xcls_filetype( _this );
242 this.el.attach ( child_1.el , 1,0,1,1 );
243 var child_2 = new Xcls_Label9( _this );
245 this.el.attach ( child_2.el , 0,1,1,1 );
246 var child_3 = new Xcls_name( _this );
248 this.el.attach ( child_3.el , 1,1,1,1 );
249 var child_4 = new Xcls_Label11( _this );
251 this.el.attach ( child_4.el , 0,2,1,1 );
252 var child_5 = new Xcls_title( _this );
254 this.el.attach ( child_5.el , 1,2,1,1 );
255 var child_6 = new Xcls_Label13( _this );
257 this.el.attach ( child_6.el , 0,3,1,1 );
258 var child_7 = new Xcls_region( _this );
260 this.el.attach ( child_7.el , 1,3,1,1 );
261 var child_8 = new Xcls_Label15( _this );
263 this.el.attach ( child_8.el , 0,4,1,1 );
264 var child_9 = new Xcls_parent( _this );
266 this.el.attach ( child_9.el , 1,4,1,1 );
267 var child_10 = new Xcls_Label17( _this );
269 this.el.attach ( child_10.el , 0,5,1,1 );
270 var child_11 = new Xcls_permname( _this );
272 this.el.attach ( child_11.el , 1,5,1,1 );
273 var child_12 = new Xcls_Label19( _this );
275 this.el.attach ( child_12.el , 0,6,1,1 );
276 var child_13 = new Xcls_modOrder( _this );
278 this.el.attach ( child_13.el , 1,6,1,1 );
279 var child_14 = new Xcls_Label21( _this );
281 this.el.attach ( child_14.el , 0,7,1,1 );
282 var child_15 = new Xcls_build_module( _this );
284 this.el.attach ( child_15.el , 1,7,1,1 );
287 // user defined functions
289 public class Xcls_filetypelbl : Object
292 private Xcls_PopoverFileDetails _this;
298 public Xcls_filetypelbl(Xcls_PopoverFileDetails _owner )
301 _this.filetypelbl = this;
302 this.el = new Gtk.Label( "File type" );
306 // set gobject values
307 this.el.justify = Gtk.Justification.RIGHT;
308 this.el.xalign = 0.900000f;
311 // user defined functions
314 public class Xcls_filetype : Object
316 public Gtk.ComboBox el;
317 private Xcls_PopoverFileDetails _this;
323 public Xcls_filetype(Xcls_PopoverFileDetails _owner )
326 _this.filetype = this;
327 this.el = new Gtk.ComboBox();
331 // set gobject values
332 var child_0 = new Xcls_ftdbcellrenderer( _this );
334 this.el.pack_start ( child_0.el , true );
335 var child_1 = new Xcls_ftdbmodel( _this );
337 this.el.set_model ( child_1.el );
341 this.el.add_attribute(_this.ftdbcellrenderer.el , "markup", 1 );
344 this.el.changed.connect( () => {
347 if (this.el.get_active_iter(out iter)) {
349 _this.ftdbmodel.el.get_value (iter, 0, out vfname);
350 is_bjs = ((string)vfname) == "BJS";
353 for (var i = 2; i < 8;i++) {
354 var el = _this.grid.el.get_child_at(0,i);
360 var el = _this.grid.el.get_child_at(1,i);
374 // user defined functions
376 public class Xcls_ftdbcellrenderer : Object
378 public Gtk.CellRendererText el;
379 private Xcls_PopoverFileDetails _this;
385 public Xcls_ftdbcellrenderer(Xcls_PopoverFileDetails _owner )
388 _this.ftdbcellrenderer = this;
389 this.el = new Gtk.CellRendererText();
393 // set gobject values
396 // user defined functions
399 public class Xcls_ftdbmodel : Object
401 public Gtk.ListStore el;
402 private Xcls_PopoverFileDetails _this;
408 public Xcls_ftdbmodel(Xcls_PopoverFileDetails _owner )
411 _this.ftdbmodel = this;
412 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
416 // set gobject values
419 // user defined functions
420 public void loadData (string cur) {
425 /// el.append(out iter);
428 // el.set_value(iter, 0, "");
429 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
434 el.set_value(iter, 0, "bjs");
435 el.set_value(iter, 1, "User Interface File (bjs)");
436 _this.filetype.el.set_active_iter(iter);
440 el.set_value(iter, 0, "vala");
441 el.set_value(iter, 1, "Vala");
443 _this.filetype.el.set_active_iter(iter);
450 el.set_value(iter, 0, "js");
451 el.set_value(iter, 1, "Javascript");
454 _this.filetype.el.set_active_iter(iter);
459 el.set_value(iter, 0, "css");
460 el.set_value(iter, 1, "CSS");
463 _this.filetype.el.set_active_iter(iter);
470 public class Xcls_Label9 : Object
473 private Xcls_PopoverFileDetails _this;
479 public Xcls_Label9(Xcls_PopoverFileDetails _owner )
482 this.el = new Gtk.Label( "Component Name" );
486 // set gobject values
487 this.el.justify = Gtk.Justification.RIGHT;
488 this.el.xalign = 0.900000f;
491 // user defined functions
494 public class Xcls_name : Object
497 private Xcls_PopoverFileDetails _this;
503 public Xcls_name(Xcls_PopoverFileDetails _owner )
507 this.el = new Gtk.Entry();
511 // set gobject values
512 this.el.visible = true;
515 // user defined functions
518 public class Xcls_Label11 : Object
521 private Xcls_PopoverFileDetails _this;
527 public Xcls_Label11(Xcls_PopoverFileDetails _owner )
530 this.el = new Gtk.Label( "Title" );
534 // set gobject values
535 this.el.justify = Gtk.Justification.RIGHT;
536 this.el.xalign = 0.900000f;
537 this.el.visible = true;
540 // user defined functions
543 public class Xcls_title : Object
546 private Xcls_PopoverFileDetails _this;
552 public Xcls_title(Xcls_PopoverFileDetails _owner )
556 this.el = new Gtk.Entry();
560 // set gobject values
561 this.el.visible = true;
564 // user defined functions
567 public class Xcls_Label13 : Object
570 private Xcls_PopoverFileDetails _this;
576 public Xcls_Label13(Xcls_PopoverFileDetails _owner )
579 this.el = new Gtk.Label( "Region" );
583 // set gobject values
584 this.el.justify = Gtk.Justification.RIGHT;
585 this.el.xalign = 0.900000f;
586 this.el.tooltip_text = "center, north, south, east, west";
587 this.el.visible = true;
590 // user defined functions
593 public class Xcls_region : Object
596 private Xcls_PopoverFileDetails _this;
602 public Xcls_region(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_Label15 : Object
620 private Xcls_PopoverFileDetails _this;
626 public Xcls_Label15(Xcls_PopoverFileDetails _owner )
629 this.el = new Gtk.Label( "Parent Name" );
633 // set gobject values
634 this.el.justify = Gtk.Justification.RIGHT;
635 this.el.xalign = 0.900000f;
636 this.el.visible = true;
639 // user defined functions
642 public class Xcls_parent : Object
645 private Xcls_PopoverFileDetails _this;
651 public Xcls_parent(Xcls_PopoverFileDetails _owner )
655 this.el = new Gtk.Entry();
659 // set gobject values
660 this.el.visible = true;
663 // user defined functions
666 public class Xcls_Label17 : Object
669 private Xcls_PopoverFileDetails _this;
675 public Xcls_Label17(Xcls_PopoverFileDetails _owner )
678 this.el = new Gtk.Label( "Permission Name" );
682 // set gobject values
683 this.el.justify = Gtk.Justification.RIGHT;
684 this.el.xalign = 0.900000f;
685 this.el.visible = true;
688 // user defined functions
691 public class Xcls_permname : Object
694 private Xcls_PopoverFileDetails _this;
700 public Xcls_permname(Xcls_PopoverFileDetails _owner )
703 _this.permname = this;
704 this.el = new Gtk.Entry();
708 // set gobject values
709 this.el.visible = true;
712 // user defined functions
715 public class Xcls_Label19 : Object
718 private Xcls_PopoverFileDetails _this;
724 public Xcls_Label19(Xcls_PopoverFileDetails _owner )
727 this.el = new Gtk.Label( "Order (for tabs)" );
731 // set gobject values
732 this.el.justify = Gtk.Justification.RIGHT;
733 this.el.xalign = 0.900000f;
734 this.el.visible = true;
737 // user defined functions
740 public class Xcls_modOrder : Object
743 private Xcls_PopoverFileDetails _this;
749 public Xcls_modOrder(Xcls_PopoverFileDetails _owner )
752 _this.modOrder = this;
753 this.el = new Gtk.Entry();
757 // set gobject values
758 this.el.visible = true;
761 // user defined functions
764 public class Xcls_Label21 : Object
767 private Xcls_PopoverFileDetails _this;
773 public Xcls_Label21(Xcls_PopoverFileDetails _owner )
776 this.el = new Gtk.Label( "Module to build (Vala only)" );
780 // set gobject values
781 this.el.justify = Gtk.Justification.RIGHT;
782 this.el.xalign = 0.900000f;
783 this.el.visible = true;
786 // user defined functions
789 public class Xcls_build_module : Object
791 public Gtk.ComboBox el;
792 private Xcls_PopoverFileDetails _this;
798 public Xcls_build_module(Xcls_PopoverFileDetails _owner )
801 _this.build_module = this;
802 this.el = new Gtk.ComboBox();
806 // set gobject values
807 var child_0 = new Xcls_dbcellrenderer( _this );
809 this.el.pack_start ( child_0.el , true );
810 var child_1 = new Xcls_dbmodel( _this );
812 this.el.set_model ( child_1.el );
816 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
819 // user defined functions
821 public class Xcls_dbcellrenderer : Object
823 public Gtk.CellRendererText el;
824 private Xcls_PopoverFileDetails _this;
830 public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
833 _this.dbcellrenderer = this;
834 this.el = new Gtk.CellRendererText();
838 // set gobject values
841 // user defined functions
844 public class Xcls_dbmodel : Object
846 public Gtk.ListStore el;
847 private Xcls_PopoverFileDetails _this;
853 public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
856 _this.dbmodel = this;
857 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
861 // set gobject values
864 // user defined functions
865 public void loadData (Gee.ArrayList<string> data, string cur) {
870 /// el.append(out iter);
873 // el.set_value(iter, 0, "");
874 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
879 el.set_value(iter, 0, "");
880 el.set_value(iter, 1, "-- select a module --");
881 _this.build_module.el.set_active_iter(iter);
883 for (var i = 0; i < data.size;i++) {
888 el.set_value(iter, 0, data.get(i));
889 el.set_value(iter, 1, data.get(i));
891 if (data.get(i) == cur) {
892 _this.build_module.el.set_active_iter(iter);
896 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
903 public class Xcls_HButtonBox25 : Object
905 public Gtk.HButtonBox el;
906 private Xcls_PopoverFileDetails _this;
912 public Xcls_HButtonBox25(Xcls_PopoverFileDetails _owner )
915 this.el = new Gtk.HButtonBox();
919 // set gobject values
920 this.el.margin_right = 4;
921 this.el.margin_left = 4;
922 this.el.margin_bottom = 4;
923 var child_0 = new Xcls_Button26( _this );
925 this.el.add ( child_0.el );
926 var child_1 = new Xcls_save_btn( _this );
928 this.el.add ( child_1.el );
931 // user defined functions
933 public class Xcls_Button26 : Object
935 public Gtk.Button el;
936 private Xcls_PopoverFileDetails _this;
942 public Xcls_Button26(Xcls_PopoverFileDetails _owner )
945 this.el = new Gtk.Button();
949 // set gobject values
950 this.el.label = "Cancel";
953 this.el.clicked.connect( () => {
960 // user defined functions
963 public class Xcls_save_btn : Object
965 public Gtk.Button el;
966 private Xcls_PopoverFileDetails _this;
972 public Xcls_save_btn(Xcls_PopoverFileDetails _owner )
975 _this.save_btn = this;
976 this.el = new Gtk.Button();
980 // set gobject values
981 this.el.label = "Save";
984 this.el.clicked.connect( ( ) => {
989 if (_this.name.el.get_text().length < 1) {
990 StandardErrorDialog.show(
992 "You have to set Component name "
997 // what does this do?
999 var isNew = _this.file.name.length > 0 ? false : true;
1001 if (!isNew && this.file.name != _this.name.el.get_text()) {
1002 Xcls_StandardErrorDialog.singleton().show(
1004 "Sorry changing names does not work yet. "
1013 // FIXME - this may be more complicated...
1014 //for (var i in this.def) {
1015 // this.file[i] = this.get(i).el.get_text();
1020 _this.updateFileFromEntry();
1021 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
1022 Xcls_StandardErrorDialog.singleton().show(
1023 _this.mainwindow.el,
1024 "The name you used already exists "
1035 var fn = _this.name.el.get_text();
1036 var dir = _this.project.firstPath();
1038 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
1039 Xcls_StandardErrorDialog.singleton().show(
1040 _this.mainwindow.el,
1041 "That file already exists"
1046 var f = JsRender.JsRender.factory(
1047 _this.file.project.xtype,
1049 dir + "/" + fn + ".bjs");
1055 _this.updateFileFromEntry();
1056 _this.file.loaded = true;
1058 _this.file.project.addFile(_this.file);
1067 _this.success(_this.project, _this.file);
1072 // user defined functions