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);
117 if (c.path.length > 0) {
118 _this.filetype.el.hide();
119 _this.filetypelbl.el.hide();
120 this.save_btn.el.set_label("Save");
122 this.save_btn.el.set_label("Create");
123 _this.ftdbmodel.loadData("bjs"); // fixme - need to determine type..
124 _this.filetype.el.show();
125 _this.filetypelbl.el.show();
128 var ar = new Gee.ArrayList<string>();
129 _this.dbmodel.loadData(ar,"");
130 // load the modules... if relivant..
131 if (this.project.xtype == "Gtk") {
132 var p = (Project.Gtk)c.project;
133 var cg = p.compilegroups;
135 var iter = cg.map_iterator();
137 var key = iter.get_key();
138 if (key == "_default_") {
143 _this.dbmodel.loadData(ar, c.build_module);
149 //console.log('show all');
150 this.el.set_modal(true);
151 this.el.set_relative_to(btn);
153 this.el.set_position(Gtk.PositionType.RIGHT);
156 print("SHOWALL - POPIP\n");
158 this.name.el.grab_focus();
160 //this.success = c.success;
164 public class Xcls_Box2 : Object
167 private Xcls_PopoverFileDetails _this;
173 public Xcls_Box2(Xcls_PopoverFileDetails _owner )
176 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
180 // set gobject values
181 this.el.homogeneous = false;
182 var child_0 = new Xcls_HeaderBar3( _this );
184 this.el.pack_start ( child_0.el , false,true,0 );
185 var child_1 = new Xcls_grid( _this );
187 this.el.pack_start ( child_1.el , false,false,4 );
188 var child_2 = new Xcls_HButtonBox25( _this );
190 this.el.pack_end ( child_2.el , false,true,0 );
193 // user defined functions
195 public class Xcls_HeaderBar3 : Object
197 public Gtk.HeaderBar el;
198 private Xcls_PopoverFileDetails _this;
204 public Xcls_HeaderBar3(Xcls_PopoverFileDetails _owner )
207 this.el = new Gtk.HeaderBar();
211 // set gobject values
212 this.el.title = "Add / Edit File";
215 // user defined functions
218 public class Xcls_grid : Object
221 private Xcls_PopoverFileDetails _this;
227 public Xcls_grid(Xcls_PopoverFileDetails _owner )
231 this.el = new Gtk.Grid();
235 // set gobject values
236 this.el.margin_right = 4;
237 this.el.margin_left = 4;
238 this.el.row_spacing = 2;
239 var child_0 = new Xcls_filetypelbl( _this );
241 this.el.attach ( child_0.el , 0,0,1,1 );
242 var child_1 = new Xcls_filetype( _this );
244 this.el.attach ( child_1.el , 1,0,1,1 );
245 var child_2 = new Xcls_Label9( _this );
247 this.el.attach ( child_2.el , 0,1,1,1 );
248 var child_3 = new Xcls_name( _this );
250 this.el.attach ( child_3.el , 1,1,1,1 );
251 var child_4 = new Xcls_Label11( _this );
253 this.el.attach ( child_4.el , 0,2,1,1 );
254 var child_5 = new Xcls_title( _this );
256 this.el.attach ( child_5.el , 1,2,1,1 );
257 var child_6 = new Xcls_Label13( _this );
259 this.el.attach ( child_6.el , 0,3,1,1 );
260 var child_7 = new Xcls_region( _this );
262 this.el.attach ( child_7.el , 1,3,1,1 );
263 var child_8 = new Xcls_Label15( _this );
265 this.el.attach ( child_8.el , 0,4,1,1 );
266 var child_9 = new Xcls_parent( _this );
268 this.el.attach ( child_9.el , 1,4,1,1 );
269 var child_10 = new Xcls_Label17( _this );
271 this.el.attach ( child_10.el , 0,5,1,1 );
272 var child_11 = new Xcls_permname( _this );
274 this.el.attach ( child_11.el , 1,5,1,1 );
275 var child_12 = new Xcls_Label19( _this );
277 this.el.attach ( child_12.el , 0,6,1,1 );
278 var child_13 = new Xcls_modOrder( _this );
280 this.el.attach ( child_13.el , 1,6,1,1 );
281 var child_14 = new Xcls_Label21( _this );
283 this.el.attach ( child_14.el , 0,7,1,1 );
284 var child_15 = new Xcls_build_module( _this );
286 this.el.attach ( child_15.el , 1,7,1,1 );
289 // user defined functions
291 public class Xcls_filetypelbl : Object
294 private Xcls_PopoverFileDetails _this;
300 public Xcls_filetypelbl(Xcls_PopoverFileDetails _owner )
303 _this.filetypelbl = this;
304 this.el = new Gtk.Label( "File type" );
308 // set gobject values
309 this.el.justify = Gtk.Justification.RIGHT;
310 this.el.xalign = 0.900000f;
313 // user defined functions
316 public class Xcls_filetype : Object
318 public Gtk.ComboBox el;
319 private Xcls_PopoverFileDetails _this;
325 public Xcls_filetype(Xcls_PopoverFileDetails _owner )
328 _this.filetype = this;
329 this.el = new Gtk.ComboBox();
333 // set gobject values
334 var child_0 = new Xcls_ftdbcellrenderer( _this );
336 this.el.pack_start ( child_0.el , true );
337 var child_1 = new Xcls_ftdbmodel( _this );
339 this.el.set_model ( child_1.el );
343 this.el.add_attribute(_this.ftdbcellrenderer.el , "markup", 1 );
346 this.el.changed.connect( () => {
349 if (this.el.get_active_iter(out iter)) {
351 _this.ftdbmodel.el.get_value (iter, 0, out vfname);
352 is_bjs = ((string)vfname) == "bjs";
355 for (var i = 2; i < 8;i++) {
356 var el = _this.grid.el.get_child_at(0,i);
362 el = _this.grid.el.get_child_at(1,i);
376 // user defined functions
378 public class Xcls_ftdbcellrenderer : Object
380 public Gtk.CellRendererText el;
381 private Xcls_PopoverFileDetails _this;
387 public Xcls_ftdbcellrenderer(Xcls_PopoverFileDetails _owner )
390 _this.ftdbcellrenderer = this;
391 this.el = new Gtk.CellRendererText();
395 // set gobject values
398 // user defined functions
401 public class Xcls_ftdbmodel : Object
403 public Gtk.ListStore el;
404 private Xcls_PopoverFileDetails _this;
410 public Xcls_ftdbmodel(Xcls_PopoverFileDetails _owner )
413 _this.ftdbmodel = this;
414 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
418 // set gobject values
421 // user defined functions
422 public void loadData (string cur) {
427 /// el.append(out iter);
430 // el.set_value(iter, 0, "");
431 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
436 el.set_value(iter, 0, "bjs");
437 el.set_value(iter, 1, "User Interface File (bjs)");
438 _this.filetype.el.set_active_iter(iter);
442 el.set_value(iter, 0, "vala");
443 el.set_value(iter, 1, "Vala");
445 _this.filetype.el.set_active_iter(iter);
452 el.set_value(iter, 0, "js");
453 el.set_value(iter, 1, "Javascript");
456 _this.filetype.el.set_active_iter(iter);
461 el.set_value(iter, 0, "css");
462 el.set_value(iter, 1, "CSS");
465 _this.filetype.el.set_active_iter(iter);
472 public class Xcls_Label9 : Object
475 private Xcls_PopoverFileDetails _this;
481 public Xcls_Label9(Xcls_PopoverFileDetails _owner )
484 this.el = new Gtk.Label( "Component Name" );
488 // set gobject values
489 this.el.justify = Gtk.Justification.RIGHT;
490 this.el.xalign = 0.900000f;
493 // user defined functions
496 public class Xcls_name : Object
499 private Xcls_PopoverFileDetails _this;
505 public Xcls_name(Xcls_PopoverFileDetails _owner )
509 this.el = new Gtk.Entry();
513 // set gobject values
514 this.el.visible = true;
517 // user defined functions
520 public class Xcls_Label11 : Object
523 private Xcls_PopoverFileDetails _this;
529 public Xcls_Label11(Xcls_PopoverFileDetails _owner )
532 this.el = new Gtk.Label( "Title" );
536 // set gobject values
537 this.el.justify = Gtk.Justification.RIGHT;
538 this.el.xalign = 0.900000f;
539 this.el.visible = true;
542 // user defined functions
545 public class Xcls_title : Object
548 private Xcls_PopoverFileDetails _this;
554 public Xcls_title(Xcls_PopoverFileDetails _owner )
558 this.el = new Gtk.Entry();
562 // set gobject values
563 this.el.visible = true;
566 // user defined functions
569 public class Xcls_Label13 : Object
572 private Xcls_PopoverFileDetails _this;
578 public Xcls_Label13(Xcls_PopoverFileDetails _owner )
581 this.el = new Gtk.Label( "Region" );
585 // set gobject values
586 this.el.justify = Gtk.Justification.RIGHT;
587 this.el.xalign = 0.900000f;
588 this.el.tooltip_text = "center, north, south, east, west";
589 this.el.visible = true;
592 // user defined functions
595 public class Xcls_region : Object
598 private Xcls_PopoverFileDetails _this;
604 public Xcls_region(Xcls_PopoverFileDetails _owner )
608 this.el = new Gtk.Entry();
612 // set gobject values
613 this.el.visible = true;
616 // user defined functions
619 public class Xcls_Label15 : Object
622 private Xcls_PopoverFileDetails _this;
628 public Xcls_Label15(Xcls_PopoverFileDetails _owner )
631 this.el = new Gtk.Label( "Parent Name" );
635 // set gobject values
636 this.el.justify = Gtk.Justification.RIGHT;
637 this.el.xalign = 0.900000f;
638 this.el.visible = true;
641 // user defined functions
644 public class Xcls_parent : Object
647 private Xcls_PopoverFileDetails _this;
653 public Xcls_parent(Xcls_PopoverFileDetails _owner )
657 this.el = new Gtk.Entry();
661 // set gobject values
662 this.el.visible = true;
665 // user defined functions
668 public class Xcls_Label17 : Object
671 private Xcls_PopoverFileDetails _this;
677 public Xcls_Label17(Xcls_PopoverFileDetails _owner )
680 this.el = new Gtk.Label( "Permission Name" );
684 // set gobject values
685 this.el.justify = Gtk.Justification.RIGHT;
686 this.el.xalign = 0.900000f;
687 this.el.visible = true;
690 // user defined functions
693 public class Xcls_permname : Object
696 private Xcls_PopoverFileDetails _this;
702 public Xcls_permname(Xcls_PopoverFileDetails _owner )
705 _this.permname = this;
706 this.el = new Gtk.Entry();
710 // set gobject values
711 this.el.visible = true;
714 // user defined functions
717 public class Xcls_Label19 : Object
720 private Xcls_PopoverFileDetails _this;
726 public Xcls_Label19(Xcls_PopoverFileDetails _owner )
729 this.el = new Gtk.Label( "Order (for tabs)" );
733 // set gobject values
734 this.el.justify = Gtk.Justification.RIGHT;
735 this.el.xalign = 0.900000f;
736 this.el.visible = true;
739 // user defined functions
742 public class Xcls_modOrder : Object
745 private Xcls_PopoverFileDetails _this;
751 public Xcls_modOrder(Xcls_PopoverFileDetails _owner )
754 _this.modOrder = this;
755 this.el = new Gtk.Entry();
759 // set gobject values
760 this.el.visible = true;
763 // user defined functions
766 public class Xcls_Label21 : Object
769 private Xcls_PopoverFileDetails _this;
775 public Xcls_Label21(Xcls_PopoverFileDetails _owner )
778 this.el = new Gtk.Label( "Module to build (Vala only)" );
782 // set gobject values
783 this.el.justify = Gtk.Justification.RIGHT;
784 this.el.xalign = 0.900000f;
785 this.el.visible = true;
788 // user defined functions
791 public class Xcls_build_module : Object
793 public Gtk.ComboBox el;
794 private Xcls_PopoverFileDetails _this;
800 public Xcls_build_module(Xcls_PopoverFileDetails _owner )
803 _this.build_module = this;
804 this.el = new Gtk.ComboBox();
808 // set gobject values
809 var child_0 = new Xcls_dbcellrenderer( _this );
811 this.el.pack_start ( child_0.el , true );
812 var child_1 = new Xcls_dbmodel( _this );
814 this.el.set_model ( child_1.el );
818 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
821 // user defined functions
823 public class Xcls_dbcellrenderer : Object
825 public Gtk.CellRendererText el;
826 private Xcls_PopoverFileDetails _this;
832 public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
835 _this.dbcellrenderer = this;
836 this.el = new Gtk.CellRendererText();
840 // set gobject values
843 // user defined functions
846 public class Xcls_dbmodel : Object
848 public Gtk.ListStore el;
849 private Xcls_PopoverFileDetails _this;
855 public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
858 _this.dbmodel = this;
859 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
863 // set gobject values
866 // user defined functions
867 public void loadData (Gee.ArrayList<string> data, string cur) {
872 /// el.append(out iter);
875 // el.set_value(iter, 0, "");
876 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
881 el.set_value(iter, 0, "");
882 el.set_value(iter, 1, "-- select a module --");
883 _this.build_module.el.set_active_iter(iter);
885 for (var i = 0; i < data.size;i++) {
890 el.set_value(iter, 0, data.get(i));
891 el.set_value(iter, 1, data.get(i));
893 if (data.get(i) == cur) {
894 _this.build_module.el.set_active_iter(iter);
898 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
905 public class Xcls_HButtonBox25 : Object
907 public Gtk.HButtonBox el;
908 private Xcls_PopoverFileDetails _this;
914 public Xcls_HButtonBox25(Xcls_PopoverFileDetails _owner )
917 this.el = new Gtk.HButtonBox();
921 // set gobject values
922 this.el.margin_right = 4;
923 this.el.margin_left = 4;
924 this.el.margin_bottom = 4;
925 var child_0 = new Xcls_Button26( _this );
927 this.el.add ( child_0.el );
928 var child_1 = new Xcls_save_btn( _this );
930 this.el.add ( child_1.el );
933 // user defined functions
935 public class Xcls_Button26 : Object
937 public Gtk.Button el;
938 private Xcls_PopoverFileDetails _this;
944 public Xcls_Button26(Xcls_PopoverFileDetails _owner )
947 this.el = new Gtk.Button();
951 // set gobject values
952 this.el.label = "Cancel";
955 this.el.clicked.connect( () => {
962 // user defined functions
965 public class Xcls_save_btn : Object
967 public Gtk.Button el;
968 private Xcls_PopoverFileDetails _this;
974 public Xcls_save_btn(Xcls_PopoverFileDetails _owner )
977 _this.save_btn = this;
978 this.el = new Gtk.Button();
982 // set gobject values
983 this.el.label = "Save";
986 this.el.clicked.connect( ( ) => {
991 if (_this.name.el.get_text().length < 1) {
992 StandardErrorDialog.show(
994 "You have to set Component name "
999 // what does this do?
1001 var isNew = _this.file.name.length > 0 ? false : true;
1003 if (!isNew && this.file.name != _this.name.el.get_text()) {
1004 Xcls_StandardErrorDialog.singleton().show(
1006 "Sorry changing names does not work yet. "
1015 // FIXME - this may be more complicated...
1016 //for (var i in this.def) {
1017 // this.file[i] = this.get(i).el.get_text();
1022 _this.updateFileFromEntry();
1023 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
1024 Xcls_StandardErrorDialog.singleton().show(
1025 _this.mainwindow.el,
1026 "The name you used already exists "
1037 var fn = _this.name.el.get_text();
1038 var dir = _this.project.firstPath();
1040 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
1041 Xcls_StandardErrorDialog.singleton().show(
1042 _this.mainwindow.el,
1043 "That file already exists"
1048 var f = JsRender.JsRender.factory(
1049 _this.file.project.xtype,
1051 dir + "/" + fn + ".bjs");
1057 _this.updateFileFromEntry();
1058 _this.file.loaded = true;
1060 _this.file.project.addFile(_this.file);
1069 _this.success(_this.project, _this.file);
1074 // user defined functions