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,0,1,1 );
271 var child_12 = new Xcls_Label19( _this );
273 this.el.attach ( child_12.el , 0,0,1,1 );
274 var child_13 = new Xcls_modOrder( _this );
276 this.el.attach ( child_13.el , 1,0,1,1 );
277 var child_14 = new Xcls_Label21( _this );
279 this.el.attach ( child_14.el , 0,0,1,1 );
280 var child_15 = new Xcls_build_module( _this );
282 this.el.attach ( child_15.el , 1,0,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 // user defined functions
344 public class Xcls_ftdbcellrenderer : Object
346 public Gtk.CellRendererText el;
347 private Xcls_PopoverFileDetails _this;
353 public Xcls_ftdbcellrenderer(Xcls_PopoverFileDetails _owner )
356 _this.ftdbcellrenderer = this;
357 this.el = new Gtk.CellRendererText();
361 // set gobject values
364 // user defined functions
367 public class Xcls_ftdbmodel : Object
369 public Gtk.ListStore el;
370 private Xcls_PopoverFileDetails _this;
376 public Xcls_ftdbmodel(Xcls_PopoverFileDetails _owner )
379 _this.ftdbmodel = this;
380 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
384 // set gobject values
387 // user defined functions
388 public void loadData (string cur) {
393 /// el.append(out iter);
396 // el.set_value(iter, 0, "");
397 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
402 el.set_value(iter, 0, "bjs");
403 el.set_value(iter, 1, "User Interface File (bjs)");
404 _this.filetype.el.set_active_iter(iter);
408 el.set_value(iter, 0, "vala");
409 el.set_value(iter, 1, "Vala");
411 _this.filetype.el.set_active_iter(iter);
418 el.set_value(iter, 0, "js");
419 el.set_value(iter, 1, "Javascript");
422 _this.filetype.el.set_active_iter(iter);
427 el.set_value(iter, 0, "css");
428 el.set_value(iter, 1, "CSS");
431 _this.filetype.el.set_active_iter(iter);
438 public class Xcls_Label9 : Object
441 private Xcls_PopoverFileDetails _this;
447 public Xcls_Label9(Xcls_PopoverFileDetails _owner )
450 this.el = new Gtk.Label( "Component Name" );
454 // set gobject values
455 this.el.justify = Gtk.Justification.RIGHT;
456 this.el.xalign = 0.900000f;
459 // user defined functions
462 public class Xcls_name : Object
465 private Xcls_PopoverFileDetails _this;
471 public Xcls_name(Xcls_PopoverFileDetails _owner )
475 this.el = new Gtk.Entry();
479 // set gobject values
480 this.el.visible = true;
483 // user defined functions
486 public class Xcls_Label11 : Object
489 private Xcls_PopoverFileDetails _this;
495 public Xcls_Label11(Xcls_PopoverFileDetails _owner )
498 this.el = new Gtk.Label( "Title" );
502 // set gobject values
503 this.el.justify = Gtk.Justification.RIGHT;
504 this.el.xalign = 0.900000f;
505 this.el.visible = true;
508 // user defined functions
511 public class Xcls_title : Object
514 private Xcls_PopoverFileDetails _this;
520 public Xcls_title(Xcls_PopoverFileDetails _owner )
524 this.el = new Gtk.Entry();
528 // set gobject values
529 this.el.visible = true;
532 // user defined functions
535 public class Xcls_Label13 : Object
538 private Xcls_PopoverFileDetails _this;
544 public Xcls_Label13(Xcls_PopoverFileDetails _owner )
547 this.el = new Gtk.Label( "Region" );
551 // set gobject values
552 this.el.justify = Gtk.Justification.RIGHT;
553 this.el.xalign = 0.900000f;
554 this.el.tooltip_text = "center, north, south, east, west";
555 this.el.visible = true;
558 // user defined functions
561 public class Xcls_region : Object
564 private Xcls_PopoverFileDetails _this;
570 public Xcls_region(Xcls_PopoverFileDetails _owner )
574 this.el = new Gtk.Entry();
578 // set gobject values
579 this.el.visible = true;
582 // user defined functions
585 public class Xcls_Label15 : Object
588 private Xcls_PopoverFileDetails _this;
594 public Xcls_Label15(Xcls_PopoverFileDetails _owner )
597 this.el = new Gtk.Label( "Parent Name" );
601 // set gobject values
602 this.el.justify = Gtk.Justification.RIGHT;
603 this.el.xalign = 0.900000f;
604 this.el.visible = true;
607 // user defined functions
610 public class Xcls_parent : Object
613 private Xcls_PopoverFileDetails _this;
619 public Xcls_parent(Xcls_PopoverFileDetails _owner )
623 this.el = new Gtk.Entry();
627 // set gobject values
628 this.el.visible = true;
631 // user defined functions
634 public class Xcls_Label17 : Object
637 private Xcls_PopoverFileDetails _this;
643 public Xcls_Label17(Xcls_PopoverFileDetails _owner )
646 this.el = new Gtk.Label( "Permission Name" );
650 // set gobject values
651 this.el.justify = Gtk.Justification.RIGHT;
652 this.el.xalign = 0.900000f;
653 this.el.visible = true;
656 // user defined functions
659 public class Xcls_permname : Object
662 private Xcls_PopoverFileDetails _this;
668 public Xcls_permname(Xcls_PopoverFileDetails _owner )
671 _this.permname = this;
672 this.el = new Gtk.Entry();
676 // set gobject values
677 this.el.visible = true;
680 // user defined functions
683 public class Xcls_Label19 : Object
686 private Xcls_PopoverFileDetails _this;
692 public Xcls_Label19(Xcls_PopoverFileDetails _owner )
695 this.el = new Gtk.Label( "Order (for tabs)" );
699 // set gobject values
700 this.el.justify = Gtk.Justification.RIGHT;
701 this.el.xalign = 0.900000f;
702 this.el.visible = true;
705 // user defined functions
708 public class Xcls_modOrder : Object
711 private Xcls_PopoverFileDetails _this;
717 public Xcls_modOrder(Xcls_PopoverFileDetails _owner )
720 _this.modOrder = this;
721 this.el = new Gtk.Entry();
725 // set gobject values
726 this.el.visible = true;
729 // user defined functions
732 public class Xcls_Label21 : Object
735 private Xcls_PopoverFileDetails _this;
741 public Xcls_Label21(Xcls_PopoverFileDetails _owner )
744 this.el = new Gtk.Label( "Module to build (Vala only)" );
748 // set gobject values
749 this.el.justify = Gtk.Justification.RIGHT;
750 this.el.xalign = 0.900000f;
751 this.el.visible = true;
754 // user defined functions
757 public class Xcls_build_module : Object
759 public Gtk.ComboBox el;
760 private Xcls_PopoverFileDetails _this;
766 public Xcls_build_module(Xcls_PopoverFileDetails _owner )
769 _this.build_module = this;
770 this.el = new Gtk.ComboBox();
774 // set gobject values
775 var child_0 = new Xcls_dbcellrenderer( _this );
777 this.el.pack_start ( child_0.el , true );
778 var child_1 = new Xcls_dbmodel( _this );
780 this.el.set_model ( child_1.el );
784 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
787 // user defined functions
789 public class Xcls_dbcellrenderer : Object
791 public Gtk.CellRendererText el;
792 private Xcls_PopoverFileDetails _this;
798 public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
801 _this.dbcellrenderer = this;
802 this.el = new Gtk.CellRendererText();
806 // set gobject values
809 // user defined functions
812 public class Xcls_dbmodel : Object
814 public Gtk.ListStore el;
815 private Xcls_PopoverFileDetails _this;
821 public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
824 _this.dbmodel = this;
825 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
829 // set gobject values
832 // user defined functions
833 public void loadData (Gee.ArrayList<string> data, string cur) {
838 /// el.append(out iter);
841 // el.set_value(iter, 0, "");
842 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
847 el.set_value(iter, 0, "");
848 el.set_value(iter, 1, "-- select a module --");
849 _this.build_module.el.set_active_iter(iter);
851 for (var i = 0; i < data.size;i++) {
856 el.set_value(iter, 0, data.get(i));
857 el.set_value(iter, 1, data.get(i));
859 if (data.get(i) == cur) {
860 _this.build_module.el.set_active_iter(iter);
864 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
871 public class Xcls_HButtonBox25 : Object
873 public Gtk.HButtonBox el;
874 private Xcls_PopoverFileDetails _this;
880 public Xcls_HButtonBox25(Xcls_PopoverFileDetails _owner )
883 this.el = new Gtk.HButtonBox();
887 // set gobject values
888 this.el.margin_right = 4;
889 this.el.margin_left = 4;
890 this.el.margin_bottom = 4;
891 var child_0 = new Xcls_Button26( _this );
893 this.el.add ( child_0.el );
894 var child_1 = new Xcls_save_btn( _this );
896 this.el.add ( child_1.el );
899 // user defined functions
901 public class Xcls_Button26 : Object
903 public Gtk.Button el;
904 private Xcls_PopoverFileDetails _this;
910 public Xcls_Button26(Xcls_PopoverFileDetails _owner )
913 this.el = new Gtk.Button();
917 // set gobject values
918 this.el.label = "Cancel";
921 this.el.clicked.connect( () => {
928 // user defined functions
931 public class Xcls_save_btn : Object
933 public Gtk.Button el;
934 private Xcls_PopoverFileDetails _this;
940 public Xcls_save_btn(Xcls_PopoverFileDetails _owner )
943 _this.save_btn = this;
944 this.el = new Gtk.Button();
948 // set gobject values
949 this.el.label = "Save";
952 this.el.clicked.connect( ( ) => {
957 if (_this.name.el.get_text().length < 1) {
958 StandardErrorDialog.show(
960 "You have to set Component name "
965 // what does this do?
967 var isNew = _this.file.name.length > 0 ? false : true;
969 if (!isNew && this.file.name != _this.name.el.get_text()) {
970 Xcls_StandardErrorDialog.singleton().show(
972 "Sorry changing names does not work yet. "
981 // FIXME - this may be more complicated...
982 //for (var i in this.def) {
983 // this.file[i] = this.get(i).el.get_text();
988 _this.updateFileFromEntry();
989 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
990 Xcls_StandardErrorDialog.singleton().show(
992 "The name you used already exists "
1003 var fn = _this.name.el.get_text();
1004 var dir = _this.project.firstPath();
1006 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
1007 Xcls_StandardErrorDialog.singleton().show(
1008 _this.mainwindow.el,
1009 "That file already exists"
1014 var f = JsRender.JsRender.factory(
1015 _this.file.project.xtype,
1017 dir + "/" + fn + ".bjs");
1023 _this.updateFileFromEntry();
1024 _this.file.loaded = true;
1026 _this.file.project.addFile(_this.file);
1035 _this.success(_this.project, _this.file);
1040 // user defined functions